google-cloud-build-v1 0.1.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7d797898ba8d71737b40410f2a4d8199e9be8dbdeea0fb53f186da219d891af
4
- data.tar.gz: 490b16e90cde2a773be1aede4b0bf36bdeb4df6200d972a633c9c2a371e9f120
3
+ metadata.gz: cd426f2ceecbaecb7473cfd4b420510fc310cb5ffed52189728d0c6d3c0fccd5
4
+ data.tar.gz: 168989c197dbf7ef5534b066889b1fd779ca4fe04ef6bd664f25c0784c21072f
5
5
  SHA512:
6
- metadata.gz: 1b91839ff4778b2c3dd1b69949e44eaeb36b7e203f69eabe7ece9cb2b3869b2d48d0cfb205116a2e68475abd53cfbdf37357499ac1e2bc32100ca365645b859d
7
- data.tar.gz: d57571f3531228400a7bc99054070c32b553e86e3999519c01368e230a0a528078ea9d7497797b6359958edad9d18b3ff73dd8d8e172429a2ee801e3f7dd18eb
6
+ metadata.gz: e3ae4c6ada10a9e68c7222749855df3f280624a41560425847b903444c7a78c75cf089d777af8f2f34c16660c57d76a4075a494949657ec87021c85e4366ed07
7
+ data.tar.gz: be4e3539d2acb2b73f7c7666e5f55c214a6e10c0792b7a5a4f06bee00614f4be6000c889729a95d162b4ac20e53cbeb77d1d60f267449cb15204df46c0aa02b1
data/README.md CHANGED
@@ -6,6 +6,12 @@ Cloud Build is a service that executes your builds on Google Cloud Platform infr
6
6
 
7
7
  https://github.com/googleapis/google-cloud-ruby
8
8
 
