Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions google-cloud-parameter_manager/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ../google-cloud-parameter_manager-v1
specs:
google-cloud-parameter_manager-v1 (1.0.0)
google-cloud-parameter_manager-v1 (1.1.0)
gapic-common (~> 1.3)
google-cloud-errors (~> 1.0)
google-cloud-location (~> 1.0)
Expand All @@ -10,7 +10,7 @@ PATH
PATH
remote: .
specs:
google-cloud-parameter_manager (1.0.0)
google-cloud-parameter_manager (1.0.1)
google-cloud-core (~> 1.6)
google-cloud-parameter_manager-v1 (>= 0.0, < 2.a)

Expand Down Expand Up @@ -147,10 +147,10 @@ GEM
minitest-focus (1.4.1)
minitest (> 5.0)
minitest-mock (5.27.0)
minitest-reporters (1.5.0)
minitest-reporters (1.8.0)
ansi
builder
minitest (>= 5.0)
minitest (>= 5.0, < 7)
ruby-progressbar
minitest-rg (5.4.0)
minitest (>= 5.0, < 7)
Expand Down Expand Up @@ -229,7 +229,7 @@ DEPENDENCIES
minitest (~> 6.0.2)
minitest-focus (~> 1.4)
minitest-mock (~> 5.27)
minitest-reporters (~> 1.5.0)
minitest-reporters (~> 1.8.0)
minitest-rg (~> 5.3)
ostruct (~> 0.5.5)
rake (>= 13.0)
Expand All @@ -254,8 +254,8 @@ CHECKSUMS
google-cloud-env (2.4.0) sha256=01cb35ecee5d1c4d1cd4deaed8bb5bddc838e296bcc2a35c5d1ddd07ce40d28d
google-cloud-errors (1.7.0) sha256=6e682f42d89aae08689f36f28495de629d756da076bafff0003bac7f8042ebb3
google-cloud-location (1.5.0) sha256=336f94609b1fb18fce1929048fac964f4d5a87d27c1e5444bfed3605469c7532
google-cloud-parameter_manager (1.0.0)
google-cloud-parameter_manager-v1 (1.0.0)
google-cloud-parameter_manager (1.0.1)
google-cloud-parameter_manager-v1 (1.1.0)
google-logging-utils (0.2.0) sha256=675462b4ea5affa825a3442694ca2d75d0069455a1d0956127207498fca3df7b
google-protobuf (4.35.1) sha256=a3a6471331d918f58dfa4d014a8f6286f0af2cf4840216bde52fcf2ea3fe3726
google-protobuf (4.35.1-aarch64-linux-gnu) sha256=50ca44d0eeff3f8475e630a1accdd974256f3510694d574e2c9d6119ea8bc9e1
Expand Down Expand Up @@ -290,7 +290,7 @@ CHECKSUMS
minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1
minitest-focus (1.4.1) sha256=394517cbe2dcb2d992d8ffc41a3b2b6315777a4daa69239de4fefe7110dd810e
minitest-mock (5.27.0) sha256=7040ed7185417a966920987eaa6eaf1be4ea1fc5b25bb03ff4703f98564a55b0
minitest-reporters (1.5.0) sha256=a693acddc67987cde96d33ad6766b8d3e8522bb4c8a20628352950c30d42f0a3
minitest-reporters (1.8.0) sha256=8ce5280fb73ad3178ae525454df169b6f28c1b38b1d088ea91815d3a370ba384
minitest-rg (5.4.0) sha256=54d42bb8ce876381245be5866f3c1dd704ef79c06ba5c9ff280c0aa28c56effb
net-http (0.9.1) sha256=25ba0b67c63e89df626ed8fac771d0ad24ad151a858af2cc8e6a716ca4336996
os (1.1.4) sha256=57816d6a334e7bd6aed048f4b0308226c5fb027433b67d90a9ab435f35108d3f
Expand Down
4 changes: 4 additions & 0 deletions google-cloud-parameter_manager/samples/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ gem "google-cloud-parameter_manager", path: master ? "../../google-cloud-paramet
gem "google-cloud-secret_manager", path: master ? "../../google-cloud-secret_manager" : nil
# Required for kms_key test case.
gem "google-cloud-kms", path: master ? "../../google-cloud-kms" : nil
# Required for the tag binding samples and test cases.
gem "google-cloud-resource_manager-v3", "~> 1.3"
# Required for the checksum samples and test cases.
gem "digest-crc", "~> 0.7"

