google-cloud-billing-budgets-v1 0.1.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,347 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/billing/budgets/v1/budget_service_pb"
20
+
21
+ module Google
22
+ module Cloud
23
+ module Billing
24
+ module Budgets
25
+ module V1
26
+ module BudgetService
27
+ module Rest
28
+ ##
29
+ # REST service stub for the BudgetService service.
30
+ # Service stub contains baseline method implementations
31
+ # including transcoding, making the REST call, and deserialing the response.
32
+ #
33
+ class ServiceStub
34
+ def initialize endpoint:, credentials:
35
+ # These require statements are intentionally placed here to initialize
36
+ # the REST modules only when it's required.
37
+ require "gapic/rest"
38
+
39
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials,
40
+ numeric_enums: true,
41
+ raise_faraday_errors: false
42
+ end
43
+
44
+ ##
45
+ # Baseline implementation for the create_budget REST call
46
+ #
47
+ # @param request_pb [::Google::Cloud::Billing::Budgets::V1::CreateBudgetRequest]
48
+ # A request object representing the call parameters. Required.
49
+ # @param options [::Gapic::CallOptions]
50
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
51
+ #
52
+ # @yield [result, operation] Access the result along with the TransportOperation object
53
+ # @yieldparam result [::Google::Cloud::Billing::Budgets::V1::Budget]
54
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
55
+ #
56
+ # @return [::Google::Cloud::Billing::Budgets::V1::Budget]
57
+ # A result object deserialized from the server's reply
58
+ def create_budget request_pb, options = nil
59
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
60
+
61
+ verb, uri, query_string_params, body = ServiceStub.transcode_create_budget_request request_pb
62
+ query_string_params = if query_string_params.any?
63
+ query_string_params.to_h { |p| p.split("=", 2) }
64
+ else
65
+ {}
66
+ end
67
+
68
+ response = @client_stub.make_http_request(
69
+ verb,
70
+ uri: uri,
71
+ body: body || "",
72
+ params: query_string_params,
73
+ options: options
74
+ )
75
+ operation = ::Gapic::Rest::TransportOperation.new response
76
+ result = ::Google::Cloud::Billing::Budgets::V1::Budget.decode_json response.body, ignore_unknown_fields: true
77
+
78
+ yield result, operation if block_given?
79
+ result
80
+ end
81
+
82
+ ##
83
+ # Baseline implementation for the update_budget REST call
84
+ #
85
+ # @param request_pb [::Google::Cloud::Billing::Budgets::V1::UpdateBudgetRequest]
86
+ # A request object representing the call parameters. Required.
87
+ # @param options [::Gapic::CallOptions]
88
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
89
+ #
90
+ # @yield [result, operation] Access the result along with the TransportOperation object
91
+ # @yieldparam result [::Google::Cloud::Billing::Budgets::V1::Budget]
92
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
93
+ #
94
+ # @return [::Google::Cloud::Billing::Budgets::V1::Budget]
95
+ # A result object deserialized from the server's reply
96
+ def update_budget request_pb, options = nil
97
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
98
+
99
+ verb, uri, query_string_params, body = ServiceStub.transcode_update_budget_request request_pb
100
+ query_string_params = if query_string_params.any?
101
+ query_string_params.to_h { |p| p.split("=", 2) }
102
+ else
103
+ {}
104
+ end
105
+
106
+ response = @client_stub.make_http_request(
107
+ verb,
108
+ uri: uri,
109
+ body: body || "",
110
+ params: query_string_params,
111
+ options: options
112
+ )
113
+ operation = ::Gapic::Rest::TransportOperation.new response
114
+ result = ::Google::Cloud::Billing::Budgets::V1::Budget.decode_json response.body, ignore_unknown_fields: true
115
+
116
+ yield result, operation if block_given?
117
+ result
118
+ end
119
+
120
+ ##
121
+ # Baseline implementation for the get_budget REST call
122
+ #
123
+ # @param request_pb [::Google::Cloud::Billing::Budgets::V1::GetBudgetRequest]
124
+ # A request object representing the call parameters. Required.
125
+ # @param options [::Gapic::CallOptions]
126
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
127
+ #
128
+ # @yield [result, operation] Access the result along with the TransportOperation object
129
+ # @yieldparam result [::Google::Cloud::Billing::Budgets::V1::Budget]
130
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
131
+ #
132
+ # @return [::Google::Cloud::Billing::Budgets::V1::Budget]
133
+ # A result object deserialized from the server's reply
134
+ def get_budget request_pb, options = nil
135
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
136
+
137
+ verb, uri, query_string_params, body = ServiceStub.transcode_get_budget_request request_pb
138
+ query_string_params = if query_string_params.any?
139
+ query_string_params.to_h { |p| p.split("=", 2) }
140
+ else
141
+ {}
142
+ end
143
+
144
+ response = @client_stub.make_http_request(
145
+ verb,
146
+ uri: uri,
147
+ body: body || "",
148
+ params: query_string_params,
149
+ options: options
150
+ )
151
+ operation = ::Gapic::Rest::TransportOperation.new response
152
+ result = ::Google::Cloud::Billing::Budgets::V1::Budget.decode_json response.body, ignore_unknown_fields: true
153
+
154
+ yield result, operation if block_given?
155
+ result
156
+ end
157
+
158
+ ##
159
+ # Baseline implementation for the list_budgets REST call
160
+ #
161
+ # @param request_pb [::Google::Cloud::Billing::Budgets::V1::ListBudgetsRequest]
162
+ # A request object representing the call parameters. Required.
163
+ # @param options [::Gapic::CallOptions]
164
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
165
+ #
166
+ # @yield [result, operation] Access the result along with the TransportOperation object
167
+ # @yieldparam result [::Google::Cloud::Billing::Budgets::V1::ListBudgetsResponse]
168
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
169
+ #
170
+ # @return [::Google::Cloud::Billing::Budgets::V1::ListBudgetsResponse]
171
+ # A result object deserialized from the server's reply
172
+ def list_budgets request_pb, options = nil
173
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
174
+
175
+ verb, uri, query_string_params, body = ServiceStub.transcode_list_budgets_request request_pb
176
+ query_string_params = if query_string_params.any?
177
+ query_string_params.to_h { |p| p.split("=", 2) }
178
+ else
179
+ {}
180
+ end
181
+
182
+ response = @client_stub.make_http_request(
183
+ verb,
184
+ uri: uri,
185
+ body: body || "",
186
+ params: query_string_params,
187
+ options: options
188
+ )
189
+ operation = ::Gapic::Rest::TransportOperation.new response
190
+ result = ::Google::Cloud::Billing::Budgets::V1::ListBudgetsResponse.decode_json response.body, ignore_unknown_fields: true
191
+
192
+ yield result, operation if block_given?
193
+ result
194
+ end
195
+
196
+ ##
197
+ # Baseline implementation for the delete_budget REST call
198
+ #
199
+ # @param request_pb [::Google::Cloud::Billing::Budgets::V1::DeleteBudgetRequest]
200
+ # A request object representing the call parameters. Required.
201
+ # @param options [::Gapic::CallOptions]
202
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
203
+ #
204
+ # @yield [result, operation] Access the result along with the TransportOperation object
205
+ # @yieldparam result [::Google::Protobuf::Empty]
206
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
207
+ #
208
+ # @return [::Google::Protobuf::Empty]
209
+ # A result object deserialized from the server's reply
210
+ def delete_budget request_pb, options = nil
211
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
212
+
213
+ verb, uri, query_string_params, body = ServiceStub.transcode_delete_budget_request request_pb
214
+ query_string_params = if query_string_params.any?
215
+ query_string_params.to_h { |p| p.split("=", 2) }
216
+ else
217
+ {}
218
+ end
219
+
220
+ response = @client_stub.make_http_request(
221
+ verb,
222
+ uri: uri,
223
+ body: body || "",
224
+ params: query_string_params,
225
+ options: options
226
+ )
227
+ operation = ::Gapic::Rest::TransportOperation.new response
228
+ result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
229
+
230
+ yield result, operation if block_given?
231
+ result
232
+ end
233
+
234
+ ##
235
+ # @private
236
+ #
237
+ # GRPC transcoding helper method for the create_budget REST call
238
+ #
239
+ # @param request_pb [::Google::Cloud::Billing::Budgets::V1::CreateBudgetRequest]
240
+ # A request object representing the call parameters. Required.
241
+ # @return [Array(String, [String, nil], Hash{String => String})]
242
+ # Uri, Body, Query string parameters
243
+ def self.transcode_create_budget_request request_pb
244
+ transcoder = Gapic::Rest::GrpcTranscoder.new
245
+ .with_bindings(
246
+ uri_method: :post,
247
+ uri_template: "/v1/{parent}/budgets",
248
+ body: "budget",
249
+ matches: [
250
+ ["parent", %r{^billingAccounts/[^/]+/?$}, false]
251
+ ]
252
+ )
253
+ transcoder.transcode request_pb
254
+ end
255
+
256
+ ##
257
+ # @private
258
+ #
259
+ # GRPC transcoding helper method for the update_budget REST call
260
+ #
261
+ # @param request_pb [::Google::Cloud::Billing::Budgets::V1::UpdateBudgetRequest]
262
+ # A request object representing the call parameters. Required.
263
+ # @return [Array(String, [String, nil], Hash{String => String})]
264
+ # Uri, Body, Query string parameters
265
+ def self.transcode_update_budget_request request_pb
266
+ transcoder = Gapic::Rest::GrpcTranscoder.new
267
+ .with_bindings(
268
+ uri_method: :patch,
269
+ uri_template: "/v1/{budget.name}",
270
+ body: "budget",
271
+ matches: [
272
+ ["budget.name", %r{^billingAccounts/[^/]+/budgets/[^/]+/?$}, false]
273
+ ]
274
+ )
275
+ transcoder.transcode request_pb
276
+ end
277
+
278
+ ##
279
+ # @private
280
+ #
281
+ # GRPC transcoding helper method for the get_budget REST call
282
+ #
283
+ # @param request_pb [::Google::Cloud::Billing::Budgets::V1::GetBudgetRequest]
284
+ # A request object representing the call parameters. Required.
285
+ # @return [Array(String, [String, nil], Hash{String => String})]
286
+ # Uri, Body, Query string parameters
287
+ def self.transcode_get_budget_request request_pb
288
+ transcoder = Gapic::Rest::GrpcTranscoder.new
289
+ .with_bindings(
290
+ uri_method: :get,
291
+ uri_template: "/v1/{name}",
292
+ matches: [
293
+ ["name", %r{^billingAccounts/[^/]+/budgets/[^/]+/?$}, false]
294
+ ]
295
+ )
296
+ transcoder.transcode request_pb
297
+ end
298
+
299
+ ##
300
+ # @private
301
+ #
302
+ # GRPC transcoding helper method for the list_budgets REST call
303
+ #
304
+ # @param request_pb [::Google::Cloud::Billing::Budgets::V1::ListBudgetsRequest]
305
+ # A request object representing the call parameters. Required.
306
+ # @return [Array(String, [String, nil], Hash{String => String})]
307
+ # Uri, Body, Query string parameters
308
+ def self.transcode_list_budgets_request request_pb
309
+ transcoder = Gapic::Rest::GrpcTranscoder.new
310
+ .with_bindings(
311
+ uri_method: :get,
312
+ uri_template: "/v1/{parent}/budgets",
313
+ matches: [
314
+ ["parent", %r{^billingAccounts/[^/]+/?$}, false]
315
+ ]
316
+ )
317
+ transcoder.transcode request_pb
318
+ end
319
+
320
+ ##
321
+ # @private
322
+ #
323
+ # GRPC transcoding helper method for the delete_budget REST call
324
+ #
325
+ # @param request_pb [::Google::Cloud::Billing::Budgets::V1::DeleteBudgetRequest]
326
+ # A request object representing the call parameters. Required.
327
+ # @return [Array(String, [String, nil], Hash{String => String})]
328
+ # Uri, Body, Query string parameters
329
+ def self.transcode_delete_budget_request request_pb
330
+ transcoder = Gapic::Rest::GrpcTranscoder.new
331
+ .with_bindings(
332
+ uri_method: :delete,
333
+ uri_template: "/v1/{name}",
334
+ matches: [
335
+ ["name", %r{^billingAccounts/[^/]+/budgets/[^/]+/?$}, false]
336
+ ]
337
+ )
338
+ transcoder.transcode request_pb
339
+ end
340
+ end
341
+ end
342
+ end
343
+ end
344
+ end
345
+ end
346
+ end
347
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/rest"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/billing/budgets/v1/version"
24
+
25
+ require "google/cloud/billing/budgets/v1/budget_service/credentials"
26
+ require "google/cloud/billing/budgets/v1/budget_service/paths"
27
+ require "google/cloud/billing/budgets/v1/budget_service/rest/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module Billing
32
+ module Budgets
33
+ module V1
34
+ ##
35
+ # BudgetService stores Cloud Billing budgets, which define a
36
+ # budget plan and rules to execute as we track spend against that plan.
37
+ #
38
+ # To load this service and instantiate a REST client:
39
+ #
40
+ # require "google/cloud/billing/budgets/v1/budget_service/rest"
41
+ # client = ::Google::Cloud::Billing::Budgets::V1::BudgetService::Rest::Client.new
42
+ #
43
+ module BudgetService
44
+ # Client for the REST transport
45
+ module Rest
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ helper_path = ::File.join __dir__, "rest", "helpers.rb"
55
+ require "google/cloud/billing/budgets/v1/budget_service/rest/helpers" if ::File.file? helper_path
@@ -25,6 +25,7 @@ require "google/cloud/billing/budgets/v1/version"
25
25
  require "google/cloud/billing/budgets/v1/budget_service/credentials"
