oci 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +82 -0
  3. data/README.md +262 -0
  4. data/lib/oci.rb +25 -0
  5. data/lib/oci/api_client.rb +389 -0
  6. data/lib/oci/config.rb +118 -0
  7. data/lib/oci/config_file_loader.rb +96 -0
  8. data/lib/oci/core/blockstorage_client.rb +462 -0
  9. data/lib/oci/core/compute_client.rb +1415 -0
  10. data/lib/oci/core/core.rb +114 -0
  11. data/lib/oci/core/models/attach_i_scsi_volume_details.rb +137 -0
  12. data/lib/oci/core/models/attach_vnic_details.rb +144 -0
  13. data/lib/oci/core/models/attach_volume_details.rb +165 -0
  14. data/lib/oci/core/models/capture_console_history_details.rb +120 -0
  15. data/lib/oci/core/models/console_history.rb +213 -0
  16. data/lib/oci/core/models/cpe.rb +169 -0
  17. data/lib/oci/core/models/create_cpe_details.rb +145 -0
  18. data/lib/oci/core/models/create_cross_connect_details.rb +204 -0
  19. data/lib/oci/core/models/create_cross_connect_group_details.rb +133 -0
  20. data/lib/oci/core/models/create_dhcp_details.rb +153 -0
  21. data/lib/oci/core/models/create_drg_attachment_details.rb +142 -0
  22. data/lib/oci/core/models/create_drg_details.rb +131 -0
  23. data/lib/oci/core/models/create_image_details.rb +159 -0
  24. data/lib/oci/core/models/create_instance_console_connection_details.rb +131 -0
  25. data/lib/oci/core/models/create_internet_gateway_details.rb +153 -0
  26. data/lib/oci/core/models/create_ip_sec_connection_details.rb +168 -0
  27. data/lib/oci/core/models/create_private_ip_details.rb +173 -0
  28. data/lib/oci/core/models/create_route_table_details.rb +153 -0
  29. data/lib/oci/core/models/create_security_list_details.rb +164 -0
  30. data/lib/oci/core/models/create_subnet_details.rb +257 -0
  31. data/lib/oci/core/models/create_vcn_details.rb +171 -0
  32. data/lib/oci/core/models/create_virtual_circuit_details.rb +260 -0
  33. data/lib/oci/core/models/create_vnic_details.rb +214 -0
  34. data/lib/oci/core/models/create_volume_backup_details.rb +133 -0
  35. data/lib/oci/core/models/create_volume_details.rb +170 -0
  36. data/lib/oci/core/models/cross_connect.rb +235 -0
  37. data/lib/oci/core/models/cross_connect_group.rb +187 -0
  38. data/lib/oci/core/models/cross_connect_location.rb +134 -0
  39. data/lib/oci/core/models/cross_connect_mapping.rb +190 -0
  40. data/lib/oci/core/models/cross_connect_port_speed_shape.rb +137 -0
  41. data/lib/oci/core/models/cross_connect_status.rb +200 -0
  42. data/lib/oci/core/models/dhcp_dns_option.rb +171 -0
  43. data/lib/oci/core/models/dhcp_option.rb +135 -0
  44. data/lib/oci/core/models/dhcp_options.rb +208 -0
  45. data/lib/oci/core/models/dhcp_search_domain_option.rb +141 -0
  46. data/lib/oci/core/models/drg.rb +186 -0
  47. data/lib/oci/core/models/drg_attachment.rb +208 -0
  48. data/lib/oci/core/models/egress_security_rule.rb +198 -0
  49. data/lib/oci/core/models/export_image_details.rb +134 -0
  50. data/lib/oci/core/models/export_image_via_object_storage_tuple_details.rb +150 -0
  51. data/lib/oci/core/models/export_image_via_object_storage_uri_details.rb +130 -0
  52. data/lib/oci/core/models/fast_connect_provider_service.rb +145 -0
  53. data/lib/oci/core/models/i_scsi_volume_attachment.rb +212 -0
  54. data/lib/oci/core/models/icmp_options.rb +131 -0
  55. data/lib/oci/core/models/image.rb +245 -0
  56. data/lib/oci/core/models/image_source_details.rb +134 -0
  57. data/lib/oci/core/models/image_source_via_object_storage_tuple_details.rb +150 -0
  58. data/lib/oci/core/models/image_source_via_object_storage_uri_details.rb +128 -0
  59. data/lib/oci/core/models/ingress_security_rule.rb +198 -0
  60. data/lib/oci/core/models/instance.rb +307 -0
  61. data/lib/oci/core/models/instance_console_connection.rb +193 -0
  62. data/lib/oci/core/models/instance_credentials.rb +131 -0
  63. data/lib/oci/core/models/internet_gateway.rb +210 -0
  64. data/lib/oci/core/models/ip_sec_connection.rb +223 -0
  65. data/lib/oci/core/models/ip_sec_connection_device_config.rb +153 -0
  66. data/lib/oci/core/models/ip_sec_connection_device_status.rb +156 -0
  67. data/lib/oci/core/models/launch_instance_details.rb +336 -0
  68. data/lib/oci/core/models/letter_of_authority.rb +194 -0
  69. data/lib/oci/core/models/port_range.rb +133 -0
  70. data/lib/oci/core/models/private_ip.rb +248 -0
  71. data/lib/oci/core/models/route_rule.rb +135 -0
  72. data/lib/oci/core/models/route_table.rb +208 -0
  73. data/lib/oci/core/models/security_list.rb +219 -0
  74. data/lib/oci/core/models/shape.rb +122 -0
  75. data/lib/oci/core/models/subnet.rb +351 -0
  76. data/lib/oci/core/models/tcp_options.rb +135 -0
  77. data/lib/oci/core/models/tunnel_config.rb +151 -0
  78. data/lib/oci/core/models/tunnel_status.rb +178 -0
  79. data/lib/oci/core/models/udp_options.rb +135 -0
  80. data/lib/oci/core/models/update_cpe_details.rb +122 -0
  81. data/lib/oci/core/models/update_cross_connect_details.rb +138 -0
  82. data/lib/oci/core/models/update_cross_connect_group_details.rb +122 -0
  83. data/lib/oci/core/models/update_dhcp_details.rb +132 -0
  84. data/lib/oci/core/models/update_drg_attachment_details.rb +122 -0
  85. data/lib/oci/core/models/update_drg_details.rb +122 -0
  86. data/lib/oci/core/models/update_image_details.rb +124 -0
  87. data/lib/oci/core/models/update_instance_details.rb +124 -0
  88. data/lib/oci/core/models/update_internet_gateway_details.rb +133 -0
  89. data/lib/oci/core/models/update_ip_sec_connection_details.rb +122 -0
  90. data/lib/oci/core/models/update_private_ip_details.rb +157 -0
  91. data/lib/oci/core/models/update_route_table_details.rb +133 -0
  92. data/lib/oci/core/models/update_security_list_details.rb +144 -0
  93. data/lib/oci/core/models/update_subnet_details.rb +122 -0
  94. data/lib/oci/core/models/update_vcn_details.rb +122 -0
  95. data/lib/oci/core/models/update_virtual_circuit_details.rb +240 -0
  96. data/lib/oci/core/models/update_vnic_details.rb +144 -0
  97. data/lib/oci/core/models/update_volume_backup_details.rb +122 -0
  98. data/lib/oci/core/models/update_volume_details.rb +122 -0
  99. data/lib/oci/core/models/vcn.rb +276 -0
  100. data/lib/oci/core/models/virtual_circuit.rb +395 -0
  101. data/lib/oci/core/models/virtual_circuit_bandwidth_shape.rb +137 -0
  102. data/lib/oci/core/models/vnic.rb +287 -0
  103. data/lib/oci/core/models/vnic_attachment.rb +250 -0
  104. data/lib/oci/core/models/volume.rb +210 -0
  105. data/lib/oci/core/models/volume_attachment.rb +246 -0
  106. data/lib/oci/core/models/volume_backup.rb +235 -0
  107. data/lib/oci/core/util.rb +1 -0
  108. data/lib/oci/core/virtual_network_client.rb +3421 -0
  109. data/lib/oci/errors.rb +78 -0
  110. data/lib/oci/global_context.rb +20 -0
  111. data/lib/oci/identity/identity.rb +55 -0
  112. data/lib/oci/identity/identity_client.rb +2148 -0
  113. data/lib/oci/identity/models/add_user_to_group_details.rb +131 -0
  114. data/lib/oci/identity/models/api_key.rb +211 -0
  115. data/lib/oci/identity/models/availability_domain.rb +131 -0
  116. data/lib/oci/identity/models/compartment.rb +211 -0
  117. data/lib/oci/identity/models/create_api_key_details.rb +120 -0
  118. data/lib/oci/identity/models/create_compartment_details.rb +145 -0
  119. data/lib/oci/identity/models/create_customer_secret_key_details.rb +121 -0
  120. data/lib/oci/identity/models/create_group_details.rb +144 -0
  121. data/lib/oci/identity/models/create_identity_provider_details.rb +215 -0
  122. data/lib/oci/identity/models/create_idp_group_mapping_details.rb +133 -0
  123. data/lib/oci/identity/models/create_policy_details.rb +173 -0
  124. data/lib/oci/identity/models/create_region_subscription_details.rb +128 -0
  125. data/lib/oci/identity/models/create_saml2_identity_provider_details.rb +154 -0
  126. data/lib/oci/identity/models/create_swift_password_details.rb +121 -0
  127. data/lib/oci/identity/models/create_user_details.rb +144 -0
  128. data/lib/oci/identity/models/customer_secret_key.rb +225 -0
  129. data/lib/oci/identity/models/customer_secret_key_summary.rb +213 -0
  130. data/lib/oci/identity/models/group.rb +211 -0
  131. data/lib/oci/identity/models/identity_provider.rb +261 -0
  132. data/lib/oci/identity/models/idp_group_mapping.rb +220 -0
  133. data/lib/oci/identity/models/policy.rb +237 -0
  134. data/lib/oci/identity/models/region.rb +143 -0
  135. data/lib/oci/identity/models/region_subscription.rb +180 -0
  136. data/lib/oci/identity/models/saml2_identity_provider.rb +180 -0
  137. data/lib/oci/identity/models/swift_password.rb +226 -0
  138. data/lib/oci/identity/models/tenancy.rb +159 -0
  139. data/lib/oci/identity/models/ui_password.rb +187 -0
  140. data/lib/oci/identity/models/update_compartment_details.rb +132 -0
  141. data/lib/oci/identity/models/update_customer_secret_key_details.rb +120 -0
  142. data/lib/oci/identity/models/update_group_details.rb +120 -0
  143. data/lib/oci/identity/models/update_identity_provider_details.rb +160 -0
  144. data/lib/oci/identity/models/update_idp_group_mapping_details.rb +131 -0
  145. data/lib/oci/identity/models/update_policy_details.rb +148 -0
  146. data/lib/oci/identity/models/update_saml2_identity_provider_details.rb +145 -0
  147. data/lib/oci/identity/models/update_state_details.rb +121 -0
  148. data/lib/oci/identity/models/update_swift_password_details.rb +120 -0
  149. data/lib/oci/identity/models/update_user_details.rb +120 -0
  150. data/lib/oci/identity/models/user.rb +217 -0
  151. data/lib/oci/identity/models/user_group_membership.rb +209 -0
  152. data/lib/oci/identity/util.rb +1 -0
  153. data/lib/oci/internal/internal.rb +10 -0
  154. data/lib/oci/internal/util.rb +69 -0
  155. data/lib/oci/load_balancer/load_balancer.rb +51 -0
  156. data/lib/oci/load_balancer/load_balancer_client.rb +1449 -0
  157. data/lib/oci/load_balancer/models/backend.rb +220 -0
  158. data/lib/oci/load_balancer/models/backend_details.rb +206 -0
  159. data/lib/oci/load_balancer/models/backend_health.rb +158 -0
  160. data/lib/oci/load_balancer/models/backend_set.rb +182 -0
  161. data/lib/oci/load_balancer/models/backend_set_details.rb +165 -0
  162. data/lib/oci/load_balancer/models/backend_set_health.rb +207 -0
  163. data/lib/oci/load_balancer/models/certificate.rb +169 -0
  164. data/lib/oci/load_balancer/models/certificate_details.rb +205 -0
  165. data/lib/oci/load_balancer/models/create_backend_details.rb +206 -0
  166. data/lib/oci/load_balancer/models/create_backend_set_details.rb +181 -0
  167. data/lib/oci/load_balancer/models/create_certificate_details.rb +205 -0
  168. data/lib/oci/load_balancer/models/create_listener_details.rb +175 -0
  169. data/lib/oci/load_balancer/models/create_load_balancer_details.rb +220 -0
  170. data/lib/oci/load_balancer/models/health_check_result.rb +183 -0
  171. data/lib/oci/load_balancer/models/health_checker.rb +224 -0
  172. data/lib/oci/load_balancer/models/health_checker_details.rb +223 -0
  173. data/lib/oci/load_balancer/models/ip_address.rb +139 -0
  174. data/lib/oci/load_balancer/models/listener.rb +174 -0
  175. data/lib/oci/load_balancer/models/listener_details.rb +160 -0
  176. data/lib/oci/load_balancer/models/load_balancer.rb +280 -0
  177. data/lib/oci/load_balancer/models/load_balancer_health.rb +215 -0
  178. data/lib/oci/load_balancer/models/load_balancer_health_summary.rb +168 -0
  179. data/lib/oci/load_balancer/models/load_balancer_policy.rb +120 -0
  180. data/lib/oci/load_balancer/models/load_balancer_protocol.rb +120 -0
  181. data/lib/oci/load_balancer/models/load_balancer_shape.rb +120 -0
  182. data/lib/oci/load_balancer/models/session_persistence_configuration_details.rb +141 -0
  183. data/lib/oci/load_balancer/models/ssl_configuration.rb +155 -0
  184. data/lib/oci/load_balancer/models/ssl_configuration_details.rb +155 -0
  185. data/lib/oci/load_balancer/models/update_backend_details.rb +178 -0
  186. data/lib/oci/load_balancer/models/update_backend_set_details.rb +165 -0
  187. data/lib/oci/load_balancer/models/update_health_checker_details.rb +222 -0
  188. data/lib/oci/load_balancer/models/update_listener_details.rb +160 -0
  189. data/lib/oci/load_balancer/models/update_load_balancer_details.rb +124 -0
  190. data/lib/oci/load_balancer/models/work_request.rb +229 -0
  191. data/lib/oci/load_balancer/models/work_request_error.rb +145 -0
  192. data/lib/oci/load_balancer/util.rb +58 -0
  193. data/lib/oci/object_storage/models/bucket.rb +216 -0
  194. data/lib/oci/object_storage/models/bucket_summary.rb +175 -0
  195. data/lib/oci/object_storage/models/commit_multipart_upload_details.rb +133 -0
  196. data/lib/oci/object_storage/models/commit_multipart_upload_part_details.rb +131 -0
  197. data/lib/oci/object_storage/models/create_bucket_details.rb +173 -0
  198. data/lib/oci/object_storage/models/create_multipart_upload_details.rb +166 -0
  199. data/lib/oci/object_storage/models/create_preauthenticated_request_details.rb +171 -0
  200. data/lib/oci/object_storage/models/list_objects.rb +146 -0
  201. data/lib/oci/object_storage/models/multipart_upload.rb +164 -0
  202. data/lib/oci/object_storage/models/multipart_upload_part_summary.rb +153 -0
  203. data/lib/oci/object_storage/models/object_summary.rb +153 -0
  204. data/lib/oci/object_storage/models/preauthenticated_request.rb +207 -0
  205. data/lib/oci/object_storage/models/preauthenticated_request_summary.rb +196 -0
  206. data/lib/oci/object_storage/models/update_bucket_details.rb +171 -0
  207. data/lib/oci/object_storage/object_storage.rb +30 -0
  208. data/lib/oci/object_storage/object_storage_client.rb +1185 -0
  209. data/lib/oci/object_storage/util.rb +1 -0
  210. data/lib/oci/regions.rb +43 -0
  211. data/lib/oci/response.rb +80 -0
  212. data/lib/oci/response_headers.rb +144 -0
  213. data/lib/oci/signer.rb +157 -0
  214. data/lib/oci/version.rb +5 -0
  215. data/lib/oci/waiter.rb +101 -0
  216. data/lib/oraclebmc.rb +3 -0
  217. metadata +375 -0