group :test do
gem "google-style", "~> 1.30.1"
Expand Down
14 changes: 12 additions & 2 deletions google-cloud-parameter_manager/samples/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ GEM
ast (2.4.3)
base64 (0.3.0)
bigdecimal (4.1.2)
digest-crc (0.7.0)
rake (>= 12.0.0, < 14.0.0)
faraday (2.14.3)
faraday-net_http (>= 2.0, < 3.5)
json
Expand Down Expand Up @@ -45,11 +47,15 @@ GEM
google-cloud-parameter_manager (1.0.0)
google-cloud-core (~> 1.6)
google-cloud-parameter_manager-v1 (>= 0.0, < 2.a)
google-cloud-parameter_manager-v1 (1.0.0)
google-cloud-parameter_manager-v1 (1.1.0)
gapic-common (~> 1.3)
google-cloud-errors (~> 1.0)
google-cloud-location (~> 1.0)
grpc-google-iam-v1 (~> 1.11)
google-cloud-resource_manager-v3 (1.8.0)
gapic-common (~> 1.3)
google-cloud-errors (~> 1.0)
grpc-google-iam-v1 (~> 1.11)
google-cloud-secret_manager (2.2.0)
google-cloud-core (~> 1.6)
google-cloud-secret_manager-v1 (~> 1.2)
Expand Down Expand Up @@ -198,8 +204,10 @@ PLATFORMS
x86_64-linux-musl

DEPENDENCIES
digest-crc (~> 0.7)
google-cloud-kms
google-cloud-parameter_manager
google-cloud-resource_manager-v3 (~> 1.3)
google-cloud-secret_manager
google-style (~> 1.30.1)
minitest (~> 5.14)
Expand All @@ -213,6 +221,7 @@ CHECKSUMS
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd
bundler (4.0.14) sha256=d09a0a965cf772266a7e49e83610be7c2f4e49e61134c42a56804bb383cc24b8
digest-crc (0.7.0) sha256=64adc23a26a241044cbe6732477ca1b3c281d79e2240bcff275a37a5a0d78c07
faraday (2.14.3) sha256=1882247e6766615c8220b4392bf1d27f6ebb63d8e28267587cef1fb0bf37f278
faraday-net_http (3.4.4) sha256=0e78af151747ed1b00f33e25973b4bc220d7f16c00c39676817c8b12331eb588
faraday-retry (2.4.0) sha256=7b79c48fb7e56526faf247b12d94a680071ff40c9fda7cf1ec1549439ad11ebe
Expand All @@ -224,7 +233,8 @@ CHECKSUMS
google-cloud-kms-v1 (1.15.0) sha256=25942a07b11809bc535263bb4ce7e0d9ccef5e863463374defd7487dcd07ef97
google-cloud-location (1.5.0) sha256=336f94609b1fb18fce1929048fac964f4d5a87d27c1e5444bfed3605469c7532
google-cloud-parameter_manager (1.0.0) sha256=77330ff224a44fd0ebb525b62b1ae048e48f70a65bca0ceafe99767d24a796e5
google-cloud-parameter_manager-v1 (1.0.0) sha256=671faff78b7ab2e1a6928d528feef9a282d98747ecc6f3d40b876b866a7dc5d7
google-cloud-parameter_manager-v1 (1.1.0) sha256=a7217d9070bc4c9dab83f098975f50a1de5809d7d779ec7d1e3174f0641bd5d9
google-cloud-resource_manager-v3 (1.8.0) sha256=a288663a557b72e2701cbe147a64cb2e675be5f6d872bab590a288d51e7e5c41
google-cloud-secret_manager (2.2.0) sha256=71a61a1427c0b9c5876ae99b4a61a92e62af8b6f0c0c9f0639dbeff8f27c3cea
google-cloud-secret_manager-v1 (1.9.0) sha256=f24397f11fcf6e3e17c6a8add1370f1f1ea679a2134876a35990a549ec346bc9
google-iam-v1 (1.7.0) sha256=9e3ea9dcc59cbd5f8d2f62b00da41ec57a2e427b33c0e798207fa06c8fbb8b87
Expand Down
41 changes: 41 additions & 0 deletions google-cloud-parameter_manager/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ authentication:
```text
$ export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"
$ export GOOGLE_CLOUD_LOCATION="YOUR_LOCATION_ID"
$ export GOOGLE_CLOUD_TAG_KEY="YOUR_TAG_KEY_ID"
$ export GOOGLE_CLOUD_TAG_VALUE="YOUR_TAG_VALUE_ID"
```

