Class: OracleBMC::Core::BlockstorageClient
- Inherits:
-
Object
- Object
- OracleBMC::Core::BlockstorageClient
- Defined in:
- lib/oraclebmc/core/blockstorage_client.rb
Instance Attribute Summary collapse
-
#api_client ⇒ OracleBMC::ApiClient
readonly
Client used to make HTTP requests.
-
#endpoint ⇒ String
readonly
Fully qualified endpoint URL.
-
#region ⇒ String
The region, which will usually correspond to a value in Regions::REGION_ENUM.
Instance Method Summary collapse
-
#create_volume(create_volume_details, opts = {}) ⇒ Response
Creates a new volume in the specified compartment.
-
#create_volume_backup(create_volume_backup_details, opts = {}) ⇒ Response
Creates a new backup of the specified volume.
-
#delete_volume(volume_id, opts = {}) ⇒ Response
Deletes the specified volume.
-
#delete_volume_backup(volume_backup_id, opts = {}) ⇒ Response
Deletes a volume backup.
-
#get_volume(volume_id, opts = {}) ⇒ Response
Gets information for the specified volume.
-
#get_volume_backup(volume_backup_id, opts = {}) ⇒ Response
Gets information for the specified volume backup.
-
#initialize(config: nil, region: nil) ⇒ BlockstorageClient
constructor
Creates a new BlockstorageClient.
-
#list_volume_backups(compartment_id, opts = {}) ⇒ Response
Lists the volume backups in the specified compartment.
-
#list_volumes(compartment_id, opts = {}) ⇒ Response
Lists the volumes in the specified compartment and Availability Domain.
-
#logger ⇒ Logger
The logger for this client.
-
#update_volume(volume_id, update_volume_details, opts = {}) ⇒ Response
Updates the specified volume’s display name.
-
#update_volume_backup(volume_backup_id, update_volume_backup_details, opts = {}) ⇒ Response
Updates the display name for the specified volume backup.
Constructor Details
#initialize(config: nil, region: nil) ⇒ BlockstorageClient
Creates a new BlockstorageClient. If a config is not specified, then the global OracleBMC.config will be used.
A region must be specified in either the config or the region parameter. If specified in both, then the region parameter will be used.
32 33 34 35 36 37 38 39 |
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 32 def initialize(config:nil, region:nil) config ||= OracleBMC.config signer = Signer.new(config.user, config.fingerprint, config.tenancy, config.key_file, pass_phrase: config.pass_phrase) @api_client = ApiClient.new(config, signer) region ||= config.region self.region = region end |
Instance Attribute Details
#api_client ⇒ OracleBMC::ApiClient (readonly)
Client used to make HTTP requests.
12 13 14 |
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 12 def api_client @api_client end |
#endpoint ⇒ String (readonly)
Fully qualified endpoint URL
16 17 18 |
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 16 def endpoint @endpoint end |
#region ⇒ String
The region, which will usually correspond to a value in Regions::REGION_ENUM.
20 21 22 |
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 20 def region @region end |
Instance Method Details
#create_volume(create_volume_details, opts = {}) ⇒ Response
Creates a new volume in the specified compartment. The size of a volume can be either 256 GB or 2 TB. For general information about block volumes, see [Overview of Block Volume Service](docs.us-phoenix-1.oraclecloud.com/Content/Block/Concepts/overview.htm).
A volume and instance can be in separate compartments but must be in the same Availability Domain. For information about access control and compartments, see [Overview of the IAM Service](docs.us-phoenix-1.oraclecloud.com/Content/Identity/Concepts/overview.htm). For information about Availability Domains, see [Regions and Availability Domains](docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/regions.htm). To get a list of Availability Domains, use the ‘ListAvailabilityDomains` operation in the Identity and Access Management Service API.
You may optionally specify a *display name* for the volume, which is simply a friendly name or description. It does not have to be unique, and you can change it.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 82 def create_volume(create_volume_details, opts = {}) logger.debug "Calling operation BlockstorageClient#create_volume." if logger fail "Missing the required parameter 'create_volume_details' when calling create_volume." if create_volume_details.nil? path = "/volumes" # Query Params query_params = {} # Header Params header_params = {} header_params['accept'] = 'application/json' header_params['content-type'] = 'application/json' header_params[:'opc-retry-token'] = opts[:'opc_retry_token'] if opts[:'opc_retry_token'] post_body = @api_client.object_to_http_body(create_volume_details) return @api_client.call_api( :POST, path, endpoint, :header_params => header_params, :query_params => query_params, :body => post_body, :return_type => 'OracleBMC::Core::Models::Volume') end |
#create_volume_backup(create_volume_backup_details, opts = {}) ⇒ Response
Creates a new backup of the specified volume. For general information about volume backups, see [Overview of Block Volume Service Backups](docs.us-phoenix-1.oraclecloud.com/Content/Block/Concepts/blockvolumebackups.htm)
When the request is received, the backup object is in a REQUEST_RECEIVED state. When the data is imaged, it goes into a CREATING state. After the backup is fully uploaded to the cloud, it goes into an AVAILABLE state.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 126 def create_volume_backup(create_volume_backup_details, opts = {}) logger.debug "Calling operation BlockstorageClient#create_volume_backup." if logger fail "Missing the required parameter 'create_volume_backup_details' when calling create_volume_backup." if create_volume_backup_details.nil? path = "/volumeBackups" # Query Params query_params = {} # Header Params header_params = {} header_params['accept'] = 'application/json' header_params['content-type'] = 'application/json' header_params[:'opc-retry-token'] = opts[:'opc_retry_token'] if opts[:'opc_retry_token'] post_body = @api_client.object_to_http_body(create_volume_backup_details) return @api_client.call_api( :POST, path, endpoint, :header_params => header_params, :query_params => query_params, :body => post_body, :return_type => 'OracleBMC::Core::Models::VolumeBackup') end |
#delete_volume(volume_id, opts = {}) ⇒ Response
Deletes the specified volume. The volume cannot have an active connection to an instance. To disconnect the volume from a connected instance, see [Disconnecting From a Volume](docs.us-phoenix-1.oraclecloud.com/Content/Block/Tasks/disconnectingfromavolume.htm). Warning: All data on the volume will be permanently lost when the volume is deleted.
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 166 def delete_volume(volume_id, opts = {}) logger.debug "Calling operation BlockstorageClient#delete_volume." if logger fail "Missing the required parameter 'volume_id' when calling delete_volume." if volume_id.nil? path = "/volumes/{volumeId}".sub('{volumeId}', volume_id.to_s) # Query Params query_params = {} # Header Params header_params = {} header_params['accept'] = 'application/json' header_params['content-type'] = 'application/json' header_params[:'if-match'] = opts[:'if_match'] if opts[:'if_match'] post_body = nil return @api_client.call_api( :DELETE, path, endpoint, :header_params => header_params, :query_params => query_params, :body => post_body) end |
#delete_volume_backup(volume_backup_id, opts = {}) ⇒ Response
Deletes a volume backup.
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 201 def delete_volume_backup(volume_backup_id, opts = {}) logger.debug "Calling operation BlockstorageClient#delete_volume_backup." if logger fail "Missing the required parameter 'volume_backup_id' when calling delete_volume_backup." if volume_backup_id.nil? path = "/volumeBackups/{volumeBackupId}".sub('{volumeBackupId}', volume_backup_id.to_s) # Query Params query_params = {} # Header Params header_params = {} header_params['accept'] = 'application/json' header_params['content-type'] = 'application/json' header_params[:'if-match'] = opts[:'if_match'] if opts[:'if_match'] post_body = nil return @api_client.call_api( :DELETE, path, endpoint, :header_params => header_params, :query_params => query_params, :body => post_body) end |
#get_volume(volume_id, opts = {}) ⇒ Response
Gets information for the specified volume.
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 232 def get_volume(volume_id, opts = {}) logger.debug "Calling operation BlockstorageClient#get_volume." if logger fail "Missing the required parameter 'volume_id' when calling get_volume." if volume_id.nil? path = "/volumes/{volumeId}".sub('{volumeId}', volume_id.to_s) # Query Params query_params = {} # Header Params header_params = {} header_params['accept'] = 'application/json' header_params['content-type'] = 'application/json' post_body = nil return @api_client.call_api( :GET, path, endpoint, :header_params => header_params, :query_params => query_params, :body => post_body, :return_type => 'OracleBMC::Core::Models::Volume') end |
#get_volume_backup(volume_backup_id, opts = {}) ⇒ Response
Gets information for the specified volume backup.
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 263 def get_volume_backup(volume_backup_id, opts = {}) logger.debug "Calling operation BlockstorageClient#get_volume_backup." if logger fail "Missing the required parameter 'volume_backup_id' when calling get_volume_backup." if volume_backup_id.nil? path = "/volumeBackups/{volumeBackupId}".sub('{volumeBackupId}', volume_backup_id.to_s) # Query Params query_params = {} # Header Params header_params = {} header_params['accept'] = 'application/json' header_params['content-type'] = 'application/json' post_body = nil return @api_client.call_api( :GET, path, endpoint, :header_params => header_params, :query_params => query_params, :body => post_body, :return_type => 'OracleBMC::Core::Models::VolumeBackup') end |
#list_volume_backups(compartment_id, opts = {}) ⇒ Response
Lists the volume backups in the specified compartment. You can filter the results by volume.
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 302 def list_volume_backups(compartment_id, opts = {}) logger.debug "Calling operation BlockstorageClient#list_volume_backups." if logger fail "Missing the required parameter 'compartment_id' when calling list_volume_backups." if compartment_id.nil? path = "/volumeBackups" # Query Params query_params = {} query_params[:'compartmentId'] = compartment_id query_params[:'volumeId'] = opts[:'volume_id'] if opts[:'volume_id'] query_params[:'limit'] = opts[:'limit'] if opts[:'limit'] query_params[:'page'] = opts[:'page'] if opts[:'page'] # Header Params header_params = {} header_params['accept'] = 'application/json' header_params['content-type'] = 'application/json' post_body = nil return @api_client.call_api( :GET, path, endpoint, :header_params => header_params, :query_params => query_params, :body => post_body, :return_type => 'Array<OracleBMC::Core::Models::VolumeBackup>') end |
#list_volumes(compartment_id, opts = {}) ⇒ Response
Lists the volumes in the specified compartment and Availability Domain.
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 348 def list_volumes(compartment_id, opts = {}) logger.debug "Calling operation BlockstorageClient#list_volumes." if logger fail "Missing the required parameter 'compartment_id' when calling list_volumes." if compartment_id.nil? path = "/volumes" # Query Params query_params = {} query_params[:'compartmentId'] = compartment_id query_params[:'availabilityDomain'] = opts[:'availability_domain'] if opts[:'availability_domain'] query_params[:'limit'] = opts[:'limit'] if opts[:'limit'] query_params[:'page'] = opts[:'page'] if opts[:'page'] # Header Params header_params = {} header_params['accept'] = 'application/json' header_params['content-type'] = 'application/json' post_body = nil return @api_client.call_api( :GET, path, endpoint, :header_params => header_params, :query_params => query_params, :body => post_body, :return_type => 'Array<OracleBMC::Core::Models::Volume>') end |
#logger ⇒ Logger
Returns The logger for this client. May be nil.
54 55 56 |
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 54 def logger @api_client.config.logger end |
#update_volume(volume_id, update_volume_details, opts = {}) ⇒ Response
Updates the specified volume’s display name.
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 388 def update_volume(volume_id, update_volume_details, opts = {}) logger.debug "Calling operation BlockstorageClient#update_volume." if logger fail "Missing the required parameter 'volume_id' when calling update_volume." if volume_id.nil? fail "Missing the required parameter 'update_volume_details' when calling update_volume." if update_volume_details.nil? path = "/volumes/{volumeId}".sub('{volumeId}', volume_id.to_s) # Query Params query_params = {} # Header Params header_params = {} header_params['accept'] = 'application/json' header_params['content-type'] = 'application/json' header_params[:'if-match'] = opts[:'if_match'] if opts[:'if_match'] post_body = @api_client.object_to_http_body(update_volume_details) return @api_client.call_api( :PUT, path, endpoint, :header_params => header_params, :query_params => query_params, :body => post_body, :return_type => 'OracleBMC::Core::Models::Volume') end |
#update_volume_backup(volume_backup_id, update_volume_backup_details, opts = {}) ⇒ Response
Updates the display name for the specified volume backup.
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 426 def update_volume_backup(volume_backup_id, update_volume_backup_details, opts = {}) logger.debug "Calling operation BlockstorageClient#update_volume_backup." if logger fail "Missing the required parameter 'volume_backup_id' when calling update_volume_backup." if volume_backup_id.nil? fail "Missing the required parameter 'update_volume_backup_details' when calling update_volume_backup." if update_volume_backup_details.nil? path = "/volumeBackups/{volumeBackupId}".sub('{volumeBackupId}', volume_backup_id.to_s) # Query Params query_params = {} # Header Params header_params = {} header_params['accept'] = 'application/json' header_params['content-type'] = 'application/json' header_params[:'if-match'] = opts[:'if_match'] if opts[:'if_match'] post_body = @api_client.object_to_http_body(update_volume_backup_details) return @api_client.call_api( :PUT, path, endpoint, :header_params => header_params, :query_params => query_params, :body => post_body, :return_type => 'OracleBMC::Core::Models::VolumeBackup') end |