26
26
  require "google/cloud/billing/budgets/v1/budget_service/paths"
27
27
  require "google/cloud/billing/budgets/v1/budget_service/client"
28
+ require "google/cloud/billing/budgets/v1/budget_service/rest"
28
29
 
29
30
  module Google
30
31
  module Cloud
@@ -35,11 +36,16 @@ module Google
35
36
  # BudgetService stores Cloud Billing budgets, which define a
36
37
  # budget plan and rules to execute as we track spend against that plan.
37
38
  #
38
- # To load this service and instantiate a client:
39
+ # @example Load this service and instantiate a gRPC client
39
40
  #
40
41
  # require "google/cloud/billing/budgets/v1/budget_service"
41
42
  # client = ::Google::Cloud::Billing::Budgets::V1::BudgetService::Client.new
42
43
  #
44
+ # @example Load this service and instantiate a REST client
45
+ #
46
+ # require "google/cloud/billing/budgets/v1/budget_service/rest"
47
+ # client = ::Google::Cloud::Billing::Budgets::V1::BudgetService::Rest::Client.new
48
+ #
43
49
  module BudgetService
44
50
  end
45
51
  end
@@ -1,6 +1,8 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/cloud/billing/budgets/v1/budget_service.proto
3
3
 
4
+ require 'google/protobuf'
5
+
4
6
  require 'google/api/annotations_pb'
