Class: OCI::Core::BlockstorageClient
- Inherits:
-
Object
- Object
- OCI::Core::BlockstorageClient
- Defined in:
- lib/oci/core/blockstorage_client.rb
Instance Attribute Summary collapse
-
#api_client ⇒ OCI::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_boot_volume(boot_volume_id, opts = {}) ⇒ Response
Deletes the specified boot volume.
-
#delete_volume(volume_id, opts = {}) ⇒ Response
Deletes the specified volume.
-
#delete_volume_backup(volume_backup_id, opts = {}) ⇒ Response
Deletes a volume backup.
-
#get_boot_volume(boot_volume_id, opts = {}) ⇒ Response
Gets information for the specified boot volume.
-
#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_boot_volumes(availability_domain, compartment_id, opts = {}) ⇒ Response
Lists the boot volumes in the specified compartment and Availability Domain.
-
#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_boot_volume(boot_volume_id, update_boot_volume_details, opts = {}) ⇒ Response
Updates the specified boot volume’s display name.
-
#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 OCI.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 40 41 |
# File 'lib/oci/core/blockstorage_client.rb', line 32 def initialize(config:nil, region:nil) config ||= OCI.config config.validate signer = Signer.new(config.user, config.fingerprint, config.tenancy, config.key_file, pass_phrase: config.pass_phrase, private_key_content: config.key_content, signing_strategy: Signer::STANDARD) @api_client = ApiClient.new(config, signer) region ||= config.region self.region = region end |
Instance Attribute Details
#api_client ⇒ OCI::ApiClient (readonly)
Client used to make HTTP requests.
12 13 14 |
# File 'lib/oci/core/blockstorage_client.rb', line 12 def api_client @api_client end |
#endpoint ⇒ String (readonly)
Fully qualified endpoint URL
16 17 18 |
# File 'lib/oci/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/oci/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. Volumes can be created in sizes ranging from 50 GB (51200 MB) to 16 TB (16777216 MB), in 1 GB (1024 MB) increments. By default, volumes are 1 TB (1048576 MB). 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. Avoid entering confidential information.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/oci/core/blockstorage_client.rb', line 85 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 => 'OCI::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.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/oci/core/blockstorage_client.rb', line 129 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 => 'OCI::Core::Models::VolumeBackup') end |
#delete_boot_volume(boot_volume_id, opts = {}) ⇒ Response
Deletes the specified boot volume. The volume cannot have an active connection to an instance. To disconnect the boot volume from a connected instance, see [Disconnecting From a Boot Volume](docs.us-phoenix-1.oraclecloud.com/Content/Block/Tasks/deletingbootvolume.htm). Warning: All data on the boot volume will be permanently lost when the boot volume is deleted.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/oci/core/blockstorage_client.rb', line 169 def delete_boot_volume(boot_volume_id, opts = {}) logger.debug "Calling operation BlockstorageClient#delete_boot_volume." if logger fail "Missing the required parameter 'boot_volume_id' when calling delete_boot_volume." if boot_volume_id.nil? path = "/bootVolumes/{bootVolumeId}".sub('{bootVolumeId}', boot_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(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.
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/oci/core/blockstorage_client.rb', line 208 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.
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/oci/core/blockstorage_client.rb', line 243 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_boot_volume(boot_volume_id, opts = {}) ⇒ Response
Gets information for the specified boot volume.
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/oci/core/blockstorage_client.rb', line 274 def get_boot_volume(boot_volume_id, opts = {}) logger.debug "Calling operation BlockstorageClient#get_boot_volume." if logger fail "Missing the required parameter 'boot_volume_id' when calling get_boot_volume." if boot_volume_id.nil? path = "/bootVolumes/{bootVolumeId}".sub('{bootVolumeId}', boot_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 => 'OCI::Core::Models::BootVolume') end |
#get_volume(volume_id, opts = {}) ⇒ Response
Gets information for the specified volume.
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 |
# File 'lib/oci/core/blockstorage_client.rb', line 305 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 => 'OCI::Core::Models::Volume') end |
#get_volume_backup(volume_backup_id, opts = {}) ⇒ Response
Gets information for the specified volume backup.
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/oci/core/blockstorage_client.rb', line 336 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 => 'OCI::Core::Models::VolumeBackup') end |
#list_boot_volumes(availability_domain, compartment_id, opts = {}) ⇒ Response
Lists the boot volumes in the specified compartment and Availability Domain.
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
# File 'lib/oci/core/blockstorage_client.rb', line 378 def list_boot_volumes(availability_domain, compartment_id, opts = {}) logger.debug "Calling operation BlockstorageClient#list_boot_volumes." if logger fail "Missing the required parameter 'availability_domain' when calling list_boot_volumes." if availability_domain.nil? fail "Missing the required parameter 'compartment_id' when calling list_boot_volumes." if compartment_id.nil? path = "/bootVolumes" # Query Params query_params = {} query_params[:'availabilityDomain'] = availability_domain query_params[:'compartmentId'] = compartment_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<OCI::Core::Models::BootVolume>') end |
#list_volume_backups(compartment_id, opts = {}) ⇒ Response
Lists the volume backups in the specified compartment. You can filter the results by volume.
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 |
# File 'lib/oci/core/blockstorage_client.rb', line 440 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? if opts[:'sort_by'] && !['TIMECREATED', 'DISPLAYNAME'].include?(opts[:'sort_by']) fail 'Invalid value for "sort_by", must be one of TIMECREATED, DISPLAYNAME.' end if opts[:'sort_order'] && !['ASC', 'DESC'].include?(opts[:'sort_order']) fail 'Invalid value for "sort_order", must be one of ASC, DESC.' end if opts[:'lifecycle_state'] && !OCI::Core::Models::VolumeBackup::LIFECYCLE_STATE_ENUM.include?(opts[:'lifecycle_state']) fail 'Invalid value for "lifecycle_state", must be one of the values in OCI::Core::Models::VolumeBackup::LIFECYCLE_STATE_ENUM.' end 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'] query_params[:'displayName'] = opts[:'display_name'] if opts[:'display_name'] query_params[:'sortBy'] = opts[:'sort_by'] if opts[:'sort_by'] query_params[:'sortOrder'] = opts[:'sort_order'] if opts[:'sort_order'] query_params[:'lifecycleState'] = opts[:'lifecycle_state'] if opts[:'lifecycle_state'] # 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<OCI::Core::Models::VolumeBackup>') end |
#list_volumes(compartment_id, opts = {}) ⇒ Response
Lists the volumes in the specified compartment and Availability Domain.
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
# File 'lib/oci/core/blockstorage_client.rb', line 520 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? if opts[:'sort_by'] && !['TIMECREATED', 'DISPLAYNAME'].include?(opts[:'sort_by']) fail 'Invalid value for "sort_by", must be one of TIMECREATED, DISPLAYNAME.' end if opts[:'sort_order'] && !['ASC', 'DESC'].include?(opts[:'sort_order']) fail 'Invalid value for "sort_order", must be one of ASC, DESC.' end if opts[:'lifecycle_state'] && !OCI::Core::Models::Volume::LIFECYCLE_STATE_ENUM.include?(opts[:'lifecycle_state']) fail 'Invalid value for "lifecycle_state", must be one of the values in OCI::Core::Models::Volume::LIFECYCLE_STATE_ENUM.' end 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'] query_params[:'displayName'] = opts[:'display_name'] if opts[:'display_name'] query_params[:'sortBy'] = opts[:'sort_by'] if opts[:'sort_by'] query_params[:'sortOrder'] = opts[:'sort_order'] if opts[:'sort_order'] query_params[:'lifecycleState'] = opts[:'lifecycle_state'] if opts[:'lifecycle_state'] # 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<OCI::Core::Models::Volume>') end |
#logger ⇒ Logger
Returns The logger for this client. May be nil.
56 57 58 |
# File 'lib/oci/core/blockstorage_client.rb', line 56 def logger @api_client.config.logger end |
#update_boot_volume(boot_volume_id, update_boot_volume_details, opts = {}) ⇒ Response
Updates the specified boot volume’s display name.
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 |
# File 'lib/oci/core/blockstorage_client.rb', line 576 def update_boot_volume(boot_volume_id, update_boot_volume_details, opts = {}) logger.debug "Calling operation BlockstorageClient#update_boot_volume." if logger fail "Missing the required parameter 'boot_volume_id' when calling update_boot_volume." if boot_volume_id.nil? fail "Missing the required parameter 'update_boot_volume_details' when calling update_boot_volume." if update_boot_volume_details.nil? path = "/bootVolumes/{bootVolumeId}".sub('{bootVolumeId}', boot_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_boot_volume_details) return @api_client.call_api( :PUT, path, endpoint, :header_params => header_params, :query_params => query_params, :body => post_body, :return_type => 'OCI::Core::Models::BootVolume') end |
#update_volume(volume_id, update_volume_details, opts = {}) ⇒ Response
Updates the specified volume’s display name. Avoid entering confidential information.
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 |
# File 'lib/oci/core/blockstorage_client.rb', line 616 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 => 'OCI::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. Avoid entering confidential information.
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
# File 'lib/oci/core/blockstorage_client.rb', line 656 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 => 'OCI::Core::Models::VolumeBackup') end |