Skip to content

Commit 74f3d0f

Browse files
gcf-owl-bot[bot]shubhangi-google
authored andcommitted
feat: Added support for hierarchical enrollment in Quota Adjuster consumer API (googleapis#30506)
docs: Added 2 new fields in `.google.api.cloudquotas.v1beta.QuotaAdjusterSettings` docs: Added inherited and inherited_from in `.google.api.cloudquotas.v1beta.QuotaAdjusterSettings` docs: Added support for folder and organization level enrollment
1 parent 6c24007 commit 74f3d0f

File tree

6 files changed

+123
-37
lines changed

6 files changed

+123
-37
lines changed

google-cloud-cloud_quotas-v1beta/lib/google/api/cloudquotas/v1beta/quota_adjuster_settings_pb.rb

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

google-cloud-cloud_quotas-v1beta/lib/google/cloud/cloud_quotas/v1beta/quota_adjuster_settings_manager/paths.rb

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,53 @@ module Paths
2727
##
2828
# Create a fully-qualified QuotaAdjusterSettings resource string.
2929
#
30-
# The resource will be in the following format:
30+
# @overload quota_adjuster_settings_path(project:, location:)
31+
# The resource will be in the following format:
3132
#
32-
# `projects/{project}/locations/{location}/quotaAdjusterSettings`
33+
# `projects/{project}/locations/{location}/quotaAdjusterSettings`
3334
#
34-
# @param project [String]
35-
# @param location [String]
35+
# @param project [String]
36+
# @param location [String]
37+
#
38+
# @overload quota_adjuster_settings_path(organization:, location:)
39+
# The resource will be in the following format:
40+
#
41+
# `organizations/{organization}/locations/{location}/quotaAdjusterSettings`
42+
#
43+
# @param organization [String]
44+
# @param location [String]
45+
#
46+
# @overload quota_adjuster_settings_path(folder:, location:)
47+
# The resource will be in the following format:
48+
#
49+
# `folders/{folder}/locations/{location}/quotaAdjusterSettings`
50+
#
51+
# @param folder [String]
52+
# @param location [String]
3653
#
3754
# @return [::String]
38-
def quota_adjuster_settings_path project:, location:
39-
raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
55+
def quota_adjuster_settings_path **args
56+
resources = {
57+
"location:project" => (proc do |project:, location:|
58+
raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
59+
60+
"projects/#{project}/locations/#{location}/quotaAdjusterSettings"
61+
end),
62+
"location:organization" => (proc do |organization:, location:|
63+
raise ::ArgumentError, "organization cannot contain /" if organization.to_s.include? "/"
64+
65+
"organizations/#{organization}/locations/#{location}/quotaAdjusterSettings"
66+
end),
67+
"folder:location" => (proc do |folder:, location:|
68+
raise ::ArgumentError, "folder cannot contain /" if folder.to_s.include? "/"
69+
70+
"folders/#{folder}/locations/#{location}/quotaAdjusterSettings"
71+
end)
72+
}
4073

41-
"projects/#{project}/locations/#{location}/quotaAdjusterSettings"
74+
resource = resources[args.keys.sort.join(":")]
75+
raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
76+
resource.call(**args)
4277
end
4378

4479
extend self

google-cloud-cloud_quotas-v1beta/lib/google/cloud/cloud_quotas/v1beta/quota_adjuster_settings_manager/rest/service_stub.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,22 @@ def self.transcode_update_quota_adjuster_settings_request request_pb
172172
["quota_adjuster_settings.name", %r{^projects/[^/]+/locations/[^/]+/quotaAdjusterSettings/?$}, false]
173173
]
174174
)
175+
.with_bindings(
176+
uri_method: :patch,
177+
uri_template: "/v1beta/{quota_adjuster_settings.name}",
178+
body: "quota_adjuster_settings",
179+
matches: [
180+
["quota_adjuster_settings.name", %r{^folders/[^/]+/locations/[^/]+/quotaAdjusterSettings/?$}, false]
181+
]
182+
)
183+
.with_bindings(
184+
uri_method: :patch,
185+
uri_template: "/v1beta/{quota_adjuster_settings.name}",
186+
body: "quota_adjuster_settings",
187+
matches: [
188+
["quota_adjuster_settings.name", %r{^organizations/[^/]+/locations/[^/]+/quotaAdjusterSettings/?$}, false]
189+
]
190+
)
175191
transcoder.transcode request_pb
176192
end
177193