9
+ This gem is a _versioned_ client. It provides basic client classes for a
10
+ specific version of the Cloud Build V1 API. Most users should consider using
11
+ the main client gem,
12
+ [google-cloud-build](https://rubygems.org/gems/google-cloud-build).
13
+ See the section below titled *Which client should I use?* for more information.
14
+
9
15
  ## Installation
10
16
 
11
17
  ```
@@ -73,3 +79,61 @@ in security maintenance, and not end of life. Currently, this means Ruby 2.4
73
79
  and later. Older versions of Ruby _may_ still work, but are unsupported and not
74
80
  recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
75
81
  about the Ruby support schedule.
82
+
83
+ ## Which client should I use?
84
+
85
+ Most modern Ruby client libraries for Google APIs come in two flavors: the main
86
+ client library with a name such as `google-cloud-build`,
87
+ and lower-level _versioned_ client libraries with names such as
88
+ `google-cloud-build-v1`.
89
+ _In most cases, you should install the main client._
90
+
91
+ ### What's the difference between the main client and a versioned client?
92
+
93
+ A _versioned client_ provides a basic set of data types and client classes for
94
+ a _single version_ of a specific service. (That is, for a service with multiple
95
+ versions, there might be a separate versioned client for each service version.)
96
+ Most versioned clients are written and maintained by a code generator.
97
+
98
+ The _main client_ is designed to provide you with the _recommended_ client
99
+ interfaces for the service. There will be only one main client for any given
100
+ service, even a service with multiple versions. The main client includes
101
+ factory methods for constructing the client objects we recommend for most
102
+ users. In some cases, those will be classes provided by an underlying versioned
103
+ client; in other cases, they will be handwritten higher-level client objects
104
+ with additional capabilities, convenience methods, or best practices built in.
105
+ Generally, the main client will default to a recommended service version,
106
+ although in some cases you can override this if you need to talk to a specific
107
+ service version.
108
+
109
+ ### Why would I want to use the main client?
110
+
111
+ We recommend that most users install the main client gem for a service. You can
112
+ identify this gem as the one _without_ a version in its name, e.g.
113
+ `google-cloud-build`.
114
+ The main client is recommended because it will embody the best practices for
115
+ accessing the service, and may also provide more convenient interfaces or
116
+ tighter integration into frameworks and third-party libraries. In addition, the
117
+ documentation and samples published by Google will generally demonstrate use of
118
+ the main client.
119
+
120
+ ### Why would I want to use a versioned client?
121
+
122
+ You can use a versioned client if you are content with a possibly lower-level
123
+ class interface, you explicitly want to avoid features provided by the main
124
+ client, or you want to access a specific service version not be covered by the
125
+ main client. You can identify versioned client gems because the service version
126
+ is part of the name, e.g. `google-cloud-build-v1`.
127
+
128
+ ### What about the google-apis-<name> clients?
129
+
130
+ Client library gems with names that begin with `google-apis-` are based on an
131
+ older code generation technology. They talk to a REST/JSON backend (whereas
132
+ most modern clients talk to a [gRPC](https://grpc.io/) backend) and they may
133
+ not offer the same performance, features, and ease of use provided by more
134
+ modern clients.
135
+
136
+ The `google-apis-` clients have wide coverage across Google services, so you
137
+ might need to use one if there is no modern client available for the service.
138
+ However, if a modern client is available, we generally recommend it over the
139
+ older `google-apis-` clients.
@@ -33,3 +33,6 @@ module Google
33
33
  end
34
34
  end
35
35
  end
36
+
37
+ helper_path = ::File.join __dir__, "v1", "_helpers.rb"
38
+ require "google/cloud/build/v1/_helpers" if ::File.file? helper_path
@@ -23,6 +23,7 @@ require "gapic/config/method"
23
23
  require "google/cloud/build/v1/version"
24
24
 
25
25
  require "google/cloud/build/v1/cloud_build/credentials"
26
+ require "google/cloud/build/v1/cloud_build/paths"
26
27
  require "google/cloud/build/v1/cloud_build/operations"
27
28
  require "google/cloud/build/v1/cloud_build/client"
28
29
 
@@ -37,6 +37,8 @@ module Google
37
37
  # determine the status of the build.
38
38
  #
39
39
  class Client
40
+ include Paths
41
+
40
42
  # @private
41
43
  attr_reader :cloud_build_stub
42
44
 
@@ -77,7 +79,7 @@ module Google
77
79
  initial_delay: 0.1,
78
80
  max_delay: 60.0,
79
81
  multiplier: 1.3,
80
- retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
82
+ retry_codes: [14, 4]
81
83
  }
82
84
 
83
85
  default_config.rpcs.list_builds.timeout = 600.0
@@ -85,7 +87,7 @@ module Google
85
87
  initial_delay: 0.1,
86
88
  max_delay: 60.0,
87
89
  multiplier: 1.3,
88
- retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
90
+ retry_codes: [14, 4]
89
91
  }
90
92
 
91
93
  default_config.rpcs.cancel_build.timeout = 600.0
@@ -99,7 +101,7 @@ module Google
99
101
  initial_delay: 0.1,
100
102
  max_delay: 60.0,
101
103
  multiplier: 1.3,
102
- retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
104
+ retry_codes: [14, 4]
103
105
  }
104
106
 
105
107
  default_config.rpcs.list_build_triggers.timeout = 600.0
@@ -107,7 +109,7 @@ module Google
107
109
  initial_delay: 0.1,
108
110
  max_delay: 60.0,
109
111
  multiplier: 1.3,
110
- retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
112
+ retry_codes: [14, 4]
111
113
  }
112
114
 
113
115
  default_config.rpcs.delete_build_trigger.timeout = 600.0
@@ -115,7 +117,7 @@ module Google
115
117
  initial_delay: 0.1,
116
118
  max_delay: 60.0,
117
119
  multiplier: 1.3,
118
- retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
120
+ retry_codes: [14, 4]
119
121
  }
120
122
 
121
123
  default_config.rpcs.update_build_trigger.timeout = 600.0
@@ -129,7 +131,7 @@ module Google
129
131
  initial_delay: 0.1,
130
132
  max_delay: 60.0,
131
133
  multiplier: 1.3,
132
- retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
134
+ retry_codes: [14, 4]
133
135
  }
134
136
 
135
137
  default_config.rpcs.delete_worker_pool.timeout = 600.0
@@ -141,7 +143,7 @@ module Google
141
143
  initial_delay: 0.1,
142
144
  max_delay: 60.0,
143
145
  multiplier: 1.3,
144
- retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
146
+ retry_codes: [14, 4]
145
147
  }
146
148
 
147
149
  default_config
@@ -205,7 +207,13 @@ module Google
205
207
 
206
208
  # Create credentials
207
209
  credentials = @config.credentials
208
- credentials ||= Credentials.default scope: @config.scope
210
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
211
+ # but only if the default endpoint does not have a region prefix.
212
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
213
+ @config.endpoint == Client.configure.endpoint &&
214
+ !@config.endpoint.split(".").first.include?("-")
215
+ credentials ||= Credentials.default scope: @config.scope,
216
+ enable_self_signed_jwt: enable_self_signed_jwt
209
217
  if credentials.is_a?(String) || credentials.is_a?(Hash)
210
218
  credentials = Credentials.new credentials, scope: @config.scope
211
219
  end
@@ -252,11 +260,14 @@ module Google
252
260
  # @param options [::Gapic::CallOptions, ::Hash]
253
261
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
254
262
  #
255
- # @overload create_build(project_id: nil, build: nil)
263
+ # @overload create_build(parent: nil, project_id: nil, build: nil)
256
264
  # Pass arguments to `create_build` via keyword arguments. Note that at
257
265
  # least one keyword argument is required. To specify no parameters, or to keep all
258
266
  # the default parameter values, pass an empty Hash as a request object (see above).
259
267
  #
268
+ # @param parent [::String]
269
+ # The parent resource where this build will be created.
270
+ # Format: `projects/{project}/locations/{location}`
260
271
  # @param project_id [::String]
261
272
  # Required. ID of the project.
262
273
  # @param build [::Google::Cloud::Build::V1::Build, ::Hash]
@@ -324,11 +335,14 @@ module Google
324
335
  # @param options [::Gapic::CallOptions, ::Hash]
325
336
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
326
337
  #
327
- # @overload get_build(project_id: nil, id: nil)
338
+ # @overload get_build(name: nil, project_id: nil, id: nil)
328
339
  # Pass arguments to `get_build` via keyword arguments. Note that at
329
340
  # least one keyword argument is required. To specify no parameters, or to keep all
330
341
  # the default parameter values, pass an empty Hash as a request object (see above).
331
342
  #
343
+ # @param name [::String]
344
+ # The name of the `Build` to retrieve.
345
+ # Format: `projects/{project}/locations/{location}/builds/{build}`
332
346
  # @param project_id [::String]
333
347
  # Required. ID of the project.
334
348
  # @param id [::String]
@@ -396,11 +410,14 @@ module Google
396
410
  # @param options [::Gapic::CallOptions, ::Hash]
397
411
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
398
412
  #
399
- # @overload list_builds(project_id: nil, page_size: nil, page_token: nil, filter: nil)
413
+ # @overload list_builds(parent: nil, project_id: nil, page_size: nil, page_token: nil, filter: nil)
400
414
  # Pass arguments to `list_builds` via keyword arguments. Note that at
401
415
  # least one keyword argument is required. To specify no parameters, or to keep all
402
416
  # the default parameter values, pass an empty Hash as a request object (see above).
403
417
  #
418
+ # @param parent [::String]
419
+ # The parent of the collection of `Builds`.
420
+ # Format: `projects/{project}/locations/location`
404
421
  # @param project_id [::String]
405
422
  # Required. ID of the project.
406
423
  # @param page_size [::Integer]
@@ -469,11 +486,14 @@ module Google
469
486
  # @param options [::Gapic::CallOptions, ::Hash]
470
487
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
471
488
  #
472
- # @overload cancel_build(project_id: nil, id: nil)
489
+ # @overload cancel_build(name: nil, project_id: nil, id: nil)
473
490
  # Pass arguments to `cancel_build` via keyword arguments. Note that at
474
491
  # least one keyword argument is required. To specify no parameters, or to keep all
475
492
  # the default parameter values, pass an empty Hash as a request object (see above).
476
493
  #
494
+ # @param name [::String]
495
+ # The name of the `Build` to retrieve.
496
+ # Format: `projects/{project}/locations/{location}/builds/{build}`
477
497
  # @param project_id [::String]
478
498
  # Required. ID of the project.
479
499
  # @param id [::String]
@@ -564,11 +584,14 @@ module Google
564
584
  # @param options [::Gapic::CallOptions, ::Hash]
565
585
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
566
586
  #
567
- # @overload retry_build(project_id: nil, id: nil)
587
+ # @overload retry_build(name: nil, project_id: nil, id: nil)
568
588
  # Pass arguments to `retry_build` via keyword arguments. Note that at
569
589
  # least one keyword argument is required. To specify no parameters, or to keep all
570
590
  # the default parameter values, pass an empty Hash as a request object (see above).
571
591
  #
592
+ # @param name [::String]
593
+ # The name of the `Build` to retry.
594
+ # Format: `projects/{project}/locations/{location}/builds/{build}`
572
595
  # @param project_id [::String]
573
596
  # Required. ID of the project.
574
597
  # @param id [::String]
@@ -1307,7 +1330,7 @@ module Google
1307
1330
  end
1308
1331
 
1309
1332
  ##
1310
- # List project's `WorkerPool`s.
1333
+ # List project's `WorkerPools`.
1311
1334
  #
1312
1335
  # This API is experimental.
1313
1336
  #
@@ -1453,7 +1476,7 @@ module Google
1453
1476
 
1454
1477
  config_attr :endpoint, "cloudbuild.googleapis.com", ::String
1455
1478
  config_attr :credentials, nil do |value|
1456
- allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1479
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1457
1480
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
1458
1481
  allowed.any? { |klass| klass === value }
1459
1482
  end
@@ -1493,7 +1516,7 @@ module Google
1493
1516
  # Each configuration object is of type `Gapic::Config::Method` and includes
1494
1517
  # the following configuration fields:
1495
1518
  #
1496
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
1519
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
1497
1520
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
1498
1521
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1499
1522
  # include the following keys:
@@ -103,8 +103,13 @@ module Google
103
103
  # Lists operations that match the specified filter in the request. If the
104
104
  # server doesn't support this method, it returns `UNIMPLEMENTED`.
105
105
  #
106
- # NOTE: the `name` binding below allows API services to override the binding
107
- # to use different resource name schemes, such as `users/*/operations`.
106
+ # NOTE: the `name` binding allows API services to override the binding
107
+ # to use different resource name schemes, such as `users/*/operations`. To
108
+ # override the binding, API services can add a binding such as
109
+ # `"/v1/{name=users/*}/operations"` to their service configuration.
110
+ # For backwards compatibility, the default name includes the operations
111
+ # collection id, however overriding users must ensure the name binding
112
+ # is the parent resource, without the operations collection id.
108
113
  #
109
114
  # @overload list_operations(request, options = nil)
110
115
  # Pass arguments to `list_operations` via a request object, either of type
@@ -122,7 +127,7 @@ module Google
122
127
  # the default parameter values, pass an empty Hash as a request object (see above).
123
128
  #
124
129
  # @param name [::String]
125
- # The name of the operation collection.
130
+ # The name of the operation's parent resource.
126
131
  # @param filter [::String]
127
132
  # The standard list filter.
128
133
  # @param page_size [::Integer]
@@ -390,6 +395,79 @@ module Google
390
395
  raise ::Google::Cloud::Error.from_error(e)
391
396
  end
392
397
 
398
+ ##
399
+ # Waits for the specified long-running operation until it is done or reaches
400
+ # at most a specified timeout, returning the latest state. If the operation
401
+ # is already done, the latest state is immediately returned. If the timeout
402
+ # specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
403
+ # timeout is used. If the server does not support this method, it returns
404
+ # `google.rpc.Code.UNIMPLEMENTED`.
405
+ # Note that this method is on a best-effort basis. It may return the latest
406
+ # state before the specified timeout (including immediately), meaning even an
407
+ # immediate response is no guarantee that the operation is done.
408
+ #
409
+ # @overload wait_operation(request, options = nil)
410
+ # Pass arguments to `wait_operation` via a request object, either of type
411
+ # {::Google::Longrunning::WaitOperationRequest} or an equivalent Hash.
412
+ #
413
+ # @param request [::Google::Longrunning::WaitOperationRequest, ::Hash]
414
+ # A request object representing the call parameters. Required. To specify no
415
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
416
+ # @param options [::Gapic::CallOptions, ::Hash]
417
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
418
+ #
419
+ # @overload wait_operation(name: nil, timeout: nil)
420
+ # Pass arguments to `wait_operation` via keyword arguments. Note that at
421
+ # least one keyword argument is required. To specify no parameters, or to keep all
422
+ # the default parameter values, pass an empty Hash as a request object (see above).
423
+ #
424
+ # @param name [::String]
425
+ # The name of the operation resource to wait on.
426
+ # @param timeout [::Google::Protobuf::Duration, ::Hash]
427
+ # The maximum duration to wait before timing out. If left blank, the wait
428
+ # will be at most the time permitted by the underlying HTTP/RPC protocol.
429
+ # If RPC context deadline is also specified, the shorter one will be used.
430
+ #
431
+ # @yield [response, operation] Access the result along with the RPC operation
432
+ # @yieldparam response [::Gapic::Operation]
433
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
434
+ #
435
+ # @return [::Gapic::Operation]
436
+ #
437
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
438
+ #
439
+ def wait_operation request, options = nil
440
+ raise ::ArgumentError, "request must be provided" if request.nil?
441
+
442
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::WaitOperationRequest
443
+
444
+ # Converts hash and nil to an options object
445
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
446
+
447
+ # Customize the options with defaults
448
+ metadata = @config.rpcs.wait_operation.metadata.to_h
449
+
450
+ # Set x-goog-api-client and x-goog-user-project headers
451
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
452
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
453
+ gapic_version: ::Google::Cloud::Build::V1::VERSION
454
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
455
+
456
+ options.apply_defaults timeout: @config.rpcs.wait_operation.timeout,
457
+ metadata: metadata,
458
+ retry_policy: @config.rpcs.wait_operation.retry_policy
459
+ options.apply_defaults metadata: @config.metadata,
460
+ retry_policy: @config.retry_policy
461
+
462
+ @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
463
+ response = ::Gapic::Operation.new response, @operations_client, options: options
464
+ yield response, operation if block_given?
465
+ return response
466
+ end
467
+ rescue ::GRPC::BadStatus => e
468
+ raise ::Google::Cloud::Error.from_error(e)
469
+ end
470
+
393
471
  ##
394
472
  # Configuration class for the Operations API.
395
473
  #
@@ -475,7 +553,7 @@ module Google
475
553
 
476
554
  config_attr :endpoint, "cloudbuild.googleapis.com", ::String
477
555
  config_attr :credentials, nil do |value|
478
- allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
556
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
479
557
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
480
558
  allowed.any? { |klass| klass === value }
481
559
  end
@@ -515,7 +593,7 @@ module Google
515
593
  # Each configuration object is of type `Gapic::Config::Method` and includes
516
594
  # the following configuration fields:
517
595
  #
518
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
596
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
519
597
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
520
598
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
521
599
  # include the following keys:
@@ -546,6 +624,11 @@ module Google
546
624
  # @return [::Gapic::Config::Method]
547
625
  #
548
626
  attr_reader :cancel_operation
627
+ ##
628
+ # RPC-specific configuration for `wait_operation`
629
+ # @return [::Gapic::Config::Method]
630
+ #
631
+ attr_reader :wait_operation
549
632
 
550
633
  # @private
551
634
  def initialize parent_rpcs = nil
@@ -557,6 +640,8 @@ module Google
557
640
  @delete_operation = ::Gapic::Config::Method.new delete_operation_config
558
641
  cancel_operation_config = parent_rpcs&.cancel_operation if parent_rpcs&.respond_to? :cancel_operation
559
642
  @cancel_operation = ::Gapic::Config::Method.new cancel_operation_config
643
+ wait_operation_config = parent_rpcs&.wait_operation if parent_rpcs&.respond_to? :wait_operation
644
+ @wait_operation = ::Gapic::Config::Method.new wait_operation_config
560
645
 
561
646
  yield self if block_given?
562
647
  end
@@ -0,0 +1,139 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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
+
20
+ module Google
21
+ module Cloud
22
+ module Build
23
+ module V1
24
+ module CloudBuild
25
+ # Path helper methods for the CloudBuild API.
26
+ module Paths
27
+ ##
28
+ # Create a fully-qualified Build resource string.
29
+ #
30
+ # @overload build_path(project:, build:)
31
+ # The resource will be in the following format:
32
+ #
33
+ # `projects/{project}/builds/{build}`
34
+ #
35
+ # @param project [String]
36
+ # @param build [String]
37
+ #
38
+ # @overload build_path(project:, location:, build:)
39
+ # The resource will be in the following format:
40
+ #
41
+ # `projects/{project}/locations/{location}/builds/{build}`
42
+ #
43
+ # @param project [String]
44
+ # @param location [String]
45
+ # @param build [String]
46
+ #
47
+ # @return [::String]
48
+ def build_path **args
49
+ resources = {
50
+ "build:project" => (proc do |project:, build:|
51
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
52
+
53
+ "projects/#{project}/builds/#{build}"
54
+ end),
55
+ "build:location:project" => (proc do |project:, location:, build:|
56
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
57
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
58
+
59
+ "projects/#{project}/locations/#{location}/builds/#{build}"
60
+ end)
61
+ }
62
+
63
+ resource = resources[args.keys.sort.join(":")]
64
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
65
+ resource.call(**args)
66
+ end
67
+
68
+ ##
69
+ # Create a fully-qualified BuildTrigger resource string.
70
+ #
71
+ # The resource will be in the following format:
72
+ #
73
+ # `projects/{project}/triggers/{trigger}`
74
+ #
75
+ # @param project [String]
76
+ # @param trigger [String]
77
+ #
78
+ # @return [::String]
79
+ def build_trigger_path project:, trigger:
80
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
81
+
82
+ "projects/#{project}/triggers/#{trigger}"
83
+ end
84
+
85
+ ##
86
+ # Create a fully-qualified Location resource string.
87
+ #
88
+ # The resource will be in the following format:
89
+ #
90
+ # `projects/{project}/locations/{location}`
91
+ #
92
+ # @param project [String]
93
+ # @param location [String]
94
+ #
95
+ # @return [::String]
96
+ def location_path project:, location:
97
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
98
+
99
+ "projects/#{project}/locations/#{location}"
100
+ end
101
+
102
+ ##
103
+ # Create a fully-qualified Project resource string.
104
+ #
105
+ # The resource will be in the following format:
106
+ #
107
+ # `projects/{project}`
108
+ #
109
+ # @param project [String]
110
+ #
111
+ # @return [::String]
112
+ def project_path project:
113
+ "projects/#{project}"
114
+ end
115
+
116
+ ##
117
+ # Create a fully-qualified ServiceAccount resource string.
118
+ #
119
+ # The resource will be in the following format:
120
+ #
121
+ # `projects/{project}/serviceAccounts/{service_account}`
122
+ #
123
+ # @param project [String]
124
+ # @param service_account [String]
125
+ #
126
+ # @return [::String]
127
+ def service_account_path project:, service_account:
128
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
129
+
130
+ "projects/#{project}/serviceAccounts/#{service_account}"
131
+ end
132
+
133
+ extend self
134
+ end
135
+ end
136
+ end
137
+ end
138
+ end
139
+ end