| 1 |
// Copyright 2025 Google LLC |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// |
| 7 |
// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
// |
| 9 |
// Unless required by applicable law or agreed to in writing, software |
| 10 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
// See the License for the specific language governing permissions and |
| 13 |
// limitations under the License. |
| 14 |
|
| 15 |
// Code generated by protoc-gen-go_gapic. DO NOT EDIT. |
| 16 |
|
| 17 |
package cloudbuild |
| 18 |
|
| 19 |
import ( |
| 20 |
"bytes" |
| 21 |
"context" |
| 22 |
"fmt" |
| 23 |
"log/slog" |
| 24 |
"math" |
| 25 |
"net/http" |
| 26 |
"net/url" |
| 27 |
"regexp" |
| 28 |
"strings" |
| 29 |
"time" |
| 30 |
|
| 31 |
cloudbuildpb "cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb" |
| 32 |
"cloud.google.com/go/longrunning" |
| 33 |
lroauto "cloud.google.com/go/longrunning/autogen" |
| 34 |
longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" |
| 35 |
gax "github.com/googleapis/gax-go/v2" |
| 36 |
"google.golang.org/api/iterator" |
| 37 |
"google.golang.org/api/option" |
| 38 |
"google.golang.org/api/option/internaloption" |
| 39 |
gtransport "google.golang.org/api/transport/grpc" |
| 40 |
httptransport "google.golang.org/api/transport/http" |
| 41 |
"google.golang.org/grpc" |
| 42 |
"google.golang.org/grpc/codes" |
| 43 |
"google.golang.org/protobuf/encoding/protojson" |
| 44 |
"google.golang.org/protobuf/proto" |
| 45 |
) |
| 46 |
|
| 47 |
var newClientHook clientHook |
| 48 |
|
| 49 |
// CallOptions contains the retry settings for each method of Client. |
| 50 |
type CallOptions struct { |
| 51 |
CreateBuild []gax.CallOption |
| 52 |
GetBuild []gax.CallOption |
| 53 |
ListBuilds []gax.CallOption |
| 54 |
CancelBuild []gax.CallOption |
| 55 |
RetryBuild []gax.CallOption |
| 56 |
ApproveBuild []gax.CallOption |
| 57 |
CreateBuildTrigger []gax.CallOption |
| 58 |
GetBuildTrigger []gax.CallOption |
| 59 |
ListBuildTriggers []gax.CallOption |
| 60 |
DeleteBuildTrigger []gax.CallOption |
| 61 |
UpdateBuildTrigger []gax.CallOption |
| 62 |
RunBuildTrigger []gax.CallOption |
| 63 |
ReceiveTriggerWebhook []gax.CallOption |
| 64 |
CreateWorkerPool []gax.CallOption |
| 65 |
GetWorkerPool []gax.CallOption |
| 66 |
DeleteWorkerPool []gax.CallOption |
| 67 |
UpdateWorkerPool []gax.CallOption |
| 68 |
ListWorkerPools []gax.CallOption |
| 69 |
} |
| 70 |
|
| 71 |
func defaultGRPCClientOptions() []option.ClientOption { |
| 72 |
return []option.ClientOption{ |
| 73 |
internaloption.WithDefaultEndpoint("cloudbuild.googleapis.com:443"), |
| 74 |
internaloption.WithDefaultEndpointTemplate("cloudbuild.UNIVERSE_DOMAIN:443"), |
| 75 |
internaloption.WithDefaultMTLSEndpoint("cloudbuild.mtls.googleapis.com:443"), |
| 76 |
internaloption.WithDefaultUniverseDomain("googleapis.com"), |
| 77 |
internaloption.WithDefaultAudience("https://cloudbuild.googleapis.com/"), |
| 78 |
internaloption.WithDefaultScopes(DefaultAuthScopes()...), |
| 79 |
internaloption.EnableJwtWithScope(), |
| 80 |
internaloption.EnableNewAuthLibrary(), |
| 81 |
option.WithGRPCDialOption(grpc.WithDefaultCallOptions( |
| 82 |
grpc.MaxCallRecvMsgSize(math.MaxInt32))), |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
func defaultCallOptions() *CallOptions { |
| 87 |
return &CallOptions{ |
| 88 |
CreateBuild: []gax.CallOption{ |
| 89 |
gax.WithTimeout(600000 * time.Millisecond), |
| 90 |
}, |
| 91 |
GetBuild: []gax.CallOption{ |
| 92 |
gax.WithTimeout(600000 * time.Millisecond), |
| 93 |
gax.WithRetry(func() gax.Retryer { |
| 94 |
return gax.OnCodes([]codes.Code{ |
| 95 |
codes.Unavailable, |
| 96 |
codes.DeadlineExceeded, |
| 97 |
}, gax.Backoff{ |
| 98 |
Initial: 100 * time.Millisecond, |
| 99 |
Max: 60000 * time.Millisecond, |
| 100 |
Multiplier: 1.30, |
| 101 |
}) |
| 102 |
}), |
| 103 |
}, |
| 104 |
ListBuilds: []gax.CallOption{ |
| 105 |
gax.WithTimeout(600000 * time.Millisecond), |
| 106 |
gax.WithRetry(func() gax.Retryer { |
| 107 |
return gax.OnCodes([]codes.Code{ |
| 108 |
codes.Unavailable, |
| 109 |
codes.DeadlineExceeded, |
| 110 |
}, gax.Backoff{ |
| 111 |
Initial: 100 * time.Millisecond, |
| 112 |
Max: 60000 * time.Millisecond, |
| 113 |
Multiplier: 1.30, |
| 114 |
}) |
| 115 |
}), |
| 116 |
}, |
| 117 |
CancelBuild: []gax.CallOption{ |
| 118 |
gax.WithTimeout(600000 * time.Millisecond), |
| 119 |
}, |
| 120 |
RetryBuild: []gax.CallOption{ |
| 121 |
gax.WithTimeout(600000 * time.Millisecond), |
| 122 |
}, |
| 123 |
ApproveBuild: []gax.CallOption{}, |
| 124 |
CreateBuildTrigger: []gax.CallOption{ |
| 125 |
gax.WithTimeout(600000 * time.Millisecond), |
| 126 |
}, |
| 127 |
GetBuildTrigger: []gax.CallOption{ |
| 128 |
gax.WithTimeout(600000 * time.Millisecond), |
| 129 |
gax.WithRetry(func() gax.Retryer { |
| 130 |
return gax.OnCodes([]codes.Code{ |
| 131 |
codes.Unavailable, |
| 132 |
codes.DeadlineExceeded, |
| 133 |
}, gax.Backoff{ |
| 134 |
Initial: 100 * time.Millisecond, |
| 135 |
Max: 60000 * time.Millisecond, |
| 136 |
Multiplier: 1.30, |
| 137 |
}) |
| 138 |
}), |
| 139 |
}, |
| 140 |
ListBuildTriggers: []gax.CallOption{ |
| 141 |
gax.WithTimeout(600000 * time.Millisecond), |
| 142 |
gax.WithRetry(func() gax.Retryer { |
| 143 |
return gax.OnCodes([]codes.Code{ |
| 144 |
codes.Unavailable, |
| 145 |
codes.DeadlineExceeded, |
| 146 |
}, gax.Backoff{ |
| 147 |
Initial: 100 * time.Millisecond, |
| 148 |
Max: 60000 * time.Millisecond, |
| 149 |
Multiplier: 1.30, |
| 150 |
}) |
| 151 |
}), |
| 152 |
}, |
| 153 |
DeleteBuildTrigger: []gax.CallOption{ |
| 154 |
gax.WithTimeout(600000 * time.Millisecond), |
| 155 |
gax.WithRetry(func() gax.Retryer { |
| 156 |
return gax.OnCodes([]codes.Code{ |
| 157 |
codes.Unavailable, |
| 158 |
codes.DeadlineExceeded, |
| 159 |
}, gax.Backoff{ |
| 160 |
Initial: 100 * time.Millisecond, |
| 161 |
Max: 60000 * time.Millisecond, |
| 162 |
Multiplier: 1.30, |
| 163 |
}) |
| 164 |
}), |
| 165 |
}, |
| 166 |
UpdateBuildTrigger: []gax.CallOption{ |
| 167 |
gax.WithTimeout(600000 * time.Millisecond), |
| 168 |
}, |
| 169 |
RunBuildTrigger: []gax.CallOption{ |
| 170 |
gax.WithTimeout(600000 * time.Millisecond), |
| 171 |
}, |
| 172 |
ReceiveTriggerWebhook: []gax.CallOption{}, |
| 173 |
CreateWorkerPool: []gax.CallOption{ |
| 174 |
gax.WithTimeout(600000 * time.Millisecond), |
| 175 |
}, |
| 176 |
GetWorkerPool: []gax.CallOption{ |
| 177 |
gax.WithTimeout(600000 * time.Millisecond), |
| 178 |
gax.WithRetry(func() gax.Retryer { |
| 179 |
return gax.OnCodes([]codes.Code{ |
| 180 |
codes.Unavailable, |
| 181 |
codes.DeadlineExceeded, |
| 182 |
}, gax.Backoff{ |
| 183 |
Initial: 100 * time.Millisecond, |
| 184 |
Max: 60000 * time.Millisecond, |
| 185 |
Multiplier: 1.30, |
| 186 |
}) |
| 187 |
}), |
| 188 |
}, |
| 189 |
DeleteWorkerPool: []gax.CallOption{ |
| 190 |
gax.WithTimeout(600000 * time.Millisecond), |
| 191 |
}, |
| 192 |
UpdateWorkerPool: []gax.CallOption{ |
| 193 |
gax.WithTimeout(600000 * time.Millisecond), |
| 194 |
}, |
| 195 |
ListWorkerPools: []gax.CallOption{ |
| 196 |
gax.WithTimeout(600000 * time.Millisecond), |
| 197 |
gax.WithRetry(func() gax.Retryer { |
| 198 |
return gax.OnCodes([]codes.Code{ |
| 199 |
codes.Unavailable, |
| 200 |
codes.DeadlineExceeded, |
| 201 |
}, gax.Backoff{ |
| 202 |
Initial: 100 * time.Millisecond, |
| 203 |
Max: 60000 * time.Millisecond, |
| 204 |
Multiplier: 1.30, |
| 205 |
}) |
| 206 |
}), |
| 207 |
}, |
| 208 |
} |
| 209 |
} |
| 210 |
|
| 211 |
func defaultRESTCallOptions() *CallOptions { |
| 212 |
return &CallOptions{ |
| 213 |
CreateBuild: []gax.CallOption{ |
| 214 |
gax.WithTimeout(600000 * time.Millisecond), |
| 215 |
}, |
| 216 |
GetBuild: []gax.CallOption{ |
| 217 |
gax.WithTimeout(600000 * time.Millisecond), |
| 218 |
gax.WithRetry(func() gax.Retryer { |
| 219 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 220 |
Initial: 100 * time.Millisecond, |
| 221 |
Max: 60000 * time.Millisecond, |
| 222 |
Multiplier: 1.30, |
| 223 |
}, |
| 224 |
http.StatusServiceUnavailable, |
| 225 |
http.StatusGatewayTimeout) |
| 226 |
}), |
| 227 |
}, |
| 228 |
ListBuilds: []gax.CallOption{ |
| 229 |
gax.WithTimeout(600000 * time.Millisecond), |
| 230 |
gax.WithRetry(func() gax.Retryer { |
| 231 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 232 |
Initial: 100 * time.Millisecond, |
| 233 |
Max: 60000 * time.Millisecond, |
| 234 |
Multiplier: 1.30, |
| 235 |
}, |
| 236 |
http.StatusServiceUnavailable, |
| 237 |
http.StatusGatewayTimeout) |
| 238 |
}), |
| 239 |
}, |
| 240 |
CancelBuild: []gax.CallOption{ |
| 241 |
gax.WithTimeout(600000 * time.Millisecond), |
| 242 |
}, |
| 243 |
RetryBuild: []gax.CallOption{ |
| 244 |
gax.WithTimeout(600000 * time.Millisecond), |
| 245 |
}, |
| 246 |
ApproveBuild: []gax.CallOption{}, |
| 247 |
CreateBuildTrigger: []gax.CallOption{ |
| 248 |
gax.WithTimeout(600000 * time.Millisecond), |
| 249 |
}, |
| 250 |
GetBuildTrigger: []gax.CallOption{ |
| 251 |
gax.WithTimeout(600000 * time.Millisecond), |
| 252 |
gax.WithRetry(func() gax.Retryer { |
| 253 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 254 |
Initial: 100 * time.Millisecond, |
| 255 |
Max: 60000 * time.Millisecond, |
| 256 |
Multiplier: 1.30, |
| 257 |
}, |
| 258 |
http.StatusServiceUnavailable, |
| 259 |
http.StatusGatewayTimeout) |
| 260 |
}), |
| 261 |
}, |
| 262 |
ListBuildTriggers: []gax.CallOption{ |
| 263 |
gax.WithTimeout(600000 * time.Millisecond), |
| 264 |
gax.WithRetry(func() gax.Retryer { |
| 265 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 266 |
Initial: 100 * time.Millisecond, |
| 267 |
Max: 60000 * time.Millisecond, |
| 268 |
Multiplier: 1.30, |
| 269 |
}, |
| 270 |
http.StatusServiceUnavailable, |
| 271 |
http.StatusGatewayTimeout) |
| 272 |
}), |
| 273 |
}, |
| 274 |
DeleteBuildTrigger: []gax.CallOption{ |
| 275 |
gax.WithTimeout(600000 * time.Millisecond), |
| 276 |
gax.WithRetry(func() gax.Retryer { |
| 277 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 278 |
Initial: 100 * time.Millisecond, |
| 279 |
Max: 60000 * time.Millisecond, |
| 280 |
Multiplier: 1.30, |
| 281 |
}, |
| 282 |
http.StatusServiceUnavailable, |
| 283 |
http.StatusGatewayTimeout) |
| 284 |
}), |
| 285 |
}, |
| 286 |
UpdateBuildTrigger: []gax.CallOption{ |
| 287 |
gax.WithTimeout(600000 * time.Millisecond), |
| 288 |
}, |
| 289 |
RunBuildTrigger: []gax.CallOption{ |
| 290 |
gax.WithTimeout(600000 * time.Millisecond), |
| 291 |
}, |
| 292 |
ReceiveTriggerWebhook: []gax.CallOption{}, |
| 293 |
CreateWorkerPool: []gax.CallOption{ |
| 294 |
gax.WithTimeout(600000 * time.Millisecond), |
| 295 |
}, |
| 296 |
GetWorkerPool: []gax.CallOption{ |
| 297 |
gax.WithTimeout(600000 * time.Millisecond), |
| 298 |
gax.WithRetry(func() gax.Retryer { |
| 299 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 300 |
Initial: 100 * time.Millisecond, |
| 301 |
Max: 60000 * time.Millisecond, |
| 302 |
Multiplier: 1.30, |
| 303 |
}, |
| 304 |
http.StatusServiceUnavailable, |
| 305 |
http.StatusGatewayTimeout) |
| 306 |
}), |
| 307 |
}, |
| 308 |
DeleteWorkerPool: []gax.CallOption{ |
| 309 |
gax.WithTimeout(600000 * time.Millisecond), |
| 310 |
}, |
| 311 |
UpdateWorkerPool: []gax.CallOption{ |
| 312 |
gax.WithTimeout(600000 * time.Millisecond), |
| 313 |
}, |
| 314 |
ListWorkerPools: []gax.CallOption{ |
| 315 |
gax.WithTimeout(600000 * time.Millisecond), |
| 316 |
gax.WithRetry(func() gax.Retryer { |
| 317 |
return gax.OnHTTPCodes(gax.Backoff{ |
| 318 |
Initial: 100 * time.Millisecond, |
| 319 |
Max: 60000 * time.Millisecond, |
| 320 |
Multiplier: 1.30, |
| 321 |
}, |
| 322 |
http.StatusServiceUnavailable, |
| 323 |
http.StatusGatewayTimeout) |
| 324 |
}), |
| 325 |
}, |
| 326 |
} |
| 327 |
} |
| 328 |
|
| 329 |
// internalClient is an interface that defines the methods available from Cloud Build API. |
| 330 |
type internalClient interface { |
| 331 |
Close() error |
| 332 |
setGoogleClientInfo(...string) |
| 333 |
Connection() *grpc.ClientConn |
| 334 |
CreateBuild(context.Context, *cloudbuildpb.CreateBuildRequest, ...gax.CallOption) (*CreateBuildOperation, error) |
| 335 |
CreateBuildOperation(name string) *CreateBuildOperation |
| 336 |
GetBuild(context.Context, *cloudbuildpb.GetBuildRequest, ...gax.CallOption) (*cloudbuildpb.Build, error) |
| 337 |
ListBuilds(context.Context, *cloudbuildpb.ListBuildsRequest, ...gax.CallOption) *BuildIterator |
| 338 |
CancelBuild(context.Context, *cloudbuildpb.CancelBuildRequest, ...gax.CallOption) (*cloudbuildpb.Build, error) |
| 339 |
RetryBuild(context.Context, *cloudbuildpb.RetryBuildRequest, ...gax.CallOption) (*RetryBuildOperation, error) |
| 340 |
RetryBuildOperation(name string) *RetryBuildOperation |
| 341 |
ApproveBuild(context.Context, *cloudbuildpb.ApproveBuildRequest, ...gax.CallOption) (*ApproveBuildOperation, error) |
| 342 |
ApproveBuildOperation(name string) *ApproveBuildOperation |
| 343 |
CreateBuildTrigger(context.Context, *cloudbuildpb.CreateBuildTriggerRequest, ...gax.CallOption) (*cloudbuildpb.BuildTrigger, error) |
| 344 |
GetBuildTrigger(context.Context, *cloudbuildpb.GetBuildTriggerRequest, ...gax.CallOption) (*cloudbuildpb.BuildTrigger, error) |
| 345 |
ListBuildTriggers(context.Context, *cloudbuildpb.ListBuildTriggersRequest, ...gax.CallOption) *BuildTriggerIterator |
| 346 |
DeleteBuildTrigger(context.Context, *cloudbuildpb.DeleteBuildTriggerRequest, ...gax.CallOption) error |
| 347 |
UpdateBuildTrigger(context.Context, *cloudbuildpb.UpdateBuildTriggerRequest, ...gax.CallOption) (*cloudbuildpb.BuildTrigger, error) |
| 348 |
RunBuildTrigger(context.Context, *cloudbuildpb.RunBuildTriggerRequest, ...gax.CallOption) (*RunBuildTriggerOperation, error) |
| 349 |
RunBuildTriggerOperation(name string) *RunBuildTriggerOperation |
| 350 |
ReceiveTriggerWebhook(context.Context, *cloudbuildpb.ReceiveTriggerWebhookRequest, ...gax.CallOption) (*cloudbuildpb.ReceiveTriggerWebhookResponse, error) |
| 351 |
CreateWorkerPool(context.Context, *cloudbuildpb.CreateWorkerPoolRequest, ...gax.CallOption) (*CreateWorkerPoolOperation, error) |
| 352 |
CreateWorkerPoolOperation(name string) *CreateWorkerPoolOperation |
| 353 |
GetWorkerPool(context.Context, *cloudbuildpb.GetWorkerPoolRequest, ...gax.CallOption) (*cloudbuildpb.WorkerPool, error) |
| 354 |
DeleteWorkerPool(context.Context, *cloudbuildpb.DeleteWorkerPoolRequest, ...gax.CallOption) (*DeleteWorkerPoolOperation, error) |
| 355 |
DeleteWorkerPoolOperation(name string) *DeleteWorkerPoolOperation |
| 356 |
UpdateWorkerPool(context.Context, *cloudbuildpb.UpdateWorkerPoolRequest, ...gax.CallOption) (*UpdateWorkerPoolOperation, error) |
| 357 |
UpdateWorkerPoolOperation(name string) *UpdateWorkerPoolOperation |
| 358 |
ListWorkerPools(context.Context, *cloudbuildpb.ListWorkerPoolsRequest, ...gax.CallOption) *WorkerPoolIterator |
| 359 |
} |
| 360 |
|
| 361 |
// Client is a client for interacting with Cloud Build API. |
| 362 |
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. |
| 363 |
// |
| 364 |
// Creates and manages builds on Google Cloud Platform. |
| 365 |
// |
| 366 |
// The main concept used by this API is a Build, which describes the location |
| 367 |
// of the source to build, how to build the source, and where to store the |
| 368 |
// built artifacts, if any. |
| 369 |
// |
| 370 |
// A user can list previously-requested builds or get builds by their ID to |
| 371 |
// determine the status of the build. |
| 372 |
type Client struct { |
| 373 |
// The internal transport-dependent client. |
| 374 |
internalClient internalClient |
| 375 |
|
| 376 |
// The call options for this service. |
| 377 |
CallOptions *CallOptions |
| 378 |
|
| 379 |
// LROClient is used internally to handle long-running operations. |
| 380 |
// It is exposed so that its CallOptions can be modified if required. |
| 381 |
// Users should not Close this client. |
| 382 |
LROClient *lroauto.OperationsClient |
| 383 |
} |
| 384 |
|
| 385 |
// Wrapper methods routed to the internal client. |
| 386 |
|
| 387 |
// Close closes the connection to the API service. The user should invoke this when |
| 388 |
// the client is no longer required. |
| 389 |
func (c *Client) Close() error { |
| 390 |
return c.internalClient.Close() |
| 391 |
} |
| 392 |
|
| 393 |
// setGoogleClientInfo sets the name and version of the application in |
| 394 |
// the `x-goog-api-client` header passed on each request. Intended for |
| 395 |
// use by Google-written clients. |
| 396 |
func (c *Client) setGoogleClientInfo(keyval ...string) { |
| 397 |
c.internalClient.setGoogleClientInfo(keyval...) |
| 398 |
} |
| 399 |
|
| 400 |
// Connection returns a connection to the API service. |
| 401 |
// |
| 402 |
// Deprecated: Connections are now pooled so this method does not always |
| 403 |
// return the same resource. |
| 404 |
func (c *Client) Connection() *grpc.ClientConn { |
| 405 |
return c.internalClient.Connection() |
| 406 |
} |
| 407 |
|
| 408 |
// CreateBuild starts a build with the specified configuration. |
| 409 |
// |
| 410 |
// This method returns a long-running Operation, which includes the build |
| 411 |
// ID. Pass the build ID to GetBuild to determine the build status (such as |
| 412 |
// SUCCESS or FAILURE). |
| 413 |
func (c *Client) CreateBuild(ctx context.Context, req *cloudbuildpb.CreateBuildRequest, opts ...gax.CallOption) (*CreateBuildOperation, error) { |
| 414 |
return c.internalClient.CreateBuild(ctx, req, opts...) |
| 415 |
} |
| 416 |
|
| 417 |
// CreateBuildOperation returns a new CreateBuildOperation from a given name. |
| 418 |
// The name must be that of a previously created CreateBuildOperation, possibly from a different process. |
| 419 |
func (c *Client) CreateBuildOperation(name string) *CreateBuildOperation { |
| 420 |
return c.internalClient.CreateBuildOperation(name) |
| 421 |
} |
| 422 |
|
| 423 |
// GetBuild returns information about a previously requested build. |
| 424 |
// |
| 425 |
// The Build that is returned includes its status (such as SUCCESS, |
| 426 |
// FAILURE, or WORKING), and timing information. |
| 427 |
func (c *Client) GetBuild(ctx context.Context, req *cloudbuildpb.GetBuildRequest, opts ...gax.CallOption) (*cloudbuildpb.Build, error) { |
| 428 |
return c.internalClient.GetBuild(ctx, req, opts...) |
| 429 |
} |
| 430 |
|
| 431 |
// ListBuilds lists previously requested builds. |
| 432 |
// |
| 433 |
// Previously requested builds may still be in-progress, or may have finished |
| 434 |
// successfully or unsuccessfully. |
| 435 |
func (c *Client) ListBuilds(ctx context.Context, req *cloudbuildpb.ListBuildsRequest, opts ...gax.CallOption) *BuildIterator { |
| 436 |
return c.internalClient.ListBuilds(ctx, req, opts...) |
| 437 |
} |
| 438 |
|
| 439 |
// CancelBuild cancels a build in progress. |
| 440 |
func (c *Client) CancelBuild(ctx context.Context, req *cloudbuildpb.CancelBuildRequest, opts ...gax.CallOption) (*cloudbuildpb.Build, error) { |
| 441 |
return c.internalClient.CancelBuild(ctx, req, opts...) |
| 442 |
} |
| 443 |
|
| 444 |
// RetryBuild creates a new build based on the specified build. |
| 445 |
// |
| 446 |
// This method creates a new build using the original build request, which may |
| 447 |
// or may not result in an identical build. |
| 448 |
// |
| 449 |
// For triggered builds: |
| 450 |
// |
| 451 |
// Triggered builds resolve to a precise revision; therefore a retry of a |
| 452 |
// triggered build will result in a build that uses the same revision. |
| 453 |
// |
| 454 |
// For non-triggered builds that specify RepoSource: |
| 455 |
// |
| 456 |
// If the original build built from the tip of a branch, the retried build |
| 457 |
// will build from the tip of that branch, which may not be the same revision |
| 458 |
// as the original build. |
| 459 |
// |
| 460 |
// If the original build specified a commit sha or revision ID, the retried |
| 461 |
// build will use the identical source. |
| 462 |
// |
| 463 |
// For builds that specify StorageSource: |
| 464 |
// |
| 465 |
// If the original build pulled source from Cloud Storage without |
| 466 |
// specifying the generation of the object, the new build will use the current |
| 467 |
// object, which may be different from the original build source. |
| 468 |
// |
| 469 |
// If the original build pulled source from Cloud Storage and specified the |
| 470 |
// generation of the object, the new build will attempt to use the same |
| 471 |
// object, which may or may not be available depending on the bucket’s |
| 472 |
// lifecycle management settings. |
| 473 |
func (c *Client) RetryBuild(ctx context.Context, req *cloudbuildpb.RetryBuildRequest, opts ...gax.CallOption) (*RetryBuildOperation, error) { |
| 474 |
return c.internalClient.RetryBuild(ctx, req, opts...) |
| 475 |
} |
| 476 |
|
| 477 |
// RetryBuildOperation returns a new RetryBuildOperation from a given name. |
| 478 |
// The name must be that of a previously created RetryBuildOperation, possibly from a different process. |
| 479 |
func (c *Client) RetryBuildOperation(name string) *RetryBuildOperation { |
| 480 |
return c.internalClient.RetryBuildOperation(name) |
| 481 |
} |
| 482 |
|
| 483 |
// ApproveBuild approves or rejects a pending build. |
| 484 |
// |
| 485 |
// If approved, the returned LRO will be analogous to the LRO returned from |
| 486 |
// a CreateBuild call. |
| 487 |
// |
| 488 |
// If rejected, the returned LRO will be immediately done. |
| 489 |
func (c *Client) ApproveBuild(ctx context.Context, req *cloudbuildpb.ApproveBuildRequest, opts ...gax.CallOption) (*ApproveBuildOperation, error) { |
| 490 |
return c.internalClient.ApproveBuild(ctx, req, opts...) |
| 491 |
} |
| 492 |
|
| 493 |
// ApproveBuildOperation returns a new ApproveBuildOperation from a given name. |
| 494 |
// The name must be that of a previously created ApproveBuildOperation, possibly from a different process. |
| 495 |
func (c *Client) ApproveBuildOperation(name string) *ApproveBuildOperation { |
| 496 |
return c.internalClient.ApproveBuildOperation(name) |
| 497 |
} |
| 498 |
|
| 499 |
// CreateBuildTrigger creates a new BuildTrigger. |
| 500 |
// |
| 501 |
// This API is experimental. |
| 502 |
func (c *Client) CreateBuildTrigger(ctx context.Context, req *cloudbuildpb.CreateBuildTriggerRequest, opts ...gax.CallOption) (*cloudbuildpb.BuildTrigger, error) { |
| 503 |
return c.internalClient.CreateBuildTrigger(ctx, req, opts...) |
| 504 |
} |
| 505 |
|
| 506 |
// GetBuildTrigger returns information about a BuildTrigger. |
| 507 |
// |
| 508 |
// This API is experimental. |
| 509 |
func (c *Client) GetBuildTrigger(ctx context.Context, req *cloudbuildpb.GetBuildTriggerRequest, opts ...gax.CallOption) (*cloudbuildpb.BuildTrigger, error) { |
| 510 |
return c.internalClient.GetBuildTrigger(ctx, req, opts...) |
| 511 |
} |
| 512 |
|
| 513 |
// ListBuildTriggers lists existing BuildTriggers. |
| 514 |
// |
| 515 |
// This API is experimental. |
| 516 |
func (c *Client) ListBuildTriggers(ctx context.Context, req *cloudbuildpb.ListBuildTriggersRequest, opts ...gax.CallOption) *BuildTriggerIterator { |
| 517 |
return c.internalClient.ListBuildTriggers(ctx, req, opts...) |
| 518 |
} |
| 519 |
|
| 520 |
// DeleteBuildTrigger deletes a BuildTrigger by its project ID and trigger ID. |
| 521 |
// |
| 522 |
// This API is experimental. |
| 523 |
func (c *Client) DeleteBuildTrigger(ctx context.Context, req *cloudbuildpb.DeleteBuildTriggerRequest, opts ...gax.CallOption) error { |
| 524 |
return c.internalClient.DeleteBuildTrigger(ctx, req, opts...) |
| 525 |
} |
| 526 |
|
| 527 |
// UpdateBuildTrigger updates a BuildTrigger by its project ID and trigger ID. |
| 528 |
// |
| 529 |
// This API is experimental. |
| 530 |
func (c *Client) UpdateBuildTrigger(ctx context.Context, req *cloudbuildpb.UpdateBuildTriggerRequest, opts ...gax.CallOption) (*cloudbuildpb.BuildTrigger, error) { |
| 531 |
return c.internalClient.UpdateBuildTrigger(ctx, req, opts...) |
| 532 |
} |
| 533 |
|
| 534 |
// RunBuildTrigger runs a BuildTrigger at a particular source revision. |
| 535 |
// |
| 536 |
// To run a regional or global trigger, use the POST request |
| 537 |
// that includes the location endpoint in the path (ex. |
| 538 |
// v1/projects/{projectId}/locations/{region}/triggers/{triggerId}:run). The |
| 539 |
// POST request that does not include the location endpoint in the path can |
| 540 |
// only be used when running global triggers. |
| 541 |
func (c *Client) RunBuildTrigger(ctx context.Context, req *cloudbuildpb.RunBuildTriggerRequest, opts ...gax.CallOption) (*RunBuildTriggerOperation, error) { |
| 542 |
return c.internalClient.RunBuildTrigger(ctx, req, opts...) |
| 543 |
} |
| 544 |
|
| 545 |
// RunBuildTriggerOperation returns a new RunBuildTriggerOperation from a given name. |
| 546 |
// The name must be that of a previously created RunBuildTriggerOperation, possibly from a different process. |
| 547 |
func (c *Client) RunBuildTriggerOperation(name string) *RunBuildTriggerOperation { |
| 548 |
return c.internalClient.RunBuildTriggerOperation(name) |
| 549 |
} |
| 550 |
|
| 551 |
// ReceiveTriggerWebhook receiveTriggerWebhook [Experimental] is called when the API receives a |
| 552 |
// webhook request targeted at a specific trigger. |
| 553 |
func (c *Client) ReceiveTriggerWebhook(ctx context.Context, req *cloudbuildpb.ReceiveTriggerWebhookRequest, opts ...gax.CallOption) (*cloudbuildpb.ReceiveTriggerWebhookResponse, error) { |
| 554 |
return c.internalClient.ReceiveTriggerWebhook(ctx, req, opts...) |
| 555 |
} |
| 556 |
|
| 557 |
// CreateWorkerPool creates a WorkerPool. |
| 558 |
func (c *Client) CreateWorkerPool(ctx context.Context, req *cloudbuildpb.CreateWorkerPoolRequest, opts ...gax.CallOption) (*CreateWorkerPoolOperation, error) { |
| 559 |
return c.internalClient.CreateWorkerPool(ctx, req, opts...) |
| 560 |
} |
| 561 |
|
| 562 |
// CreateWorkerPoolOperation returns a new CreateWorkerPoolOperation from a given name. |
| 563 |
// The name must be that of a previously created CreateWorkerPoolOperation, possibly from a different process. |
| 564 |
func (c *Client) CreateWorkerPoolOperation(name string) *CreateWorkerPoolOperation { |
| 565 |
return c.internalClient.CreateWorkerPoolOperation(name) |
| 566 |
} |
| 567 |
|
| 568 |
// GetWorkerPool returns details of a WorkerPool. |
| 569 |
func (c *Client) GetWorkerPool(ctx context.Context, req *cloudbuildpb.GetWorkerPoolRequest, opts ...gax.CallOption) (*cloudbuildpb.WorkerPool, error) { |
| 570 |
return c.internalClient.GetWorkerPool(ctx, req, opts...) |
| 571 |
} |
| 572 |
|
| 573 |
// DeleteWorkerPool deletes a WorkerPool. |
| 574 |
func (c *Client) DeleteWorkerPool(ctx context.Context, req *cloudbuildpb.DeleteWorkerPoolRequest, opts ...gax.CallOption) (*DeleteWorkerPoolOperation, error) { |
| 575 |
return c.internalClient.DeleteWorkerPool(ctx, req, opts...) |
| 576 |
} |
| 577 |
|
| 578 |
// DeleteWorkerPoolOperation returns a new DeleteWorkerPoolOperation from a given name. |
| 579 |
// The name must be that of a previously created DeleteWorkerPoolOperation, possibly from a different process. |
| 580 |
func (c *Client) DeleteWorkerPoolOperation(name string) *DeleteWorkerPoolOperation { |
| 581 |
return c.internalClient.DeleteWorkerPoolOperation(name) |
| 582 |
} |
| 583 |
|
| 584 |
// UpdateWorkerPool updates a WorkerPool. |
| 585 |
func (c *Client) UpdateWorkerPool(ctx context.Context, req *cloudbuildpb.UpdateWorkerPoolRequest, opts ...gax.CallOption) (*UpdateWorkerPoolOperation, error) { |
| 586 |
return c.internalClient.UpdateWorkerPool(ctx, req, opts...) |
| 587 |
} |
| 588 |
|
| 589 |
// UpdateWorkerPoolOperation returns a new UpdateWorkerPoolOperation from a given name. |
| 590 |
// The name must be that of a previously created UpdateWorkerPoolOperation, possibly from a different process. |
| 591 |
func (c *Client) UpdateWorkerPoolOperation(name string) *UpdateWorkerPoolOperation { |
| 592 |
return c.internalClient.UpdateWorkerPoolOperation(name) |
| 593 |
} |
| 594 |
|
| 595 |
// ListWorkerPools lists WorkerPools. |
| 596 |
func (c *Client) ListWorkerPools(ctx context.Context, req *cloudbuildpb.ListWorkerPoolsRequest, opts ...gax.CallOption) *WorkerPoolIterator { |
| 597 |
return c.internalClient.ListWorkerPools(ctx, req, opts...) |
| 598 |
} |
| 599 |
|
| 600 |
// gRPCClient is a client for interacting with Cloud Build API over gRPC transport. |
| 601 |
// |
| 602 |
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. |
| 603 |
type gRPCClient struct { |
| 604 |
// Connection pool of gRPC connections to the service. |
| 605 |
connPool gtransport.ConnPool |
| 606 |
|
| 607 |
// Points back to the CallOptions field of the containing Client |
| 608 |
CallOptions **CallOptions |
| 609 |
|
| 610 |
// The gRPC API client. |
| 611 |
client cloudbuildpb.CloudBuildClient |
| 612 |
|
| 613 |
// LROClient is used internally to handle long-running operations. |
| 614 |
// It is exposed so that its CallOptions can be modified if required. |
| 615 |
// Users should not Close this client. |
| 616 |
LROClient **lroauto.OperationsClient |
| 617 |
|
| 618 |
// The x-goog-* metadata to be sent with each request. |
| 619 |
xGoogHeaders []string |
| 620 |
|
| 621 |
logger *slog.Logger |
| 622 |
} |
| 623 |
|
| 624 |
// NewClient creates a new cloud build client based on gRPC. |
| 625 |
// The returned client must be Closed when it is done being used to clean up its underlying connections. |
| 626 |
// |
| 627 |
// Creates and manages builds on Google Cloud Platform. |
| 628 |
// |
| 629 |
// The main concept used by this API is a Build, which describes the location |
| 630 |
// of the source to build, how to build the source, and where to store the |
| 631 |
// built artifacts, if any. |
| 632 |
// |
| 633 |
// A user can list previously-requested builds or get builds by their ID to |
| 634 |
// determine the status of the build. |
| 635 |
func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) { |
| 636 |
clientOpts := defaultGRPCClientOptions() |
| 637 |
if newClientHook != nil { |
| 638 |
hookOpts, err := newClientHook(ctx, clientHookParams{}) |
| 639 |
if err != nil { |
| 640 |
return nil, err |
| 641 |
} |
| 642 |
clientOpts = append(clientOpts, hookOpts...) |
| 643 |
} |
| 644 |
|
| 645 |
connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) |
| 646 |
if err != nil { |
| 647 |
return nil, err |
| 648 |
} |
| 649 |
client := Client{CallOptions: defaultCallOptions()} |
| 650 |
|
| 651 |
c := &gRPCClient{ |
| 652 |
connPool: connPool, |
| 653 |
client: cloudbuildpb.NewCloudBuildClient(connPool), |
| 654 |
CallOptions: &client.CallOptions, |
| 655 |
logger: internaloption.GetLogger(opts), |
| 656 |
} |
| 657 |
c.setGoogleClientInfo() |
| 658 |
|
| 659 |
client.internalClient = c |
| 660 |
|
| 661 |
client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) |
| 662 |
if err != nil { |
| 663 |
// This error "should not happen", since we are just reusing old connection pool |
| 664 |
// and never actually need to dial. |
| 665 |
// If this does happen, we could leak connp. However, we cannot close conn: |
| 666 |
// If the user invoked the constructor with option.WithGRPCConn, |
| 667 |
// we would close a connection that's still in use. |
| 668 |
// TODO: investigate error conditions. |
| 669 |
return nil, err |
| 670 |
} |
| 671 |
c.LROClient = &client.LROClient |
| 672 |
return &client, nil |
| 673 |
} |
| 674 |
|
| 675 |
// Connection returns a connection to the API service. |
| 676 |
// |
| 677 |
// Deprecated: Connections are now pooled so this method does not always |
| 678 |
// return the same resource. |
| 679 |
func (c *gRPCClient) Connection() *grpc.ClientConn { |
| 680 |
return c.connPool.Conn() |
| 681 |
} |
| 682 |
|
| 683 |
// setGoogleClientInfo sets the name and version of the application in |
| 684 |
// the `x-goog-api-client` header passed on each request. Intended for |
| 685 |
// use by Google-written clients. |
| 686 |
func (c *gRPCClient) setGoogleClientInfo(keyval ...string) { |
| 687 |
kv := append([]string{"gl-go", gax.GoVersion}, keyval...) |
| 688 |
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion) |
| 689 |
c.xGoogHeaders = []string{ |
| 690 |
"x-goog-api-client", gax.XGoogHeader(kv...), |
| 691 |
} |
| 692 |
} |
| 693 |
|
| 694 |
// Close closes the connection to the API service. The user should invoke this when |
| 695 |
// the client is no longer required. |
| 696 |
func (c *gRPCClient) Close() error { |
| 697 |
return c.connPool.Close() |
| 698 |
} |
| 699 |
|
| 700 |
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. |
| 701 |
type restClient struct { |
| 702 |
// The http endpoint to connect to. |
| 703 |
endpoint string |
| 704 |
|
| 705 |
// The http client. |
| 706 |
httpClient *http.Client |
| 707 |
|
| 708 |
// LROClient is used internally to handle long-running operations. |
| 709 |
// It is exposed so that its CallOptions can be modified if required. |
| 710 |
// Users should not Close this client. |
| 711 |
LROClient **lroauto.OperationsClient |
| 712 |
|
| 713 |
// The x-goog-* headers to be sent with each request. |
| 714 |
xGoogHeaders []string |
| 715 |
|
| 716 |
// Points back to the CallOptions field of the containing Client |
| 717 |
CallOptions **CallOptions |
| 718 |
|
| 719 |
logger *slog.Logger |
| 720 |
} |
| 721 |
|
| 722 |
// NewRESTClient creates a new cloud build rest client. |
| 723 |
// |
| 724 |
// Creates and manages builds on Google Cloud Platform. |
| 725 |
// |
| 726 |
// The main concept used by this API is a Build, which describes the location |
| 727 |
// of the source to build, how to build the source, and where to store the |
| 728 |
// built artifacts, if any. |
| 729 |
// |
| 730 |
// A user can list previously-requested builds or get builds by their ID to |
| 731 |
// determine the status of the build. |
| 732 |
func NewRESTClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) { |
| 733 |
clientOpts := append(defaultRESTClientOptions(), opts...) |
| 734 |
httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...) |
| 735 |
if err != nil { |
| 736 |
return nil, err |
| 737 |
} |
| 738 |
|
| 739 |
callOpts := defaultRESTCallOptions() |
| 740 |
c := &restClient{ |
| 741 |
endpoint: endpoint, |
| 742 |
httpClient: httpClient, |
| 743 |
CallOptions: &callOpts, |
| 744 |
logger: internaloption.GetLogger(opts), |
| 745 |
} |
| 746 |
c.setGoogleClientInfo() |
| 747 |
|
| 748 |
lroOpts := []option.ClientOption{ |
| 749 |
option.WithHTTPClient(httpClient), |
| 750 |
option.WithEndpoint(endpoint), |
| 751 |
} |
| 752 |
opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...) |
| 753 |
if err != nil { |
| 754 |
return nil, err |
| 755 |
} |
| 756 |
c.LROClient = &opClient |
| 757 |
|
| 758 |
return &Client{internalClient: c, CallOptions: callOpts}, nil |
| 759 |
} |
| 760 |
|
| 761 |
func defaultRESTClientOptions() []option.ClientOption { |
| 762 |
return []option.ClientOption{ |
| 763 |
internaloption.WithDefaultEndpoint("https://cloudbuild.googleapis.com"), |
| 764 |
internaloption.WithDefaultEndpointTemplate("https://cloudbuild.UNIVERSE_DOMAIN"), |
| 765 |
internaloption.WithDefaultMTLSEndpoint("https://cloudbuild.mtls.googleapis.com"), |
| 766 |
internaloption.WithDefaultUniverseDomain("googleapis.com"), |
| 767 |
internaloption.WithDefaultAudience("https://cloudbuild.googleapis.com/"), |
| 768 |
internaloption.WithDefaultScopes(DefaultAuthScopes()...), |
| 769 |
internaloption.EnableNewAuthLibrary(), |
| 770 |
} |
| 771 |
} |
| 772 |
|
| 773 |
// setGoogleClientInfo sets the name and version of the application in |
| 774 |
// the `x-goog-api-client` header passed on each request. Intended for |
| 775 |
// use by Google-written clients. |
| 776 |
func (c *restClient) setGoogleClientInfo(keyval ...string) { |
| 777 |
kv := append([]string{"gl-go", gax.GoVersion}, keyval...) |
| 778 |
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion) |
| 779 |
c.xGoogHeaders = []string{ |
| 780 |
"x-goog-api-client", gax.XGoogHeader(kv...), |
| 781 |
} |
| 782 |
} |
| 783 |
|
| 784 |
// Close closes the connection to the API service. The user should invoke this when |
| 785 |
// the client is no longer required. |
| 786 |
func (c *restClient) Close() error { |
| 787 |
// Replace httpClient with nil to force cleanup. |
| 788 |
c.httpClient = nil |
| 789 |
return nil |
| 790 |
} |
| 791 |
|
| 792 |
// Connection returns a connection to the API service. |
| 793 |
// |
| 794 |
// Deprecated: This method always returns nil. |
| 795 |
func (c *restClient) Connection() *grpc.ClientConn { |
| 796 |
return nil |
| 797 |
} |
| 798 |
func (c *gRPCClient) CreateBuild(ctx context.Context, req *cloudbuildpb.CreateBuildRequest, opts ...gax.CallOption) (*CreateBuildOperation, error) { |
| 799 |
routingHeaders := "" |
| 800 |
routingHeadersMap := make(map[string]string) |
| 801 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)"); reg.MatchString(req.GetParent()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1])) > 0 { |
| 802 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1]) |
| 803 |
} |
| 804 |
for headerName, headerValue := range routingHeadersMap { |
| 805 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 806 |
} |
| 807 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 808 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 809 |
|
| 810 |
hds = append(c.xGoogHeaders, hds...) |
| 811 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 812 |
opts = append((*c.CallOptions).CreateBuild[0:len((*c.CallOptions).CreateBuild):len((*c.CallOptions).CreateBuild)], opts...) |
| 813 |
var resp *longrunningpb.Operation |
| 814 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 815 |
var err error |
| 816 |
resp, err = executeRPC(ctx, c.client.CreateBuild, req, settings.GRPC, c.logger, "CreateBuild") |
| 817 |
return err |
| 818 |
}, opts...) |
| 819 |
if err != nil { |
| 820 |
return nil, err |
| 821 |
} |
| 822 |
return &CreateBuildOperation{ |
| 823 |
lro: longrunning.InternalNewOperation(*c.LROClient, resp), |
| 824 |
}, nil |
| 825 |
} |
| 826 |
|
| 827 |
func (c *gRPCClient) GetBuild(ctx context.Context, req *cloudbuildpb.GetBuildRequest, opts ...gax.CallOption) (*cloudbuildpb.Build, error) { |
| 828 |
routingHeaders := "" |
| 829 |
routingHeadersMap := make(map[string]string) |
| 830 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/builds/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 831 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 832 |
} |
| 833 |
for headerName, headerValue := range routingHeadersMap { |
| 834 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 835 |
} |
| 836 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 837 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 838 |
|
| 839 |
hds = append(c.xGoogHeaders, hds...) |
| 840 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 841 |
opts = append((*c.CallOptions).GetBuild[0:len((*c.CallOptions).GetBuild):len((*c.CallOptions).GetBuild)], opts...) |
| 842 |
var resp *cloudbuildpb.Build |
| 843 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 844 |
var err error |
| 845 |
resp, err = executeRPC(ctx, c.client.GetBuild, req, settings.GRPC, c.logger, "GetBuild") |
| 846 |
return err |
| 847 |
}, opts...) |
| 848 |
if err != nil { |
| 849 |
return nil, err |
| 850 |
} |
| 851 |
return resp, nil |
| 852 |
} |
| 853 |
|
| 854 |
func (c *gRPCClient) ListBuilds(ctx context.Context, req *cloudbuildpb.ListBuildsRequest, opts ...gax.CallOption) *BuildIterator { |
| 855 |
routingHeaders := "" |
| 856 |
routingHeadersMap := make(map[string]string) |
| 857 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)"); reg.MatchString(req.GetParent()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1])) > 0 { |
| 858 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1]) |
| 859 |
} |
| 860 |
for headerName, headerValue := range routingHeadersMap { |
| 861 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 862 |
} |
| 863 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 864 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 865 |
|
| 866 |
hds = append(c.xGoogHeaders, hds...) |
| 867 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 868 |
opts = append((*c.CallOptions).ListBuilds[0:len((*c.CallOptions).ListBuilds):len((*c.CallOptions).ListBuilds)], opts...) |
| 869 |
it := &BuildIterator{} |
| 870 |
req = proto.Clone(req).(*cloudbuildpb.ListBuildsRequest) |
| 871 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*cloudbuildpb.Build, string, error) { |
| 872 |
resp := &cloudbuildpb.ListBuildsResponse{} |
| 873 |
if pageToken != "" { |
| 874 |
req.PageToken = pageToken |
| 875 |
} |
| 876 |
if pageSize > math.MaxInt32 { |
| 877 |
req.PageSize = math.MaxInt32 |
| 878 |
} else if pageSize != 0 { |
| 879 |
req.PageSize = int32(pageSize) |
| 880 |
} |
| 881 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 882 |
var err error |
| 883 |
resp, err = executeRPC(ctx, c.client.ListBuilds, req, settings.GRPC, c.logger, "ListBuilds") |
| 884 |
return err |
| 885 |
}, opts...) |
| 886 |
if err != nil { |
| 887 |
return nil, "", err |
| 888 |
} |
| 889 |
|
| 890 |
it.Response = resp |
| 891 |
return resp.GetBuilds(), resp.GetNextPageToken(), nil |
| 892 |
} |
| 893 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 894 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 895 |
if err != nil { |
| 896 |
return "", err |
| 897 |
} |
| 898 |
it.items = append(it.items, items...) |
| 899 |
return nextPageToken, nil |
| 900 |
} |
| 901 |
|
| 902 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 903 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 904 |
it.pageInfo.Token = req.GetPageToken() |
| 905 |
|
| 906 |
return it |
| 907 |
} |
| 908 |
|
| 909 |
func (c *gRPCClient) CancelBuild(ctx context.Context, req *cloudbuildpb.CancelBuildRequest, opts ...gax.CallOption) (*cloudbuildpb.Build, error) { |
| 910 |
routingHeaders := "" |
| 911 |
routingHeadersMap := make(map[string]string) |
| 912 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/builds/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 913 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 914 |
} |
| 915 |
for headerName, headerValue := range routingHeadersMap { |
| 916 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 917 |
} |
| 918 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 919 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 920 |
|
| 921 |
hds = append(c.xGoogHeaders, hds...) |
| 922 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 923 |
opts = append((*c.CallOptions).CancelBuild[0:len((*c.CallOptions).CancelBuild):len((*c.CallOptions).CancelBuild)], opts...) |
| 924 |
var resp *cloudbuildpb.Build |
| 925 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 926 |
var err error |
| 927 |
resp, err = executeRPC(ctx, c.client.CancelBuild, req, settings.GRPC, c.logger, "CancelBuild") |
| 928 |
return err |
| 929 |
}, opts...) |
| 930 |
if err != nil { |
| 931 |
return nil, err |
| 932 |
} |
| 933 |
return resp, nil |
| 934 |
} |
| 935 |
|
| 936 |
func (c *gRPCClient) RetryBuild(ctx context.Context, req *cloudbuildpb.RetryBuildRequest, opts ...gax.CallOption) (*RetryBuildOperation, error) { |
| 937 |
routingHeaders := "" |
| 938 |
routingHeadersMap := make(map[string]string) |
| 939 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/builds/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 940 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 941 |
} |
| 942 |
for headerName, headerValue := range routingHeadersMap { |
| 943 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 944 |
} |
| 945 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 946 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 947 |
|
| 948 |
hds = append(c.xGoogHeaders, hds...) |
| 949 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 950 |
opts = append((*c.CallOptions).RetryBuild[0:len((*c.CallOptions).RetryBuild):len((*c.CallOptions).RetryBuild)], opts...) |
| 951 |
var resp *longrunningpb.Operation |
| 952 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 953 |
var err error |
| 954 |
resp, err = executeRPC(ctx, c.client.RetryBuild, req, settings.GRPC, c.logger, "RetryBuild") |
| 955 |
return err |
| 956 |
}, opts...) |
| 957 |
if err != nil { |
| 958 |
return nil, err |
| 959 |
} |
| 960 |
return &RetryBuildOperation{ |
| 961 |
lro: longrunning.InternalNewOperation(*c.LROClient, resp), |
| 962 |
}, nil |
| 963 |
} |
| 964 |
|
| 965 |
func (c *gRPCClient) ApproveBuild(ctx context.Context, req *cloudbuildpb.ApproveBuildRequest, opts ...gax.CallOption) (*ApproveBuildOperation, error) { |
| 966 |
routingHeaders := "" |
| 967 |
routingHeadersMap := make(map[string]string) |
| 968 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/builds/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 969 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 970 |
} |
| 971 |
for headerName, headerValue := range routingHeadersMap { |
| 972 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 973 |
} |
| 974 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 975 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 976 |
|
| 977 |
hds = append(c.xGoogHeaders, hds...) |
| 978 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 979 |
opts = append((*c.CallOptions).ApproveBuild[0:len((*c.CallOptions).ApproveBuild):len((*c.CallOptions).ApproveBuild)], opts...) |
| 980 |
var resp *longrunningpb.Operation |
| 981 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 982 |
var err error |
| 983 |
resp, err = executeRPC(ctx, c.client.ApproveBuild, req, settings.GRPC, c.logger, "ApproveBuild") |
| 984 |
return err |
| 985 |
}, opts...) |
| 986 |
if err != nil { |
| 987 |
return nil, err |
| 988 |
} |
| 989 |
return &ApproveBuildOperation{ |
| 990 |
lro: longrunning.InternalNewOperation(*c.LROClient, resp), |
| 991 |
}, nil |
| 992 |
} |
| 993 |
|
| 994 |
func (c *gRPCClient) CreateBuildTrigger(ctx context.Context, req *cloudbuildpb.CreateBuildTriggerRequest, opts ...gax.CallOption) (*cloudbuildpb.BuildTrigger, error) { |
| 995 |
routingHeaders := "" |
| 996 |
routingHeadersMap := make(map[string]string) |
| 997 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)"); reg.MatchString(req.GetParent()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1])) > 0 { |
| 998 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1]) |
| 999 |
} |
| 1000 |
for headerName, headerValue := range routingHeadersMap { |
| 1001 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1002 |
} |
| 1003 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1004 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1005 |
|
| 1006 |
hds = append(c.xGoogHeaders, hds...) |
| 1007 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 1008 |
opts = append((*c.CallOptions).CreateBuildTrigger[0:len((*c.CallOptions).CreateBuildTrigger):len((*c.CallOptions).CreateBuildTrigger)], opts...) |
| 1009 |
var resp *cloudbuildpb.BuildTrigger |
| 1010 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1011 |
var err error |
| 1012 |
resp, err = executeRPC(ctx, c.client.CreateBuildTrigger, req, settings.GRPC, c.logger, "CreateBuildTrigger") |
| 1013 |
return err |
| 1014 |
}, opts...) |
| 1015 |
if err != nil { |
| 1016 |
return nil, err |
| 1017 |
} |
| 1018 |
return resp, nil |
| 1019 |
} |
| 1020 |
|
| 1021 |
func (c *gRPCClient) GetBuildTrigger(ctx context.Context, req *cloudbuildpb.GetBuildTriggerRequest, opts ...gax.CallOption) (*cloudbuildpb.BuildTrigger, error) { |
| 1022 |
routingHeaders := "" |
| 1023 |
routingHeadersMap := make(map[string]string) |
| 1024 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/triggers/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 1025 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 1026 |
} |
| 1027 |
for headerName, headerValue := range routingHeadersMap { |
| 1028 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1029 |
} |
| 1030 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1031 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1032 |
|
| 1033 |
hds = append(c.xGoogHeaders, hds...) |
| 1034 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 1035 |
opts = append((*c.CallOptions).GetBuildTrigger[0:len((*c.CallOptions).GetBuildTrigger):len((*c.CallOptions).GetBuildTrigger)], opts...) |
| 1036 |
var resp *cloudbuildpb.BuildTrigger |
| 1037 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1038 |
var err error |
| 1039 |
resp, err = executeRPC(ctx, c.client.GetBuildTrigger, req, settings.GRPC, c.logger, "GetBuildTrigger") |
| 1040 |
return err |
| 1041 |
}, opts...) |
| 1042 |
if err != nil { |
| 1043 |
return nil, err |
| 1044 |
} |
| 1045 |
return resp, nil |
| 1046 |
} |
| 1047 |
|
| 1048 |
func (c *gRPCClient) ListBuildTriggers(ctx context.Context, req *cloudbuildpb.ListBuildTriggersRequest, opts ...gax.CallOption) *BuildTriggerIterator { |
| 1049 |
routingHeaders := "" |
| 1050 |
routingHeadersMap := make(map[string]string) |
| 1051 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)"); reg.MatchString(req.GetParent()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1])) > 0 { |
| 1052 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1]) |
| 1053 |
} |
| 1054 |
for headerName, headerValue := range routingHeadersMap { |
| 1055 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1056 |
} |
| 1057 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1058 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1059 |
|
| 1060 |
hds = append(c.xGoogHeaders, hds...) |
| 1061 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 1062 |
opts = append((*c.CallOptions).ListBuildTriggers[0:len((*c.CallOptions).ListBuildTriggers):len((*c.CallOptions).ListBuildTriggers)], opts...) |
| 1063 |
it := &BuildTriggerIterator{} |
| 1064 |
req = proto.Clone(req).(*cloudbuildpb.ListBuildTriggersRequest) |
| 1065 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*cloudbuildpb.BuildTrigger, string, error) { |
| 1066 |
resp := &cloudbuildpb.ListBuildTriggersResponse{} |
| 1067 |
if pageToken != "" { |
| 1068 |
req.PageToken = pageToken |
| 1069 |
} |
| 1070 |
if pageSize > math.MaxInt32 { |
| 1071 |
req.PageSize = math.MaxInt32 |
| 1072 |
} else if pageSize != 0 { |
| 1073 |
req.PageSize = int32(pageSize) |
| 1074 |
} |
| 1075 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1076 |
var err error |
| 1077 |
resp, err = executeRPC(ctx, c.client.ListBuildTriggers, req, settings.GRPC, c.logger, "ListBuildTriggers") |
| 1078 |
return err |
| 1079 |
}, opts...) |
| 1080 |
if err != nil { |
| 1081 |
return nil, "", err |
| 1082 |
} |
| 1083 |
|
| 1084 |
it.Response = resp |
| 1085 |
return resp.GetTriggers(), resp.GetNextPageToken(), nil |
| 1086 |
} |
| 1087 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 1088 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 1089 |
if err != nil { |
| 1090 |
return "", err |
| 1091 |
} |
| 1092 |
it.items = append(it.items, items...) |
| 1093 |
return nextPageToken, nil |
| 1094 |
} |
| 1095 |
|
| 1096 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 1097 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 1098 |
it.pageInfo.Token = req.GetPageToken() |
| 1099 |
|
| 1100 |
return it |
| 1101 |
} |
| 1102 |
|
| 1103 |
func (c *gRPCClient) DeleteBuildTrigger(ctx context.Context, req *cloudbuildpb.DeleteBuildTriggerRequest, opts ...gax.CallOption) error { |
| 1104 |
routingHeaders := "" |
| 1105 |
routingHeadersMap := make(map[string]string) |
| 1106 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/triggers/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 1107 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 1108 |
} |
| 1109 |
for headerName, headerValue := range routingHeadersMap { |
| 1110 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1111 |
} |
| 1112 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1113 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1114 |
|
| 1115 |
hds = append(c.xGoogHeaders, hds...) |
| 1116 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 1117 |
opts = append((*c.CallOptions).DeleteBuildTrigger[0:len((*c.CallOptions).DeleteBuildTrigger):len((*c.CallOptions).DeleteBuildTrigger)], opts...) |
| 1118 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1119 |
var err error |
| 1120 |
_, err = executeRPC(ctx, c.client.DeleteBuildTrigger, req, settings.GRPC, c.logger, "DeleteBuildTrigger") |
| 1121 |
return err |
| 1122 |
}, opts...) |
| 1123 |
return err |
| 1124 |
} |
| 1125 |
|
| 1126 |
func (c *gRPCClient) UpdateBuildTrigger(ctx context.Context, req *cloudbuildpb.UpdateBuildTriggerRequest, opts ...gax.CallOption) (*cloudbuildpb.BuildTrigger, error) { |
| 1127 |
routingHeaders := "" |
| 1128 |
routingHeadersMap := make(map[string]string) |
| 1129 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/triggers/[^/]+"); reg.MatchString(req.GetTrigger().GetResourceName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetTrigger().GetResourceName())[1])) > 0 { |
| 1130 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetTrigger().GetResourceName())[1]) |
| 1131 |
} |
| 1132 |
for headerName, headerValue := range routingHeadersMap { |
| 1133 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1134 |
} |
| 1135 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1136 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1137 |
|
| 1138 |
hds = append(c.xGoogHeaders, hds...) |
| 1139 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 1140 |
opts = append((*c.CallOptions).UpdateBuildTrigger[0:len((*c.CallOptions).UpdateBuildTrigger):len((*c.CallOptions).UpdateBuildTrigger)], opts...) |
| 1141 |
var resp *cloudbuildpb.BuildTrigger |
| 1142 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1143 |
var err error |
| 1144 |
resp, err = executeRPC(ctx, c.client.UpdateBuildTrigger, req, settings.GRPC, c.logger, "UpdateBuildTrigger") |
| 1145 |
return err |
| 1146 |
}, opts...) |
| 1147 |
if err != nil { |
| 1148 |
return nil, err |
| 1149 |
} |
| 1150 |
return resp, nil |
| 1151 |
} |
| 1152 |
|
| 1153 |
func (c *gRPCClient) RunBuildTrigger(ctx context.Context, req *cloudbuildpb.RunBuildTriggerRequest, opts ...gax.CallOption) (*RunBuildTriggerOperation, error) { |
| 1154 |
routingHeaders := "" |
| 1155 |
routingHeadersMap := make(map[string]string) |
| 1156 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/triggers/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 1157 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 1158 |
} |
| 1159 |
for headerName, headerValue := range routingHeadersMap { |
| 1160 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1161 |
} |
| 1162 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1163 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1164 |
|
| 1165 |
hds = append(c.xGoogHeaders, hds...) |
| 1166 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 1167 |
opts = append((*c.CallOptions).RunBuildTrigger[0:len((*c.CallOptions).RunBuildTrigger):len((*c.CallOptions).RunBuildTrigger)], opts...) |
| 1168 |
var resp *longrunningpb.Operation |
| 1169 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1170 |
var err error |
| 1171 |
resp, err = executeRPC(ctx, c.client.RunBuildTrigger, req, settings.GRPC, c.logger, "RunBuildTrigger") |
| 1172 |
return err |
| 1173 |
}, opts...) |
| 1174 |
if err != nil { |
| 1175 |
return nil, err |
| 1176 |
} |
| 1177 |
return &RunBuildTriggerOperation{ |
| 1178 |
lro: longrunning.InternalNewOperation(*c.LROClient, resp), |
| 1179 |
}, nil |
| 1180 |
} |
| 1181 |
|
| 1182 |
func (c *gRPCClient) ReceiveTriggerWebhook(ctx context.Context, req *cloudbuildpb.ReceiveTriggerWebhookRequest, opts ...gax.CallOption) (*cloudbuildpb.ReceiveTriggerWebhookResponse, error) { |
| 1183 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "trigger", url.QueryEscape(req.GetTrigger()), "name", url.QueryEscape(req.GetName()))} |
| 1184 |
|
| 1185 |
hds = append(c.xGoogHeaders, hds...) |
| 1186 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 1187 |
opts = append((*c.CallOptions).ReceiveTriggerWebhook[0:len((*c.CallOptions).ReceiveTriggerWebhook):len((*c.CallOptions).ReceiveTriggerWebhook)], opts...) |
| 1188 |
var resp *cloudbuildpb.ReceiveTriggerWebhookResponse |
| 1189 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1190 |
var err error |
| 1191 |
resp, err = executeRPC(ctx, c.client.ReceiveTriggerWebhook, req, settings.GRPC, c.logger, "ReceiveTriggerWebhook") |
| 1192 |
return err |
| 1193 |
}, opts...) |
| 1194 |
if err != nil { |
| 1195 |
return nil, err |
| 1196 |
} |
| 1197 |
return resp, nil |
| 1198 |
} |
| 1199 |
|
| 1200 |
func (c *gRPCClient) CreateWorkerPool(ctx context.Context, req *cloudbuildpb.CreateWorkerPoolRequest, opts ...gax.CallOption) (*CreateWorkerPoolOperation, error) { |
| 1201 |
routingHeaders := "" |
| 1202 |
routingHeadersMap := make(map[string]string) |
| 1203 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)"); reg.MatchString(req.GetParent()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1])) > 0 { |
| 1204 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1]) |
| 1205 |
} |
| 1206 |
for headerName, headerValue := range routingHeadersMap { |
| 1207 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1208 |
} |
| 1209 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1210 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1211 |
|
| 1212 |
hds = append(c.xGoogHeaders, hds...) |
| 1213 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 1214 |
opts = append((*c.CallOptions).CreateWorkerPool[0:len((*c.CallOptions).CreateWorkerPool):len((*c.CallOptions).CreateWorkerPool)], opts...) |
| 1215 |
var resp *longrunningpb.Operation |
| 1216 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1217 |
var err error |
| 1218 |
resp, err = executeRPC(ctx, c.client.CreateWorkerPool, req, settings.GRPC, c.logger, "CreateWorkerPool") |
| 1219 |
return err |
| 1220 |
}, opts...) |
| 1221 |
if err != nil { |
| 1222 |
return nil, err |
| 1223 |
} |
| 1224 |
return &CreateWorkerPoolOperation{ |
| 1225 |
lro: longrunning.InternalNewOperation(*c.LROClient, resp), |
| 1226 |
}, nil |
| 1227 |
} |
| 1228 |
|
| 1229 |
func (c *gRPCClient) GetWorkerPool(ctx context.Context, req *cloudbuildpb.GetWorkerPoolRequest, opts ...gax.CallOption) (*cloudbuildpb.WorkerPool, error) { |
| 1230 |
routingHeaders := "" |
| 1231 |
routingHeadersMap := make(map[string]string) |
| 1232 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/workerPools/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 1233 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 1234 |
} |
| 1235 |
for headerName, headerValue := range routingHeadersMap { |
| 1236 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1237 |
} |
| 1238 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1239 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1240 |
|
| 1241 |
hds = append(c.xGoogHeaders, hds...) |
| 1242 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 1243 |
opts = append((*c.CallOptions).GetWorkerPool[0:len((*c.CallOptions).GetWorkerPool):len((*c.CallOptions).GetWorkerPool)], opts...) |
| 1244 |
var resp *cloudbuildpb.WorkerPool |
| 1245 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1246 |
var err error |
| 1247 |
resp, err = executeRPC(ctx, c.client.GetWorkerPool, req, settings.GRPC, c.logger, "GetWorkerPool") |
| 1248 |
return err |
| 1249 |
}, opts...) |
| 1250 |
if err != nil { |
| 1251 |
return nil, err |
| 1252 |
} |
| 1253 |
return resp, nil |
| 1254 |
} |
| 1255 |
|
| 1256 |
func (c *gRPCClient) DeleteWorkerPool(ctx context.Context, req *cloudbuildpb.DeleteWorkerPoolRequest, opts ...gax.CallOption) (*DeleteWorkerPoolOperation, error) { |
| 1257 |
routingHeaders := "" |
| 1258 |
routingHeadersMap := make(map[string]string) |
| 1259 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/workerPools/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 1260 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 1261 |
} |
| 1262 |
for headerName, headerValue := range routingHeadersMap { |
| 1263 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1264 |
} |
| 1265 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1266 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1267 |
|
| 1268 |
hds = append(c.xGoogHeaders, hds...) |
| 1269 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 1270 |
opts = append((*c.CallOptions).DeleteWorkerPool[0:len((*c.CallOptions).DeleteWorkerPool):len((*c.CallOptions).DeleteWorkerPool)], opts...) |
| 1271 |
var resp *longrunningpb.Operation |
| 1272 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1273 |
var err error |
| 1274 |
resp, err = executeRPC(ctx, c.client.DeleteWorkerPool, req, settings.GRPC, c.logger, "DeleteWorkerPool") |
| 1275 |
return err |
| 1276 |
}, opts...) |
| 1277 |
if err != nil { |
| 1278 |
return nil, err |
| 1279 |
} |
| 1280 |
return &DeleteWorkerPoolOperation{ |
| 1281 |
lro: longrunning.InternalNewOperation(*c.LROClient, resp), |
| 1282 |
}, nil |
| 1283 |
} |
| 1284 |
|
| 1285 |
func (c *gRPCClient) UpdateWorkerPool(ctx context.Context, req *cloudbuildpb.UpdateWorkerPoolRequest, opts ...gax.CallOption) (*UpdateWorkerPoolOperation, error) { |
| 1286 |
routingHeaders := "" |
| 1287 |
routingHeadersMap := make(map[string]string) |
| 1288 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/workerPools/[^/]+"); reg.MatchString(req.GetWorkerPool().GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetWorkerPool().GetName())[1])) > 0 { |
| 1289 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetWorkerPool().GetName())[1]) |
| 1290 |
} |
| 1291 |
for headerName, headerValue := range routingHeadersMap { |
| 1292 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1293 |
} |
| 1294 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1295 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1296 |
|
| 1297 |
hds = append(c.xGoogHeaders, hds...) |
| 1298 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 1299 |
opts = append((*c.CallOptions).UpdateWorkerPool[0:len((*c.CallOptions).UpdateWorkerPool):len((*c.CallOptions).UpdateWorkerPool)], opts...) |
| 1300 |
var resp *longrunningpb.Operation |
| 1301 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1302 |
var err error |
| 1303 |
resp, err = executeRPC(ctx, c.client.UpdateWorkerPool, req, settings.GRPC, c.logger, "UpdateWorkerPool") |
| 1304 |
return err |
| 1305 |
}, opts...) |
| 1306 |
if err != nil { |
| 1307 |
return nil, err |
| 1308 |
} |
| 1309 |
return &UpdateWorkerPoolOperation{ |
| 1310 |
lro: longrunning.InternalNewOperation(*c.LROClient, resp), |
| 1311 |
}, nil |
| 1312 |
} |
| 1313 |
|
| 1314 |
func (c *gRPCClient) ListWorkerPools(ctx context.Context, req *cloudbuildpb.ListWorkerPoolsRequest, opts ...gax.CallOption) *WorkerPoolIterator { |
| 1315 |
routingHeaders := "" |
| 1316 |
routingHeadersMap := make(map[string]string) |
| 1317 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)"); reg.MatchString(req.GetParent()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1])) > 0 { |
| 1318 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1]) |
| 1319 |
} |
| 1320 |
for headerName, headerValue := range routingHeadersMap { |
| 1321 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1322 |
} |
| 1323 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1324 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1325 |
|
| 1326 |
hds = append(c.xGoogHeaders, hds...) |
| 1327 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 1328 |
opts = append((*c.CallOptions).ListWorkerPools[0:len((*c.CallOptions).ListWorkerPools):len((*c.CallOptions).ListWorkerPools)], opts...) |
| 1329 |
it := &WorkerPoolIterator{} |
| 1330 |
req = proto.Clone(req).(*cloudbuildpb.ListWorkerPoolsRequest) |
| 1331 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*cloudbuildpb.WorkerPool, string, error) { |
| 1332 |
resp := &cloudbuildpb.ListWorkerPoolsResponse{} |
| 1333 |
if pageToken != "" { |
| 1334 |
req.PageToken = pageToken |
| 1335 |
} |
| 1336 |
if pageSize > math.MaxInt32 { |
| 1337 |
req.PageSize = math.MaxInt32 |
| 1338 |
} else if pageSize != 0 { |
| 1339 |
req.PageSize = int32(pageSize) |
| 1340 |
} |
| 1341 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1342 |
var err error |
| 1343 |
resp, err = executeRPC(ctx, c.client.ListWorkerPools, req, settings.GRPC, c.logger, "ListWorkerPools") |
| 1344 |
return err |
| 1345 |
}, opts...) |
| 1346 |
if err != nil { |
| 1347 |
return nil, "", err |
| 1348 |
} |
| 1349 |
|
| 1350 |
it.Response = resp |
| 1351 |
return resp.GetWorkerPools(), resp.GetNextPageToken(), nil |
| 1352 |
} |
| 1353 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 1354 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 1355 |
if err != nil { |
| 1356 |
return "", err |
| 1357 |
} |
| 1358 |
it.items = append(it.items, items...) |
| 1359 |
return nextPageToken, nil |
| 1360 |
} |
| 1361 |
|
| 1362 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 1363 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 1364 |
it.pageInfo.Token = req.GetPageToken() |
| 1365 |
|
| 1366 |
return it |
| 1367 |
} |
| 1368 |
|
| 1369 |
// CreateBuild starts a build with the specified configuration. |
| 1370 |
// |
| 1371 |
// This method returns a long-running Operation, which includes the build |
| 1372 |
// ID. Pass the build ID to GetBuild to determine the build status (such as |
| 1373 |
// SUCCESS or FAILURE). |
| 1374 |
func (c *restClient) CreateBuild(ctx context.Context, req *cloudbuildpb.CreateBuildRequest, opts ...gax.CallOption) (*CreateBuildOperation, error) { |
| 1375 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 1376 |
body := req.GetBuild() |
| 1377 |
jsonReq, err := m.Marshal(body) |
| 1378 |
if err != nil { |
| 1379 |
return nil, err |
| 1380 |
} |
| 1381 |
|
| 1382 |
baseUrl, err := url.Parse(c.endpoint) |
| 1383 |
if err != nil { |
| 1384 |
return nil, err |
| 1385 |
} |
| 1386 |
baseUrl.Path += fmt.Sprintf("/v1/projects/%v/builds", req.GetProjectId()) |
| 1387 |
|
| 1388 |
params := url.Values{} |
| 1389 |
params.Add("$alt", "json;enum-encoding=int") |
| 1390 |
if req.GetParent() != "" { |
| 1391 |
params.Add("parent", fmt.Sprintf("%v", req.GetParent())) |
| 1392 |
} |
| 1393 |
|
| 1394 |
baseUrl.RawQuery = params.Encode() |
| 1395 |
|
| 1396 |
// Build HTTP headers from client and context metadata. |
| 1397 |
routingHeaders := "" |
| 1398 |
routingHeadersMap := make(map[string]string) |
| 1399 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)"); reg.MatchString(req.GetParent()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1])) > 0 { |
| 1400 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1]) |
| 1401 |
} |
| 1402 |
for headerName, headerValue := range routingHeadersMap { |
| 1403 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1404 |
} |
| 1405 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1406 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1407 |
|
| 1408 |
hds = append(c.xGoogHeaders, hds...) |
| 1409 |
hds = append(hds, "Content-Type", "application/json") |
| 1410 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1411 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1412 |
resp := &longrunningpb.Operation{} |
| 1413 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1414 |
if settings.Path != "" { |
| 1415 |
baseUrl.Path = settings.Path |
| 1416 |
} |
| 1417 |
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 1418 |
if err != nil { |
| 1419 |
return err |
| 1420 |
} |
| 1421 |
httpReq = httpReq.WithContext(ctx) |
| 1422 |
httpReq.Header = headers |
| 1423 |
|
| 1424 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateBuild") |
| 1425 |
if err != nil { |
| 1426 |
return err |
| 1427 |
} |
| 1428 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1429 |
return err |
| 1430 |
} |
| 1431 |
|
| 1432 |
return nil |
| 1433 |
}, opts...) |
| 1434 |
if e != nil { |
| 1435 |
return nil, e |
| 1436 |
} |
| 1437 |
|
| 1438 |
override := fmt.Sprintf("/v1/%s", resp.GetName()) |
| 1439 |
return &CreateBuildOperation{ |
| 1440 |
lro: longrunning.InternalNewOperation(*c.LROClient, resp), |
| 1441 |
pollPath: override, |
| 1442 |
}, nil |
| 1443 |
} |
| 1444 |
|
| 1445 |
// GetBuild returns information about a previously requested build. |
| 1446 |
// |
| 1447 |
// The Build that is returned includes its status (such as SUCCESS, |
| 1448 |
// FAILURE, or WORKING), and timing information. |
| 1449 |
func (c *restClient) GetBuild(ctx context.Context, req *cloudbuildpb.GetBuildRequest, opts ...gax.CallOption) (*cloudbuildpb.Build, error) { |
| 1450 |
baseUrl, err := url.Parse(c.endpoint) |
| 1451 |
if err != nil { |
| 1452 |
return nil, err |
| 1453 |
} |
| 1454 |
baseUrl.Path += fmt.Sprintf("/v1/projects/%v/builds/%v", req.GetProjectId(), req.GetId()) |
| 1455 |
|
| 1456 |
params := url.Values{} |
| 1457 |
params.Add("$alt", "json;enum-encoding=int") |
| 1458 |
if req.GetName() != "" { |
| 1459 |
params.Add("name", fmt.Sprintf("%v", req.GetName())) |
| 1460 |
} |
| 1461 |
|
| 1462 |
baseUrl.RawQuery = params.Encode() |
| 1463 |
|
| 1464 |
// Build HTTP headers from client and context metadata. |
| 1465 |
routingHeaders := "" |
| 1466 |
routingHeadersMap := make(map[string]string) |
| 1467 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/builds/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 1468 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 1469 |
} |
| 1470 |
for headerName, headerValue := range routingHeadersMap { |
| 1471 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1472 |
} |
| 1473 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1474 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1475 |
|
| 1476 |
hds = append(c.xGoogHeaders, hds...) |
| 1477 |
hds = append(hds, "Content-Type", "application/json") |
| 1478 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1479 |
opts = append((*c.CallOptions).GetBuild[0:len((*c.CallOptions).GetBuild):len((*c.CallOptions).GetBuild)], opts...) |
| 1480 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1481 |
resp := &cloudbuildpb.Build{} |
| 1482 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1483 |
if settings.Path != "" { |
| 1484 |
baseUrl.Path = settings.Path |
| 1485 |
} |
| 1486 |
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| 1487 |
if err != nil { |
| 1488 |
return err |
| 1489 |
} |
| 1490 |
httpReq = httpReq.WithContext(ctx) |
| 1491 |
httpReq.Header = headers |
| 1492 |
|
| 1493 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetBuild") |
| 1494 |
if err != nil { |
| 1495 |
return err |
| 1496 |
} |
| 1497 |
|
| 1498 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1499 |
return err |
| 1500 |
} |
| 1501 |
|
| 1502 |
return nil |
| 1503 |
}, opts...) |
| 1504 |
if e != nil { |
| 1505 |
return nil, e |
| 1506 |
} |
| 1507 |
return resp, nil |
| 1508 |
} |
| 1509 |
|
| 1510 |
// ListBuilds lists previously requested builds. |
| 1511 |
// |
| 1512 |
// Previously requested builds may still be in-progress, or may have finished |
| 1513 |
// successfully or unsuccessfully. |
| 1514 |
func (c *restClient) ListBuilds(ctx context.Context, req *cloudbuildpb.ListBuildsRequest, opts ...gax.CallOption) *BuildIterator { |
| 1515 |
it := &BuildIterator{} |
| 1516 |
req = proto.Clone(req).(*cloudbuildpb.ListBuildsRequest) |
| 1517 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1518 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*cloudbuildpb.Build, string, error) { |
| 1519 |
resp := &cloudbuildpb.ListBuildsResponse{} |
| 1520 |
if pageToken != "" { |
| 1521 |
req.PageToken = pageToken |
| 1522 |
} |
| 1523 |
if pageSize > math.MaxInt32 { |
| 1524 |
req.PageSize = math.MaxInt32 |
| 1525 |
} else if pageSize != 0 { |
| 1526 |
req.PageSize = int32(pageSize) |
| 1527 |
} |
| 1528 |
baseUrl, err := url.Parse(c.endpoint) |
| 1529 |
if err != nil { |
| 1530 |
return nil, "", err |
| 1531 |
} |
| 1532 |
baseUrl.Path += fmt.Sprintf("/v1/projects/%v/builds", req.GetProjectId()) |
| 1533 |
|
| 1534 |
params := url.Values{} |
| 1535 |
params.Add("$alt", "json;enum-encoding=int") |
| 1536 |
if req.GetFilter() != "" { |
| 1537 |
params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) |
| 1538 |
} |
| 1539 |
if req.GetPageSize() != 0 { |
| 1540 |
params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) |
| 1541 |
} |
| 1542 |
if req.GetPageToken() != "" { |
| 1543 |
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) |
| 1544 |
} |
| 1545 |
if req.GetParent() != "" { |
| 1546 |
params.Add("parent", fmt.Sprintf("%v", req.GetParent())) |
| 1547 |
} |
| 1548 |
|
| 1549 |
baseUrl.RawQuery = params.Encode() |
| 1550 |
|
| 1551 |
// Build HTTP headers from client and context metadata. |
| 1552 |
hds := append(c.xGoogHeaders, "Content-Type", "application/json") |
| 1553 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1554 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1555 |
if settings.Path != "" { |
| 1556 |
baseUrl.Path = settings.Path |
| 1557 |
} |
| 1558 |
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| 1559 |
if err != nil { |
| 1560 |
return err |
| 1561 |
} |
| 1562 |
httpReq.Header = headers |
| 1563 |
|
| 1564 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListBuilds") |
| 1565 |
if err != nil { |
| 1566 |
return err |
| 1567 |
} |
| 1568 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1569 |
return err |
| 1570 |
} |
| 1571 |
|
| 1572 |
return nil |
| 1573 |
}, opts...) |
| 1574 |
if e != nil { |
| 1575 |
return nil, "", e |
| 1576 |
} |
| 1577 |
it.Response = resp |
| 1578 |
return resp.GetBuilds(), resp.GetNextPageToken(), nil |
| 1579 |
} |
| 1580 |
|
| 1581 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 1582 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 1583 |
if err != nil { |
| 1584 |
return "", err |
| 1585 |
} |
| 1586 |
it.items = append(it.items, items...) |
| 1587 |
return nextPageToken, nil |
| 1588 |
} |
| 1589 |
|
| 1590 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 1591 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 1592 |
it.pageInfo.Token = req.GetPageToken() |
| 1593 |
|
| 1594 |
return it |
| 1595 |
} |
| 1596 |
|
| 1597 |
// CancelBuild cancels a build in progress. |
| 1598 |
func (c *restClient) CancelBuild(ctx context.Context, req *cloudbuildpb.CancelBuildRequest, opts ...gax.CallOption) (*cloudbuildpb.Build, error) { |
| 1599 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 1600 |
jsonReq, err := m.Marshal(req) |
| 1601 |
if err != nil { |
| 1602 |
return nil, err |
| 1603 |
} |
| 1604 |
|
| 1605 |
baseUrl, err := url.Parse(c.endpoint) |
| 1606 |
if err != nil { |
| 1607 |
return nil, err |
| 1608 |
} |
| 1609 |
baseUrl.Path += fmt.Sprintf("/v1/projects/%v/builds/%v:cancel", req.GetProjectId(), req.GetId()) |
| 1610 |
|
| 1611 |
params := url.Values{} |
| 1612 |
params.Add("$alt", "json;enum-encoding=int") |
| 1613 |
|
| 1614 |
baseUrl.RawQuery = params.Encode() |
| 1615 |
|
| 1616 |
// Build HTTP headers from client and context metadata. |
| 1617 |
routingHeaders := "" |
| 1618 |
routingHeadersMap := make(map[string]string) |
| 1619 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/builds/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 1620 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 1621 |
} |
| 1622 |
for headerName, headerValue := range routingHeadersMap { |
| 1623 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1624 |
} |
| 1625 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1626 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1627 |
|
| 1628 |
hds = append(c.xGoogHeaders, hds...) |
| 1629 |
hds = append(hds, "Content-Type", "application/json") |
| 1630 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1631 |
opts = append((*c.CallOptions).CancelBuild[0:len((*c.CallOptions).CancelBuild):len((*c.CallOptions).CancelBuild)], opts...) |
| 1632 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1633 |
resp := &cloudbuildpb.Build{} |
| 1634 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1635 |
if settings.Path != "" { |
| 1636 |
baseUrl.Path = settings.Path |
| 1637 |
} |
| 1638 |
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 1639 |
if err != nil { |
| 1640 |
return err |
| 1641 |
} |
| 1642 |
httpReq = httpReq.WithContext(ctx) |
| 1643 |
httpReq.Header = headers |
| 1644 |
|
| 1645 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CancelBuild") |
| 1646 |
if err != nil { |
| 1647 |
return err |
| 1648 |
} |
| 1649 |
|
| 1650 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1651 |
return err |
| 1652 |
} |
| 1653 |
|
| 1654 |
return nil |
| 1655 |
}, opts...) |
| 1656 |
if e != nil { |
| 1657 |
return nil, e |
| 1658 |
} |
| 1659 |
return resp, nil |
| 1660 |
} |
| 1661 |
|
| 1662 |
// RetryBuild creates a new build based on the specified build. |
| 1663 |
// |
| 1664 |
// This method creates a new build using the original build request, which may |
| 1665 |
// or may not result in an identical build. |
| 1666 |
// |
| 1667 |
// For triggered builds: |
| 1668 |
// |
| 1669 |
// Triggered builds resolve to a precise revision; therefore a retry of a |
| 1670 |
// triggered build will result in a build that uses the same revision. |
| 1671 |
// |
| 1672 |
// For non-triggered builds that specify RepoSource: |
| 1673 |
// |
| 1674 |
// If the original build built from the tip of a branch, the retried build |
| 1675 |
// will build from the tip of that branch, which may not be the same revision |
| 1676 |
// as the original build. |
| 1677 |
// |
| 1678 |
// If the original build specified a commit sha or revision ID, the retried |
| 1679 |
// build will use the identical source. |
| 1680 |
// |
| 1681 |
// For builds that specify StorageSource: |
| 1682 |
// |
| 1683 |
// If the original build pulled source from Cloud Storage without |
| 1684 |
// specifying the generation of the object, the new build will use the current |
| 1685 |
// object, which may be different from the original build source. |
| 1686 |
// |
| 1687 |
// If the original build pulled source from Cloud Storage and specified the |
| 1688 |
// generation of the object, the new build will attempt to use the same |
| 1689 |
// object, which may or may not be available depending on the bucket’s |
| 1690 |
// lifecycle management settings. |
| 1691 |
func (c *restClient) RetryBuild(ctx context.Context, req *cloudbuildpb.RetryBuildRequest, opts ...gax.CallOption) (*RetryBuildOperation, error) { |
| 1692 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 1693 |
jsonReq, err := m.Marshal(req) |
| 1694 |
if err != nil { |
| 1695 |
return nil, err |
| 1696 |
} |
| 1697 |
|
| 1698 |
baseUrl, err := url.Parse(c.endpoint) |
| 1699 |
if err != nil { |
| 1700 |
return nil, err |
| 1701 |
} |
| 1702 |
baseUrl.Path += fmt.Sprintf("/v1/projects/%v/builds/%v:retry", req.GetProjectId(), req.GetId()) |
| 1703 |
|
| 1704 |
params := url.Values{} |
| 1705 |
params.Add("$alt", "json;enum-encoding=int") |
| 1706 |
|
| 1707 |
baseUrl.RawQuery = params.Encode() |
| 1708 |
|
| 1709 |
// Build HTTP headers from client and context metadata. |
| 1710 |
routingHeaders := "" |
| 1711 |
routingHeadersMap := make(map[string]string) |
| 1712 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/builds/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 1713 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 1714 |
} |
| 1715 |
for headerName, headerValue := range routingHeadersMap { |
| 1716 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1717 |
} |
| 1718 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1719 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1720 |
|
| 1721 |
hds = append(c.xGoogHeaders, hds...) |
| 1722 |
hds = append(hds, "Content-Type", "application/json") |
| 1723 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1724 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1725 |
resp := &longrunningpb.Operation{} |
| 1726 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1727 |
if settings.Path != "" { |
| 1728 |
baseUrl.Path = settings.Path |
| 1729 |
} |
| 1730 |
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 1731 |
if err != nil { |
| 1732 |
return err |
| 1733 |
} |
| 1734 |
httpReq = httpReq.WithContext(ctx) |
| 1735 |
httpReq.Header = headers |
| 1736 |
|
| 1737 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RetryBuild") |
| 1738 |
if err != nil { |
| 1739 |
return err |
| 1740 |
} |
| 1741 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1742 |
return err |
| 1743 |
} |
| 1744 |
|
| 1745 |
return nil |
| 1746 |
}, opts...) |
| 1747 |
if e != nil { |
| 1748 |
return nil, e |
| 1749 |
} |
| 1750 |
|
| 1751 |
override := fmt.Sprintf("/v1/%s", resp.GetName()) |
| 1752 |
return &RetryBuildOperation{ |
| 1753 |
lro: longrunning.InternalNewOperation(*c.LROClient, resp), |
| 1754 |
pollPath: override, |
| 1755 |
}, nil |
| 1756 |
} |
| 1757 |
|
| 1758 |
// ApproveBuild approves or rejects a pending build. |
| 1759 |
// |
| 1760 |
// If approved, the returned LRO will be analogous to the LRO returned from |
| 1761 |
// a CreateBuild call. |
| 1762 |
// |
| 1763 |
// If rejected, the returned LRO will be immediately done. |
| 1764 |
func (c *restClient) ApproveBuild(ctx context.Context, req *cloudbuildpb.ApproveBuildRequest, opts ...gax.CallOption) (*ApproveBuildOperation, error) { |
| 1765 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 1766 |
jsonReq, err := m.Marshal(req) |
| 1767 |
if err != nil { |
| 1768 |
return nil, err |
| 1769 |
} |
| 1770 |
|
| 1771 |
baseUrl, err := url.Parse(c.endpoint) |
| 1772 |
if err != nil { |
| 1773 |
return nil, err |
| 1774 |
} |
| 1775 |
baseUrl.Path += fmt.Sprintf("/v1/%v:approve", req.GetName()) |
| 1776 |
|
| 1777 |
params := url.Values{} |
| 1778 |
params.Add("$alt", "json;enum-encoding=int") |
| 1779 |
|
| 1780 |
baseUrl.RawQuery = params.Encode() |
| 1781 |
|
| 1782 |
// Build HTTP headers from client and context metadata. |
| 1783 |
routingHeaders := "" |
| 1784 |
routingHeadersMap := make(map[string]string) |
| 1785 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/builds/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 1786 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 1787 |
} |
| 1788 |
for headerName, headerValue := range routingHeadersMap { |
| 1789 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1790 |
} |
| 1791 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1792 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1793 |
|
| 1794 |
hds = append(c.xGoogHeaders, hds...) |
| 1795 |
hds = append(hds, "Content-Type", "application/json") |
| 1796 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1797 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1798 |
resp := &longrunningpb.Operation{} |
| 1799 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1800 |
if settings.Path != "" { |
| 1801 |
baseUrl.Path = settings.Path |
| 1802 |
} |
| 1803 |
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 1804 |
if err != nil { |
| 1805 |
return err |
| 1806 |
} |
| 1807 |
httpReq = httpReq.WithContext(ctx) |
| 1808 |
httpReq.Header = headers |
| 1809 |
|
| 1810 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ApproveBuild") |
| 1811 |
if err != nil { |
| 1812 |
return err |
| 1813 |
} |
| 1814 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1815 |
return err |
| 1816 |
} |
| 1817 |
|
| 1818 |
return nil |
| 1819 |
}, opts...) |
| 1820 |
if e != nil { |
| 1821 |
return nil, e |
| 1822 |
} |
| 1823 |
|
| 1824 |
override := fmt.Sprintf("/v1/%s", resp.GetName()) |
| 1825 |
return &ApproveBuildOperation{ |
| 1826 |
lro: longrunning.InternalNewOperation(*c.LROClient, resp), |
| 1827 |
pollPath: override, |
| 1828 |
}, nil |
| 1829 |
} |
| 1830 |
|
| 1831 |
// CreateBuildTrigger creates a new BuildTrigger. |
| 1832 |
// |
| 1833 |
// This API is experimental. |
| 1834 |
func (c *restClient) CreateBuildTrigger(ctx context.Context, req *cloudbuildpb.CreateBuildTriggerRequest, opts ...gax.CallOption) (*cloudbuildpb.BuildTrigger, error) { |
| 1835 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 1836 |
body := req.GetTrigger() |
| 1837 |
jsonReq, err := m.Marshal(body) |
| 1838 |
if err != nil { |
| 1839 |
return nil, err |
| 1840 |
} |
| 1841 |
|
| 1842 |
baseUrl, err := url.Parse(c.endpoint) |
| 1843 |
if err != nil { |
| 1844 |
return nil, err |
| 1845 |
} |
| 1846 |
baseUrl.Path += fmt.Sprintf("/v1/projects/%v/triggers", req.GetProjectId()) |
| 1847 |
|
| 1848 |
params := url.Values{} |
| 1849 |
params.Add("$alt", "json;enum-encoding=int") |
| 1850 |
if req.GetParent() != "" { |
| 1851 |
params.Add("parent", fmt.Sprintf("%v", req.GetParent())) |
| 1852 |
} |
| 1853 |
|
| 1854 |
baseUrl.RawQuery = params.Encode() |
| 1855 |
|
| 1856 |
// Build HTTP headers from client and context metadata. |
| 1857 |
routingHeaders := "" |
| 1858 |
routingHeadersMap := make(map[string]string) |
| 1859 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)"); reg.MatchString(req.GetParent()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1])) > 0 { |
| 1860 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1]) |
| 1861 |
} |
| 1862 |
for headerName, headerValue := range routingHeadersMap { |
| 1863 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1864 |
} |
| 1865 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1866 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1867 |
|
| 1868 |
hds = append(c.xGoogHeaders, hds...) |
| 1869 |
hds = append(hds, "Content-Type", "application/json") |
| 1870 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1871 |
opts = append((*c.CallOptions).CreateBuildTrigger[0:len((*c.CallOptions).CreateBuildTrigger):len((*c.CallOptions).CreateBuildTrigger)], opts...) |
| 1872 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1873 |
resp := &cloudbuildpb.BuildTrigger{} |
| 1874 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1875 |
if settings.Path != "" { |
| 1876 |
baseUrl.Path = settings.Path |
| 1877 |
} |
| 1878 |
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 1879 |
if err != nil { |
| 1880 |
return err |
| 1881 |
} |
| 1882 |
httpReq = httpReq.WithContext(ctx) |
| 1883 |
httpReq.Header = headers |
| 1884 |
|
| 1885 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateBuildTrigger") |
| 1886 |
if err != nil { |
| 1887 |
return err |
| 1888 |
} |
| 1889 |
|
| 1890 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1891 |
return err |
| 1892 |
} |
| 1893 |
|
| 1894 |
return nil |
| 1895 |
}, opts...) |
| 1896 |
if e != nil { |
| 1897 |
return nil, e |
| 1898 |
} |
| 1899 |
return resp, nil |
| 1900 |
} |
| 1901 |
|
| 1902 |
// GetBuildTrigger returns information about a BuildTrigger. |
| 1903 |
// |
| 1904 |
// This API is experimental. |
| 1905 |
func (c *restClient) GetBuildTrigger(ctx context.Context, req *cloudbuildpb.GetBuildTriggerRequest, opts ...gax.CallOption) (*cloudbuildpb.BuildTrigger, error) { |
| 1906 |
baseUrl, err := url.Parse(c.endpoint) |
| 1907 |
if err != nil { |
| 1908 |
return nil, err |
| 1909 |
} |
| 1910 |
baseUrl.Path += fmt.Sprintf("/v1/projects/%v/triggers/%v", req.GetProjectId(), req.GetTriggerId()) |
| 1911 |
|
| 1912 |
params := url.Values{} |
| 1913 |
params.Add("$alt", "json;enum-encoding=int") |
| 1914 |
if req.GetName() != "" { |
| 1915 |
params.Add("name", fmt.Sprintf("%v", req.GetName())) |
| 1916 |
} |
| 1917 |
|
| 1918 |
baseUrl.RawQuery = params.Encode() |
| 1919 |
|
| 1920 |
// Build HTTP headers from client and context metadata. |
| 1921 |
routingHeaders := "" |
| 1922 |
routingHeadersMap := make(map[string]string) |
| 1923 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/triggers/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 1924 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 1925 |
} |
| 1926 |
for headerName, headerValue := range routingHeadersMap { |
| 1927 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 1928 |
} |
| 1929 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 1930 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 1931 |
|
| 1932 |
hds = append(c.xGoogHeaders, hds...) |
| 1933 |
hds = append(hds, "Content-Type", "application/json") |
| 1934 |
headers := gax.BuildHeaders(ctx, hds...) |
| 1935 |
opts = append((*c.CallOptions).GetBuildTrigger[0:len((*c.CallOptions).GetBuildTrigger):len((*c.CallOptions).GetBuildTrigger)], opts...) |
| 1936 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1937 |
resp := &cloudbuildpb.BuildTrigger{} |
| 1938 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 1939 |
if settings.Path != "" { |
| 1940 |
baseUrl.Path = settings.Path |
| 1941 |
} |
| 1942 |
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| 1943 |
if err != nil { |
| 1944 |
return err |
| 1945 |
} |
| 1946 |
httpReq = httpReq.WithContext(ctx) |
| 1947 |
httpReq.Header = headers |
| 1948 |
|
| 1949 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetBuildTrigger") |
| 1950 |
if err != nil { |
| 1951 |
return err |
| 1952 |
} |
| 1953 |
|
| 1954 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 1955 |
return err |
| 1956 |
} |
| 1957 |
|
| 1958 |
return nil |
| 1959 |
}, opts...) |
| 1960 |
if e != nil { |
| 1961 |
return nil, e |
| 1962 |
} |
| 1963 |
return resp, nil |
| 1964 |
} |
| 1965 |
|
| 1966 |
// ListBuildTriggers lists existing BuildTriggers. |
| 1967 |
// |
| 1968 |
// This API is experimental. |
| 1969 |
func (c *restClient) ListBuildTriggers(ctx context.Context, req *cloudbuildpb.ListBuildTriggersRequest, opts ...gax.CallOption) *BuildTriggerIterator { |
| 1970 |
it := &BuildTriggerIterator{} |
| 1971 |
req = proto.Clone(req).(*cloudbuildpb.ListBuildTriggersRequest) |
| 1972 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 1973 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*cloudbuildpb.BuildTrigger, string, error) { |
| 1974 |
resp := &cloudbuildpb.ListBuildTriggersResponse{} |
| 1975 |
if pageToken != "" { |
| 1976 |
req.PageToken = pageToken |
| 1977 |
} |
| 1978 |
if pageSize > math.MaxInt32 { |
| 1979 |
req.PageSize = math.MaxInt32 |
| 1980 |
} else if pageSize != 0 { |
| 1981 |
req.PageSize = int32(pageSize) |
| 1982 |
} |
| 1983 |
baseUrl, err := url.Parse(c.endpoint) |
| 1984 |
if err != nil { |
| 1985 |
return nil, "", err |
| 1986 |
} |
| 1987 |
baseUrl.Path += fmt.Sprintf("/v1/projects/%v/triggers", req.GetProjectId()) |
| 1988 |
|
| 1989 |
params := url.Values{} |
| 1990 |
params.Add("$alt", "json;enum-encoding=int") |
| 1991 |
if req.GetPageSize() != 0 { |
| 1992 |
params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) |
| 1993 |
} |
| 1994 |
if req.GetPageToken() != "" { |
| 1995 |
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) |
| 1996 |
} |
| 1997 |
if req.GetParent() != "" { |
| 1998 |
params.Add("parent", fmt.Sprintf("%v", req.GetParent())) |
| 1999 |
} |
| 2000 |
|
| 2001 |
baseUrl.RawQuery = params.Encode() |
| 2002 |
|
| 2003 |
// Build HTTP headers from client and context metadata. |
| 2004 |
hds := append(c.xGoogHeaders, "Content-Type", "application/json") |
| 2005 |
headers := gax.BuildHeaders(ctx, hds...) |
| 2006 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 2007 |
if settings.Path != "" { |
| 2008 |
baseUrl.Path = settings.Path |
| 2009 |
} |
| 2010 |
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| 2011 |
if err != nil { |
| 2012 |
return err |
| 2013 |
} |
| 2014 |
httpReq.Header = headers |
| 2015 |
|
| 2016 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListBuildTriggers") |
| 2017 |
if err != nil { |
| 2018 |
return err |
| 2019 |
} |
| 2020 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 2021 |
return err |
| 2022 |
} |
| 2023 |
|
| 2024 |
return nil |
| 2025 |
}, opts...) |
| 2026 |
if e != nil { |
| 2027 |
return nil, "", e |
| 2028 |
} |
| 2029 |
it.Response = resp |
| 2030 |
return resp.GetTriggers(), resp.GetNextPageToken(), nil |
| 2031 |
} |
| 2032 |
|
| 2033 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 2034 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 2035 |
if err != nil { |
| 2036 |
return "", err |
| 2037 |
} |
| 2038 |
it.items = append(it.items, items...) |
| 2039 |
return nextPageToken, nil |
| 2040 |
} |
| 2041 |
|
| 2042 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 2043 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 2044 |
it.pageInfo.Token = req.GetPageToken() |
| 2045 |
|
| 2046 |
return it |
| 2047 |
} |
| 2048 |
|
| 2049 |
// DeleteBuildTrigger deletes a BuildTrigger by its project ID and trigger ID. |
| 2050 |
// |
| 2051 |
// This API is experimental. |
| 2052 |
func (c *restClient) DeleteBuildTrigger(ctx context.Context, req *cloudbuildpb.DeleteBuildTriggerRequest, opts ...gax.CallOption) error { |
| 2053 |
baseUrl, err := url.Parse(c.endpoint) |
| 2054 |
if err != nil { |
| 2055 |
return err |
| 2056 |
} |
| 2057 |
baseUrl.Path += fmt.Sprintf("/v1/projects/%v/triggers/%v", req.GetProjectId(), req.GetTriggerId()) |
| 2058 |
|
| 2059 |
params := url.Values{} |
| 2060 |
params.Add("$alt", "json;enum-encoding=int") |
| 2061 |
if req.GetName() != "" { |
| 2062 |
params.Add("name", fmt.Sprintf("%v", req.GetName())) |
| 2063 |
} |
| 2064 |
|
| 2065 |
baseUrl.RawQuery = params.Encode() |
| 2066 |
|
| 2067 |
// Build HTTP headers from client and context metadata. |
| 2068 |
routingHeaders := "" |
| 2069 |
routingHeadersMap := make(map[string]string) |
| 2070 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/triggers/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 2071 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 2072 |
} |
| 2073 |
for headerName, headerValue := range routingHeadersMap { |
| 2074 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 2075 |
} |
| 2076 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 2077 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 2078 |
|
| 2079 |
hds = append(c.xGoogHeaders, hds...) |
| 2080 |
hds = append(hds, "Content-Type", "application/json") |
| 2081 |
headers := gax.BuildHeaders(ctx, hds...) |
| 2082 |
return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 2083 |
if settings.Path != "" { |
| 2084 |
baseUrl.Path = settings.Path |
| 2085 |
} |
| 2086 |
httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) |
| 2087 |
if err != nil { |
| 2088 |
return err |
| 2089 |
} |
| 2090 |
httpReq = httpReq.WithContext(ctx) |
| 2091 |
httpReq.Header = headers |
| 2092 |
|
| 2093 |
_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteBuildTrigger") |
| 2094 |
return err |
| 2095 |
}, opts...) |
| 2096 |
} |
| 2097 |
|
| 2098 |
// UpdateBuildTrigger updates a BuildTrigger by its project ID and trigger ID. |
| 2099 |
// |
| 2100 |
// This API is experimental. |
| 2101 |
func (c *restClient) UpdateBuildTrigger(ctx context.Context, req *cloudbuildpb.UpdateBuildTriggerRequest, opts ...gax.CallOption) (*cloudbuildpb.BuildTrigger, error) { |
| 2102 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 2103 |
body := req.GetTrigger() |
| 2104 |
jsonReq, err := m.Marshal(body) |
| 2105 |
if err != nil { |
| 2106 |
return nil, err |
| 2107 |
} |
| 2108 |
|
| 2109 |
baseUrl, err := url.Parse(c.endpoint) |
| 2110 |
if err != nil { |
| 2111 |
return nil, err |
| 2112 |
} |
| 2113 |
baseUrl.Path += fmt.Sprintf("/v1/projects/%v/triggers/%v", req.GetProjectId(), req.GetTriggerId()) |
| 2114 |
|
| 2115 |
params := url.Values{} |
| 2116 |
params.Add("$alt", "json;enum-encoding=int") |
| 2117 |
if req.GetUpdateMask() != nil { |
| 2118 |
field, err := protojson.Marshal(req.GetUpdateMask()) |
| 2119 |
if err != nil { |
| 2120 |
return nil, err |
| 2121 |
} |
| 2122 |
params.Add("updateMask", string(field[1:len(field)-1])) |
| 2123 |
} |
| 2124 |
|
| 2125 |
baseUrl.RawQuery = params.Encode() |
| 2126 |
|
| 2127 |
// Build HTTP headers from client and context metadata. |
| 2128 |
routingHeaders := "" |
| 2129 |
routingHeadersMap := make(map[string]string) |
| 2130 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/triggers/[^/]+"); reg.MatchString(req.GetTrigger().GetResourceName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetTrigger().GetResourceName())[1])) > 0 { |
| 2131 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetTrigger().GetResourceName())[1]) |
| 2132 |
} |
| 2133 |
for headerName, headerValue := range routingHeadersMap { |
| 2134 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 2135 |
} |
| 2136 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 2137 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 2138 |
|
| 2139 |
hds = append(c.xGoogHeaders, hds...) |
| 2140 |
hds = append(hds, "Content-Type", "application/json") |
| 2141 |
headers := gax.BuildHeaders(ctx, hds...) |
| 2142 |
opts = append((*c.CallOptions).UpdateBuildTrigger[0:len((*c.CallOptions).UpdateBuildTrigger):len((*c.CallOptions).UpdateBuildTrigger)], opts...) |
| 2143 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 2144 |
resp := &cloudbuildpb.BuildTrigger{} |
| 2145 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 2146 |
if settings.Path != "" { |
| 2147 |
baseUrl.Path = settings.Path |
| 2148 |
} |
| 2149 |
httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 2150 |
if err != nil { |
| 2151 |
return err |
| 2152 |
} |
| 2153 |
httpReq = httpReq.WithContext(ctx) |
| 2154 |
httpReq.Header = headers |
| 2155 |
|
| 2156 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateBuildTrigger") |
| 2157 |
if err != nil { |
| 2158 |
return err |
| 2159 |
} |
| 2160 |
|
| 2161 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 2162 |
return err |
| 2163 |
} |
| 2164 |
|
| 2165 |
return nil |
| 2166 |
}, opts...) |
| 2167 |
if e != nil { |
| 2168 |
return nil, e |
| 2169 |
} |
| 2170 |
return resp, nil |
| 2171 |
} |
| 2172 |
|
| 2173 |
// RunBuildTrigger runs a BuildTrigger at a particular source revision. |
| 2174 |
// |
| 2175 |
// To run a regional or global trigger, use the POST request |
| 2176 |
// that includes the location endpoint in the path (ex. |
| 2177 |
// v1/projects/{projectId}/locations/{region}/triggers/{triggerId}:run). The |
| 2178 |
// POST request that does not include the location endpoint in the path can |
| 2179 |
// only be used when running global triggers. |
| 2180 |
func (c *restClient) RunBuildTrigger(ctx context.Context, req *cloudbuildpb.RunBuildTriggerRequest, opts ...gax.CallOption) (*RunBuildTriggerOperation, error) { |
| 2181 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 2182 |
body := req.GetSource() |
| 2183 |
jsonReq, err := m.Marshal(body) |
| 2184 |
if err != nil { |
| 2185 |
return nil, err |
| 2186 |
} |
| 2187 |
|
| 2188 |
baseUrl, err := url.Parse(c.endpoint) |
| 2189 |
if err != nil { |
| 2190 |
return nil, err |
| 2191 |
} |
| 2192 |
baseUrl.Path += fmt.Sprintf("/v1/projects/%v/triggers/%v:run", req.GetProjectId(), req.GetTriggerId()) |
| 2193 |
|
| 2194 |
params := url.Values{} |
| 2195 |
params.Add("$alt", "json;enum-encoding=int") |
| 2196 |
if req.GetName() != "" { |
| 2197 |
params.Add("name", fmt.Sprintf("%v", req.GetName())) |
| 2198 |
} |
| 2199 |
|
| 2200 |
baseUrl.RawQuery = params.Encode() |
| 2201 |
|
| 2202 |
// Build HTTP headers from client and context metadata. |
| 2203 |
routingHeaders := "" |
| 2204 |
routingHeadersMap := make(map[string]string) |
| 2205 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/triggers/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 2206 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 2207 |
} |
| 2208 |
for headerName, headerValue := range routingHeadersMap { |
| 2209 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 2210 |
} |
| 2211 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 2212 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 2213 |
|
| 2214 |
hds = append(c.xGoogHeaders, hds...) |
| 2215 |
hds = append(hds, "Content-Type", "application/json") |
| 2216 |
headers := gax.BuildHeaders(ctx, hds...) |
| 2217 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 2218 |
resp := &longrunningpb.Operation{} |
| 2219 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 2220 |
if settings.Path != "" { |
| 2221 |
baseUrl.Path = settings.Path |
| 2222 |
} |
| 2223 |
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 2224 |
if err != nil { |
| 2225 |
return err |
| 2226 |
} |
| 2227 |
httpReq = httpReq.WithContext(ctx) |
| 2228 |
httpReq.Header = headers |
| 2229 |
|
| 2230 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RunBuildTrigger") |
| 2231 |
if err != nil { |
| 2232 |
return err |
| 2233 |
} |
| 2234 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 2235 |
return err |
| 2236 |
} |
| 2237 |
|
| 2238 |
return nil |
| 2239 |
}, opts...) |
| 2240 |
if e != nil { |
| 2241 |
return nil, e |
| 2242 |
} |
| 2243 |
|
| 2244 |
override := fmt.Sprintf("/v1/%s", resp.GetName()) |
| 2245 |
return &RunBuildTriggerOperation{ |
| 2246 |
lro: longrunning.InternalNewOperation(*c.LROClient, resp), |
| 2247 |
pollPath: override, |
| 2248 |
}, nil |
| 2249 |
} |
| 2250 |
|
| 2251 |
// ReceiveTriggerWebhook receiveTriggerWebhook [Experimental] is called when the API receives a |
| 2252 |
// webhook request targeted at a specific trigger. |
| 2253 |
func (c *restClient) ReceiveTriggerWebhook(ctx context.Context, req *cloudbuildpb.ReceiveTriggerWebhookRequest, opts ...gax.CallOption) (*cloudbuildpb.ReceiveTriggerWebhookResponse, error) { |
| 2254 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 2255 |
body := req.GetBody() |
| 2256 |
jsonReq, err := m.Marshal(body) |
| 2257 |
if err != nil { |
| 2258 |
return nil, err |
| 2259 |
} |
| 2260 |
|
| 2261 |
baseUrl, err := url.Parse(c.endpoint) |
| 2262 |
if err != nil { |
| 2263 |
return nil, err |
| 2264 |
} |
| 2265 |
baseUrl.Path += fmt.Sprintf("/v1/projects/%v/triggers/%v:webhook", req.GetProjectId(), req.GetTrigger()) |
| 2266 |
|
| 2267 |
params := url.Values{} |
| 2268 |
params.Add("$alt", "json;enum-encoding=int") |
| 2269 |
if req.GetName() != "" { |
| 2270 |
params.Add("name", fmt.Sprintf("%v", req.GetName())) |
| 2271 |
} |
| 2272 |
if req.GetSecret() != "" { |
| 2273 |
params.Add("secret", fmt.Sprintf("%v", req.GetSecret())) |
| 2274 |
} |
| 2275 |
|
| 2276 |
baseUrl.RawQuery = params.Encode() |
| 2277 |
|
| 2278 |
// Build HTTP headers from client and context metadata. |
| 2279 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "trigger", url.QueryEscape(req.GetTrigger()), "name", url.QueryEscape(req.GetName()))} |
| 2280 |
|
| 2281 |
hds = append(c.xGoogHeaders, hds...) |
| 2282 |
hds = append(hds, "Content-Type", "application/json") |
| 2283 |
headers := gax.BuildHeaders(ctx, hds...) |
| 2284 |
opts = append((*c.CallOptions).ReceiveTriggerWebhook[0:len((*c.CallOptions).ReceiveTriggerWebhook):len((*c.CallOptions).ReceiveTriggerWebhook)], opts...) |
| 2285 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 2286 |
resp := &cloudbuildpb.ReceiveTriggerWebhookResponse{} |
| 2287 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 2288 |
if settings.Path != "" { |
| 2289 |
baseUrl.Path = settings.Path |
| 2290 |
} |
| 2291 |
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 2292 |
if err != nil { |
| 2293 |
return err |
| 2294 |
} |
| 2295 |
httpReq = httpReq.WithContext(ctx) |
| 2296 |
httpReq.Header = headers |
| 2297 |
|
| 2298 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ReceiveTriggerWebhook") |
| 2299 |
if err != nil { |
| 2300 |
return err |
| 2301 |
} |
| 2302 |
|
| 2303 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 2304 |
return err |
| 2305 |
} |
| 2306 |
|
| 2307 |
return nil |
| 2308 |
}, opts...) |
| 2309 |
if e != nil { |
| 2310 |
return nil, e |
| 2311 |
} |
| 2312 |
return resp, nil |
| 2313 |
} |
| 2314 |
|
| 2315 |
// CreateWorkerPool creates a WorkerPool. |
| 2316 |
func (c *restClient) CreateWorkerPool(ctx context.Context, req *cloudbuildpb.CreateWorkerPoolRequest, opts ...gax.CallOption) (*CreateWorkerPoolOperation, error) { |
| 2317 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 2318 |
body := req.GetWorkerPool() |
| 2319 |
jsonReq, err := m.Marshal(body) |
| 2320 |
if err != nil { |
| 2321 |
return nil, err |
| 2322 |
} |
| 2323 |
|
| 2324 |
baseUrl, err := url.Parse(c.endpoint) |
| 2325 |
if err != nil { |
| 2326 |
return nil, err |
| 2327 |
} |
| 2328 |
baseUrl.Path += fmt.Sprintf("/v1/%v/workerPools", req.GetParent()) |
| 2329 |
|
| 2330 |
params := url.Values{} |
| 2331 |
params.Add("$alt", "json;enum-encoding=int") |
| 2332 |
if req.GetValidateOnly() { |
| 2333 |
params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly())) |
| 2334 |
} |
| 2335 |
params.Add("workerPoolId", fmt.Sprintf("%v", req.GetWorkerPoolId())) |
| 2336 |
|
| 2337 |
baseUrl.RawQuery = params.Encode() |
| 2338 |
|
| 2339 |
// Build HTTP headers from client and context metadata. |
| 2340 |
routingHeaders := "" |
| 2341 |
routingHeadersMap := make(map[string]string) |
| 2342 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)"); reg.MatchString(req.GetParent()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1])) > 0 { |
| 2343 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1]) |
| 2344 |
} |
| 2345 |
for headerName, headerValue := range routingHeadersMap { |
| 2346 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 2347 |
} |
| 2348 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 2349 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 2350 |
|
| 2351 |
hds = append(c.xGoogHeaders, hds...) |
| 2352 |
hds = append(hds, "Content-Type", "application/json") |
| 2353 |
headers := gax.BuildHeaders(ctx, hds...) |
| 2354 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 2355 |
resp := &longrunningpb.Operation{} |
| 2356 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 2357 |
if settings.Path != "" { |
| 2358 |
baseUrl.Path = settings.Path |
| 2359 |
} |
| 2360 |
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 2361 |
if err != nil { |
| 2362 |
return err |
| 2363 |
} |
| 2364 |
httpReq = httpReq.WithContext(ctx) |
| 2365 |
httpReq.Header = headers |
| 2366 |
|
| 2367 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateWorkerPool") |
| 2368 |
if err != nil { |
| 2369 |
return err |
| 2370 |
} |
| 2371 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 2372 |
return err |
| 2373 |
} |
| 2374 |
|
| 2375 |
return nil |
| 2376 |
}, opts...) |
| 2377 |
if e != nil { |
| 2378 |
return nil, e |
| 2379 |
} |
| 2380 |
|
| 2381 |
override := fmt.Sprintf("/v1/%s", resp.GetName()) |
| 2382 |
return &CreateWorkerPoolOperation{ |
| 2383 |
lro: longrunning.InternalNewOperation(*c.LROClient, resp), |
| 2384 |
pollPath: override, |
| 2385 |
}, nil |
| 2386 |
} |
| 2387 |
|
| 2388 |
// GetWorkerPool returns details of a WorkerPool. |
| 2389 |
func (c *restClient) GetWorkerPool(ctx context.Context, req *cloudbuildpb.GetWorkerPoolRequest, opts ...gax.CallOption) (*cloudbuildpb.WorkerPool, error) { |
| 2390 |
baseUrl, err := url.Parse(c.endpoint) |
| 2391 |
if err != nil { |
| 2392 |
return nil, err |
| 2393 |
} |
| 2394 |
baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName()) |
| 2395 |
|
| 2396 |
params := url.Values{} |
| 2397 |
params.Add("$alt", "json;enum-encoding=int") |
| 2398 |
|
| 2399 |
baseUrl.RawQuery = params.Encode() |
| 2400 |
|
| 2401 |
// Build HTTP headers from client and context metadata. |
| 2402 |
routingHeaders := "" |
| 2403 |
routingHeadersMap := make(map[string]string) |
| 2404 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/workerPools/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 2405 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 2406 |
} |
| 2407 |
for headerName, headerValue := range routingHeadersMap { |
| 2408 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 2409 |
} |
| 2410 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 2411 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 2412 |
|
| 2413 |
hds = append(c.xGoogHeaders, hds...) |
| 2414 |
hds = append(hds, "Content-Type", "application/json") |
| 2415 |
headers := gax.BuildHeaders(ctx, hds...) |
| 2416 |
opts = append((*c.CallOptions).GetWorkerPool[0:len((*c.CallOptions).GetWorkerPool):len((*c.CallOptions).GetWorkerPool)], opts...) |
| 2417 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 2418 |
resp := &cloudbuildpb.WorkerPool{} |
| 2419 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 2420 |
if settings.Path != "" { |
| 2421 |
baseUrl.Path = settings.Path |
| 2422 |
} |
| 2423 |
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| 2424 |
if err != nil { |
| 2425 |
return err |
| 2426 |
} |
| 2427 |
httpReq = httpReq.WithContext(ctx) |
| 2428 |
httpReq.Header = headers |
| 2429 |
|
| 2430 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetWorkerPool") |
| 2431 |
if err != nil { |
| 2432 |
return err |
| 2433 |
} |
| 2434 |
|
| 2435 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 2436 |
return err |
| 2437 |
} |
| 2438 |
|
| 2439 |
return nil |
| 2440 |
}, opts...) |
| 2441 |
if e != nil { |
| 2442 |
return nil, e |
| 2443 |
} |
| 2444 |
return resp, nil |
| 2445 |
} |
| 2446 |
|
| 2447 |
// DeleteWorkerPool deletes a WorkerPool. |
| 2448 |
func (c *restClient) DeleteWorkerPool(ctx context.Context, req *cloudbuildpb.DeleteWorkerPoolRequest, opts ...gax.CallOption) (*DeleteWorkerPoolOperation, error) { |
| 2449 |
baseUrl, err := url.Parse(c.endpoint) |
| 2450 |
if err != nil { |
| 2451 |
return nil, err |
| 2452 |
} |
| 2453 |
baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName()) |
| 2454 |
|
| 2455 |
params := url.Values{} |
| 2456 |
params.Add("$alt", "json;enum-encoding=int") |
| 2457 |
if req.GetAllowMissing() { |
| 2458 |
params.Add("allowMissing", fmt.Sprintf("%v", req.GetAllowMissing())) |
| 2459 |
} |
| 2460 |
if req.GetEtag() != "" { |
| 2461 |
params.Add("etag", fmt.Sprintf("%v", req.GetEtag())) |
| 2462 |
} |
| 2463 |
if req.GetValidateOnly() { |
| 2464 |
params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly())) |
| 2465 |
} |
| 2466 |
|
| 2467 |
baseUrl.RawQuery = params.Encode() |
| 2468 |
|
| 2469 |
// Build HTTP headers from client and context metadata. |
| 2470 |
routingHeaders := "" |
| 2471 |
routingHeadersMap := make(map[string]string) |
| 2472 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/workerPools/[^/]+"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { |
| 2473 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1]) |
| 2474 |
} |
| 2475 |
for headerName, headerValue := range routingHeadersMap { |
| 2476 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 2477 |
} |
| 2478 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 2479 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 2480 |
|
| 2481 |
hds = append(c.xGoogHeaders, hds...) |
| 2482 |
hds = append(hds, "Content-Type", "application/json") |
| 2483 |
headers := gax.BuildHeaders(ctx, hds...) |
| 2484 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 2485 |
resp := &longrunningpb.Operation{} |
| 2486 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 2487 |
if settings.Path != "" { |
| 2488 |
baseUrl.Path = settings.Path |
| 2489 |
} |
| 2490 |
httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) |
| 2491 |
if err != nil { |
| 2492 |
return err |
| 2493 |
} |
| 2494 |
httpReq = httpReq.WithContext(ctx) |
| 2495 |
httpReq.Header = headers |
| 2496 |
|
| 2497 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteWorkerPool") |
| 2498 |
if err != nil { |
| 2499 |
return err |
| 2500 |
} |
| 2501 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 2502 |
return err |
| 2503 |
} |
| 2504 |
|
| 2505 |
return nil |
| 2506 |
}, opts...) |
| 2507 |
if e != nil { |
| 2508 |
return nil, e |
| 2509 |
} |
| 2510 |
|
| 2511 |
override := fmt.Sprintf("/v1/%s", resp.GetName()) |
| 2512 |
return &DeleteWorkerPoolOperation{ |
| 2513 |
lro: longrunning.InternalNewOperation(*c.LROClient, resp), |
| 2514 |
pollPath: override, |
| 2515 |
}, nil |
| 2516 |
} |
| 2517 |
|
| 2518 |
// UpdateWorkerPool updates a WorkerPool. |
| 2519 |
func (c *restClient) UpdateWorkerPool(ctx context.Context, req *cloudbuildpb.UpdateWorkerPoolRequest, opts ...gax.CallOption) (*UpdateWorkerPoolOperation, error) { |
| 2520 |
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| 2521 |
body := req.GetWorkerPool() |
| 2522 |
jsonReq, err := m.Marshal(body) |
| 2523 |
if err != nil { |
| 2524 |
return nil, err |
| 2525 |
} |
| 2526 |
|
| 2527 |
baseUrl, err := url.Parse(c.endpoint) |
| 2528 |
if err != nil { |
| 2529 |
return nil, err |
| 2530 |
} |
| 2531 |
baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetWorkerPool().GetName()) |
| 2532 |
|
| 2533 |
params := url.Values{} |
| 2534 |
params.Add("$alt", "json;enum-encoding=int") |
| 2535 |
if req.GetUpdateMask() != nil { |
| 2536 |
field, err := protojson.Marshal(req.GetUpdateMask()) |
| 2537 |
if err != nil { |
| 2538 |
return nil, err |
| 2539 |
} |
| 2540 |
params.Add("updateMask", string(field[1:len(field)-1])) |
| 2541 |
} |
| 2542 |
if req.GetValidateOnly() { |
| 2543 |
params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly())) |
| 2544 |
} |
| 2545 |
|
| 2546 |
baseUrl.RawQuery = params.Encode() |
| 2547 |
|
| 2548 |
// Build HTTP headers from client and context metadata. |
| 2549 |
routingHeaders := "" |
| 2550 |
routingHeadersMap := make(map[string]string) |
| 2551 |
if reg := regexp.MustCompile("projects/[^/]+/locations/(?P<location>[^/]+)/workerPools/[^/]+"); reg.MatchString(req.GetWorkerPool().GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetWorkerPool().GetName())[1])) > 0 { |
| 2552 |
routingHeadersMap["location"] = url.QueryEscape(reg.FindStringSubmatch(req.GetWorkerPool().GetName())[1]) |
| 2553 |
} |
| 2554 |
for headerName, headerValue := range routingHeadersMap { |
| 2555 |
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) |
| 2556 |
} |
| 2557 |
routingHeaders = strings.TrimSuffix(routingHeaders, "&") |
| 2558 |
hds := []string{"x-goog-request-params", routingHeaders} |
| 2559 |
|
| 2560 |
hds = append(c.xGoogHeaders, hds...) |
| 2561 |
hds = append(hds, "Content-Type", "application/json") |
| 2562 |
headers := gax.BuildHeaders(ctx, hds...) |
| 2563 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 2564 |
resp := &longrunningpb.Operation{} |
| 2565 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 2566 |
if settings.Path != "" { |
| 2567 |
baseUrl.Path = settings.Path |
| 2568 |
} |
| 2569 |
httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) |
| 2570 |
if err != nil { |
| 2571 |
return err |
| 2572 |
} |
| 2573 |
httpReq = httpReq.WithContext(ctx) |
| 2574 |
httpReq.Header = headers |
| 2575 |
|
| 2576 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateWorkerPool") |
| 2577 |
if err != nil { |
| 2578 |
return err |
| 2579 |
} |
| 2580 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 2581 |
return err |
| 2582 |
} |
| 2583 |
|
| 2584 |
return nil |
| 2585 |
}, opts...) |
| 2586 |
if e != nil { |
| 2587 |
return nil, e |
| 2588 |
} |
| 2589 |
|
| 2590 |
override := fmt.Sprintf("/v1/%s", resp.GetName()) |
| 2591 |
return &UpdateWorkerPoolOperation{ |
| 2592 |
lro: longrunning.InternalNewOperation(*c.LROClient, resp), |
| 2593 |
pollPath: override, |
| 2594 |
}, nil |
| 2595 |
} |
| 2596 |
|
| 2597 |
// ListWorkerPools lists WorkerPools. |
| 2598 |
func (c *restClient) ListWorkerPools(ctx context.Context, req *cloudbuildpb.ListWorkerPoolsRequest, opts ...gax.CallOption) *WorkerPoolIterator { |
| 2599 |
it := &WorkerPoolIterator{} |
| 2600 |
req = proto.Clone(req).(*cloudbuildpb.ListWorkerPoolsRequest) |
| 2601 |
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| 2602 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*cloudbuildpb.WorkerPool, string, error) { |
| 2603 |
resp := &cloudbuildpb.ListWorkerPoolsResponse{} |
| 2604 |
if pageToken != "" { |
| 2605 |
req.PageToken = pageToken |
| 2606 |
} |
| 2607 |
if pageSize > math.MaxInt32 { |
| 2608 |
req.PageSize = math.MaxInt32 |
| 2609 |
} else if pageSize != 0 { |
| 2610 |
req.PageSize = int32(pageSize) |
| 2611 |
} |
| 2612 |
baseUrl, err := url.Parse(c.endpoint) |
| 2613 |
if err != nil { |
| 2614 |
return nil, "", err |
| 2615 |
} |
| 2616 |
baseUrl.Path += fmt.Sprintf("/v1/%v/workerPools", req.GetParent()) |
| 2617 |
|
| 2618 |
params := url.Values{} |
| 2619 |
params.Add("$alt", "json;enum-encoding=int") |
| 2620 |
if req.GetPageSize() != 0 { |
| 2621 |
params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) |
| 2622 |
} |
| 2623 |
if req.GetPageToken() != "" { |
| 2624 |
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) |
| 2625 |
} |
| 2626 |
|
| 2627 |
baseUrl.RawQuery = params.Encode() |
| 2628 |
|
| 2629 |
// Build HTTP headers from client and context metadata. |
| 2630 |
hds := append(c.xGoogHeaders, "Content-Type", "application/json") |
| 2631 |
headers := gax.BuildHeaders(ctx, hds...) |
| 2632 |
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 2633 |
if settings.Path != "" { |
| 2634 |
baseUrl.Path = settings.Path |
| 2635 |
} |
| 2636 |
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| 2637 |
if err != nil { |
| 2638 |
return err |
| 2639 |
} |
| 2640 |
httpReq.Header = headers |
| 2641 |
|
| 2642 |
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListWorkerPools") |
| 2643 |
if err != nil { |
| 2644 |
return err |
| 2645 |
} |
| 2646 |
if err := unm.Unmarshal(buf, resp); err != nil { |
| 2647 |
return err |
| 2648 |
} |
| 2649 |
|
| 2650 |
return nil |
| 2651 |
}, opts...) |
| 2652 |
if e != nil { |
| 2653 |
return nil, "", e |
| 2654 |
} |
| 2655 |
it.Response = resp |
| 2656 |
return resp.GetWorkerPools(), resp.GetNextPageToken(), nil |
| 2657 |
} |
| 2658 |
|
| 2659 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 2660 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 2661 |
if err != nil { |
| 2662 |
return "", err |
| 2663 |
} |
| 2664 |
it.items = append(it.items, items...) |
| 2665 |
return nextPageToken, nil |
| 2666 |
} |
| 2667 |
|
| 2668 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 2669 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 2670 |
it.pageInfo.Token = req.GetPageToken() |
| 2671 |
|
| 2672 |
return it |
| 2673 |
} |
| 2674 |
|
| 2675 |
// ApproveBuildOperation returns a new ApproveBuildOperation from a given name. |
| 2676 |
// The name must be that of a previously created ApproveBuildOperation, possibly from a different process. |
| 2677 |
func (c *gRPCClient) ApproveBuildOperation(name string) *ApproveBuildOperation { |
| 2678 |
return &ApproveBuildOperation{ |
| 2679 |
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), |
| 2680 |
} |
| 2681 |
} |
| 2682 |
|
| 2683 |
// ApproveBuildOperation returns a new ApproveBuildOperation from a given name. |
| 2684 |
// The name must be that of a previously created ApproveBuildOperation, possibly from a different process. |
| 2685 |
func (c *restClient) ApproveBuildOperation(name string) *ApproveBuildOperation { |
| 2686 |
override := fmt.Sprintf("/v1/%s", name) |
| 2687 |
return &ApproveBuildOperation{ |
| 2688 |
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), |
| 2689 |
pollPath: override, |
| 2690 |
} |
| 2691 |
} |
| 2692 |
|
| 2693 |
// CreateBuildOperation returns a new CreateBuildOperation from a given name. |
| 2694 |
// The name must be that of a previously created CreateBuildOperation, possibly from a different process. |
| 2695 |
func (c *gRPCClient) CreateBuildOperation(name string) *CreateBuildOperation { |
| 2696 |
return &CreateBuildOperation{ |
| 2697 |
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), |
| 2698 |
} |
| 2699 |
} |
| 2700 |
|
| 2701 |
// CreateBuildOperation returns a new CreateBuildOperation from a given name. |
| 2702 |
// The name must be that of a previously created CreateBuildOperation, possibly from a different process. |
| 2703 |
func (c *restClient) CreateBuildOperation(name string) *CreateBuildOperation { |
| 2704 |
override := fmt.Sprintf("/v1/%s", name) |
| 2705 |
return &CreateBuildOperation{ |
| 2706 |
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), |
| 2707 |
pollPath: override, |
| 2708 |
} |
| 2709 |
} |
| 2710 |
|
| 2711 |
// CreateWorkerPoolOperation returns a new CreateWorkerPoolOperation from a given name. |
| 2712 |
// The name must be that of a previously created CreateWorkerPoolOperation, possibly from a different process. |
| 2713 |
func (c *gRPCClient) CreateWorkerPoolOperation(name string) *CreateWorkerPoolOperation { |
| 2714 |
return &CreateWorkerPoolOperation{ |
| 2715 |
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), |
| 2716 |
} |
| 2717 |
} |
| 2718 |
|
| 2719 |
// CreateWorkerPoolOperation returns a new CreateWorkerPoolOperation from a given name. |
| 2720 |
// The name must be that of a previously created CreateWorkerPoolOperation, possibly from a different process. |
| 2721 |
func (c *restClient) CreateWorkerPoolOperation(name string) *CreateWorkerPoolOperation { |
| 2722 |
override := fmt.Sprintf("/v1/%s", name) |
| 2723 |
return &CreateWorkerPoolOperation{ |
| 2724 |
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), |
| 2725 |
pollPath: override, |
| 2726 |
} |
| 2727 |
} |
| 2728 |
|
| 2729 |
// DeleteWorkerPoolOperation returns a new DeleteWorkerPoolOperation from a given name. |
| 2730 |
// The name must be that of a previously created DeleteWorkerPoolOperation, possibly from a different process. |
| 2731 |
func (c *gRPCClient) DeleteWorkerPoolOperation(name string) *DeleteWorkerPoolOperation { |
| 2732 |
return &DeleteWorkerPoolOperation{ |
| 2733 |
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), |
| 2734 |
} |
| 2735 |
} |
| 2736 |
|
| 2737 |
// DeleteWorkerPoolOperation returns a new DeleteWorkerPoolOperation from a given name. |
| 2738 |
// The name must be that of a previously created DeleteWorkerPoolOperation, possibly from a different process. |
| 2739 |
func (c *restClient) DeleteWorkerPoolOperation(name string) *DeleteWorkerPoolOperation { |
| 2740 |
override := fmt.Sprintf("/v1/%s", name) |
| 2741 |
return &DeleteWorkerPoolOperation{ |
| 2742 |
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), |
| 2743 |
pollPath: override, |
| 2744 |
} |
| 2745 |
} |
| 2746 |
|
| 2747 |
// RetryBuildOperation returns a new RetryBuildOperation from a given name. |
| 2748 |
// The name must be that of a previously created RetryBuildOperation, possibly from a different process. |
| 2749 |
func (c *gRPCClient) RetryBuildOperation(name string) *RetryBuildOperation { |
| 2750 |
return &RetryBuildOperation{ |
| 2751 |
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), |
| 2752 |
} |
| 2753 |
} |
| 2754 |
|
| 2755 |
// RetryBuildOperation returns a new RetryBuildOperation from a given name. |
| 2756 |
// The name must be that of a previously created RetryBuildOperation, possibly from a different process. |
| 2757 |
func (c *restClient) RetryBuildOperation(name string) *RetryBuildOperation { |
| 2758 |
override := fmt.Sprintf("/v1/%s", name) |
| 2759 |
return &RetryBuildOperation{ |
| 2760 |
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), |
| 2761 |
pollPath: override, |
| 2762 |
} |
| 2763 |
} |
| 2764 |
|
| 2765 |
// RunBuildTriggerOperation returns a new RunBuildTriggerOperation from a given name. |
| 2766 |
// The name must be that of a previously created RunBuildTriggerOperation, possibly from a different process. |
| 2767 |
func (c *gRPCClient) RunBuildTriggerOperation(name string) *RunBuildTriggerOperation { |
| 2768 |
return &RunBuildTriggerOperation{ |
| 2769 |
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), |
| 2770 |
} |
| 2771 |
} |
| 2772 |
|
| 2773 |
// RunBuildTriggerOperation returns a new RunBuildTriggerOperation from a given name. |
| 2774 |
// The name must be that of a previously created RunBuildTriggerOperation, possibly from a different process. |
| 2775 |
func (c *restClient) RunBuildTriggerOperation(name string) *RunBuildTriggerOperation { |
| 2776 |
override := fmt.Sprintf("/v1/%s", name) |
| 2777 |
return &RunBuildTriggerOperation{ |
| 2778 |
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), |
| 2779 |
pollPath: override, |
| 2780 |
} |
| 2781 |
} |
| 2782 |
|
| 2783 |
// UpdateWorkerPoolOperation returns a new UpdateWorkerPoolOperation from a given name. |
| 2784 |
// The name must be that of a previously created UpdateWorkerPoolOperation, possibly from a different process. |
| 2785 |
func (c *gRPCClient) UpdateWorkerPoolOperation(name string) *UpdateWorkerPoolOperation { |
| 2786 |
return &UpdateWorkerPoolOperation{ |
| 2787 |
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), |
| 2788 |
} |
| 2789 |
} |
| 2790 |
|
| 2791 |
// UpdateWorkerPoolOperation returns a new UpdateWorkerPoolOperation from a given name. |
| 2792 |
// The name must be that of a previously created UpdateWorkerPoolOperation, possibly from a different process. |
| 2793 |
func (c *restClient) UpdateWorkerPoolOperation(name string) *UpdateWorkerPoolOperation { |
| 2794 |
override := fmt.Sprintf("/v1/%s", name) |
| 2795 |
return &UpdateWorkerPoolOperation{ |
| 2796 |
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), |
| 2797 |
pollPath: override, |
| 2798 |
} |
| 2799 |
} |