Class: OracleBMC::Core::BlockstorageClient

Inherits:
Object
  • Object
show all
Defined in:
lib/oraclebmc/core/blockstorage_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Parameters:

  • config (Config) (defaults to: nil)

    A Config object.

  • region (String) (defaults to: nil)

    A region used to determine the service endpoint. This will usually correspond to a value in Regions::REGION_ENUM, but may be an arbitrary string.



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_clientOracleBMC::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

#endpointString (readonly)

Fully qualified endpoint URL

Returns:

  • (String)


16
17
18
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 16

def endpoint
  @endpoint
end

#regionString

The region, which will usually correspond to a value in Regions::REGION_ENUM.

Returns:

  • (String)


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.

Parameters:

  • create_volume_details (CreateVolumeDetails)

    Request to create a new volume.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :opc_retry_token (String)

    A token that uniquely identifies a request so it can be retried in case of a timeout or server error without risk of executing that same action again. Retry tokens expire after 24 hours, but can be invalidated before then due to conflicting operations (e.g., if a resource has been deleted and purged from the system, then a retry of the original creation request may be rejected).

Returns:

  • (Response)

    A Response object with data of type OracleBMC::Core::Models::Volume



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
112
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 86

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.

Parameters:

  • create_volume_backup_details (CreateVolumeBackupDetails)

    Request to create a new backup of given volume.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :opc_retry_token (String)

    A token that uniquely identifies a request so it can be retried in case of a timeout or server error without risk of executing that same action again. Retry tokens expire after 24 hours, but can be invalidated before then due to conflicting operations (e.g., if a resource has been deleted and purged from the system, then a retry of the original creation request may be rejected).

Returns:

  • (Response)

    A Response object with data of type OracleBMC::Core::Models::VolumeBackup



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
156
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 130

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.

Parameters:

  • volume_id (String)

    The OCID of the volume.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :if_match (String)

    For optimistic concurrency control. In the PUT or DELETE call for a resource, set the ‘if-match` parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource's current etag value.

Returns:

  • (Response)

    A Response object with data of type nil



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
195
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 170

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.

Parameters:

  • volume_backup_id (String)

    The OCID of the volume backup.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :if_match (String)

    For optimistic concurrency control. In the PUT or DELETE call for a resource, set the ‘if-match` parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource's current etag value.

Returns:

  • (Response)

    A Response object with data of type nil



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 205

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.

Parameters:

  • volume_id (String)

    The OCID of the volume.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Response)

    A Response object with data of type OracleBMC::Core::Models::Volume



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 236

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.

Parameters:

  • volume_backup_id (String)

    The OCID of the volume backup.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Response)

    A Response object with data of type OracleBMC::Core::Models::VolumeBackup



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 267

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.

Parameters:

  • compartment_id (String)

    The OCID of the compartment.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :volume_id (String)

    The OCID of the volume.

  • :limit (Integer)

    The maximum number of items to return in a paginated "List" call.

    Example: ‘500`

  • :page (String)

    The value of the ‘opc-next-page` response header from the previous "List" call.

Returns:

  • (Response)

    A Response object with data of type Array<OracleBMC::Core::Models::VolumeBackup>



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
332
333
334
335
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 306

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.

Parameters:

  • compartment_id (String)

    The OCID of the compartment.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :availability_domain (String)

    The name of the Availability Domain.

    Example: ‘Uocm:PHX-AD-1`

  • :limit (Integer)

    The maximum number of items to return in a paginated &quot;List&quot; call.

    Example: ‘500`

  • :page (String)

    The value of the ‘opc-next-page` response header from the previous &quot;List&quot; call.

Returns:

  • (Response)

    A Response object with data of type Array<OracleBMC::Core::Models::Volume>



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
378
379
380
381
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 352

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

#loggerLogger

Returns The logger for this client. May be nil.

Returns:

  • (Logger)

    The logger for this client. May be nil.



58
59
60
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 58

def logger
  @api_client.config.logger
end

#update_volume(volume_id, update_volume_details, opts = {}) ⇒ Response

Updates the specified volume’s display name.

Parameters:

  • volume_id (String)

    The OCID of the volume.

  • update_volume_details (UpdateVolumeDetails)

    Update volume&#39;s display name.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :if_match (String)

    For optimistic concurrency control. In the PUT or DELETE call for a resource, set the ‘if-match` parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource&#39;s current etag value.

Returns:

  • (Response)

    A Response object with data of type OracleBMC::Core::Models::Volume



392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 392

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.

Parameters:

  • volume_backup_id (String)

    The OCID of the volume backup.

  • update_volume_backup_details (UpdateVolumeBackupDetails)

    Update volume backup fields

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :if_match (String)

    For optimistic concurrency control. In the PUT or DELETE call for a resource, set the ‘if-match` parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource&#39;s current etag value.

Returns:

  • (Response)

    A Response object with data of type OracleBMC::Core::Models::VolumeBackup



430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
# File 'lib/oraclebmc/core/blockstorage_client.rb', line 430

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