class Google::Cloud::Storage::Bucket::Lifecycle


end
l.add_delete_rule age: 30, is_live: false
l.add_set_storage_class_rule “COLDLINE”, age: 10, is_live: true
end
r.matches_storage_class.include? “NEARLINE”
l.delete_if do |r|
# Remove all rules with the given condition
l.pop
# Remove the last rule from the array
bucket.lifecycle do |l|
bucket = storage.bucket “my-bucket”
storage = Google::Cloud::Storage.new
require “google/cloud/storage”
@example Updating the bucket’s lifecycle management rules in a block.
rule.matches_suffix #=> [“.jpg”, “.png”]
rule.matches_prefix #=> [“myprefix/foo”]
rule.matches_storage_class #=> [“STANDARD”, “NEARLINE”]
rule.age #=> 10
rule.storage_class #=> “COLDLINE”
rule.action #=> “SetStorageClass”
rule = bucket.lifecycle.first
bucket.lifecycle.size #=> 2
bucket = storage.bucket “my-bucket”
storage = Google::Cloud::Storage.new
require “google/cloud/storage”
@example Retrieving a bucket’s lifecycle management rules.
end
b.lifecycle.add_delete_rule age: 30, is_live: false
b.lifecycle.add_set_storage_class_rule “COLDLINE”, age: 10
bucket = storage.create_bucket “my-bucket” do |b|
storage = Google::Cloud::Storage.new
require “google/cloud/storage”
@example Specifying the lifecycle management rules for a new bucket.
Managing Object Lifecycles
@see cloud.google.com/storage/docs/managing-lifecycles<br>Lifecycle Management
@see cloud.google.com/storage/docs/lifecycle Object
rules for a bucket. Accessed via {Bucket#lifecycle}.
A special-case Array for managing the Object Lifecycle Management
# Bucket Lifecycle
#

def self.from_gapi gapi

Other tags:
    Private: -
def self.from_gapi gapi
  gapi_list = gapi.rule if gapi
  rules = Array(gapi_list).map do |rule_gapi|
    Rule.from_gapi rule_gapi
  end
  new rules
end

def add_abort_incomplete_multipart_upload_rule age: nil,

Parameters:
  • matches_suffix (Array) --
  • matches_prefix (Array) --
  • age (Integer) -- The age of a file (in days). This condition is

Other tags:
    See: https://cloud.google.com/storage/docs/managing-lifecycles -
    See: https://cloud.google.com/storage/docs/lifecycle - Object
def add_abort_incomplete_multipart_upload_rule age: nil,
                                               matches_prefix: nil,
                                               matches_suffix: nil
  push Rule.new(
    "AbortIncompleteMultipartUpload",
    age: age,
    matches_prefix: Array(matches_prefix),
    matches_suffix: Array(matches_suffix)
  )
end

def add_delete_rule age: nil,

Parameters:
  • matches_suffix (Array) --
  • matches_prefix (Array) --
  • num_newer_versions (Integer) -- Relevant only for versioned
  • noncurrent_time_before (String, Date) -- A date in RFC 3339 format
  • matches_storage_class (String, Symbol, Array) --
  • is_live (Boolean) -- Relevant only for versioned files. If the
  • days_since_noncurrent_time (Integer) -- Represents the number of
  • days_since_custom_time (Integer) -- Represents the number of
  • custom_time_before (String, Date) -- A date in RFC 3339 format with
  • created_before (String, Date) -- A date in RFC 3339 format with
  • age (Integer) -- The age of a file (in days). This condition is

Other tags:
    See: https://cloud.google.com/storage/docs/managing-lifecycles -
    See: https://cloud.google.com/storage/docs/lifecycle - Object
def add_delete_rule age: nil,
                    created_before: nil,
                    custom_time_before: nil,
                    days_since_custom_time: nil,
                    days_since_noncurrent_time: nil,
                    is_live: nil,
                    matches_storage_class: nil,
                    noncurrent_time_before: nil,
                    num_newer_versions: nil,
                    matches_prefix: nil,
                    matches_suffix: nil
  push Rule.new(
    "Delete",
    age: age,
    created_before: created_before,
    custom_time_before: custom_time_before,
    days_since_custom_time: days_since_custom_time,
    days_since_noncurrent_time: days_since_noncurrent_time,
    is_live: is_live,
    matches_storage_class: storage_class_for(matches_storage_class),
    noncurrent_time_before: noncurrent_time_before,
    num_newer_versions: num_newer_versions,
    matches_prefix: Array(matches_prefix),
    matches_suffix: Array(matches_suffix)
  )
end

def add_set_storage_class_rule storage_class,

Parameters:
  • matches_suffix (Array) --
  • matches_prefix (Array) --
  • num_newer_versions (Integer) -- Relevant only for versioned
  • noncurrent_time_before (String, Date) -- A date in RFC 3339 format
  • matches_storage_class (String, Symbol, Array) --
  • is_live (Boolean) -- Relevant only for versioned files. If the
  • days_since_noncurrent_time (Integer) -- Represents the number of
  • days_since_custom_time (Integer) -- Represents the number of
  • custom_time_before (String, Date) -- A date in RFC 3339 format with
  • created_before (String, Date) -- A date in RFC 3339 format with
  • age (Integer) -- The age of a file (in days). This condition is
  • storage_class (String, Symbol) -- The target storage class.

Other tags:
    See: https://cloud.google.com/storage/docs/managing-lifecycles -
    See: https://cloud.google.com/storage/docs/lifecycle - Object
def add_set_storage_class_rule storage_class,
                               age: nil,
                               created_before: nil,
                               custom_time_before: nil,
                               days_since_custom_time: nil,
                               days_since_noncurrent_time: nil,
                               is_live: nil,
                               matches_storage_class: nil,
                               noncurrent_time_before: nil,
                               num_newer_versions: nil,
                               matches_prefix: nil,
                               matches_suffix: nil
  push Rule.new(
    "SetStorageClass",
    storage_class: storage_class_for(storage_class),
    age: age,
    created_before: created_before,
    custom_time_before: custom_time_before,
    days_since_custom_time: days_since_custom_time,
    days_since_noncurrent_time: days_since_noncurrent_time,
    is_live: is_live,
    matches_storage_class: storage_class_for(matches_storage_class),
    noncurrent_time_before: noncurrent_time_before,
    num_newer_versions: num_newer_versions,
    matches_prefix: Array(matches_prefix),
    matches_suffix: Array(matches_suffix)
  )
end

def changed?

Other tags:
    Private: -
def changed?
  @original != to_gapi.rule.map(&:to_json)
end

def freeze

Other tags:
    Private: -
def freeze
  each(&:freeze)
  super
end

def initialize rules = []

Other tags:
    Private: - Initialize a new lifecycle rules builder with existing
def initialize rules = []
  super rules
  @original = to_gapi.rule.map(&:to_json)
end

def to_gapi

Other tags:
    Private: -
def to_gapi
  Google::Apis::StorageV1::Bucket::Lifecycle.new(
    rule: map(&:to_gapi)
  )
end