Class: Google::Cloud::Storage::Bucket::Updater

Inherits:
Bucket
  • Object
show all
Defined in:
lib/google/cloud/storage/bucket.rb

Overview

Yielded to a block to accumulate changes for a patch request.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gapi) ⇒ Updater

Create an Updater object.



3523
3524
3525
3526
3527
3528
3529
3530
# File 'lib/google/cloud/storage/bucket.rb', line 3523

def initialize gapi
  super()
  @updates = []
  @gapi = gapi
  @labels = @gapi.labels.to_h.dup
  @cors_builder = nil
  @lifecycle_builder = nil
end

Instance Attribute Details

#updatesObject (readonly)

Returns the value of attribute updates.



3519
3520
3521
# File 'lib/google/cloud/storage/bucket.rb', line 3519

def updates
  @updates
end

Instance Method Details

#check_for_encryption_enforcement_config!Object



3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
# File 'lib/google/cloud/storage/bucket.rb', line 3592

def check_for_encryption_enforcement_config!
  return unless @gapi.encryption

  [
    :google_managed_encryption_enforcement_config,
    :customer_managed_encryption_enforcement_config,
    :customer_supplied_encryption_enforcement_config
  ].each do |attr|
    config = @gapi.encryption.send(attr)
    next unless config
    unless config.respond_to?(:to_h)
      raise ArgumentError, "Encryption config for #{attr} must be a Hash or valid Config object"
    end
    clean_config = config.to_h
    clean_config.delete :effective_time
    clean_config.delete "effective_time"
    @gapi.encryption.send "#{attr}=", clean_config
  end
end

#cors {|@cors_builder| ... } ⇒ Object

Yields:

  • (@cors_builder)


3560
3561
3562
3563
3564
3565
# File 'lib/google/cloud/storage/bucket.rb', line 3560

def cors
  # Same as Bucket#cors, but not frozen
  @cors_builder ||= Bucket::Cors.from_gapi @gapi.cors_configurations
  yield @cors_builder if block_given?
  @cors_builder
end

#labelsHash(String => String)

A hash of user-provided labels. Changes are allowed.

Returns:

  • (Hash(String => String))


3537
3538
3539
# File 'lib/google/cloud/storage/bucket.rb', line 3537

def labels
  @labels
end

#labels=(labels) ⇒ Object

Updates the hash of user-provided labels.

Parameters:

  • labels (Hash(String => String))

    The user-provided labels.



3546
3547
3548
3549
3550
# File 'lib/google/cloud/storage/bucket.rb', line 3546

def labels= labels
  @labels = labels
  @gapi.labels = @labels
  patch_gapi! :labels
end

#lifecycle {|@lifecycle_builder| ... } ⇒ Object

Yields:

  • (@lifecycle_builder)


3576
3577
3578
3579
3580
3581
# File 'lib/google/cloud/storage/bucket.rb', line 3576

def lifecycle
  # Same as Bucket#lifecycle, but not frozen
  @lifecycle_builder ||= Bucket::Lifecycle.from_gapi @gapi.lifecycle
  yield @lifecycle_builder if block_given?
  @lifecycle_builder
end