@@ -193,6 +209,20 @@ def self.transcode_get_quota_adjuster_settings_request request_pb
193209
["name", %r{^projects/[^/]+/locations/[^/]+/quotaAdjusterSettings/?$}, false]
194210
]
195211
)
212+
.with_bindings(
213+
uri_method: :get,
214+
uri_template: "/v1beta/{name}",
215+
matches: [
216+
["name", %r{^folders/[^/]+/locations/[^/]+/quotaAdjusterSettings/?$}, false]
217+
]
218+
)
219+
.with_bindings(
220+
uri_method: :get,
221+
uri_template: "/v1beta/{name}",
222+
matches: [
223+
["name", %r{^organizations/[^/]+/locations/[^/]+/quotaAdjusterSettings/?$}, false]
224+
]
225+
)
196226
transcoder.transcode request_pb
197227
end
198228
end

google-cloud-cloud_quotas-v1beta/proto_docs/google/api/cloudquotas/v1beta/quota_adjuster_settings.rb

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,13 @@ class UpdateQuotaAdjusterSettingsRequest
5252
# Adjuster.
5353
# @!attribute [rw] name
5454
# @return [::String]
55-
# Identifier. Name of the configuration, in the following format:
56-
# `projects/PROJECT_NUMBER/locations/global/quotaAdjusterSettings`.
57-
# Replace PROJECT_NUMBER with the project number for your project.
55+
# Identifier. Name of the config would be of the format:
56+
# projects/PROJECT_NUMBER/locations/global/quotaAdjusterSettings
57+
# folders/FOLDER_NUMBER/locations/global/quotaAdjusterSettings
58+
# organizations/ORGANIZATION_NUMBER/locations/global/quotaAdjusterSettings
5859
# @!attribute [rw] enablement
5960
# @return [::Google::Cloud::CloudQuotas::V1beta::QuotaAdjusterSettings::Enablement]
60-
# Required. The configured value of the enablement at the given resource.
61+
# Optional. The configured value of the enablement at the given resource.
6162
# @!attribute [r] update_time
6263
# @return [::Google::Protobuf::Timestamp]
6364
# Output only. The timestamp when the QuotaAdjusterSettings resource was last
@@ -68,6 +69,18 @@ class UpdateQuotaAdjusterSettingsRequest
6869
# provided on update and does not match the current server's ETag in the
6970
# QuotaAdjusterSettings, the request is blocked and returns an ABORTED error.
7071
# See https://google.aip.dev/134#etags for more details on ETags.
72+
# @!attribute [rw] inherited
73+
# @return [::Boolean]
74+
# Optional. Indicates whether the setting is inherited or explicitly
75+
# specified.
76+
# @!attribute [r] inherited_from
77+
# @return [::String]
78+
# Output only. The resource container from which the setting is inherited.
79+
# This refers to the nearest ancestor with enablement set (either ENABLED or
80+
# DISABLED). The value can be an organizations/\\{organization_id},
81+
# folders/\\{folder_id}, or can be 'default' if no ancestor exists with
82+
# enablement set. The value will be empty when enablement is directly set on
83+
# this container.
7184
class QuotaAdjusterSettings
7285
include ::Google::Protobuf::MessageExts
7386
extend ::Google::Protobuf::MessageExts::ClassMethods

0 commit comments

Comments
 (0)