`GOOGLE_CLOUD_TAG_KEY` and `GOOGLE_CLOUD_TAG_VALUE` (for example `tagKeys/123456789` and `tagValues/123456789`)
must refer to an existing tag key and tag value. They are only used by the tag samples and their tests.

## Run Tests

1. **Test only global samples using the Project ID configured above**
Expand Down Expand Up @@ -107,6 +112,24 @@ authentication:
| update_param_kms_key.rb | `parameter_id`, `kms_key` | Updates a global parameter kms_key. |
| remove_param_kms_key.rb | `parameter_id` | Removes a kms_key for global parameter. |
| quickstart.rb | `parameter_id`, `version_id` | Creates a global parameter, parameter version and retrieves the parameter version. |
| create_param_template.rb | `template_id` | Creates a global template with JSON format. |
| create_param_template_version.rb | `template_id`, `version_id` | Creates a global template version with placeholders. |
| get_param_template.rb | `template_id` | Retrieves a global template. |
| get_param_template_version.rb | `template_id`, `version_id` | Retrieves a global template version. |
| list_param_templates.rb | | Lists all global templates. |
| list_param_template_versions.rb | `template_id` | Lists all global template versions. |
| update_param_template_labels.rb | `template_id`, `label_key`, `label_value` | Updates the labels of a global template. |
| delete_param_template.rb | `template_id` | Deletes a global template. |
| disable_param_template_version.rb | `template_id`, `version_id` | Disables a global template version. |
| enable_param_template_version.rb | `template_id`, `version_id` | Enables a global template version. |
| delete_param_template_version.rb | `template_id`, `version_id` | Deletes a global template version. |
| render_param_template_version.rb | `template_id`, `version_id`, `parameter_id`, `parameter_version_id` | Renders a global template version. |
| create_param_with_tags.rb | `parameter_id`, `tag_key`, `tag_value` | Creates a global parameter with tags. |
| bind_tags_to_param.rb | `parameter_id`, `tag_value` | Creates a global parameter and binds a tag to it. |
| get_param_tags.rb | `parameter_id` | Lists the tags bound to a global parameter. |
| create_param_version_with_checksum.rb | `parameter_id`, `version_id` | Creates a global parameter version with a checksum. |
| get_param_version_verify_checksum.rb | `parameter_id`, `version_id` | Retrieves a global parameter version and verifies its checksum. |
| template_quickstart.rb | `template_id`, `parameter_id`, `version_id` | Creates a global template, a global parameter and renders the template. |

### Run regional samples

Expand All @@ -132,3 +155,21 @@ authentication:
| update_regional_param_kms_key.rb | `parameter_id`, `kms_key` | Updates a regional parameter kms_key. |
| remove_regional_param_kms_key.rb | `parameter_id` | Removes a kms_key for regional parameter. |
| regional_quickstart.rb | `parameter_id`, `version_id` | Creates a regional parameter, parameter version and retrieves the parameter version. |
| create_regional_param_template.rb | `template_id` | Creates a regional template with JSON format. |
| create_regional_param_template_version.rb | `template_id`, `version_id` | Creates a regional template version with placeholders. |
| get_regional_param_template.rb | `template_id` | Retrieves a regional template. |
| get_regional_param_template_version.rb | `template_id`, `version_id` | Retrieves a regional template version. |
| list_regional_param_templates.rb | | Lists all regional templates. |
| list_regional_param_template_versions.rb | `template_id` | Lists all regional template versions. |
| update_regional_param_template_labels.rb | `template_id`, `label_key`, `label_value` | Updates the labels of a regional template. |
| delete_regional_param_template.rb | `template_id` | Deletes a regional template. |
| disable_regional_param_template_version.rb | `template_id`, `version_id` | Disables a regional template version. |
| enable_regional_param_template_version.rb | `template_id`, `version_id` | Enables a regional template version. |
| delete_regional_param_template_version.rb | `template_id`, `version_id` | Deletes a regional template version. |
| render_regional_param_template_version.rb | `template_id`, `version_id`, `parameter_id`, `parameter_version_id` | Renders a regional template version. |
| create_regional_param_with_tags.rb | `parameter_id`, `tag_key`, `tag_value` | Creates a regional parameter with tags. |
| bind_tags_to_regional_param.rb | `parameter_id`, `tag_value` | Creates a regional parameter and binds a tag to it. |
| get_regional_param_tags.rb | `parameter_id` | Lists the tags bound to a regional parameter. |
| create_regional_param_version_with_checksum.rb | `parameter_id`, `version_id` | Creates a regional parameter version with a checksum. |
| get_regional_param_version_verify_checksum.rb | `parameter_id`, `version_id` | Retrieves a regional parameter version and verifies its checksum. |
| regional_template_quickstart.rb | `template_id`, `parameter_id`, `version_id` | Creates a regional template, a regional parameter and renders the template. |
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require_relative "helper"