@@ -0,0 +1,118 @@
1
+ # Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
2
+
3
+ require 'uri'
4
+
5
+ module OCI
6
+ # This class contains accessors for configuration attributes needed when using the
7
+ # SDK
8
+ class InvalidConfigError < RuntimeError; end
9
+
10
+ class Config
11
+ # Patterns to use validate value for different attribute
12
+ PATTERNS = { 'tenancy' => /^([0-9a-zA-Z\-_]+[.:])([0-9a-zA-Z\-_]*[.:]){3,}([0-9a-zA-Z\-_]+)$/,
13
+ 'user' => /^([0-9a-zA-Z\-_]+[.:])([0-9a-zA-Z\-_]*[.:]){3,}([0-9a-zA-Z\-_]+)$/,
14
+ 'fingerprint' => /^([0-9a-f]{2}:){15}[0-9a-f]{2}$/ }.freeze
15
+
16
+ private_constant :PATTERNS
17
+
18
+ # OCID of the user to use for authentication.
19
+ # Example: ocidv1:user:oc1:phx:1460406592659:aaaaaaaawcbqrkycbolrirg2n3xjl5fabc
20
+ #
21
+ # @return [String]
22
+ attr_accessor :user
23
+
24
+ # SSL Fingerprint to use for authentication.
25
+ # Example: 20:3b:97:13:55:1c:1c:0d:d3:37:d8:50:4e:c5:3a:12
26
+ #
27
+ # @return [String]
28
+ attr_accessor :fingerprint
29
+
30
+ # OCID of the tenancy to use for authentication.
31
+ # Example: ocid1.tenancy.oc1..aaaaaaaaba3pv6wkcr4jqae5f15p2b2m2yt2j6rx32uzr4h25vqstifsfdsq
32
+ #
33
+ # @return [String]
34
+ attr_accessor :tenancy
35
+
36
+ # Client private key file.
37
+ # Example: ~/.ssh/oci_key
38
+ #
39
+ # @return [String]
40
+ attr_accessor :key_file
41
+
42
+ # Client private key content.
43
+ # key_content takes precedence if both key_file and key_content are provided.
44
+ # For the security reason, don't provide the key content in the configuration file itself and it will be ignored by SDK.
45
+ # The value should be same as the content which is normally found in a .pem file.
46
+ # Example: "-----BEGIN RSA PRIVATE KEY-----\nProc-Type: 4,ENCRYPTED\nDEK-Info: AES-128-CBC,D3D04C29BD3061489F4FF579A2133620\n\njZO+B3DMBTz6Pszk0EUS8O2gU0T...jZpo\n-----END RSA PRIVATE KEY-----\n"
47
+ #
48
+ # @return [String]
49
+ attr_accessor :key_content
50
+
51
+ # Pass phrase used for key file, if it is encrypted.
52
+ #
53
+ # @return [String]
54
+ attr_accessor :pass_phrase
55
+
56
+ # A region to use for APIs created with this Config.
57
+ #
58
+ # @return [OCI::Regions::REGION_ENUM]
59
+ attr_accessor :region
60
+
61
+ # Defines the logger used for debugging.
62
+ # For example, log to STDOUT by setting this to Logger.new(STDOUT).
63
+ # This property cannot be set from a config file.
64
+ #
65
+ # @return [Logger]
66
+ attr_accessor :logger
67
+
68
+ # Whether to log detailed request and response
69
+ # data. This will always write to STDOUT.
70
+ # Defaults to false.
71
+ #
72
+ # @return [true, false]
73
+ attr_accessor :log_requests
74
+
75
+ # The time limit for HTTP request in seconds.
76
+ # Defaults to 0 (times out in 365 days).
77
+ #
78
+ # @return [Integer]
79
+ attr_accessor :timeout
80
+
81
+ # The time limit for the connection phase in seconds.
82
+ # Defaults to 10 seconds.
83
+ #
84
+ # @return [Integer]
85
+ attr_accessor :connection_timeout
86
+
87
+ # If set, then this string will be added to the
88
+ # user agent sent with each request.
89
+ #
90
+ # @return [String]
91
+ attr_accessor :additional_user_agent
92
+
93
+ def initialize
94
+ @timeout = 0
95
+ @connection_timeout = 10
96
+ @log_requests = false
97
+ @key_content = nil
98
+ end
99
+
100
+ def validate
101
+ %w[user fingerprint tenancy region].each do |name|
102
+ if !instance_variable_defined?("@#{name}") || instance_variable_get("@#{name}").nil?
103
+ raise OCI::InvalidConfigError, "The #{name} is missing in configuration."
104
+ end
105
+ end
106
+
107
+ if (!instance_variable_defined?('@key_file') || instance_variable_get('@key_file').nil?) && @key_content.nil?
108
+ raise OCI::InvalidConfigError, 'The key_file and key_content cannot both be missing in configuration.'
109
+ end
110
+
111
+ PATTERNS.each do |name, pattern|
112
+ if (pattern =~ instance_variable_get("@#{name}")).nil?
113
+ raise OCI::InvalidConfigError, "The format of #{name} is invalid."
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,96 @@
1
+ # Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
2
+
3
+ require 'inifile'
4
+ require 'logger'
5
+ require_relative 'config'
6
+
7
+ module OCI
8
+ # Module for loading Config from a file
9
+ module ConfigFileLoader
10
+ module Errors
11
+ class ConfigFileNotFoundError < RuntimeError; end
12
+ class ProfileNotFoundError < RuntimeError; end
13
+ class DefaultProfileDoesNotExistError < RuntimeError; end
14
+ end
15
+
16
+ # Name of the default profile to load from a config file
17
+ DEFAULT_PROFILE = 'DEFAULT'.freeze
18
+
19
+ # Default config file name and location
20
+ DEFAULT_CONFIG_FILE = "#{Dir.home}/.oci/config".freeze
21
+ FALLBACK_DEFAULT_CONFIG_FILE = "#{Dir.home}/.oraclebmc/config".freeze
22
+
23
+ # Loads the a Config from the specified file and profile.
24
+ #
25
+ # @param [String] config_file_location Filename and path of the config file.
26
+ # Defaults to "~/.oci/config" (on windows "C:\Users\{user}\.oci\config") with a fallback to
27
+ # "~/.oraclebmc/config" (on windows "C:\Users\{user}\.oraclebmc\config")
28
+ # @param [String] profile_name Name of the profile from the file. Defaults to "DEFAULT".
29
+ # @return [Config] A Config
30
+ def self.load_config(config_file_location: DEFAULT_CONFIG_FILE, profile_name: DEFAULT_PROFILE)
31
+ if config_file_location == DEFAULT_CONFIG_FILE
32
+ configs = if File.exist?(File.expand_path(config_file_location))
33
+ load_configs(config_file_location)
34
+ elsif File.exist?(File.expand_path(FALLBACK_DEFAULT_CONFIG_FILE))
35
+ load_configs(FALLBACK_DEFAULT_CONFIG_FILE)
36
+ else
37
+ raise Errors::ConfigFileNotFoundError, 'Config file does not exist.'
38
+ end
39
+ else
40
+ configs = load_configs(config_file_location)
41
+ end
42
+
43
+ return configs[profile_name] if configs && configs.key?(profile_name)
44
+ raise Errors::ProfileNotFoundError, 'Profile not found in the given config file.'
45
+ end
46
+
47
+ # Loads all of the Configs from the specified file.
48
+ #
49
+ # @param [String] config_file_location Filename and path of the config file.
50
+ # @return [Array<Config>] An array containing all the configs found in the given file.
51
+ def self.load_configs(config_file_location)
52
+ config_file_location = File.expand_path(config_file_location)
53
+
54
+ unless File.file?(config_file_location)
55
+ raise Errors::ConfigFileNotFoundError, 'Config file does not exist.'
56
+ end
57
+
58
+ config_file = IniFile.load(config_file_location)
59
+ configs = {}
60
+
61
+ if config_file.nil? || !config_file.has_section?(DEFAULT_PROFILE)
62
+ raise Errors::DefaultProfileDoesNotExistError, 'The DEFAULT profile does not exist.'
63
+ end
64
+
65
+ config_file.each_section do |section|
66
+ config = Config.new
67
+
68
+ unless section.equal? DEFAULT_PROFILE
69
+ load_section(config_file[DEFAULT_PROFILE], config)
70
+ end
71
+ load_section(config_file[section], config)
72
+
73
+ configs[section] = config
74
+ end
75
+
76
+ configs
77
+ end
78
+
79
+ def self.load_section(section, config)
80
+ section.each_key do |key|
81
+ value = section[key]
82
+ value = File.expand_path(value) if key == 'key_file'
83
+
84
+ # key_content is not allowed in configuration file
85
+ if key != 'key_content'
86
+ if config.respond_to?("#{key}=") && config.respond_to?(key)
87
+ config.instance_variable_set('@' + key, value)
88
+ end
89
+ # TODO log the key been ignored by Ruby SDK
90
+ end
91
+ end
92
+ end
93
+
94
+ private_class_method :load_section
95
+ end
96
+ end
@@ -0,0 +1,462 @@
1
+ # Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
2
+
3
+ require "uri"
4
+ require "logger"
5
+
6
+ module OCI
7
+
8
+ class Core::BlockstorageClient
9
+
10
+ # Client used to make HTTP requests.
11
+ # @return [OCI::ApiClient]
12
+ attr_reader :api_client
13
+
14
+ # Fully qualified endpoint URL
15
+ # @return [String]
16
+ attr_reader :endpoint
17
+
18
+ # The region, which will usually correspond to a value in {OCI::Regions::REGION_ENUM}.
19
+ # @return [String]
20
+ attr_accessor :region
21
+
22
+ # Creates a new BlockstorageClient.
23
+ # If a config is not specified, then the global OCI.config will be used.
24
+ #
25
+ # A region must be specified in either the config or the region parameter. If specified
26
+ # in both, then the region parameter will be used.
27
+ #
28
+ # @param [Config] config A Config object.
29
+ # @param [String] region A region used to determine the service endpoint. This will usually
30
+ # correspond to a value in {OCI::Regions::REGION_ENUM}, but may be an arbitrary string.
31
+ #
32
+ def initialize(config:nil, region:nil)
33
+ config ||= OCI.config
34
+ config.validate
35
+
36
+ signer = Signer.new(config.user, config.fingerprint, config.tenancy, config.key_file, pass_phrase: config.pass_phrase, private_key_content: config.key_content)
37
+ @api_client = ApiClient.new(config, signer)
38
+
39
+ region ||= config.region
40
+ self.region = region
41
+ end
42
+
43
+ # Set the region that will be used to determine the service endpoint.
44
+ # This will usually correspond to a value in {OCI::Regions::REGION_ENUM},
45
+ # but may be an arbitrary string.
46
+ def region=(r)
47
+ @region = r
48
+
49
+ fail 'A region must be specified.' unless @region
50
+
51
+ @endpoint = OCI::Regions.get_service_endpoint(@region, :BlockstorageClient) + '/20160918'
52
+ logger.info "BlockstorageClient endpoint set to '#{endpoint}'." if logger
53
+ end
54
+
55
+ # @return [Logger] The logger for this client. May be nil.
56
+ def logger
57
+ @api_client.config.logger
58
+ end
59
+
60
+
61
+ # Creates a new volume in the specified compartment. Volumes can be created in sizes ranging from
62
+ # 50 GB (51200 MB) to 2 TB (2097152 MB), in 1 GB (1024 MB) increments. By default, volumes are 1 TB (1048576 MB).
63
+ # For general information about block volumes, see
64
+ # [Overview of Block Volume Service](https://docs.us-phoenix-1.oraclecloud.com/Content/Block/Concepts/overview.htm).
65
+ #
66
+ # A volume and instance can be in separate compartments but must be in the same Availability Domain.
67
+ # For information about access control and compartments, see
68
+ # [Overview of the IAM Service](https://docs.us-phoenix-1.oraclecloud.com/Content/Identity/Concepts/overview.htm). For information about
69
+ # Availability Domains, see [Regions and Availability Domains](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/regions.htm).
70
+ # To get a list of Availability Domains, use the `ListAvailabilityDomains` operation
71
+ # in the Identity and Access Management Service API.
72
+ #
73
+ # You may optionally specify a *display name* for the volume, which is simply a friendly name or
74
+ # description. It does not have to be unique, and you can change it. Avoid entering confidential information.
75
+ #
76
+ # @param [CreateVolumeDetails] create_volume_details Request to create a new volume.
77
+ # @param [Hash] opts the optional parameters
78
+ # @option opts [String] :opc_retry_token A token that uniquely identifies a request so it can be retried in case of a timeout or
79
+ # server error without risk of executing that same action again. Retry tokens expire after 24
80
+ # hours, but can be invalidated before then due to conflicting operations (for example, if a resource
81
+ # has been deleted and purged from the system, then a retry of the original creation request
82
+ # may be rejected).
83
+ #
84
+ # @return [Response] A Response object with data of type OCI::Core::Models::Volume
85
+ def create_volume(create_volume_details, opts = {})
86
+ logger.debug "Calling operation BlockstorageClient#create_volume." if logger
87
+
88
+ fail "Missing the required parameter 'create_volume_details' when calling create_volume." if create_volume_details.nil?
89
+
90
+ path = "/volumes"
91
+
92
+ # Query Params
93
+ query_params = {}
94
+
95
+ # Header Params
96
+ header_params = {}
97
+ header_params['accept'] = 'application/json'
98
+ header_params['content-type'] = 'application/json'
99
+ header_params[:'opc-retry-token'] = opts[:'opc_retry_token'] if opts[:'opc_retry_token']
100
+
101
+ post_body = @api_client.object_to_http_body(create_volume_details)
102
+
103
+ return @api_client.call_api(
104
+ :POST,
105
+ path,
106
+ endpoint,
107
+ :header_params => header_params,
108
+ :query_params => query_params,
109
+ :body => post_body,
110
+ :return_type => 'OCI::Core::Models::Volume')
111
+ end
112
+
113
+ # Creates a new backup of the specified volume. For general information about volume backups,
114
+ # see [Overview of Block Volume Service Backups](https://docs.us-phoenix-1.oraclecloud.com/Content/Block/Concepts/blockvolumebackups.htm)
115
+ #
116
+ # When the request is received, the backup object is in a REQUEST_RECEIVED state.
117
+ # When the data is imaged, it goes into a CREATING state.
118
+ # After the backup is fully uploaded to the cloud, it goes into an AVAILABLE state.
119
+ #
120
+ # @param [CreateVolumeBackupDetails] create_volume_backup_details Request to create a new backup of given volume.
121
+ # @param [Hash] opts the optional parameters
122
+ # @option opts [String] :opc_retry_token A token that uniquely identifies a request so it can be retried in case of a timeout or
123
+ # server error without risk of executing that same action again. Retry tokens expire after 24
124
+ # hours, but can be invalidated before then due to conflicting operations (for example, if a resource
125
+ # has been deleted and purged from the system, then a retry of the original creation request
126
+ # may be rejected).
127
+ #
128
+ # @return [Response] A Response object with data of type OCI::Core::Models::VolumeBackup
129
+ def create_volume_backup(create_volume_backup_details, opts = {})
130
+ logger.debug "Calling operation BlockstorageClient#create_volume_backup." if logger
131
+
132
+ fail "Missing the required parameter 'create_volume_backup_details' when calling create_volume_backup." if create_volume_backup_details.nil?
133
+
134
+ path = "/volumeBackups"
135
+
136
+ # Query Params
137
+ query_params = {}
138
+
139
+ # Header Params
140
+ header_params = {}
141
+ header_params['accept'] = 'application/json'
142
+ header_params['content-type'] = 'application/json'
143
+ header_params[:'opc-retry-token'] = opts[:'opc_retry_token'] if opts[:'opc_retry_token']
144
+
145
+ post_body = @api_client.object_to_http_body(create_volume_backup_details)
146
+
147
+ return @api_client.call_api(
148
+ :POST,
149
+ path,
150
+ endpoint,
151
+ :header_params => header_params,
152
+ :query_params => query_params,
153
+ :body => post_body,
154
+ :return_type => 'OCI::Core::Models::VolumeBackup')
155
+ end
156
+
157
+ # Deletes the specified volume. The volume cannot have an active connection to an instance.
158
+ # To disconnect the volume from a connected instance, see
159
+ # [Disconnecting From a Volume](https://docs.us-phoenix-1.oraclecloud.com/Content/Block/Tasks/disconnectingfromavolume.htm).
160
+ # **Warning:** All data on the volume will be permanently lost when the volume is deleted.
161
+ #
162
+ # @param [String] volume_id The OCID of the volume.
163
+ # @param [Hash] opts the optional parameters
164
+ # @option opts [String] :if_match For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match`
165
+ # parameter to the value of the etag from a previous GET or POST response for that resource. The resource
166
+ # will be updated or deleted only if the etag you provide matches the resource's current etag value.
167
+ #
168
+ # @return [Response] A Response object with data of type nil
169
+ def delete_volume(volume_id, opts = {})
170
+ logger.debug "Calling operation BlockstorageClient#delete_volume." if logger
171
+
172
+ fail "Missing the required parameter 'volume_id' when calling delete_volume." if volume_id.nil?
173
+
174
+ path = "/volumes/{volumeId}".sub('{volumeId}', volume_id.to_s)
175
+
176
+ # Query Params
177
+ query_params = {}
178
+
179
+ # Header Params
180
+ header_params = {}
181
+ header_params['accept'] = 'application/json'
182
+ header_params['content-type'] = 'application/json'
183
+ header_params[:'if-match'] = opts[:'if_match'] if opts[:'if_match']
184
+
185
+ post_body = nil
186
+
187
+ return @api_client.call_api(
188
+ :DELETE,
189
+ path,
190
+ endpoint,
191
+ :header_params => header_params,
192
+ :query_params => query_params,
193
+ :body => post_body)
194
+ end
195
+
196
+ # Deletes a volume backup.
197
+ # @param [String] volume_backup_id The OCID of the volume backup.
198
+ # @param [Hash] opts the optional parameters
199
+ # @option opts [String] :if_match For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match`
200
+ # parameter to the value of the etag from a previous GET or POST response for that resource. The resource
201
+ # will be updated or deleted only if the etag you provide matches the resource's current etag value.
202
+ #
203
+ # @return [Response] A Response object with data of type nil
204
+ def delete_volume_backup(volume_backup_id, opts = {})
205
+ logger.debug "Calling operation BlockstorageClient#delete_volume_backup." if logger
206
+
207
+ fail "Missing the required parameter 'volume_backup_id' when calling delete_volume_backup." if volume_backup_id.nil?
208
+
209
+ path = "/volumeBackups/{volumeBackupId}".sub('{volumeBackupId}', volume_backup_id.to_s)
210
+
211
+ # Query Params
212
+ query_params = {}
213
+
214
+ # Header Params
215
+ header_params = {}
216
+ header_params['accept'] = 'application/json'
217
+ header_params['content-type'] = 'application/json'
218
+ header_params[:'if-match'] = opts[:'if_match'] if opts[:'if_match']
219
+
220
+ post_body = nil
221
+
222
+ return @api_client.call_api(
223
+ :DELETE,
224
+ path,
225
+ endpoint,
226
+ :header_params => header_params,
227
+ :query_params => query_params,
228
+ :body => post_body)
229
+ end
230
+
231
+ # Gets information for the specified volume.
232
+ # @param [String] volume_id The OCID of the volume.
233
+ # @param [Hash] opts the optional parameters
234
+ # @return [Response] A Response object with data of type OCI::Core::Models::Volume
235
+ def get_volume(volume_id, opts = {})
236
+ logger.debug "Calling operation BlockstorageClient#get_volume." if logger
237
+
238
+ fail "Missing the required parameter 'volume_id' when calling get_volume." if volume_id.nil?
239
+
240
+ path = "/volumes/{volumeId}".sub('{volumeId}', volume_id.to_s)
241
+
242
+ # Query Params
243
+ query_params = {}
244
+
245
+ # Header Params
246
+ header_params = {}
247
+ header_params['accept'] = 'application/json'
248
+ header_params['content-type'] = 'application/json'
249
+
250
+ post_body = nil
251
+
252
+ return @api_client.call_api(
253
+ :GET,
254
+ path,
255
+ endpoint,
256
+ :header_params => header_params,
257
+ :query_params => query_params,
258
+ :body => post_body,
259
+ :return_type => 'OCI::Core::Models::Volume')
260
+ end
261
+
262
+ # Gets information for the specified volume backup.
263
+ # @param [String] volume_backup_id The OCID of the volume backup.
264
+ # @param [Hash] opts the optional parameters
265
+ # @return [Response] A Response object with data of type OCI::Core::Models::VolumeBackup
266
+ def get_volume_backup(volume_backup_id, opts = {})
267
+ logger.debug "Calling operation BlockstorageClient#get_volume_backup." if logger
268
+
269
+ fail "Missing the required parameter 'volume_backup_id' when calling get_volume_backup." if volume_backup_id.nil?
270
+
271
+ path = "/volumeBackups/{volumeBackupId}".sub('{volumeBackupId}', volume_backup_id.to_s)
272
+
273
+ # Query Params
274
+ query_params = {}
275
+
276
+ # Header Params
277
+ header_params = {}
278
+ header_params['accept'] = 'application/json'
279
+ header_params['content-type'] = 'application/json'
280
+
281
+ post_body = nil
282
+
283
+ return @api_client.call_api(
284
+ :GET,
285
+ path,
286
+ endpoint,
287
+ :header_params => header_params,
288
+ :query_params => query_params,
289
+ :body => post_body,
290
+ :return_type => 'OCI::Core::Models::VolumeBackup')
291
+ end
292
+
293
+ # Lists the volume backups in the specified compartment. You can filter the results by volume.
294
+ #
295
+ # @param [String] compartment_id The OCID of the compartment.
296
+ # @param [Hash] opts the optional parameters
297
+ # @option opts [String] :volume_id The OCID of the volume.
298
+ # @option opts [Integer] :limit The maximum number of items to return in a paginated \"List\" call.
299
+ #
300
+ # Example: `500`
301
+ #
302
+ # @option opts [String] :page The value of the `opc-next-page` response header from the previous \"List\" call.
303
+ #
304
+ # @return [Response] A Response object with data of type Array<OCI::Core::Models::VolumeBackup>
305
+ def list_volume_backups(compartment_id, opts = {})
306
+ logger.debug "Calling operation BlockstorageClient#list_volume_backups." if logger
307
+
308
+ fail "Missing the required parameter 'compartment_id' when calling list_volume_backups." if compartment_id.nil?
309
+
310
+ path = "/volumeBackups"
311
+
312
+ # Query Params
313
+ query_params = {}
314
+ query_params[:'compartmentId'] = compartment_id
315
+ query_params[:'volumeId'] = opts[:'volume_id'] if opts[:'volume_id']
316
+ query_params[:'limit'] = opts[:'limit'] if opts[:'limit']
317
+ query_params[:'page'] = opts[:'page'] if opts[:'page']
318
+
319
+ # Header Params
320
+ header_params = {}
321
+ header_params['accept'] = 'application/json'
322
+ header_params['content-type'] = 'application/json'
323
+
324
+ post_body = nil
325
+
326
+ return @api_client.call_api(
327
+ :GET,
328
+ path,
329
+ endpoint,
330
+ :header_params => header_params,
331
+ :query_params => query_params,
332
+ :body => post_body,
333
+ :return_type => 'Array<OCI::Core::Models::VolumeBackup>')
334
+ end
335
+
336
+ # Lists the volumes in the specified compartment and Availability Domain.
337
+ #
338
+ # @param [String] compartment_id The OCID of the compartment.
339
+ # @param [Hash] opts the optional parameters
340
+ # @option opts [String] :availability_domain The name of the Availability Domain.
341
+ #
342
+ # Example: `Uocm:PHX-AD-1`
343
+ #
344
+ # @option opts [Integer] :limit The maximum number of items to return in a paginated \"List\" call.
345
+ #
346
+ # Example: `500`
347
+ #
348
+ # @option opts [String] :page The value of the `opc-next-page` response header from the previous \"List\" call.
349
+ #
350
+ # @return [Response] A Response object with data of type Array<OCI::Core::Models::Volume>
351
+ def list_volumes(compartment_id, opts = {})
352
+ logger.debug "Calling operation BlockstorageClient#list_volumes." if logger
353
+
354
+ fail "Missing the required parameter 'compartment_id' when calling list_volumes." if compartment_id.nil?
355
+
356
+ path = "/volumes"
357
+
358
+ # Query Params
359
+ query_params = {}
360
+ query_params[:'compartmentId'] = compartment_id
361
+ query_params[:'availabilityDomain'] = opts[:'availability_domain'] if opts[:'availability_domain']
362
+ query_params[:'limit'] = opts[:'limit'] if opts[:'limit']
363
+ query_params[:'page'] = opts[:'page'] if opts[:'page']
364
+
365
+ # Header Params
366
+ header_params = {}
367
+ header_params['accept'] = 'application/json'
368
+ header_params['content-type'] = 'application/json'
369
+
370
+ post_body = nil
371
+
372
+ return @api_client.call_api(
373
+ :GET,
374
+ path,
375
+ endpoint,
376
+ :header_params => header_params,
377
+ :query_params => query_params,
378
+ :body => post_body,
379
+ :return_type => 'Array<OCI::Core::Models::Volume>')
380
+ end
381
+
382
+ # Updates the specified volume's display name.
383
+ # Avoid entering confidential information.
384
+ #
385
+ # @param [String] volume_id The OCID of the volume.
386
+ # @param [UpdateVolumeDetails] update_volume_details Update volume's display name. Avoid entering confidential information.
387
+ # @param [Hash] opts the optional parameters
388
+ # @option opts [String] :if_match For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match`
389
+ # parameter to the value of the etag from a previous GET or POST response for that resource. The resource
390
+ # will be updated or deleted only if the etag you provide matches the resource's current etag value.
391
+ #
392
+ # @return [Response] A Response object with data of type OCI::Core::Models::Volume
393
+ def update_volume(volume_id, update_volume_details, opts = {})
394
+ logger.debug "Calling operation BlockstorageClient#update_volume." if logger
395
+
396
+ fail "Missing the required parameter 'volume_id' when calling update_volume." if volume_id.nil?
397
+ fail "Missing the required parameter 'update_volume_details' when calling update_volume." if update_volume_details.nil?
398
+
399
+ path = "/volumes/{volumeId}".sub('{volumeId}', volume_id.to_s)
400
+
401
+ # Query Params
402
+ query_params = {}
403
+
404
+ # Header Params
405
+ header_params = {}
406
+ header_params['accept'] = 'application/json'
407
+ header_params['content-type'] = 'application/json'
408
+ header_params[:'if-match'] = opts[:'if_match'] if opts[:'if_match']
409
+
410
+ post_body = @api_client.object_to_http_body(update_volume_details)
411
+
412
+ return @api_client.call_api(
413
+ :PUT,
414
+ path,
415
+ endpoint,
416
+ :header_params => header_params,
417
+ :query_params => query_params,
418
+ :body => post_body,
419
+ :return_type => 'OCI::Core::Models::Volume')
420
+ end
421
+
422
+ # Updates the display name for the specified volume backup.
423
+ # Avoid entering confidential information.
424
+ #
425
+ # @param [String] volume_backup_id The OCID of the volume backup.
426
+ # @param [UpdateVolumeBackupDetails] update_volume_backup_details Update volume backup fields
427
+ # @param [Hash] opts the optional parameters
428
+ # @option opts [String] :if_match For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match`
429
+ # parameter to the value of the etag from a previous GET or POST response for that resource. The resource
430
+ # will be updated or deleted only if the etag you provide matches the resource's current etag value.
431
+ #
432
+ # @return [Response] A Response object with data of type OCI::Core::Models::VolumeBackup
433
+ def update_volume_backup(volume_backup_id, update_volume_backup_details, opts = {})
434
+ logger.debug "Calling operation BlockstorageClient#update_volume_backup." if logger
435
+
436
+ fail "Missing the required parameter 'volume_backup_id' when calling update_volume_backup." if volume_backup_id.nil?
437
+ fail "Missing the required parameter 'update_volume_backup_details' when calling update_volume_backup." if update_volume_backup_details.nil?
438
+
439
+ path = "/volumeBackups/{volumeBackupId}".sub('{volumeBackupId}', volume_backup_id.to_s)
440
+
441
+ # Query Params
442
+ query_params = {}
443
+
444
+ # Header Params
445
+ header_params = {}
446
+ header_params['accept'] = 'application/json'
447
+ header_params['content-type'] = 'application/json'
448
+ header_params[:'if-match'] = opts[:'if_match'] if opts[:'if_match']
449
+
450
+ post_body = @api_client.object_to_http_body(update_volume_backup_details)
451
+
452
+ return @api_client.call_api(
453
+ :PUT,
454
+ path,
455
+ endpoint,
456
+ :header_params => header_params,
457
+ :query_params => query_params,
458
+ :body => post_body,
459
+ :return_type => 'OCI::Core::Models::VolumeBackup')
460
+ end
461
+ end
462
+ end