From ce42a3efba4f264f0faca9531c717395861d0c50 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Tue, 29 Oct 2019 18:06:24 -0600 Subject: [PATCH] docs(storage): Add ARCHIVE storage class * Update some storage class testing to use ARCHIVE. [closes #4285] --- .../acceptance/storage/file_test.rb | 6 ++--- .../lib/google/cloud/storage/bucket.rb | 16 ++++++------- .../google/cloud/storage/bucket/lifecycle.rb | 10 ++++---- .../lib/google/cloud/storage/convert.rb | 7 +++--- .../lib/google/cloud/storage/file.rb | 1 + .../lib/google/cloud/storage/project.rb | 4 ++-- .../google/cloud/storage/file_update_test.rb | 24 +++++++++---------- 7 files changed, 35 insertions(+), 33 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/file_test.rb b/google-cloud-storage/acceptance/storage/file_test.rb index 23ef7f4977ea..e315b9f2f8fa 100644 --- a/google-cloud-storage/acceptance/storage/file_test.rb +++ b/google-cloud-storage/acceptance/storage/file_test.rb @@ -468,12 +468,12 @@ uploaded = bucket.create_file files[:logo][:path], "CloudLogo-storage_class.png", storage_class: :nearline uploaded.storage_class.must_equal "NEARLINE" - uploaded.storage_class = :dra - uploaded.storage_class.must_equal "DURABLE_REDUCED_AVAILABILITY" + uploaded.storage_class = :archive + uploaded.storage_class.must_equal "ARCHIVE" retrieved1 = bucket.file "CloudLogo-storage_class.png" - retrieved1.storage_class.must_equal "DURABLE_REDUCED_AVAILABILITY" + retrieved1.storage_class.must_equal "ARCHIVE" end it "should copy an existing file" do diff --git a/google-cloud-storage/lib/google/cloud/storage/bucket.rb b/google-cloud-storage/lib/google/cloud/storage/bucket.rb index f22822ad7b42..8a02f0f001fb 100644 --- a/google-cloud-storage/lib/google/cloud/storage/bucket.rb +++ b/google-cloud-storage/lib/google/cloud/storage/bucket.rb @@ -357,7 +357,7 @@ def logging_prefix= logging_prefix ## # The bucket's storage class. This defines how objects in the bucket are # stored and determines the SLA and the cost of storage. Values include - # `STANDARD`, `NEARLINE`, and `COLDLINE`. `REGIONAL`,`MULTI_REGIONAL`, + # `STANDARD`, `NEARLINE`, `COLDLINE`, and `ARCHIVE`. `REGIONAL`,`MULTI_REGIONAL`, # and `DURABLE_REDUCED_AVAILABILITY` are supported as legacy storage # classes. # @@ -370,11 +370,11 @@ def storage_class ## # Updates the bucket's storage class. This defines how objects in the # bucket are stored and determines the SLA and the cost of storage. - # Accepted values include `:standard`, `:nearline`, and `:coldline`, as - # well as the equivalent strings returned by {Bucket#storage_class}. - # `:multi_regional`, `:regional`, and `durable_reduced_availability` - # are accepted as legacy storage classes. For more information, see - # [Storage + # Accepted values include `:standard`, `:nearline`, `:coldline`, and + # `:archive`, as well as the equivalent strings returned by + # {Bucket#storage_class}. `:multi_regional`, `:regional`, and + # `durable_reduced_availability` are accepted as legacy storage classes. + # For more information, see [Storage # Classes](https://cloud.google.com/storage/docs/storage-classes). # # @param [Symbol, String] new_storage_class Storage class of the bucket. @@ -1143,8 +1143,8 @@ def file path, generation: nil, skip_lookup: nil, encryption_key: nil # @param [Symbol, String] storage_class Storage class of the file. # Determines how the file is stored and determines the SLA and the # cost of storage. Accepted values include `:standard`, `:nearline`, - # and `:coldline`, as well as the equivalent strings returned by - # {#storage_class}. `:multi_regional`, `:regional`, and + # `:coldline`, and `:archive`, as well as the equivalent strings + # returned by {#storage_class}. `:multi_regional`, `:regional`, and # `durable_reduced_availability` are accepted legacy storage classes. # For more information, see [Storage # Classes](https://cloud.google.com/storage/docs/storage-classes) diff --git a/google-cloud-storage/lib/google/cloud/storage/bucket/lifecycle.rb b/google-cloud-storage/lib/google/cloud/storage/bucket/lifecycle.rb index 5a47df46c9c3..9b04e25f2a92 100644 --- a/google-cloud-storage/lib/google/cloud/storage/bucket/lifecycle.rb +++ b/google-cloud-storage/lib/google/cloud/storage/bucket/lifecycle.rb @@ -111,7 +111,7 @@ def changed? # @param [String,Symbol,Array] matches_storage_class # Files having any of the storage classes specified by this # condition will be matched. Values include `STANDARD`, `NEARLINE`, - # and `COLDLINE`. `REGIONAL`,`MULTI_REGIONAL`, and + # `COLDLINE`, and `ARCHIVE`. `REGIONAL`,`MULTI_REGIONAL`, and # `DURABLE_REDUCED_AVAILABILITY` are supported as legacy storage # classes. Arguments will be converted from symbols and lower-case # to upper-case strings. @@ -162,7 +162,7 @@ def add_set_storage_class_rule storage_class, age: nil, # @param [String,Symbol,Array] matches_storage_class # Files having any of the storage classes specified by this # condition will be matched. Values include `STANDARD`, `NEARLINE`, - # and `COLDLINE`. `REGIONAL`,`MULTI_REGIONAL`, and + # `COLDLINE`, and `ARCHIVE`. `REGIONAL`,`MULTI_REGIONAL`, and # `DURABLE_REDUCED_AVAILABILITY` are supported as legacy storage # classes. Arguments will be converted from symbols and lower-case # to upper-case strings. @@ -240,9 +240,9 @@ def freeze # is `false`, it matches archived files. # @attr [Array] matches_storage_class Files having any of the # storage classes specified by this condition will be matched. - # Values include `STANDARD`, `NEARLINE`, and `COLDLINE`. `REGIONAL`, - # `MULTI_REGIONAL`, and `DURABLE_REDUCED_AVAILABILITY` are supported - # as legacy storage classes. + # Values include `STANDARD`, `NEARLINE`, `COLDLINE`, and `ARCHIVE`. + # `REGIONAL`, `MULTI_REGIONAL`, and `DURABLE_REDUCED_AVAILABILITY` + # are supported as legacy storage classes. # @attr [Integer] num_newer_versions Relevant only for versioned # files. If the value is N, this condition is satisfied when there # are at least N versions (including the live version) newer than diff --git a/google-cloud-storage/lib/google/cloud/storage/convert.rb b/google-cloud-storage/lib/google/cloud/storage/convert.rb index b1e55642f308..d7f0e300d308 100644 --- a/google-cloud-storage/lib/google/cloud/storage/convert.rb +++ b/google-cloud-storage/lib/google/cloud/storage/convert.rb @@ -25,12 +25,13 @@ module Convert def storage_class_for str return nil if str.nil? return str.map { |s| storage_class_for s } if str.is_a? Array - { "durable_reduced_availability" => "DURABLE_REDUCED_AVAILABILITY", + { "archive" => "ARCHIVE", + "coldline" => "COLDLINE", "dra" => "DURABLE_REDUCED_AVAILABILITY", "durable" => "DURABLE_REDUCED_AVAILABILITY", - "nearline" => "NEARLINE", - "coldline" => "COLDLINE", + "durable_reduced_availability" => "DURABLE_REDUCED_AVAILABILITY", "multi_regional" => "MULTI_REGIONAL", + "nearline" => "NEARLINE", "regional" => "REGIONAL", "standard" => "STANDARD" }[str.to_s.downcase] || str.to_s end diff --git a/google-cloud-storage/lib/google/cloud/storage/file.rb b/google-cloud-storage/lib/google/cloud/storage/file.rb index 5e4740dea285..deb32c2f868d 100644 --- a/google-cloud-storage/lib/google/cloud/storage/file.rb +++ b/google-cloud-storage/lib/google/cloud/storage/file.rb @@ -431,6 +431,7 @@ def storage_class # * `:standard` # * `:nearline` # * `:coldline` + # * `:archive` # # as well as the equivalent strings returned by {File#storage_class} or # {Bucket#storage_class}. For more information, see [Storage diff --git a/google-cloud-storage/lib/google/cloud/storage/project.rb b/google-cloud-storage/lib/google/cloud/storage/project.rb index 91106bc26b53..6a9d75373304 100644 --- a/google-cloud-storage/lib/google/cloud/storage/project.rb +++ b/google-cloud-storage/lib/google/cloud/storage/project.rb @@ -296,8 +296,8 @@ def bucket bucket_name, skip_lookup: false, user_project: nil # Logs](https://cloud.google.com/storage/docs/access-logs). # @param [Symbol, String] storage_class Defines how objects in the # bucket are stored and determines the SLA and the cost of storage. - # Accepted values include `:standard`, `:nearline`, and `:coldline`, - # as well as the equivalent strings returned by + # Accepted values include `:standard`, `:nearline`, `:coldline`, and + # `:archive`, as well as the equivalent strings returned by # {Bucket#storage_class}. For more information, see [Storage # Classes](https://cloud.google.com/storage/docs/storage-classes). The # default value is the `:standard` storage class. diff --git a/google-cloud-storage/test/google/cloud/storage/file_update_test.rb b/google-cloud-storage/test/google/cloud/storage/file_update_test.rb index 35d5c00108ac..b41ebb8f2dc6 100644 --- a/google-cloud-storage/test/google/cloud/storage/file_update_test.rb +++ b/google-cloud-storage/test/google/cloud/storage/file_update_test.rb @@ -107,43 +107,43 @@ it "updates its storage_class" do mock = Minitest::Mock.new - patch_file_gapi = Google::Apis::StorageV1::Object.new storage_class: "DURABLE_REDUCED_AVAILABILITY" + patch_file_gapi = Google::Apis::StorageV1::Object.new storage_class: "NEARLINE" patched_file_gapi = file_gapi.dup - patched_file_gapi.storage_class = "DURABLE_REDUCED_AVAILABILITY" + patched_file_gapi.storage_class = "NEARLINE" mock.expect :rewrite_object, done_rewrite(patched_file_gapi), [bucket_name, file.name, bucket_name, file.name, patch_file_gapi, destination_kms_key_name: nil, destination_predefined_acl: nil, source_generation: nil, rewrite_token: nil, user_project: nil, options: {}] file.service.mocked_service = mock file.storage_class.must_equal "STANDARD" - file.storage_class = :dra - file.storage_class.must_equal "DURABLE_REDUCED_AVAILABILITY" + file.storage_class = :nearline + file.storage_class.must_equal "NEARLINE" mock.verify end it "updates its storage_class with user_project set to true" do mock = Minitest::Mock.new - patch_file_gapi = Google::Apis::StorageV1::Object.new storage_class: "DURABLE_REDUCED_AVAILABILITY" + patch_file_gapi = Google::Apis::StorageV1::Object.new storage_class: "COLDLINE" patched_file_gapi = file_gapi.dup - patched_file_gapi.storage_class = "DURABLE_REDUCED_AVAILABILITY" + patched_file_gapi.storage_class = "COLDLINE" mock.expect :rewrite_object, done_rewrite(patched_file_gapi), [bucket_name, file.name, bucket_name, file_user_project.name, patch_file_gapi, destination_kms_key_name: nil, destination_predefined_acl: nil, source_generation: nil, rewrite_token: nil, user_project: "test", options: {}] file_user_project.service.mocked_service = mock file_user_project.storage_class.must_equal "STANDARD" - file_user_project.storage_class = :dra - file_user_project.storage_class.must_equal "DURABLE_REDUCED_AVAILABILITY" + file_user_project.storage_class = :coldline + file_user_project.storage_class.must_equal "COLDLINE" mock.verify end it "updates its storage_class, calling rewrite_object as many times as is needed" do mock = Minitest::Mock.new - patch_file_gapi = Google::Apis::StorageV1::Object.new storage_class: "DURABLE_REDUCED_AVAILABILITY" + patch_file_gapi = Google::Apis::StorageV1::Object.new storage_class: "ARCHIVE" patched_file_gapi = file_gapi.dup - patched_file_gapi.storage_class = "DURABLE_REDUCED_AVAILABILITY" + patched_file_gapi.storage_class = "ARCHIVE" mock.expect :rewrite_object, undone_rewrite("notyetcomplete"), [bucket_name, file.name, bucket_name, file.name, patch_file_gapi, destination_kms_key_name: nil, destination_predefined_acl: nil, source_generation: nil, rewrite_token: nil, user_project: nil, options: {}] mock.expect :rewrite_object, undone_rewrite("keeptrying"), @@ -160,8 +160,8 @@ def file.sleep *args end file.storage_class.must_equal "STANDARD" - file.storage_class = :dra - file.storage_class.must_equal "DURABLE_REDUCED_AVAILABILITY" + file.storage_class = :archive + file.storage_class.must_equal "ARCHIVE" mock.verify end