5
7
  require 'google/api/client_pb'
6
8
  require 'google/api/field_behavior_pb'
@@ -8,7 +10,6 @@ require 'google/api/resource_pb'
8
10
  require 'google/cloud/billing/budgets/v1/budget_model_pb'
9
11
  require 'google/protobuf/empty_pb'
10
12
  require 'google/protobuf/field_mask_pb'
11
- require 'google/protobuf'
12
13
 
13
14
  Google::Protobuf::DescriptorPool.generated_pool.build do
14
15
  add_file("google/cloud/billing/budgets/v1/budget_service.proto", :syntax => :proto3) do
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/billing/budgets/v1/budget_service/rest"
20
+ require "google/cloud/billing/budgets/v1/version"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Billing
25
+ module Budgets
26
+ ##
27
+ # To load just the REST part of this package, including all its services, and instantiate a REST client:
28
+ #
29
+ # @example
30
+ #
31
+ # require "google/cloud/billing/budgets/v1/rest"
32
+ # client = ::Google::Cloud::Billing::Budgets::V1::BudgetService::Rest::Client.new
33
+ #
34
+ module V1
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -22,7 +22,7 @@ module Google
22
22
  module Billing
23
23
  module Budgets
24
24
  module V1
25
- VERSION = "0.1.2"
25
+ VERSION = "0.3.0"
26
26
  end
27
27
  end
28
28
  end
@@ -24,11 +24,18 @@ module Google
24
24
  module Billing
25
25
  module Budgets
26
26
  ##
27
- # To load this package, including all its services, and instantiate a client:
27
+ # API client module.
28
+ #
29
+ # @example Load this package, including all its services, and instantiate a gRPC client
28
30
  #
29
31
  # require "google/cloud/billing/budgets/v1"
30
32
  # client = ::Google::Cloud::Billing::Budgets::V1::BudgetService::Client.new
31
33
  #
34
+ # @example Load this package, including all its services, and instantiate a REST client
35
+ #
36
+ # require "google/cloud/billing/budgets/v1"
37
+ # client = ::Google::Cloud::Billing::Budgets::V1::BudgetService::Rest::Client.new
38
+ #
32
39
  module V1
33
40
  end
34
41
  end