describe "#bind_tags_to_param", :parameter_manager_snippet do
it "creates a parameter and binds a tag" do
sample = SampleLoader.load "bind_tags_to_param.rb"

out, _err = capture_io do
sample.run project_id: project_id, parameter_id: parameter_id, tag_value: tag_value
end

assert_includes out, "Created parameter #{parameter_name}\n"
assert_includes out, "Created tag binding "

param = client.get_parameter name: parameter_name
bindings = tag_bindings_client.list_tag_bindings parent: "//parametermanager.googleapis.com/#{param.name}"
assert_includes bindings.map(&:tag_value), tag_value
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require_relative "regional_helper"

describe "#bind_tags_to_regional_param", :regional_parameter_manager_snippet do
it "creates a regional parameter and binds a tag" do
sample = SampleLoader.load "bind_tags_to_regional_param.rb"

out, _err = capture_io do
sample.run project_id: project_id, location_id: location_id, parameter_id: parameter_id, tag_value: tag_value
end

assert_includes out, "Created regional parameter #{parameter_name}\n"
assert_includes out, "Created tag binding "

param = client.get_parameter name: parameter_name
bindings = tag_bindings_client.list_tag_bindings parent: "//parametermanager.googleapis.com/#{param.name}"
assert_includes bindings.map(&:tag_value), tag_value
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require_relative "helper"

describe "#create_param_template", :parameter_manager_snippet do
it "creates a template" do
sample = SampleLoader.load "create_param_template.rb"

out, _err = capture_io do
sample.run project_id: project_id, template_id: template_id, format: :TEMPLATE_FORMAT_JSON
end

assert_equal "Created template #{template_name} with format TEMPLATE_FORMAT_JSON\n", out
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require_relative "helper"

describe "#create_param_template_version", :parameter_manager_snippet do
before do
client.create_template parent: location_name, template_id: template_id,
template: { format: :TEMPLATE_FORMAT_JSON }
end

it "creates a template version" do
sample = SampleLoader.load "create_param_template_version.rb"

out, _err = capture_io do
sample.run project_id: project_id, template_id: template_id, version_id: template_version_id
end

assert_equal "Created template version #{template_version_name}\n", out
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require "digest/crc32c"

require_relative "helper"

describe "#create_param_version_with_checksum", :parameter_manager_snippet do
before do
client.create_parameter parent: location_name, parameter_id: parameter_id
end

it "creates a parameter version with a checksum" do
sample = SampleLoader.load "create_param_version_with_checksum.rb"

out, _err = capture_io do
sample.run project_id: project_id, parameter_id: parameter_id, version_id: version_id
end

assert_equal "Created parameter version #{parameter_version_name}\nChecksum source: USER_SPECIFIED\n", out
end

it "rejects a parameter version with a mismatched checksum" do
err = assert_raises Google::Cloud::InvalidArgumentError do
client.create_parameter_version parent: parameter_name, parameter_version_id: version_id,
parameter_version: { payload: { data: "hello world!", data_crc32c: 1 } }
end
assert_includes err.message, "The CRC32C checksum of the provided payload does not match the provided value"
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require_relative "helper"

describe "#create_param_with_tags", :parameter_manager_snippet do
it "creates a parameter with tags" do
sample = SampleLoader.load "create_param_with_tags.rb"

out, _err = capture_io do
sample.run project_id: project_id, parameter_id: parameter_id, tag_key: tag_key, tag_value: tag_value
end

assert_equal "Created parameter #{parameter_name} with tag #{tag_key}: #{tag_value}\n", out

param = client.get_parameter name: parameter_name
bindings = tag_bindings_client.list_tag_bindings parent: "//parametermanager.googleapis.com/#{param.name}"
assert_includes bindings.map(&:tag_value), tag_value
end
end
Loading
Loading