class Google::Cloud::Storage::Bucket::Lifecycle::Rule
end
end
l.add_set_storage_class_rule “COLDLINE”, age: 10
# Add a rule
end
r.age = 90 if r.action == “Delete”
l.each do |r|
# Update rules
end
r.matches_storage_class.include? “NEARLINE”
l.delete_if do |r|
# Remove rules with the given condition
l.pop
# Remove the last rule from the array
b.lifecycle do |l|
bucket.update do |b|
bucket = storage.bucket “my-bucket”
storage = Google::Cloud::Storage.new
require “google/cloud/storage”
@example Updating the bucket’s lifecycle 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.
this version of the file.
are at least N versions (including the live version) newer than
files. If the value is N, this condition is satisfied when there
@attr [Integer] num_newer_versions Relevant only for versioned
Date object.
When returned by the service, a non-empty value will always be a
date in UTC. This condition is relevant only for versioned objects.
is satisfied when the noncurrent time on an object is before this
with only the date part (for instance, “2013-01-15”). This condition
@attr [String,Date,nil] noncurrent_time_before A date in RFC 3339 format
are supported as legacy storage classes.
‘REGIONAL`, `MULTI_REGIONAL`, and `DURABLE_REDUCED_AVAILABILITY`
Values include `STANDARD`, `NEARLINE`, `COLDLINE`, and `ARCHIVE`.
storage classes specified by this condition will be matched.
@attr [Array<String>] matches_storage_class Files having any of the
is `false`, it matches archived files.
value is `true`, this condition matches live files; if the value
@attr [Boolean] is_live Relevant only for versioned files. If the
buckets. (See {Bucket#versioning?})
soon as it becomes noncurrent. Relevant only for versioning-enabled
the object version will become eligible for Lifecycle action as
The value of the field must be a nonnegative integer. If it’s zero,
condition is satisfied if the days elapsed is at least this number.
days elapsed since the noncurrent timestamp of an object. The
@attr [Integer] days_since_noncurrent_time Represents the number of
condition does not apply.
number. If no custom timestamp is specified on an object, the
The condition is satisfied if the days elapsed is at least this
days elapsed since the user-specified timestamp set on an object.
@attr [Integer,nil] days_since_custom_time Represents the number of
satisfied when the custom time on an object is before this date in UTC.
only the date part (for instance, “2013-01-15”). This condition is
@attr [String,Date,nil] custom_time_before A date in RFC 3339 format with
always be a Date object.
date in UTC. When returned by the service, a non-empty value will
satisfied when a file is created before midnight of the specified
only the date part (for instance, “2013-01-15”). This condition is
@attr [String,Date,nil] created_before A date in RFC 3339 format with
satisfied when a file reaches the specified age.
@attr [Integer] age The age of a file (in days). This condition is
action. Required only if the action is ‘SetStorageClass`.
@attr [String] storage_class The target storage class for the
are supported.
conditions are met. Currently, only `Delete` and `SetStorageClass`
@attr [String] action The type of action taken when the rule’s
Managing Object Lifecycles
@see cloud.google.com/storage/docs/managing-lifecycles<br>Lifecycle Management
@see cloud.google.com/storage/docs/lifecycle Object
Accessed via {Bucket#lifecycle}.
action for the rule will be taken when its conditions are met.
Represents an Object Lifecycle Management rule for a bucket. The
# Bucket Lifecycle Rule
#
def self.from_gapi gapi
-
gapi
(Google::Apis::StorageV1::Bucket::Rule
) --
Other tags:
- Private: -
def self.from_gapi gapi action = gapi.action c = gapi.condition new( action.type, storage_class: action.storage_class, age: c.age, created_before: c.created_before, custom_time_before: c.custom_time_before, days_since_custom_time: c.days_since_custom_time, days_since_noncurrent_time: c.days_since_noncurrent_time, is_live: c.is_live, matches_storage_class: c.matches_storage_class, noncurrent_time_before: c.noncurrent_time_before, num_newer_versions: c.num_newer_versions, matches_prefix: c.matches_prefix, matches_suffix: c.matches_suffix ) end
def action_gapi action, storage_class
- Private: -
def action_gapi action, storage_class Google::Apis::StorageV1::Bucket::Lifecycle::Rule::Action.new( type: action, storage_class: storage_class ) end
def condition_gapi age,
- Private: -
def condition_gapi age, created_before, custom_time_before, days_since_custom_time, days_since_noncurrent_time, is_live, matches_storage_class, noncurrent_time_before, num_newer_versions, matches_prefix, matches_suffix Google::Apis::StorageV1::Bucket::Lifecycle::Rule::Condition.new( 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: Array(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 freeze
- Private: -
def freeze @matches_storage_class.freeze super end
def initialize action,
- Private: -
def initialize action, storage_class: nil, 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 @action = action @storage_class = 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 = Array(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 to_gapi
-
(Google::Apis::StorageV1::Bucket::Lifecycle)
-
Other tags:
- Private: -
def to_gapi condition = condition_gapi( age, created_before, custom_time_before, days_since_custom_time, days_since_noncurrent_time, is_live, matches_storage_class, noncurrent_time_before, num_newer_versions, matches_prefix, matches_suffix ) Google::Apis::StorageV1::Bucket::Lifecycle::Rule.new( action: action_gapi(action, storage_class), condition: condition ) end