go.mod: update osbuild/images to v0.156.0

tag v0.155.0
Tagger: imagebuilder-bot <imagebuilder-bots+imagebuilder-bot@redhat.com>

Changes with 0.155.0

----------------
  * Fedora 43: add shadow-utils when LockRoot is enabled, update cloud-init service name (osbuild/images#1618)
    * Author: Achilleas Koutsou, Reviewers: Gianluca Zuccarelli, Michael Vogt
  * Update osbuild dependency commit ID to latest (osbuild/images#1609)
    * Author: SchutzBot, Reviewers: Achilleas Koutsou, Simon de Vlieger, Tomáš Hozza
  * Update snapshots to 20250626 (osbuild/images#1623)
    * Author: SchutzBot, Reviewers: Achilleas Koutsou, Simon de Vlieger
  * distro/rhel9: xz compress azure-cvm image type [HMS-8587] (osbuild/images#1620)
    * Author: Achilleas Koutsou, Reviewers: Simon de Vlieger, Tomáš Hozza
  * distro/rhel: introduce new image type: Azure SAP Apps [HMS-8738] (osbuild/images#1612)
    * Author: Achilleas Koutsou, Reviewers: Simon de Vlieger, Tomáš Hozza
  * distro/rhel: move ansible-core to sap_extras_pkgset (osbuild/images#1624)
    * Author: Achilleas Koutsou, Reviewers: Brian C. Lane, Tomáš Hozza
  * github/create-tag: allow passing the version when run manually (osbuild/images#1621)
    * Author: Achilleas Koutsou, Reviewers: Lukáš Zapletal, Tomáš Hozza
  * rhel9: move image-config into pure YAML (HMS-8593) (osbuild/images#1616)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Simon de Vlieger
  * test: split manifest checksums into separate files (osbuild/images#1625)
    * Author: Achilleas Koutsou, Reviewers: Simon de Vlieger, Tomáš Hozza

— Somewhere on the Internet, 2025-06-30

---

tag v0.156.0
Tagger: imagebuilder-bot <imagebuilder-bots+imagebuilder-bot@redhat.com>

Changes with 0.156.0

----------------
  * Many: delete repositories for EOL distributions (HMS-7044) (osbuild/images#1607)
    * Author: Tomáš Hozza, Reviewers: Michael Vogt, Simon de Vlieger
  * RHSM/facts: add 'image-builder CLI' API type (osbuild/images#1640)
    * Author: Tomáš Hozza, Reviewers: Brian C. Lane, Simon de Vlieger
  * Update dependencies 2025-06-29 (osbuild/images#1628)
    * Author: SchutzBot, Reviewers: Simon de Vlieger, Tomáš Hozza
  * Update osbuild dependency commit ID to latest (osbuild/images#1627)
    * Author: SchutzBot, Reviewers: Simon de Vlieger, Tomáš Hozza
  * [RFC] image: drop `InstallWeakDeps` from image.DiskImage (osbuild/images#1642)
    * Author: Michael Vogt, Reviewers: Brian C. Lane, Simon de Vlieger, Tomáš Hozza
  * build(deps): bump the go-deps group across 1 directory with 3 updates (osbuild/images#1632)
    * Author: dependabot[bot], Reviewers: SchutzBot, Tomáš Hozza
  * distro/rhel10: xz compress azure-cvm image type (osbuild/images#1638)
    * Author: Achilleas Koutsou, Reviewers: Brian C. Lane, Simon de Vlieger
  * distro: cleanup/refactor distro/{defs,generic} (HMS-8744) (osbuild/images#1570)
    * Author: Michael Vogt, Reviewers: Simon de Vlieger, Tomáš Hozza
  * distro: remove some hardcoded values from generic/images.go (osbuild/images#1636)
    * Author: Michael Vogt, Reviewers: Simon de Vlieger, Tomáš Hozza
  * distro: small tweaks for the YAML based imagetypes (osbuild/images#1622)
    * Author: Michael Vogt, Reviewers: Brian C. Lane, Simon de Vlieger
  * fedora/wsl: packages and locale (osbuild/images#1635)
    * Author: Simon de Vlieger, Reviewers: Michael Vogt, Tomáš Hozza
  * image/many: make compression more generic (osbuild/images#1634)
    * Author: Simon de Vlieger, Reviewers: Brian C. Lane, Michael Vogt
  * manifest: handle content template name with spaces (osbuild/images#1641)
    * Author: Bryttanie, Reviewers: Brian C. Lane, Michael Vogt, Tomáš Hozza
  * many: implement gzip (osbuild/images#1633)
    * Author: Simon de Vlieger, Reviewers: Michael Vogt, Tomáš Hozza
  * rhel/azure: set GRUB_TERMINAL based on architecture [RHEL-91383] (osbuild/images#1626)
    * Author: Achilleas Koutsou, Reviewers: Simon de Vlieger, Tomáš Hozza

— Somewhere on the Internet, 2025-07-07

---
This commit is contained in:
Achilleas Koutsou 2025-07-10 16:14:25 +02:00
parent 60c5f10af8
commit 3fd7092db5
1486 changed files with 124742 additions and 82516 deletions

View file

@ -1,2 +1,2 @@
7.0.1
7.3.2
# Keep this pinned version in parity with cel-go

View file

@ -8,26 +8,38 @@ bazel_dep(
)
bazel_dep(
name = "gazelle",
version = "0.36.0",
version = "0.39.1",
repo_name = "bazel_gazelle",
)
bazel_dep(
name = "googleapis",
version = "0.0.0-20240819-fe8ba054a",
version = "0.0.0-20241220-5e258e33.bcr.1",
repo_name = "com_google_googleapis",
)
bazel_dep(
name = "googleapis-cc",
version = "1.0.0",
)
bazel_dep(
name = "googleapis-java",
version = "1.0.0",
)
bazel_dep(
name = "googleapis-go",
version = "1.0.0",
)
bazel_dep(
name = "protobuf",
version = "26.0",
version = "27.0",
repo_name = "com_google_protobuf",
)
bazel_dep(
name = "rules_cc",
version = "0.0.9",
version = "0.0.17",
)
bazel_dep(
name = "rules_go",
version = "0.49.0",
version = "0.53.0",
repo_name = "io_bazel_rules_go",
)
bazel_dep(
@ -36,7 +48,7 @@ bazel_dep(
)
bazel_dep(
name = "rules_proto",
version = "6.0.0",
version = "7.0.2",
)
bazel_dep(
name = "rules_python",
@ -50,16 +62,8 @@ python.toolchain(
python_version = "3.11",
)
switched_rules = use_extension("@com_google_googleapis//:extensions.bzl", "switched_rules")
switched_rules.use_languages(
cc = True,
go = True,
java = True,
)
use_repo(switched_rules, "com_google_googleapis_imports")
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.21.1")
go_sdk.download(version = "1.22.0")
go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")

View file

@ -69,5 +69,3 @@ For more detail, see:
* [Language Definition](doc/langdef.md)
Released under the [Apache License](LICENSE).
Disclaimer: This is not an official Google product.

View file

@ -1,5 +1,5 @@
steps:
- name: 'gcr.io/cloud-builders/bazel:7.0.1'
- name: 'gcr.io/cloud-builders/bazel:7.3.2'
entrypoint: bazel
args: ['build', '...']
id: bazel-build

View file

@ -1,5 +1,41 @@
# Changelog
## [0.16.2](https://github.com/googleapis/google-cloud-go/compare/auth/v0.16.1...auth/v0.16.2) (2025-06-04)
### Bug Fixes
* **auth:** Add back DirectPath misconfiguration logging ([#11162](https://github.com/googleapis/google-cloud-go/issues/11162)) ([8d52da5](https://github.com/googleapis/google-cloud-go/commit/8d52da58da5a0ed77a0f6307d1b561bc045406a1))
* **auth:** Remove s2a fallback option ([#12354](https://github.com/googleapis/google-cloud-go/issues/12354)) ([d5acc59](https://github.com/googleapis/google-cloud-go/commit/d5acc599cd775ddc404349e75906fa02e8ff133e))
## [0.16.1](https://github.com/googleapis/google-cloud-go/compare/auth/v0.16.0...auth/v0.16.1) (2025-04-23)
### Bug Fixes
* **auth:** Clone detectopts before assigning TokenBindingType ([#11881](https://github.com/googleapis/google-cloud-go/issues/11881)) ([2167b02](https://github.com/googleapis/google-cloud-go/commit/2167b020fdc43b517c2b6ecca264a10e357ea035))
## [0.16.0](https://github.com/googleapis/google-cloud-go/compare/auth/v0.15.0...auth/v0.16.0) (2025-04-14)
### Features
* **auth/credentials:** Return X.509 certificate chain as subject token ([#11948](https://github.com/googleapis/google-cloud-go/issues/11948)) ([d445a3f](https://github.com/googleapis/google-cloud-go/commit/d445a3f66272ffd5c39c4939af9bebad4582631c)), refs [#11757](https://github.com/googleapis/google-cloud-go/issues/11757)
* **auth:** Configure DirectPath bound credentials from AllowedHardBoundTokens ([#11665](https://github.com/googleapis/google-cloud-go/issues/11665)) ([0fc40bc](https://github.com/googleapis/google-cloud-go/commit/0fc40bcf4e4673704df0973e9fa65957395d7bb4))
### Bug Fixes
* **auth:** Allow non-default SA credentials for DP ([#11828](https://github.com/googleapis/google-cloud-go/issues/11828)) ([3a996b4](https://github.com/googleapis/google-cloud-go/commit/3a996b4129e6d0a34dfda6671f535d5aefb26a82))
* **auth:** Restore calling DialContext ([#11930](https://github.com/googleapis/google-cloud-go/issues/11930)) ([9ec9a29](https://github.com/googleapis/google-cloud-go/commit/9ec9a29494e93197edbaf45aba28984801e9770a)), refs [#11118](https://github.com/googleapis/google-cloud-go/issues/11118)
## [0.15.0](https://github.com/googleapis/google-cloud-go/compare/auth/v0.14.1...auth/v0.15.0) (2025-02-19)
### Features
* **auth:** Add hard-bound token request to compute token provider. ([#11588](https://github.com/googleapis/google-cloud-go/issues/11588)) ([0e608bb](https://github.com/googleapis/google-cloud-go/commit/0e608bb5ac3d694c8ad36ca4340071d3a2c78699))
## [0.14.1](https://github.com/googleapis/google-cloud-go/compare/auth/v0.14.0...auth/v0.14.1) (2025-01-24)

View file

@ -39,8 +39,9 @@ var (
// uses the metadata service to retrieve tokens.
func computeTokenProvider(opts *DetectOptions, client *metadata.Client) auth.TokenProvider {
return auth.NewCachedTokenProvider(&computeProvider{
scopes: opts.Scopes,
client: client,
scopes: opts.Scopes,
client: client,
tokenBindingType: opts.TokenBindingType,
}, &auth.CachedTokenProviderOptions{
ExpireEarly: opts.EarlyTokenRefresh,
DisableAsyncRefresh: opts.DisableAsyncRefresh,
@ -49,8 +50,9 @@ func computeTokenProvider(opts *DetectOptions, client *metadata.Client) auth.Tok
// computeProvider fetches tokens from the google cloud metadata service.
type computeProvider struct {
scopes []string
client *metadata.Client
scopes []string
client *metadata.Client
tokenBindingType TokenBindingType
}
type metadataTokenResp struct {
@ -64,9 +66,19 @@ func (cs *computeProvider) Token(ctx context.Context) (*auth.Token, error) {
if err != nil {
return nil, err
}
if len(cs.scopes) > 0 {
hasScopes := len(cs.scopes) > 0
if hasScopes || cs.tokenBindingType != NoBinding {
v := url.Values{}
v.Set("scopes", strings.Join(cs.scopes, ","))
if hasScopes {
v.Set("scopes", strings.Join(cs.scopes, ","))
}
switch cs.tokenBindingType {
case MTLSHardBinding:
v.Set("transport", "mtls")
v.Set("binding-enforcement", "on")
case ALTSHardBinding:
v.Set("transport", "alts")
}
tokenURI.RawQuery = v.Encode()
}
tokenJSON, err := cs.client.GetWithContext(ctx, tokenURI.String())

View file

@ -51,6 +51,23 @@ var (
allowOnGCECheck = true
)
// TokenBindingType specifies the type of binding used when requesting a token
// whether to request a hard-bound token using mTLS or an instance identity
// bound token using ALTS.
type TokenBindingType int
const (
// NoBinding specifies that requested tokens are not required to have a
// binding. This is the default option.
NoBinding TokenBindingType = iota
// MTLSHardBinding specifies that a hard-bound token should be requested
// using an mTLS with S2A channel.
MTLSHardBinding
// ALTSHardBinding specifies that an instance identity bound token should
// be requested using an ALTS channel.
ALTSHardBinding
)
// OnGCE reports whether this process is running in Google Cloud.
func OnGCE() bool {
// TODO(codyoss): once all libs use this auth lib move metadata check here
@ -121,6 +138,10 @@ type DetectOptions struct {
// https://www.googleapis.com/auth/cloud-platform. Required if Audience is
// not provided.
Scopes []string
// TokenBindingType specifies the type of binding used when requesting a
// token whether to request a hard-bound token using mTLS or an instance
// identity bound token using ALTS. Optional.
TokenBindingType TokenBindingType
// Audience that credentials tokens should have. Only applicable for 2LO
// flows with service accounts. If specified, scopes should not be provided.
Audience string

View file

@ -413,7 +413,10 @@ func newSubjectTokenProvider(o *Options) (subjectTokenProvider, error) {
if cert.UseDefaultCertificateConfig && cert.CertificateConfigLocation != "" {
return nil, errors.New("credentials: \"certificate\" object cannot specify both a certificate_config_location and use_default_certificate_config=true")
}
return &x509Provider{}, nil
return &x509Provider{
TrustChainPath: o.CredentialSource.Certificate.TrustChainPath,
ConfigFilePath: o.CredentialSource.Certificate.CertificateConfigLocation,
}, nil
}
return nil, errors.New("credentials: unable to parse credential source")
}

View file

@ -17,27 +17,184 @@ package externalaccount
import (
"context"
"crypto/tls"
"crypto/x509"
"encoding/base64"
"encoding/json"
"encoding/pem"
"errors"
"fmt"
"io/fs"
"net/http"
"os"
"strings"
"time"
"cloud.google.com/go/auth/internal/transport/cert"
)
// x509Provider implements the subjectTokenProvider type for
// x509 workload identity credentials. Because x509 credentials
// rely on an mTLS connection to represent the 3rd party identity
// rather than a subject token, this provider will always return
// an empty string when a subject token is requested by the external account
// token provider.
// x509Provider implements the subjectTokenProvider type for x509 workload
// identity credentials. This provider retrieves and formats a JSON array
// containing the leaf certificate and trust chain (if provided) as
// base64-encoded strings. This JSON array serves as the subject token for
// mTLS authentication.
type x509Provider struct {
// TrustChainPath is the path to the file containing the trust chain certificates.
// The file should contain one or more PEM-encoded certificates.
TrustChainPath string
// ConfigFilePath is the path to the configuration file containing the path
// to the leaf certificate file.
ConfigFilePath string
}
const pemCertificateHeader = "-----BEGIN CERTIFICATE-----"
func (xp *x509Provider) providerType() string {
return x509ProviderType
}
func (xp *x509Provider) subjectToken(ctx context.Context) (string, error) {
return "", nil
// loadLeafCertificate loads and parses the leaf certificate from the specified
// configuration file. It retrieves the certificate path from the config file,
// reads the certificate file, and parses the certificate data.
func loadLeafCertificate(configFilePath string) (*x509.Certificate, error) {
// Get the path to the certificate file from the configuration file.
path, err := cert.GetCertificatePath(configFilePath)
if err != nil {
return nil, fmt.Errorf("failed to get certificate path from config file: %w", err)
}
leafCertBytes, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("failed to read leaf certificate file: %w", err)
}
// Parse the certificate bytes.
return parseCertificate(leafCertBytes)
}
// encodeCert encodes a x509.Certificate to a base64 string.
func encodeCert(cert *x509.Certificate) string {
// cert.Raw contains the raw DER-encoded certificate. Encode the raw certificate bytes to base64.
return base64.StdEncoding.EncodeToString(cert.Raw)
}
// parseCertificate parses a PEM-encoded certificate from the given byte slice.
func parseCertificate(certData []byte) (*x509.Certificate, error) {
if len(certData) == 0 {
return nil, errors.New("invalid certificate data: empty input")
}
// Decode the PEM-encoded data.
block, _ := pem.Decode(certData)
if block == nil {
return nil, errors.New("invalid PEM-encoded certificate data: no PEM block found")
}
if block.Type != "CERTIFICATE" {
return nil, fmt.Errorf("invalid PEM-encoded certificate data: expected CERTIFICATE block type, got %s", block.Type)
}
// Parse the DER-encoded certificate.
certificate, err := x509.ParseCertificate(block.Bytes)
if err != nil {
return nil, fmt.Errorf("failed to parse certificate: %w", err)
}
return certificate, nil
}
// readTrustChain reads a file of PEM-encoded X.509 certificates and returns a slice of parsed certificates.
// It splits the file content into PEM certificate blocks and parses each one.
func readTrustChain(trustChainPath string) ([]*x509.Certificate, error) {
certificateTrustChain := []*x509.Certificate{}
// If no trust chain path is provided, return an empty slice.
if trustChainPath == "" {
return certificateTrustChain, nil
}
// Read the trust chain file.
trustChainData, err := os.ReadFile(trustChainPath)
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
return nil, fmt.Errorf("trust chain file not found: %w", err)
}
return nil, fmt.Errorf("failed to read trust chain file: %w", err)
}
// Split the file content into PEM certificate blocks.
certBlocks := strings.Split(string(trustChainData), pemCertificateHeader)
// Iterate over each certificate block.
for _, certBlock := range certBlocks {
// Trim whitespace from the block.
certBlock = strings.TrimSpace(certBlock)
if certBlock != "" {
// Add the PEM header to the block.
certData := pemCertificateHeader + "\n" + certBlock
// Parse the certificate data.
cert, err := parseCertificate([]byte(certData))
if err != nil {
return nil, fmt.Errorf("error parsing certificate from trust chain file: %w", err)
}
// Append the certificate to the trust chain.
certificateTrustChain = append(certificateTrustChain, cert)
}
}
return certificateTrustChain, nil
}
// subjectToken retrieves the X.509 subject token. It loads the leaf
// certificate and, if a trust chain path is configured, the trust chain
// certificates. It then constructs a JSON array containing the base64-encoded
// leaf certificate and each base64-encoded certificate in the trust chain.
// The leaf certificate must be at the top of the trust chain file. This JSON
// array is used as the subject token for mTLS authentication.
func (xp *x509Provider) subjectToken(context.Context) (string, error) {
// Load the leaf certificate.
leafCert, err := loadLeafCertificate(xp.ConfigFilePath)
if err != nil {
return "", fmt.Errorf("failed to load leaf certificate: %w", err)
}
// Read the trust chain.
trustChain, err := readTrustChain(xp.TrustChainPath)
if err != nil {
return "", fmt.Errorf("failed to read trust chain: %w", err)
}
// Initialize the certificate chain with the leaf certificate.
certChain := []string{encodeCert(leafCert)}
// If there is a trust chain, add certificates to the certificate chain.
if len(trustChain) > 0 {
firstCert := encodeCert(trustChain[0])
// If the first certificate in the trust chain is not the same as the leaf certificate, add it to the chain.
if firstCert != certChain[0] {
certChain = append(certChain, firstCert)
}
// Iterate over the remaining certificates in the trust chain.
for i := 1; i < len(trustChain); i++ {
encoded := encodeCert(trustChain[i])
// Return an error if the current certificate is the same as the leaf certificate.
if encoded == certChain[0] {
return "", errors.New("the leaf certificate must be at the top of the trust chain file")
}
// Add the current certificate to the chain.
certChain = append(certChain, encoded)
}
}
// Convert the certificate chain to a JSON array of base64-encoded strings.
jsonChain, err := json.Marshal(certChain)
if err != nil {
return "", fmt.Errorf("failed to format certificate data: %w", err)
}
// Return the JSON-formatted certificate chain.
return string(jsonChain), nil
}
// createX509Client creates a new client that is configured with mTLS, using the

View file

@ -20,13 +20,18 @@ import (
"os"
"strconv"
"strings"
"time"
"cloud.google.com/go/auth"
"cloud.google.com/go/auth/credentials"
"cloud.google.com/go/auth/internal/compute"
"golang.org/x/time/rate"
"google.golang.org/grpc"
grpcgoogle "google.golang.org/grpc/credentials/google"
)
var logRateLimiter = rate.Sometimes{Interval: 1 * time.Second}
func isDirectPathEnabled(endpoint string, opts *Options) bool {
if opts.InternalOptions != nil && !opts.InternalOptions.EnableDirectPath {
return false
@ -55,7 +60,7 @@ func checkDirectPathEndPoint(endpoint string) bool {
return true
}
func isTokenProviderDirectPathCompatible(tp auth.TokenProvider, o *Options) bool {
func isTokenProviderComputeEngine(tp auth.TokenProvider) bool {
if tp == nil {
return false
}
@ -69,15 +74,22 @@ func isTokenProviderDirectPathCompatible(tp auth.TokenProvider, o *Options) bool
if tok.MetadataString("auth.google.tokenSource") != "compute-metadata" {
return false
}
if o.InternalOptions != nil && o.InternalOptions.EnableNonDefaultSAForDirectPath {
return true
}
if tok.MetadataString("auth.google.serviceAccount") != "default" {
return false
}
return true
}
func isTokenProviderDirectPathCompatible(tp auth.TokenProvider, o *Options) bool {
if tp == nil {
return false
}
if o.InternalOptions != nil && o.InternalOptions.EnableNonDefaultSAForDirectPath {
return true
}
return isTokenProviderComputeEngine(tp)
}
func isDirectPathXdsUsed(o *Options) bool {
// Method 1: Enable DirectPath xDS by env;
if b, _ := strconv.ParseBool(os.Getenv(enableDirectPathXdsEnvVar)); b {
@ -90,14 +102,36 @@ func isDirectPathXdsUsed(o *Options) bool {
return false
}
func isDirectPathBoundTokenEnabled(opts *InternalOptions) bool {
for _, ev := range opts.AllowHardBoundTokens {
if ev == "ALTS" {
return true
}
}
return false
}
// configureDirectPath returns some dial options and an endpoint to use if the
// configuration allows the use of direct path. If it does not the provided
// grpcOpts and endpoint are returned.
func configureDirectPath(grpcOpts []grpc.DialOption, opts *Options, endpoint string, creds *auth.Credentials) ([]grpc.DialOption, string) {
func configureDirectPath(grpcOpts []grpc.DialOption, opts *Options, endpoint string, creds *auth.Credentials) ([]grpc.DialOption, string, error) {
logRateLimiter.Do(func() {
logDirectPathMisconfig(endpoint, creds, opts)
})
if isDirectPathEnabled(endpoint, opts) && compute.OnComputeEngine() && isTokenProviderDirectPathCompatible(creds, opts) {
// Overwrite all of the previously specific DialOptions, DirectPath uses its own set of credentials and certificates.
defaultCredetialsOptions := grpcgoogle.DefaultCredentialsOptions{PerRPCCreds: &grpcCredentialsProvider{creds: creds}}
if isDirectPathBoundTokenEnabled(opts.InternalOptions) && isTokenProviderComputeEngine(creds) {
optsClone := opts.resolveDetectOptions()
optsClone.TokenBindingType = credentials.ALTSHardBinding
altsCreds, err := credentials.DetectDefault(optsClone)
if err != nil {
return nil, "", err
}
defaultCredetialsOptions.ALTSPerRPCCreds = &grpcCredentialsProvider{creds: altsCreds}
}
grpcOpts = []grpc.DialOption{
grpc.WithCredentialsBundle(grpcgoogle.NewDefaultCredentialsWithOptions(grpcgoogle.DefaultCredentialsOptions{PerRPCCreds: &grpcCredentialsProvider{creds: creds}}))}
grpc.WithCredentialsBundle(grpcgoogle.NewDefaultCredentialsWithOptions(defaultCredetialsOptions))}
if timeoutDialerOption != nil {
grpcOpts = append(grpcOpts, timeoutDialerOption)
}
@ -122,5 +156,22 @@ func configureDirectPath(grpcOpts []grpc.DialOption, opts *Options, endpoint str
}
// TODO: add support for system parameters (quota project, request reason) via chained interceptor.
}
return grpcOpts, endpoint
return grpcOpts, endpoint, nil
}
func logDirectPathMisconfig(endpoint string, creds *auth.Credentials, o *Options) {
// Case 1: does not enable DirectPath
if !isDirectPathEnabled(endpoint, o) {
o.logger().Warn("DirectPath is disabled. To enable, please set the EnableDirectPath option along with the EnableDirectPathXds option.")
} else {
// Case 2: credential is not correctly set
if !isTokenProviderDirectPathCompatible(creds, o) {
o.logger().Warn("DirectPath is disabled. Please make sure the token source is fetched from GCE metadata server and the default service account is used.")
}
// Case 3: not running on GCE
if !compute.OnComputeEngine() {
o.logger().Warn("DirectPath is disabled. DirectPath is only available in a GCE environment.")
}
}
}

View file

@ -204,6 +204,10 @@ type InternalOptions struct {
EnableDirectPathXds bool
// EnableJWTWithScope specifies if scope can be used with self-signed JWT.
EnableJWTWithScope bool
// AllowHardBoundTokens allows libraries to request a hard-bound token.
// Obtaining hard-bound tokens requires the connection to be established
// using either ALTS or mTLS with S2A.
AllowHardBoundTokens []string
// DefaultAudience specifies a default audience to be used as the audience
// field ("aud") for the JWT token authentication.
DefaultAudience string
@ -262,13 +266,13 @@ func dial(ctx context.Context, secure bool, opts *Options) (*grpc.ClientConn, er
tOpts.EnableDirectPath = io.EnableDirectPath
tOpts.EnableDirectPathXds = io.EnableDirectPathXds
}
transportCreds, endpoint, err := transport.GetGRPCTransportCredsAndEndpoint(tOpts)
transportCreds, err := transport.GetGRPCTransportCredsAndEndpoint(tOpts)
if err != nil {
return nil, err
}
if !secure {
transportCreds = grpcinsecure.NewCredentials()
transportCreds.TransportCredentials = grpcinsecure.NewCredentials()
}
// Initialize gRPC dial options with transport-level security options.
@ -297,8 +301,21 @@ func dial(ctx context.Context, secure bool, opts *Options) (*grpc.ClientConn, er
if opts.Credentials != nil {
creds = opts.Credentials
} else {
// This condition is only met for non-DirectPath clients because
// TransportTypeMTLSS2A is used only when InternalOptions.EnableDirectPath
// is false.
optsClone := opts.resolveDetectOptions()
if transportCreds.TransportType == transport.TransportTypeMTLSS2A {
// Check that the client allows requesting hard-bound token for the transport type mTLS using S2A.
for _, ev := range opts.InternalOptions.AllowHardBoundTokens {
if ev == "MTLS_S2A" {
optsClone.TokenBindingType = credentials.MTLSHardBinding
break
}
}
}
var err error
creds, err = credentials.DetectDefault(opts.resolveDetectOptions())
creds, err = credentials.DetectDefault(optsClone)
if err != nil {
return nil, err
}
@ -324,9 +341,11 @@ func dial(ctx context.Context, secure bool, opts *Options) (*grpc.ClientConn, er
clientUniverseDomain: opts.UniverseDomain,
}),
)
// Attempt Direct Path
grpcOpts, endpoint = configureDirectPath(grpcOpts, opts, endpoint, creds)
grpcOpts, transportCreds.Endpoint, err = configureDirectPath(grpcOpts, opts, transportCreds.Endpoint, creds)
if err != nil {
return nil, err
}
}
// Add tracing, but before the other options, so that clients can override the
@ -335,7 +354,7 @@ func dial(ctx context.Context, secure bool, opts *Options) (*grpc.ClientConn, er
grpcOpts = addOpenTelemetryStatsHandler(grpcOpts, opts)
grpcOpts = append(grpcOpts, opts.GRPCDialOpts...)
return grpc.Dial(endpoint, grpcOpts...)
return grpc.DialContext(ctx, transportCreds.Endpoint, grpcOpts...)
}
// grpcKeyProvider satisfies https://pkg.go.dev/google.golang.org/grpc/credentials#PerRPCCredentials.

View file

@ -127,6 +127,7 @@ type ExecutableConfig struct {
type CertificateConfig struct {
UseDefaultCertificateConfig bool `json:"use_default_certificate_config"`
CertificateConfigLocation string `json:"certificate_config_location"`
TrustChainPath string `json:"trust_chain_path"`
}
// ServiceAccountImpersonationInfo has impersonation configuration.

View file

@ -31,7 +31,6 @@ import (
"cloud.google.com/go/auth/internal"
"cloud.google.com/go/auth/internal/transport/cert"
"github.com/google/s2a-go"
"github.com/google/s2a-go/fallback"
"google.golang.org/grpc/credentials"
)
@ -52,6 +51,16 @@ const (
mtlsMDSKey = "/run/google-mds-mtls/client.key"
)
// Type represents the type of transport used.
type Type int
const (
// TransportTypeUnknown represents an unknown transport type and is the default option.
TransportTypeUnknown Type = iota
// TransportTypeMTLSS2A represents the mTLS transport type using S2A.
TransportTypeMTLSS2A
)
// Options is a struct that is duplicated information from the individual
// transport packages in order to avoid cyclic deps. It correlates 1:1 with
// fields on httptransport.Options and grpctransport.Options.
@ -120,13 +129,20 @@ func fixScheme(baseURL string) string {
return baseURL
}
// GRPCTransportCredentials embeds interface TransportCredentials with additional data.
type GRPCTransportCredentials struct {
credentials.TransportCredentials
Endpoint string
TransportType Type
}
// GetGRPCTransportCredsAndEndpoint returns an instance of
// [google.golang.org/grpc/credentials.TransportCredentials], and the
// corresponding endpoint to use for GRPC client.
func GetGRPCTransportCredsAndEndpoint(opts *Options) (credentials.TransportCredentials, string, error) {
// corresponding endpoint and transport type to use for GRPC client.
func GetGRPCTransportCredsAndEndpoint(opts *Options) (*GRPCTransportCredentials, error) {
config, err := getTransportConfig(opts)
if err != nil {
return nil, "", err
return nil, err
}
defaultTransportCreds := credentials.NewTLS(&tls.Config{
@ -144,33 +160,24 @@ func GetGRPCTransportCredsAndEndpoint(opts *Options) (credentials.TransportCrede
if config.s2aAddress != "" {
s2aAddr = config.s2aAddress
} else {
return defaultTransportCreds, config.endpoint, nil
return &GRPCTransportCredentials{defaultTransportCreds, config.endpoint, TransportTypeUnknown}, nil
}
}
} else if config.s2aAddress != "" {
s2aAddr = config.s2aAddress
} else {
return defaultTransportCreds, config.endpoint, nil
}
var fallbackOpts *s2a.FallbackOptions
// In case of S2A failure, fall back to the endpoint that would've been used without S2A.
if fallbackHandshake, err := fallback.DefaultFallbackClientHandshakeFunc(config.endpoint); err == nil {
fallbackOpts = &s2a.FallbackOptions{
FallbackClientHandshakeFunc: fallbackHandshake,
}
return &GRPCTransportCredentials{defaultTransportCreds, config.endpoint, TransportTypeUnknown}, nil
}
s2aTransportCreds, err := s2a.NewClientCreds(&s2a.ClientOptions{
S2AAddress: s2aAddr,
TransportCreds: transportCredsForS2A,
FallbackOpts: fallbackOpts,
})
if err != nil {
// Use default if we cannot initialize S2A client transport credentials.
return defaultTransportCreds, config.endpoint, nil
return &GRPCTransportCredentials{defaultTransportCreds, config.endpoint, TransportTypeUnknown}, nil
}
return s2aTransportCreds, config.s2aMTLSEndpoint, nil
return &GRPCTransportCredentials{s2aTransportCreds, config.s2aMTLSEndpoint, TransportTypeMTLSS2A}, nil
}
// GetHTTPTransportConfig returns a client certificate source and a function for
@ -201,23 +208,9 @@ func GetHTTPTransportConfig(opts *Options) (cert.Provider, func(context.Context,
return config.clientCertSource, nil, nil
}
var fallbackOpts *s2a.FallbackOptions
// In case of S2A failure, fall back to the endpoint that would've been used without S2A.
if fallbackURL, err := url.Parse(config.endpoint); err == nil {
if fallbackDialer, fallbackServerAddr, err := fallback.DefaultFallbackDialerAndAddress(fallbackURL.Hostname()); err == nil {
fallbackOpts = &s2a.FallbackOptions{
FallbackDialer: &s2a.FallbackDialer{
Dialer: fallbackDialer,
ServerAddr: fallbackServerAddr,
},
}
}
}
dialTLSContextFunc := s2a.NewS2ADialTLSContextFunc(&s2a.ClientOptions{
S2AAddress: s2aAddr,
TransportCreds: transportCredsForS2A,
FallbackOpts: fallbackOpts,
})
return nil, dialTLSContextFunc, nil
}

View file

@ -37,6 +37,36 @@ type certificateConfig struct {
CertConfigs certConfigs `json:"cert_configs"`
}
// getconfigFilePath determines the path to the certificate configuration file.
// It first checks for the presence of an environment variable that specifies
// the file path. If the environment variable is not set, it falls back to
// a default configuration file path.
func getconfigFilePath() string {
envFilePath := util.GetConfigFilePathFromEnv()
if envFilePath != "" {
return envFilePath
}
return util.GetDefaultConfigFilePath()
}
// GetCertificatePath retrieves the certificate file path from the provided
// configuration file. If the configFilePath is empty, it attempts to load
// the configuration from a well-known gcloud location.
// This function is exposed to allow other packages, such as the
// externalaccount package, to retrieve the certificate path without needing
// to load the entire certificate configuration.
func GetCertificatePath(configFilePath string) (string, error) {
if configFilePath == "" {
configFilePath = getconfigFilePath()
}
certFile, _, err := getCertAndKeyFiles(configFilePath)
if err != nil {
return "", err
}
return certFile, nil
}
// NewWorkloadX509CertProvider creates a certificate source
// that reads a certificate and private key file from the local file system.
// This is intended to be used for workload identity federation.
@ -47,14 +77,8 @@ type certificateConfig struct {
// a well-known gcloud location.
func NewWorkloadX509CertProvider(configFilePath string) (Provider, error) {
if configFilePath == "" {
envFilePath := util.GetConfigFilePathFromEnv()
if envFilePath != "" {
configFilePath = envFilePath
} else {
configFilePath = util.GetDefaultConfigFilePath()
}
configFilePath = getconfigFilePath()
}
certFile, keyFile, err := getCertAndKeyFiles(configFilePath)
if err != nil {
return nil, err

View file

@ -37,6 +37,7 @@ func CloneDetectOptions(oldDo *credentials.DetectOptions) *credentials.DetectOpt
}
newDo := &credentials.DetectOptions{
// Simple types
TokenBindingType: oldDo.TokenBindingType,
Audience: oldDo.Audience,
Subject: oldDo.Subject,
EarlyTokenRefresh: oldDo.EarlyTokenRefresh,
@ -46,8 +47,8 @@ func CloneDetectOptions(oldDo *credentials.DetectOptions) *credentials.DetectOpt
UseSelfSignedJWT: oldDo.UseSelfSignedJWT,
UniverseDomain: oldDo.UniverseDomain,
// These fields are are pointer types that we just want to use exactly
// as the user set, copy the ref
// These fields are pointer types that we just want to use exactly as
// the user set, copy the ref
Client: oldDo.Client,
Logger: oldDo.Logger,
AuthHandlerOptions: oldDo.AuthHandlerOptions,

View file

@ -1,5 +1,12 @@
# Changelog
## [0.2.8](https://github.com/googleapis/google-cloud-go/compare/auth/oauth2adapt/v0.2.7...auth/oauth2adapt/v0.2.8) (2025-03-17)
### Bug Fixes
* **auth/oauth2adapt:** Update golang.org/x/net to 0.37.0 ([1144978](https://github.com/googleapis/google-cloud-go/commit/11449782c7fb4896bf8b8b9cde8e7441c84fb2fd))
## [0.2.7](https://github.com/googleapis/google-cloud-go/compare/auth/oauth2adapt/v0.2.6...auth/oauth2adapt/v0.2.7) (2025-01-09)

View file

@ -207,7 +207,7 @@ func defaultAcceleratorTypesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *acceleratorTypesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -257,7 +257,7 @@ func defaultAddressesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *addressesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -257,7 +257,7 @@ func defaultAutoscalersRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *autoscalersRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -468,6 +468,53 @@ func (it *BackendServicesScopedListPairIterator) takeBuf() interface{} {
return b
}
// BgpRouteIterator manages a stream of *computepb.BgpRoute.
type BgpRouteIterator struct {
items []*computepb.BgpRoute
pageInfo *iterator.PageInfo
nextFunc func() error
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.BgpRoute, nextPageToken string, err error)
}
// PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
func (it *BgpRouteIterator) PageInfo() *iterator.PageInfo {
return it.pageInfo
}
// Next returns the next result. Its second return value is iterator.Done if there are no more
// results. Once Next returns Done, all subsequent calls will return Done.
func (it *BgpRouteIterator) Next() (*computepb.BgpRoute, error) {
var item *computepb.BgpRoute
if err := it.nextFunc(); err != nil {
return item, err
}
item = it.items[0]
it.items = it.items[1:]
return item, nil
}
func (it *BgpRouteIterator) bufLen() int {
return len(it.items)
}
func (it *BgpRouteIterator) takeBuf() interface{} {
b := it.items
it.items = nil
return b
}
// CommitmentIterator manages a stream of *computepb.Commitment.
type CommitmentIterator struct {
items []*computepb.Commitment
@ -1944,6 +1991,53 @@ func (it *InstantSnapshotsScopedListPairIterator) takeBuf() interface{} {
return b
}
// InterconnectAttachmentGroupIterator manages a stream of *computepb.InterconnectAttachmentGroup.
type InterconnectAttachmentGroupIterator struct {
items []*computepb.InterconnectAttachmentGroup
pageInfo *iterator.PageInfo
nextFunc func() error
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.InterconnectAttachmentGroup, nextPageToken string, err error)
}
// PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
func (it *InterconnectAttachmentGroupIterator) PageInfo() *iterator.PageInfo {
return it.pageInfo
}
// Next returns the next result. Its second return value is iterator.Done if there are no more
// results. Once Next returns Done, all subsequent calls will return Done.
func (it *InterconnectAttachmentGroupIterator) Next() (*computepb.InterconnectAttachmentGroup, error) {
var item *computepb.InterconnectAttachmentGroup
if err := it.nextFunc(); err != nil {
return item, err
}
item = it.items[0]
it.items = it.items[1:]
return item, nil
}
func (it *InterconnectAttachmentGroupIterator) bufLen() int {
return len(it.items)
}
func (it *InterconnectAttachmentGroupIterator) takeBuf() interface{} {
b := it.items
it.items = nil
return b
}
// InterconnectAttachmentIterator manages a stream of *computepb.InterconnectAttachment.
type InterconnectAttachmentIterator struct {
items []*computepb.InterconnectAttachment
@ -2044,6 +2138,53 @@ func (it *InterconnectAttachmentsScopedListPairIterator) takeBuf() interface{} {
return b
}
// InterconnectGroupIterator manages a stream of *computepb.InterconnectGroup.
type InterconnectGroupIterator struct {
items []*computepb.InterconnectGroup
pageInfo *iterator.PageInfo
nextFunc func() error
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.InterconnectGroup, nextPageToken string, err error)
}
// PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
func (it *InterconnectGroupIterator) PageInfo() *iterator.PageInfo {
return it.pageInfo
}
// Next returns the next result. Its second return value is iterator.Done if there are no more
// results. Once Next returns Done, all subsequent calls will return Done.
func (it *InterconnectGroupIterator) Next() (*computepb.InterconnectGroup, error) {
var item *computepb.InterconnectGroup
if err := it.nextFunc(); err != nil {
return item, err
}
item = it.items[0]
it.items = it.items[1:]
return item, nil
}
func (it *InterconnectGroupIterator) bufLen() int {
return len(it.items)
}
func (it *InterconnectGroupIterator) takeBuf() interface{} {
b := it.items
it.items = nil
return b
}
// InterconnectIterator manages a stream of *computepb.Interconnect.
type InterconnectIterator struct {
items []*computepb.Interconnect
@ -3749,6 +3890,53 @@ func (it *RegionIterator) takeBuf() interface{} {
return b
}
// ReservationBlockIterator manages a stream of *computepb.ReservationBlock.
type ReservationBlockIterator struct {
items []*computepb.ReservationBlock
pageInfo *iterator.PageInfo
nextFunc func() error
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.ReservationBlock, nextPageToken string, err error)
}
// PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
func (it *ReservationBlockIterator) PageInfo() *iterator.PageInfo {
return it.pageInfo
}
// Next returns the next result. Its second return value is iterator.Done if there are no more
// results. Once Next returns Done, all subsequent calls will return Done.
func (it *ReservationBlockIterator) Next() (*computepb.ReservationBlock, error) {
var item *computepb.ReservationBlock
if err := it.nextFunc(); err != nil {
return item, err
}
item = it.items[0]
it.items = it.items[1:]
return item, nil
}
func (it *ReservationBlockIterator) bufLen() int {
return len(it.items)
}
func (it *ReservationBlockIterator) takeBuf() interface{} {
b := it.items
it.items = nil
return b
}
// ReservationIterator manages a stream of *computepb.Reservation.
type ReservationIterator struct {
items []*computepb.Reservation
@ -3796,6 +3984,53 @@ func (it *ReservationIterator) takeBuf() interface{} {
return b
}
// ReservationSubBlockIterator manages a stream of *computepb.ReservationSubBlock.
type ReservationSubBlockIterator struct {
items []*computepb.ReservationSubBlock
pageInfo *iterator.PageInfo
nextFunc func() error
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.ReservationSubBlock, nextPageToken string, err error)
}
// PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
func (it *ReservationSubBlockIterator) PageInfo() *iterator.PageInfo {
return it.pageInfo
}
// Next returns the next result. Its second return value is iterator.Done if there are no more
// results. Once Next returns Done, all subsequent calls will return Done.
func (it *ReservationSubBlockIterator) Next() (*computepb.ReservationSubBlock, error) {
var item *computepb.ReservationSubBlock
if err := it.nextFunc(); err != nil {
return item, err
}
item = it.items[0]
it.items = it.items[1:]
return item, nil
}
func (it *ReservationSubBlockIterator) bufLen() int {
return len(it.items)
}
func (it *ReservationSubBlockIterator) takeBuf() interface{} {
b := it.items
it.items = nil
return b
}
// ReservationsScopedListPair is a holder type for string/*computepb.ReservationsScopedList map entries
type ReservationsScopedListPair struct {
Key string
@ -3996,6 +4231,53 @@ func (it *RouteIterator) takeBuf() interface{} {
return b
}
// RoutePolicyIterator manages a stream of *computepb.RoutePolicy.
type RoutePolicyIterator struct {
items []*computepb.RoutePolicy
pageInfo *iterator.PageInfo
nextFunc func() error
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.RoutePolicy, nextPageToken string, err error)
}
// PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
func (it *RoutePolicyIterator) PageInfo() *iterator.PageInfo {
return it.pageInfo
}
// Next returns the next result. Its second return value is iterator.Done if there are no more
// results. Once Next returns Done, all subsequent calls will return Done.
func (it *RoutePolicyIterator) Next() (*computepb.RoutePolicy, error) {
var item *computepb.RoutePolicy
if err := it.nextFunc(); err != nil {
return item, err
}
item = it.items[0]
it.items = it.items[1:]
return item, nil
}
func (it *RoutePolicyIterator) bufLen() int {
return len(it.items)
}
func (it *RoutePolicyIterator) takeBuf() interface{} {
b := it.items
it.items = nil
return b
}
// RouterIterator manages a stream of *computepb.Router.
type RouterIterator struct {
items []*computepb.Router

View file

@ -79,6 +79,12 @@ func (it *BackendServicesScopedListPairIterator) All() iter.Seq2[BackendServices
return iterator.RangeAdapter(it.Next)
}
// All returns an iterator. If an error is returned by the iterator, the
// iterator will stop after that iteration.
func (it *BgpRouteIterator) All() iter.Seq2[*computepb.BgpRoute, error] {
return iterator.RangeAdapter(it.Next)
}
// All returns an iterator. If an error is returned by the iterator, the
// iterator will stop after that iteration.
func (it *CommitmentIterator) All() iter.Seq2[*computepb.Commitment, error] {
@ -259,6 +265,12 @@ func (it *InstantSnapshotsScopedListPairIterator) All() iter.Seq2[InstantSnapsho
return iterator.RangeAdapter(it.Next)
}
// All returns an iterator. If an error is returned by the iterator, the
// iterator will stop after that iteration.
func (it *InterconnectAttachmentGroupIterator) All() iter.Seq2[*computepb.InterconnectAttachmentGroup, error] {
return iterator.RangeAdapter(it.Next)
}
// All returns an iterator. If an error is returned by the iterator, the
// iterator will stop after that iteration.
func (it *InterconnectAttachmentIterator) All() iter.Seq2[*computepb.InterconnectAttachment, error] {
@ -271,6 +283,12 @@ func (it *InterconnectAttachmentsScopedListPairIterator) All() iter.Seq2[Interco
return iterator.RangeAdapter(it.Next)
}
// All returns an iterator. If an error is returned by the iterator, the
// iterator will stop after that iteration.
func (it *InterconnectGroupIterator) All() iter.Seq2[*computepb.InterconnectGroup, error] {
return iterator.RangeAdapter(it.Next)
}
// All returns an iterator. If an error is returned by the iterator, the
// iterator will stop after that iteration.
func (it *InterconnectIterator) All() iter.Seq2[*computepb.Interconnect, error] {
@ -481,12 +499,24 @@ func (it *RegionIterator) All() iter.Seq2[*computepb.Region, error] {
return iterator.RangeAdapter(it.Next)
}
// All returns an iterator. If an error is returned by the iterator, the
// iterator will stop after that iteration.
func (it *ReservationBlockIterator) All() iter.Seq2[*computepb.ReservationBlock, error] {
return iterator.RangeAdapter(it.Next)
}
// All returns an iterator. If an error is returned by the iterator, the
// iterator will stop after that iteration.
func (it *ReservationIterator) All() iter.Seq2[*computepb.Reservation, error] {
return iterator.RangeAdapter(it.Next)
}
// All returns an iterator. If an error is returned by the iterator, the
// iterator will stop after that iteration.
func (it *ReservationSubBlockIterator) All() iter.Seq2[*computepb.ReservationSubBlock, error] {
return iterator.RangeAdapter(it.Next)
}
// All returns an iterator. If an error is returned by the iterator, the
// iterator will stop after that iteration.
func (it *ReservationsScopedListPairIterator) All() iter.Seq2[ReservationsScopedListPair, error] {
@ -511,6 +541,12 @@ func (it *RouteIterator) All() iter.Seq2[*computepb.Route, error] {
return iterator.RangeAdapter(it.Next)
}
// All returns an iterator. If an error is returned by the iterator, the
// iterator will stop after that iteration.
func (it *RoutePolicyIterator) All() iter.Seq2[*computepb.RoutePolicy, error] {
return iterator.RangeAdapter(it.Next)
}
// All returns an iterator. If an error is returned by the iterator, the
// iterator will stop after that iteration.
func (it *RouterIterator) All() iter.Seq2[*computepb.Router, error] {

View file

@ -306,7 +306,7 @@ func defaultBackendBucketsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *backendBucketsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -365,7 +365,7 @@ func defaultBackendServicesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *backendServicesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

File diff suppressed because it is too large Load diff

View file

@ -203,7 +203,7 @@ func defaultDiskTypesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *diskTypesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -45,6 +45,7 @@ type DisksCallOptions struct {
AddResourcePolicies []gax.CallOption
AggregatedList []gax.CallOption
BulkInsert []gax.CallOption
BulkSetLabels []gax.CallOption
CreateSnapshot []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
@ -82,6 +83,9 @@ func defaultDisksRESTCallOptions() *DisksCallOptions {
BulkInsert: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
BulkSetLabels: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
CreateSnapshot: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
@ -165,6 +169,7 @@ type internalDisksClient interface {
AddResourcePolicies(context.Context, *computepb.AddResourcePoliciesDiskRequest, ...gax.CallOption) (*Operation, error)
AggregatedList(context.Context, *computepb.AggregatedListDisksRequest, ...gax.CallOption) *DisksScopedListPairIterator
BulkInsert(context.Context, *computepb.BulkInsertDiskRequest, ...gax.CallOption) (*Operation, error)
BulkSetLabels(context.Context, *computepb.BulkSetLabelsDiskRequest, ...gax.CallOption) (*Operation, error)
CreateSnapshot(context.Context, *computepb.CreateSnapshotDiskRequest, ...gax.CallOption) (*Operation, error)
Delete(context.Context, *computepb.DeleteDiskRequest, ...gax.CallOption) (*Operation, error)
Get(context.Context, *computepb.GetDiskRequest, ...gax.CallOption) (*computepb.Disk, error)
@ -232,6 +237,11 @@ func (c *DisksClient) BulkInsert(ctx context.Context, req *computepb.BulkInsertD
return c.internalClient.BulkInsert(ctx, req, opts...)
}
// BulkSetLabels sets the labels on many disks at once. To learn more about labels, read the Labeling Resources documentation.
func (c *DisksClient) BulkSetLabels(ctx context.Context, req *computepb.BulkSetLabelsDiskRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.BulkSetLabels(ctx, req, opts...)
}
// CreateSnapshot creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using snapshots.insert instead, as that method supports more features, such as creating snapshots in a project different from the source disk project.
func (c *DisksClient) CreateSnapshot(ctx context.Context, req *computepb.CreateSnapshotDiskRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.CreateSnapshot(ctx, req, opts...)
@ -376,7 +386,7 @@ func defaultDisksRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *disksRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}
@ -633,6 +643,76 @@ func (c *disksRESTClient) BulkInsert(ctx context.Context, req *computepb.BulkIns
return op, nil
}
// BulkSetLabels sets the labels on many disks at once. To learn more about labels, read the Labeling Resources documentation.
func (c *disksRESTClient) BulkSetLabels(ctx context.Context, req *computepb.BulkSetLabelsDiskRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetBulkZoneSetLabelsRequestResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/disks/bulkSetLabels", req.GetProject(), req.GetZone())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
if req != nil && req.Resource != nil {
params.Add("resource", fmt.Sprintf("%v", req.GetResource()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "zone", url.QueryEscape(req.GetZone()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).BulkSetLabels[0:len((*c.CallOptions).BulkSetLabels):len((*c.CallOptions).BulkSetLabels)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "BulkSetLabels")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
op := &Operation{
&zoneOperationsHandle{
c: c.operationClient,
proto: resp,
project: req.GetProject(),
zone: req.GetZone(),
},
}
return op, nil
}
// CreateSnapshot creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using snapshots.insert instead, as that method supports more features, such as creating snapshots in a project different from the source disk project.
func (c *disksRESTClient) CreateSnapshot(ctx context.Context, req *computepb.CreateSnapshotDiskRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}

View file

@ -237,7 +237,7 @@ func defaultExternalVpnGatewaysRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *externalVpnGatewaysRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -393,7 +393,7 @@ func defaultFirewallPoliciesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *firewallPoliciesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -237,7 +237,7 @@ func defaultFirewallsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *firewallsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -267,7 +267,7 @@ func defaultForwardingRulesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *forwardingRulesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -319,6 +319,11 @@
"BulkInsert"
]
},
"BulkSetLabels": {
"methods": [
"BulkSetLabels"
]
},
"CreateSnapshot": {
"methods": [
"CreateSnapshot"
@ -1355,6 +1360,11 @@
"RemoveResourcePolicies"
]
},
"ReportHostAsFaulty": {
"methods": [
"ReportHostAsFaulty"
]
},
"Reset": {
"methods": [
"Reset"
@ -1553,6 +1563,60 @@
}
}
},
"InterconnectAttachmentGroups": {
"clients": {
"rest": {
"libraryClient": "InterconnectAttachmentGroupsClient",
"rpcs": {
"Delete": {
"methods": [
"Delete"
]
},
"Get": {
"methods": [
"Get"
]
},
"GetIamPolicy": {
"methods": [
"GetIamPolicy"
]
},
"GetOperationalStatus": {
"methods": [
"GetOperationalStatus"
]
},
"Insert": {
"methods": [
"Insert"
]
},
"List": {
"methods": [
"List"
]
},
"Patch": {
"methods": [
"Patch"
]
},
"SetIamPolicy": {
"methods": [
"SetIamPolicy"
]
},
"TestIamPermissions": {
"methods": [
"TestIamPermissions"
]
}
}
}
}
},
"InterconnectAttachments": {
"clients": {
"rest": {
@ -1597,6 +1661,65 @@
}
}
},
"InterconnectGroups": {
"clients": {
"rest": {
"libraryClient": "InterconnectGroupsClient",
"rpcs": {
"CreateMembers": {
"methods": [
"CreateMembers"
]
},
"Delete": {
"methods": [
"Delete"
]
},
"Get": {
"methods": [
"Get"
]
},
"GetIamPolicy": {
"methods": [
"GetIamPolicy"
]
},
"GetOperationalStatus": {
"methods": [
"GetOperationalStatus"
]
},
"Insert": {
"methods": [
"Insert"
]
},
"List": {
"methods": [
"List"
]
},
"Patch": {
"methods": [
"Patch"
]
},
"SetIamPolicy": {
"methods": [
"SetIamPolicy"
]
},
"TestIamPermissions": {
"methods": [
"TestIamPermissions"
]
}
}
}
}
},
"InterconnectLocations": {
"clients": {
"rest": {
@ -1742,6 +1865,11 @@
"methods": [
"TestIamPermissions"
]
},
"Update": {
"methods": [
"Update"
]
}
}
}
@ -1782,6 +1910,11 @@
"SetIamPolicy"
]
},
"SetLabels": {
"methods": [
"SetLabels"
]
},
"TestIamPermissions": {
"methods": [
"TestIamPermissions"
@ -1967,6 +2100,11 @@
"AddAssociation"
]
},
"AddPacketMirroringRule": {
"methods": [
"AddPacketMirroringRule"
]
},
"AddRule": {
"methods": [
"AddRule"
@ -2002,6 +2140,11 @@
"GetIamPolicy"
]
},
"GetPacketMirroringRule": {
"methods": [
"GetPacketMirroringRule"
]
},
"GetRule": {
"methods": [
"GetRule"
@ -2022,6 +2165,11 @@
"Patch"
]
},
"PatchPacketMirroringRule": {
"methods": [
"PatchPacketMirroringRule"
]
},
"PatchRule": {
"methods": [
"PatchRule"
@ -2032,6 +2180,11 @@
"RemoveAssociation"
]
},
"RemovePacketMirroringRule": {
"methods": [
"RemovePacketMirroringRule"
]
},
"RemoveRule": {
"methods": [
"RemoveRule"
@ -3587,6 +3740,49 @@
}
}
},
"ReservationBlocks": {
"clients": {
"rest": {
"libraryClient": "ReservationBlocksClient",
"rpcs": {
"Get": {
"methods": [
"Get"
]
},
"List": {
"methods": [
"List"
]
},
"PerformMaintenance": {
"methods": [
"PerformMaintenance"
]
}
}
}
}
},
"ReservationSubBlocks": {
"clients": {
"rest": {
"libraryClient": "ReservationSubBlocksClient",
"rpcs": {
"Get": {
"methods": [
"Get"
]
},
"List": {
"methods": [
"List"
]
}
}
}
}
},
"Reservations": {
"clients": {
"rest": {
@ -3622,6 +3818,11 @@
"List"
]
},
"PerformMaintenance": {
"methods": [
"PerformMaintenance"
]
},
"Resize": {
"methods": [
"Resize"
@ -3715,6 +3916,11 @@
"Delete"
]
},
"DeleteRoutePolicy": {
"methods": [
"DeleteRoutePolicy"
]
},
"Get": {
"methods": [
"Get"
@ -3730,6 +3936,11 @@
"GetNatMappingInfo"
]
},
"GetRoutePolicy": {
"methods": [
"GetRoutePolicy"
]
},
"GetRouterStatus": {
"methods": [
"GetRouterStatus"
@ -3745,11 +3956,26 @@
"List"
]
},
"ListBgpRoutes": {
"methods": [
"ListBgpRoutes"
]
},
"ListRoutePolicies": {
"methods": [
"ListRoutePolicies"
]
},
"Patch": {
"methods": [
"Patch"
]
},
"PatchRoutePolicy": {
"methods": [
"PatchRoutePolicy"
]
},
"Preview": {
"methods": [
"Preview"
@ -3759,6 +3985,11 @@
"methods": [
"Update"
]
},
"UpdateRoutePolicy": {
"methods": [
"UpdateRoutePolicy"
]
}
}
}

View file

@ -237,7 +237,7 @@ func defaultGlobalAddressesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *globalAddressesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -247,7 +247,7 @@ func defaultGlobalForwardingRulesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *globalForwardingRulesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -247,7 +247,7 @@ func defaultGlobalNetworkEndpointGroupsRESTClientOptions() []option.ClientOption
// use by Google-written clients.
func (c *globalNetworkEndpointGroupsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -223,7 +223,7 @@ func defaultGlobalOperationsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *globalOperationsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -193,7 +193,7 @@ func defaultGlobalOrganizationOperationsRESTClientOptions() []option.ClientOptio
// use by Google-written clients.
func (c *globalOrganizationOperationsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -227,7 +227,7 @@ func defaultGlobalPublicDelegatedPrefixesRESTClientOptions() []option.ClientOpti
// use by Google-written clients.
func (c *globalPublicDelegatedPrefixesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -257,7 +257,7 @@ func defaultHealthChecksRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *healthChecksRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -18,6 +18,7 @@ package compute
import (
"context"
"fmt"
"io"
"log/slog"
"net/http"
@ -25,10 +26,13 @@ import (
"github.com/googleapis/gax-go/v2/internallog"
"google.golang.org/api/googleapi"
"google.golang.org/api/option"
"google.golang.org/protobuf/runtime/protoimpl"
)
const serviceName = "compute.googleapis.com"
var protoVersion = fmt.Sprintf("1.%d", protoimpl.MaxVersion)
// For more information on implementing a client constructor hook, see
// https://github.com/googleapis/google-cloud-go/wiki/Customizing-constructors.
type clientHookParams struct{}

View file

@ -161,7 +161,7 @@ func defaultImageFamilyViewsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *imageFamilyViewsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -305,7 +305,7 @@ func defaultImagesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *imagesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -227,7 +227,7 @@ func defaultInstanceGroupManagerResizeRequestsRESTClientOptions() []option.Clien
// use by Google-written clients.
func (c *instanceGroupManagerResizeRequestsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -436,7 +436,7 @@ func defaultInstanceGroupManagersRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *instanceGroupManagersRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -277,7 +277,7 @@ func defaultInstanceGroupsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *instanceGroupsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -185,7 +185,7 @@ func defaultInstanceSettingsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *instanceSettingsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -276,7 +276,7 @@ func defaultInstanceTemplatesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *instanceTemplatesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -62,6 +62,7 @@ type InstancesCallOptions struct {
ListReferrers []gax.CallOption
PerformMaintenance []gax.CallOption
RemoveResourcePolicies []gax.CallOption
ReportHostAsFaulty []gax.CallOption
Reset []gax.CallOption
Resume []gax.CallOption
SendDiagnosticInterrupt []gax.CallOption
@ -244,6 +245,9 @@ func defaultInstancesRESTCallOptions() *InstancesCallOptions {
RemoveResourcePolicies: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
ReportHostAsFaulty: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
Reset: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
@ -356,6 +360,7 @@ type internalInstancesClient interface {
ListReferrers(context.Context, *computepb.ListReferrersInstancesRequest, ...gax.CallOption) *ReferenceIterator
PerformMaintenance(context.Context, *computepb.PerformMaintenanceInstanceRequest, ...gax.CallOption) (*Operation, error)
RemoveResourcePolicies(context.Context, *computepb.RemoveResourcePoliciesInstanceRequest, ...gax.CallOption) (*Operation, error)
ReportHostAsFaulty(context.Context, *computepb.ReportHostAsFaultyInstanceRequest, ...gax.CallOption) (*Operation, error)
Reset(context.Context, *computepb.ResetInstanceRequest, ...gax.CallOption) (*Operation, error)
Resume(context.Context, *computepb.ResumeInstanceRequest, ...gax.CallOption) (*Operation, error)
SendDiagnosticInterrupt(context.Context, *computepb.SendDiagnosticInterruptInstanceRequest, ...gax.CallOption) (*computepb.SendDiagnosticInterruptInstanceResponse, error)
@ -521,6 +526,11 @@ func (c *InstancesClient) RemoveResourcePolicies(ctx context.Context, req *compu
return c.internalClient.RemoveResourcePolicies(ctx, req, opts...)
}
// ReportHostAsFaulty mark the host as faulty and try to restart the instance on a new host.
func (c *InstancesClient) ReportHostAsFaulty(ctx context.Context, req *computepb.ReportHostAsFaultyInstanceRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.ReportHostAsFaulty(ctx, req, opts...)
}
// Reset performs a reset on the instance. This is a hard reset. The VM does not do a graceful shutdown. For more information, see Resetting an instance.
func (c *InstancesClient) Reset(ctx context.Context, req *computepb.ResetInstanceRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.Reset(ctx, req, opts...)
@ -730,7 +740,7 @@ func defaultInstancesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *instancesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}
@ -2027,6 +2037,73 @@ func (c *instancesRESTClient) RemoveResourcePolicies(ctx context.Context, req *c
return op, nil
}
// ReportHostAsFaulty mark the host as faulty and try to restart the instance on a new host.
func (c *instancesRESTClient) ReportHostAsFaulty(ctx context.Context, req *computepb.ReportHostAsFaultyInstanceRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetInstancesReportHostAsFaultyRequestResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instances/%v/reportHostAsFaulty", req.GetProject(), req.GetZone(), req.GetInstance())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "zone", url.QueryEscape(req.GetZone()), "instance", url.QueryEscape(req.GetInstance()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).ReportHostAsFaulty[0:len((*c.CallOptions).ReportHostAsFaulty):len((*c.CallOptions).ReportHostAsFaulty)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ReportHostAsFaulty")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
op := &Operation{
&zoneOperationsHandle{
c: c.operationClient,
proto: resp,
project: req.GetProject(),
zone: req.GetZone(),
},
}
return op, nil
}
// Reset performs a reset on the instance. This is a hard reset. The VM does not do a graceful shutdown. For more information, see Resetting an instance.
func (c *instancesRESTClient) Reset(ctx context.Context, req *computepb.ResetInstanceRequest, opts ...gax.CallOption) (*Operation, error) {
baseUrl, err := url.Parse(c.endpoint)

View file

@ -286,7 +286,7 @@ func defaultInstantSnapshotsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *instantSnapshotsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -0,0 +1,836 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
package compute
import (
"bytes"
"context"
"fmt"
"log/slog"
"math"
"net/http"
"net/url"
"time"
computepb "cloud.google.com/go/compute/apiv1/computepb"
gax "github.com/googleapis/gax-go/v2"
"google.golang.org/api/iterator"
"google.golang.org/api/option"
"google.golang.org/api/option/internaloption"
httptransport "google.golang.org/api/transport/http"
"google.golang.org/grpc"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)
var newInterconnectAttachmentGroupsClientHook clientHook
// InterconnectAttachmentGroupsCallOptions contains the retry settings for each method of InterconnectAttachmentGroupsClient.
type InterconnectAttachmentGroupsCallOptions struct {
Delete []gax.CallOption
Get []gax.CallOption
GetIamPolicy []gax.CallOption
GetOperationalStatus []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Patch []gax.CallOption
SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
}
func defaultInterconnectAttachmentGroupsRESTCallOptions() *InterconnectAttachmentGroupsCallOptions {
return &InterconnectAttachmentGroupsCallOptions{
Delete: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
Get: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusGatewayTimeout,
http.StatusServiceUnavailable)
}),
},
GetIamPolicy: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusGatewayTimeout,
http.StatusServiceUnavailable)
}),
},
GetOperationalStatus: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusGatewayTimeout,
http.StatusServiceUnavailable)
}),
},
Insert: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
List: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusGatewayTimeout,
http.StatusServiceUnavailable)
}),
},
Patch: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
SetIamPolicy: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
TestIamPermissions: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
}
}
// internalInterconnectAttachmentGroupsClient is an interface that defines the methods available from Google Compute Engine API.
type internalInterconnectAttachmentGroupsClient interface {
Close() error
setGoogleClientInfo(...string)
Connection() *grpc.ClientConn
Delete(context.Context, *computepb.DeleteInterconnectAttachmentGroupRequest, ...gax.CallOption) (*Operation, error)
Get(context.Context, *computepb.GetInterconnectAttachmentGroupRequest, ...gax.CallOption) (*computepb.InterconnectAttachmentGroup, error)
GetIamPolicy(context.Context, *computepb.GetIamPolicyInterconnectAttachmentGroupRequest, ...gax.CallOption) (*computepb.Policy, error)
GetOperationalStatus(context.Context, *computepb.GetOperationalStatusInterconnectAttachmentGroupRequest, ...gax.CallOption) (*computepb.InterconnectAttachmentGroupsGetOperationalStatusResponse, error)
Insert(context.Context, *computepb.InsertInterconnectAttachmentGroupRequest, ...gax.CallOption) (*Operation, error)
List(context.Context, *computepb.ListInterconnectAttachmentGroupsRequest, ...gax.CallOption) *InterconnectAttachmentGroupIterator
Patch(context.Context, *computepb.PatchInterconnectAttachmentGroupRequest, ...gax.CallOption) (*Operation, error)
SetIamPolicy(context.Context, *computepb.SetIamPolicyInterconnectAttachmentGroupRequest, ...gax.CallOption) (*computepb.Policy, error)
TestIamPermissions(context.Context, *computepb.TestIamPermissionsInterconnectAttachmentGroupRequest, ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
}
// InterconnectAttachmentGroupsClient is a client for interacting with Google Compute Engine API.
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
//
// The InterconnectAttachmentGroups API.
type InterconnectAttachmentGroupsClient struct {
// The internal transport-dependent client.
internalClient internalInterconnectAttachmentGroupsClient
// The call options for this service.
CallOptions *InterconnectAttachmentGroupsCallOptions
}
// Wrapper methods routed to the internal client.
// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *InterconnectAttachmentGroupsClient) Close() error {
return c.internalClient.Close()
}
// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *InterconnectAttachmentGroupsClient) setGoogleClientInfo(keyval ...string) {
c.internalClient.setGoogleClientInfo(keyval...)
}
// Connection returns a connection to the API service.
//
// Deprecated: Connections are now pooled so this method does not always
// return the same resource.
func (c *InterconnectAttachmentGroupsClient) Connection() *grpc.ClientConn {
return c.internalClient.Connection()
}
// Delete deletes the specified InterconnectAttachmentGroup in the given scope
func (c *InterconnectAttachmentGroupsClient) Delete(ctx context.Context, req *computepb.DeleteInterconnectAttachmentGroupRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.Delete(ctx, req, opts...)
}
// Get returns the specified InterconnectAttachmentGroup resource in the given scope.
func (c *InterconnectAttachmentGroupsClient) Get(ctx context.Context, req *computepb.GetInterconnectAttachmentGroupRequest, opts ...gax.CallOption) (*computepb.InterconnectAttachmentGroup, error) {
return c.internalClient.Get(ctx, req, opts...)
}
// GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists.
func (c *InterconnectAttachmentGroupsClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyInterconnectAttachmentGroupRequest, opts ...gax.CallOption) (*computepb.Policy, error) {
return c.internalClient.GetIamPolicy(ctx, req, opts...)
}
// GetOperationalStatus returns the InterconnectAttachmentStatuses for the specified InterconnectAttachmentGroup resource.
func (c *InterconnectAttachmentGroupsClient) GetOperationalStatus(ctx context.Context, req *computepb.GetOperationalStatusInterconnectAttachmentGroupRequest, opts ...gax.CallOption) (*computepb.InterconnectAttachmentGroupsGetOperationalStatusResponse, error) {
return c.internalClient.GetOperationalStatus(ctx, req, opts...)
}
// Insert creates a InterconnectAttachmentGroup in the specified project in the given scope using the parameters that are included in the request.
func (c *InterconnectAttachmentGroupsClient) Insert(ctx context.Context, req *computepb.InsertInterconnectAttachmentGroupRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.Insert(ctx, req, opts...)
}
// List lists the InterconnectAttachmentGroups for a project in the given scope.
func (c *InterconnectAttachmentGroupsClient) List(ctx context.Context, req *computepb.ListInterconnectAttachmentGroupsRequest, opts ...gax.CallOption) *InterconnectAttachmentGroupIterator {
return c.internalClient.List(ctx, req, opts...)
}
// Patch patches the specified InterconnectAttachmentGroup resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules.
func (c *InterconnectAttachmentGroupsClient) Patch(ctx context.Context, req *computepb.PatchInterconnectAttachmentGroupRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.Patch(ctx, req, opts...)
}
// SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.
func (c *InterconnectAttachmentGroupsClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyInterconnectAttachmentGroupRequest, opts ...gax.CallOption) (*computepb.Policy, error) {
return c.internalClient.SetIamPolicy(ctx, req, opts...)
}
// TestIamPermissions returns permissions that a caller has on the specified resource.
func (c *InterconnectAttachmentGroupsClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsInterconnectAttachmentGroupRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error) {
return c.internalClient.TestIamPermissions(ctx, req, opts...)
}
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
type interconnectAttachmentGroupsRESTClient struct {
// The http endpoint to connect to.
endpoint string
// The http client.
httpClient *http.Client
// operationClient is used to call the operation-specific management service.
operationClient *GlobalOperationsClient
// The x-goog-* headers to be sent with each request.
xGoogHeaders []string
// Points back to the CallOptions field of the containing InterconnectAttachmentGroupsClient
CallOptions **InterconnectAttachmentGroupsCallOptions
logger *slog.Logger
}
// NewInterconnectAttachmentGroupsRESTClient creates a new interconnect attachment groups rest client.
//
// The InterconnectAttachmentGroups API.
func NewInterconnectAttachmentGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InterconnectAttachmentGroupsClient, error) {
clientOpts := append(defaultInterconnectAttachmentGroupsRESTClientOptions(), opts...)
httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
if err != nil {
return nil, err
}
callOpts := defaultInterconnectAttachmentGroupsRESTCallOptions()
c := &interconnectAttachmentGroupsRESTClient{
endpoint: endpoint,
httpClient: httpClient,
CallOptions: &callOpts,
logger: internaloption.GetLogger(opts),
}
c.setGoogleClientInfo()
o := []option.ClientOption{
option.WithHTTPClient(httpClient),
option.WithEndpoint(endpoint),
}
opC, err := NewGlobalOperationsRESTClient(ctx, o...)
if err != nil {
return nil, err
}
c.operationClient = opC
return &InterconnectAttachmentGroupsClient{internalClient: c, CallOptions: callOpts}, nil
}
func defaultInterconnectAttachmentGroupsRESTClientOptions() []option.ClientOption {
return []option.ClientOption{
internaloption.WithDefaultEndpoint("https://compute.googleapis.com"),
internaloption.WithDefaultEndpointTemplate("https://compute.UNIVERSE_DOMAIN"),
internaloption.WithDefaultMTLSEndpoint("https://compute.mtls.googleapis.com"),
internaloption.WithDefaultUniverseDomain("googleapis.com"),
internaloption.WithDefaultAudience("https://compute.googleapis.com/"),
internaloption.WithDefaultScopes(DefaultAuthScopes()...),
internaloption.EnableNewAuthLibrary(),
}
}
// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *interconnectAttachmentGroupsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}
}
// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *interconnectAttachmentGroupsRESTClient) Close() error {
// Replace httpClient with nil to force cleanup.
c.httpClient = nil
if err := c.operationClient.Close(); err != nil {
return err
}
return nil
}
// Connection returns a connection to the API service.
//
// Deprecated: This method always returns nil.
func (c *interconnectAttachmentGroupsRESTClient) Connection() *grpc.ClientConn {
return nil
}
// Delete deletes the specified InterconnectAttachmentGroup in the given scope
func (c *interconnectAttachmentGroupsRESTClient) Delete(ctx context.Context, req *computepb.DeleteInterconnectAttachmentGroupRequest, opts ...gax.CallOption) (*Operation, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectAttachmentGroups/%v", req.GetProject(), req.GetInterconnectAttachmentGroup())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "interconnect_attachment_group", url.QueryEscape(req.GetInterconnectAttachmentGroup()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).Delete[0:len((*c.CallOptions).Delete):len((*c.CallOptions).Delete)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "Delete")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
op := &Operation{
&globalOperationsHandle{
c: c.operationClient,
proto: resp,
project: req.GetProject(),
},
}
return op, nil
}
// Get returns the specified InterconnectAttachmentGroup resource in the given scope.
func (c *interconnectAttachmentGroupsRESTClient) Get(ctx context.Context, req *computepb.GetInterconnectAttachmentGroupRequest, opts ...gax.CallOption) (*computepb.InterconnectAttachmentGroup, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectAttachmentGroups/%v", req.GetProject(), req.GetInterconnectAttachmentGroup())
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "interconnect_attachment_group", url.QueryEscape(req.GetInterconnectAttachmentGroup()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).Get[0:len((*c.CallOptions).Get):len((*c.CallOptions).Get)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.InterconnectAttachmentGroup{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "Get")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists.
func (c *interconnectAttachmentGroupsRESTClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyInterconnectAttachmentGroupRequest, opts ...gax.CallOption) (*computepb.Policy, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectAttachmentGroups/%v/getIamPolicy", req.GetProject(), req.GetResource())
params := url.Values{}
if req != nil && req.OptionsRequestedPolicyVersion != nil {
params.Add("optionsRequestedPolicyVersion", fmt.Sprintf("%v", req.GetOptionsRequestedPolicyVersion()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "resource", url.QueryEscape(req.GetResource()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Policy{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetIamPolicy")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// GetOperationalStatus returns the InterconnectAttachmentStatuses for the specified InterconnectAttachmentGroup resource.
func (c *interconnectAttachmentGroupsRESTClient) GetOperationalStatus(ctx context.Context, req *computepb.GetOperationalStatusInterconnectAttachmentGroupRequest, opts ...gax.CallOption) (*computepb.InterconnectAttachmentGroupsGetOperationalStatusResponse, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectAttachmentGroups/%v/getOperationalStatus", req.GetProject(), req.GetInterconnectAttachmentGroup())
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "interconnect_attachment_group", url.QueryEscape(req.GetInterconnectAttachmentGroup()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).GetOperationalStatus[0:len((*c.CallOptions).GetOperationalStatus):len((*c.CallOptions).GetOperationalStatus)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.InterconnectAttachmentGroupsGetOperationalStatusResponse{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperationalStatus")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// Insert creates a InterconnectAttachmentGroup in the specified project in the given scope using the parameters that are included in the request.
func (c *interconnectAttachmentGroupsRESTClient) Insert(ctx context.Context, req *computepb.InsertInterconnectAttachmentGroupRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetInterconnectAttachmentGroupResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectAttachmentGroups", req.GetProject())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "project", url.QueryEscape(req.GetProject()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).Insert[0:len((*c.CallOptions).Insert):len((*c.CallOptions).Insert)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "Insert")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
op := &Operation{
&globalOperationsHandle{
c: c.operationClient,
proto: resp,
project: req.GetProject(),
},
}
return op, nil
}
// List lists the InterconnectAttachmentGroups for a project in the given scope.
func (c *interconnectAttachmentGroupsRESTClient) List(ctx context.Context, req *computepb.ListInterconnectAttachmentGroupsRequest, opts ...gax.CallOption) *InterconnectAttachmentGroupIterator {
it := &InterconnectAttachmentGroupIterator{}
req = proto.Clone(req).(*computepb.ListInterconnectAttachmentGroupsRequest)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
it.InternalFetch = func(pageSize int, pageToken string) ([]*computepb.InterconnectAttachmentGroup, string, error) {
resp := &computepb.InterconnectAttachmentGroupsListResponse{}
if pageToken != "" {
req.PageToken = proto.String(pageToken)
}
if pageSize > math.MaxInt32 {
req.MaxResults = proto.Uint32(uint32(math.MaxInt32))
} else if pageSize != 0 {
req.MaxResults = proto.Uint32(uint32(pageSize))
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, "", err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectAttachmentGroups", req.GetProject())
params := url.Values{}
if req != nil && req.Filter != nil {
params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
}
if req != nil && req.MaxResults != nil {
params.Add("maxResults", fmt.Sprintf("%v", req.GetMaxResults()))
}
if req != nil && req.OrderBy != nil {
params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
}
if req != nil && req.PageToken != nil {
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
}
if req != nil && req.ReturnPartialSuccess != nil {
params.Add("returnPartialSuccess", fmt.Sprintf("%v", req.GetReturnPartialSuccess()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := append(c.xGoogHeaders, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "List")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, "", e
}
it.Response = resp
return resp.GetItems(), resp.GetNextPageToken(), nil
}
fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
if err != nil {
return "", err
}
it.items = append(it.items, items...)
return nextPageToken, nil
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
it.pageInfo.MaxSize = int(req.GetMaxResults())
it.pageInfo.Token = req.GetPageToken()
return it
}
// Patch patches the specified InterconnectAttachmentGroup resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules.
func (c *interconnectAttachmentGroupsRESTClient) Patch(ctx context.Context, req *computepb.PatchInterconnectAttachmentGroupRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetInterconnectAttachmentGroupResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectAttachmentGroups/%v", req.GetProject(), req.GetInterconnectAttachmentGroup())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
if req != nil && req.UpdateMask != nil {
params.Add("updateMask", fmt.Sprintf("%v", req.GetUpdateMask()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "interconnect_attachment_group", url.QueryEscape(req.GetInterconnectAttachmentGroup()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).Patch[0:len((*c.CallOptions).Patch):len((*c.CallOptions).Patch)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "Patch")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
op := &Operation{
&globalOperationsHandle{
c: c.operationClient,
proto: resp,
project: req.GetProject(),
},
}
return op, nil
}
// SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.
func (c *interconnectAttachmentGroupsRESTClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyInterconnectAttachmentGroupRequest, opts ...gax.CallOption) (*computepb.Policy, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetGlobalSetPolicyRequestResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectAttachmentGroups/%v/setIamPolicy", req.GetProject(), req.GetResource())
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "resource", url.QueryEscape(req.GetResource()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Policy{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SetIamPolicy")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// TestIamPermissions returns permissions that a caller has on the specified resource.
func (c *interconnectAttachmentGroupsRESTClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsInterconnectAttachmentGroupRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetTestPermissionsRequestResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectAttachmentGroups/%v/testIamPermissions", req.GetProject(), req.GetResource())
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "resource", url.QueryEscape(req.GetResource()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.TestPermissionsResponse{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TestIamPermissions")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}

View file

@ -257,7 +257,7 @@ func defaultInterconnectAttachmentsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *interconnectAttachmentsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -0,0 +1,905 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
package compute
import (
"bytes"
"context"
"fmt"
"log/slog"
"math"
"net/http"
"net/url"
"time"
computepb "cloud.google.com/go/compute/apiv1/computepb"
gax "github.com/googleapis/gax-go/v2"
"google.golang.org/api/iterator"
"google.golang.org/api/option"
"google.golang.org/api/option/internaloption"
httptransport "google.golang.org/api/transport/http"
"google.golang.org/grpc"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)
var newInterconnectGroupsClientHook clientHook
// InterconnectGroupsCallOptions contains the retry settings for each method of InterconnectGroupsClient.
type InterconnectGroupsCallOptions struct {
CreateMembers []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
GetIamPolicy []gax.CallOption
GetOperationalStatus []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Patch []gax.CallOption
SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
}
func defaultInterconnectGroupsRESTCallOptions() *InterconnectGroupsCallOptions {
return &InterconnectGroupsCallOptions{
CreateMembers: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
Delete: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
Get: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusGatewayTimeout,
http.StatusServiceUnavailable)
}),
},
GetIamPolicy: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusGatewayTimeout,
http.StatusServiceUnavailable)
}),
},
GetOperationalStatus: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusGatewayTimeout,
http.StatusServiceUnavailable)
}),
},
Insert: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
List: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusGatewayTimeout,
http.StatusServiceUnavailable)
}),
},
Patch: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
SetIamPolicy: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
TestIamPermissions: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
}
}
// internalInterconnectGroupsClient is an interface that defines the methods available from Google Compute Engine API.
type internalInterconnectGroupsClient interface {
Close() error
setGoogleClientInfo(...string)
Connection() *grpc.ClientConn
CreateMembers(context.Context, *computepb.CreateMembersInterconnectGroupRequest, ...gax.CallOption) (*Operation, error)
Delete(context.Context, *computepb.DeleteInterconnectGroupRequest, ...gax.CallOption) (*Operation, error)
Get(context.Context, *computepb.GetInterconnectGroupRequest, ...gax.CallOption) (*computepb.InterconnectGroup, error)
GetIamPolicy(context.Context, *computepb.GetIamPolicyInterconnectGroupRequest, ...gax.CallOption) (*computepb.Policy, error)
GetOperationalStatus(context.Context, *computepb.GetOperationalStatusInterconnectGroupRequest, ...gax.CallOption) (*computepb.InterconnectGroupsGetOperationalStatusResponse, error)
Insert(context.Context, *computepb.InsertInterconnectGroupRequest, ...gax.CallOption) (*Operation, error)
List(context.Context, *computepb.ListInterconnectGroupsRequest, ...gax.CallOption) *InterconnectGroupIterator
Patch(context.Context, *computepb.PatchInterconnectGroupRequest, ...gax.CallOption) (*Operation, error)
SetIamPolicy(context.Context, *computepb.SetIamPolicyInterconnectGroupRequest, ...gax.CallOption) (*computepb.Policy, error)
TestIamPermissions(context.Context, *computepb.TestIamPermissionsInterconnectGroupRequest, ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
}
// InterconnectGroupsClient is a client for interacting with Google Compute Engine API.
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
//
// The InterconnectGroups API.
type InterconnectGroupsClient struct {
// The internal transport-dependent client.
internalClient internalInterconnectGroupsClient
// The call options for this service.
CallOptions *InterconnectGroupsCallOptions
}
// Wrapper methods routed to the internal client.
// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *InterconnectGroupsClient) Close() error {
return c.internalClient.Close()
}
// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *InterconnectGroupsClient) setGoogleClientInfo(keyval ...string) {
c.internalClient.setGoogleClientInfo(keyval...)
}
// Connection returns a connection to the API service.
//
// Deprecated: Connections are now pooled so this method does not always
// return the same resource.
func (c *InterconnectGroupsClient) Connection() *grpc.ClientConn {
return c.internalClient.Connection()
}
// CreateMembers create Interconnects with redundancy by creating them in a specified interconnect group.
func (c *InterconnectGroupsClient) CreateMembers(ctx context.Context, req *computepb.CreateMembersInterconnectGroupRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.CreateMembers(ctx, req, opts...)
}
// Delete deletes the specified InterconnectGroup in the given scope
func (c *InterconnectGroupsClient) Delete(ctx context.Context, req *computepb.DeleteInterconnectGroupRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.Delete(ctx, req, opts...)
}
// Get returns the specified InterconnectGroup resource in the given scope.
func (c *InterconnectGroupsClient) Get(ctx context.Context, req *computepb.GetInterconnectGroupRequest, opts ...gax.CallOption) (*computepb.InterconnectGroup, error) {
return c.internalClient.Get(ctx, req, opts...)
}
// GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists.
func (c *InterconnectGroupsClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyInterconnectGroupRequest, opts ...gax.CallOption) (*computepb.Policy, error) {
return c.internalClient.GetIamPolicy(ctx, req, opts...)
}
// GetOperationalStatus returns the interconnectStatuses for the specified InterconnectGroup.
func (c *InterconnectGroupsClient) GetOperationalStatus(ctx context.Context, req *computepb.GetOperationalStatusInterconnectGroupRequest, opts ...gax.CallOption) (*computepb.InterconnectGroupsGetOperationalStatusResponse, error) {
return c.internalClient.GetOperationalStatus(ctx, req, opts...)
}
// Insert creates a InterconnectGroup in the specified project in the given scope using the parameters that are included in the request.
func (c *InterconnectGroupsClient) Insert(ctx context.Context, req *computepb.InsertInterconnectGroupRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.Insert(ctx, req, opts...)
}
// List lists the InterconnectGroups for a project in the given scope.
func (c *InterconnectGroupsClient) List(ctx context.Context, req *computepb.ListInterconnectGroupsRequest, opts ...gax.CallOption) *InterconnectGroupIterator {
return c.internalClient.List(ctx, req, opts...)
}
// Patch patches the specified InterconnectGroup resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules.
func (c *InterconnectGroupsClient) Patch(ctx context.Context, req *computepb.PatchInterconnectGroupRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.Patch(ctx, req, opts...)
}
// SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.
func (c *InterconnectGroupsClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyInterconnectGroupRequest, opts ...gax.CallOption) (*computepb.Policy, error) {
return c.internalClient.SetIamPolicy(ctx, req, opts...)
}
// TestIamPermissions returns permissions that a caller has on the specified resource.
func (c *InterconnectGroupsClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsInterconnectGroupRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error) {
return c.internalClient.TestIamPermissions(ctx, req, opts...)
}
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
type interconnectGroupsRESTClient struct {
// The http endpoint to connect to.
endpoint string
// The http client.
httpClient *http.Client
// operationClient is used to call the operation-specific management service.
operationClient *GlobalOperationsClient
// The x-goog-* headers to be sent with each request.
xGoogHeaders []string
// Points back to the CallOptions field of the containing InterconnectGroupsClient
CallOptions **InterconnectGroupsCallOptions
logger *slog.Logger
}
// NewInterconnectGroupsRESTClient creates a new interconnect groups rest client.
//
// The InterconnectGroups API.
func NewInterconnectGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InterconnectGroupsClient, error) {
clientOpts := append(defaultInterconnectGroupsRESTClientOptions(), opts...)
httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
if err != nil {
return nil, err
}
callOpts := defaultInterconnectGroupsRESTCallOptions()
c := &interconnectGroupsRESTClient{
endpoint: endpoint,
httpClient: httpClient,
CallOptions: &callOpts,
logger: internaloption.GetLogger(opts),
}
c.setGoogleClientInfo()
o := []option.ClientOption{
option.WithHTTPClient(httpClient),
option.WithEndpoint(endpoint),
}
opC, err := NewGlobalOperationsRESTClient(ctx, o...)
if err != nil {
return nil, err
}
c.operationClient = opC
return &InterconnectGroupsClient{internalClient: c, CallOptions: callOpts}, nil
}
func defaultInterconnectGroupsRESTClientOptions() []option.ClientOption {
return []option.ClientOption{
internaloption.WithDefaultEndpoint("https://compute.googleapis.com"),
internaloption.WithDefaultEndpointTemplate("https://compute.UNIVERSE_DOMAIN"),
internaloption.WithDefaultMTLSEndpoint("https://compute.mtls.googleapis.com"),
internaloption.WithDefaultUniverseDomain("googleapis.com"),
internaloption.WithDefaultAudience("https://compute.googleapis.com/"),
internaloption.WithDefaultScopes(DefaultAuthScopes()...),
internaloption.EnableNewAuthLibrary(),
}
}
// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *interconnectGroupsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}
}
// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *interconnectGroupsRESTClient) Close() error {
// Replace httpClient with nil to force cleanup.
c.httpClient = nil
if err := c.operationClient.Close(); err != nil {
return err
}
return nil
}
// Connection returns a connection to the API service.
//
// Deprecated: This method always returns nil.
func (c *interconnectGroupsRESTClient) Connection() *grpc.ClientConn {
return nil
}
// CreateMembers create Interconnects with redundancy by creating them in a specified interconnect group.
func (c *interconnectGroupsRESTClient) CreateMembers(ctx context.Context, req *computepb.CreateMembersInterconnectGroupRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetInterconnectGroupsCreateMembersRequestResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectGroups/%v/createMembers", req.GetProject(), req.GetInterconnectGroup())
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "interconnect_group", url.QueryEscape(req.GetInterconnectGroup()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).CreateMembers[0:len((*c.CallOptions).CreateMembers):len((*c.CallOptions).CreateMembers)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateMembers")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
op := &Operation{
&globalOperationsHandle{
c: c.operationClient,
proto: resp,
project: req.GetProject(),
},
}
return op, nil
}
// Delete deletes the specified InterconnectGroup in the given scope
func (c *interconnectGroupsRESTClient) Delete(ctx context.Context, req *computepb.DeleteInterconnectGroupRequest, opts ...gax.CallOption) (*Operation, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectGroups/%v", req.GetProject(), req.GetInterconnectGroup())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "interconnect_group", url.QueryEscape(req.GetInterconnectGroup()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).Delete[0:len((*c.CallOptions).Delete):len((*c.CallOptions).Delete)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "Delete")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
op := &Operation{
&globalOperationsHandle{
c: c.operationClient,
proto: resp,
project: req.GetProject(),
},
}
return op, nil
}
// Get returns the specified InterconnectGroup resource in the given scope.
func (c *interconnectGroupsRESTClient) Get(ctx context.Context, req *computepb.GetInterconnectGroupRequest, opts ...gax.CallOption) (*computepb.InterconnectGroup, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectGroups/%v", req.GetProject(), req.GetInterconnectGroup())
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "interconnect_group", url.QueryEscape(req.GetInterconnectGroup()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).Get[0:len((*c.CallOptions).Get):len((*c.CallOptions).Get)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.InterconnectGroup{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "Get")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists.
func (c *interconnectGroupsRESTClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyInterconnectGroupRequest, opts ...gax.CallOption) (*computepb.Policy, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectGroups/%v/getIamPolicy", req.GetProject(), req.GetResource())
params := url.Values{}
if req != nil && req.OptionsRequestedPolicyVersion != nil {
params.Add("optionsRequestedPolicyVersion", fmt.Sprintf("%v", req.GetOptionsRequestedPolicyVersion()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "resource", url.QueryEscape(req.GetResource()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Policy{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetIamPolicy")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// GetOperationalStatus returns the interconnectStatuses for the specified InterconnectGroup.
func (c *interconnectGroupsRESTClient) GetOperationalStatus(ctx context.Context, req *computepb.GetOperationalStatusInterconnectGroupRequest, opts ...gax.CallOption) (*computepb.InterconnectGroupsGetOperationalStatusResponse, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectGroups/%v/getOperationalStatus", req.GetProject(), req.GetInterconnectGroup())
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "interconnect_group", url.QueryEscape(req.GetInterconnectGroup()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).GetOperationalStatus[0:len((*c.CallOptions).GetOperationalStatus):len((*c.CallOptions).GetOperationalStatus)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.InterconnectGroupsGetOperationalStatusResponse{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperationalStatus")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// Insert creates a InterconnectGroup in the specified project in the given scope using the parameters that are included in the request.
func (c *interconnectGroupsRESTClient) Insert(ctx context.Context, req *computepb.InsertInterconnectGroupRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetInterconnectGroupResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectGroups", req.GetProject())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "project", url.QueryEscape(req.GetProject()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).Insert[0:len((*c.CallOptions).Insert):len((*c.CallOptions).Insert)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "Insert")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
op := &Operation{
&globalOperationsHandle{
c: c.operationClient,
proto: resp,
project: req.GetProject(),
},
}
return op, nil
}
// List lists the InterconnectGroups for a project in the given scope.
func (c *interconnectGroupsRESTClient) List(ctx context.Context, req *computepb.ListInterconnectGroupsRequest, opts ...gax.CallOption) *InterconnectGroupIterator {
it := &InterconnectGroupIterator{}
req = proto.Clone(req).(*computepb.ListInterconnectGroupsRequest)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
it.InternalFetch = func(pageSize int, pageToken string) ([]*computepb.InterconnectGroup, string, error) {
resp := &computepb.InterconnectGroupsListResponse{}
if pageToken != "" {
req.PageToken = proto.String(pageToken)
}
if pageSize > math.MaxInt32 {
req.MaxResults = proto.Uint32(uint32(math.MaxInt32))
} else if pageSize != 0 {
req.MaxResults = proto.Uint32(uint32(pageSize))
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, "", err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectGroups", req.GetProject())
params := url.Values{}
if req != nil && req.Filter != nil {
params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
}
if req != nil && req.MaxResults != nil {
params.Add("maxResults", fmt.Sprintf("%v", req.GetMaxResults()))
}
if req != nil && req.OrderBy != nil {
params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
}
if req != nil && req.PageToken != nil {
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
}
if req != nil && req.ReturnPartialSuccess != nil {
params.Add("returnPartialSuccess", fmt.Sprintf("%v", req.GetReturnPartialSuccess()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := append(c.xGoogHeaders, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "List")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, "", e
}
it.Response = resp
return resp.GetItems(), resp.GetNextPageToken(), nil
}
fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
if err != nil {
return "", err
}
it.items = append(it.items, items...)
return nextPageToken, nil
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
it.pageInfo.MaxSize = int(req.GetMaxResults())
it.pageInfo.Token = req.GetPageToken()
return it
}
// Patch patches the specified InterconnectGroup resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules.
func (c *interconnectGroupsRESTClient) Patch(ctx context.Context, req *computepb.PatchInterconnectGroupRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetInterconnectGroupResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectGroups/%v", req.GetProject(), req.GetInterconnectGroup())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
if req != nil && req.UpdateMask != nil {
params.Add("updateMask", fmt.Sprintf("%v", req.GetUpdateMask()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "interconnect_group", url.QueryEscape(req.GetInterconnectGroup()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).Patch[0:len((*c.CallOptions).Patch):len((*c.CallOptions).Patch)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "Patch")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
op := &Operation{
&globalOperationsHandle{
c: c.operationClient,
proto: resp,
project: req.GetProject(),
},
}
return op, nil
}
// SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.
func (c *interconnectGroupsRESTClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyInterconnectGroupRequest, opts ...gax.CallOption) (*computepb.Policy, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetGlobalSetPolicyRequestResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectGroups/%v/setIamPolicy", req.GetProject(), req.GetResource())
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "resource", url.QueryEscape(req.GetResource()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Policy{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SetIamPolicy")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// TestIamPermissions returns permissions that a caller has on the specified resource.
func (c *interconnectGroupsRESTClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsInterconnectGroupRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetTestPermissionsRequestResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/interconnectGroups/%v/testIamPermissions", req.GetProject(), req.GetResource())
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "resource", url.QueryEscape(req.GetResource()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.TestPermissionsResponse{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TestIamPermissions")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}

View file

@ -183,7 +183,7 @@ func defaultInterconnectLocationsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *interconnectLocationsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -183,7 +183,7 @@ func defaultInterconnectRemoteLocationsRESTClientOptions() []option.ClientOption
// use by Google-written clients.
func (c *interconnectRemoteLocationsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -275,7 +275,7 @@ func defaultInterconnectsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *interconnectsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -172,7 +172,7 @@ func defaultLicenseCodesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *licenseCodesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -48,6 +48,7 @@ type LicensesCallOptions struct {
List []gax.CallOption
SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
Update []gax.CallOption
}
func defaultLicensesRESTCallOptions() *LicensesCallOptions {
@ -100,6 +101,9 @@ func defaultLicensesRESTCallOptions() *LicensesCallOptions {
TestIamPermissions: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
Update: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
}
}
@ -115,6 +119,7 @@ type internalLicensesClient interface {
List(context.Context, *computepb.ListLicensesRequest, ...gax.CallOption) *LicenseIterator
SetIamPolicy(context.Context, *computepb.SetIamPolicyLicenseRequest, ...gax.CallOption) (*computepb.Policy, error)
TestIamPermissions(context.Context, *computepb.TestIamPermissionsLicenseRequest, ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
Update(context.Context, *computepb.UpdateLicenseRequest, ...gax.CallOption) (*Operation, error)
}
// LicensesClient is a client for interacting with Google Compute Engine API.
@ -187,6 +192,11 @@ func (c *LicensesClient) TestIamPermissions(ctx context.Context, req *computepb.
return c.internalClient.TestIamPermissions(ctx, req, opts...)
}
// Update updates a License resource in the specified project. Caution This resource is intended for use only by third-party partners who are creating Cloud Marketplace images.
func (c *LicensesClient) Update(ctx context.Context, req *computepb.UpdateLicenseRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.Update(ctx, req, opts...)
}
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
type licensesRESTClient struct {
// The http endpoint to connect to.
@ -256,7 +266,7 @@ func defaultLicensesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *licensesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}
@ -691,3 +701,72 @@ func (c *licensesRESTClient) TestIamPermissions(ctx context.Context, req *comput
}
return resp, nil
}
// Update updates a License resource in the specified project. Caution This resource is intended for use only by third-party partners who are creating Cloud Marketplace images.
func (c *licensesRESTClient) Update(ctx context.Context, req *computepb.UpdateLicenseRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetLicenseResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/licenses/%v", req.GetProject(), req.GetLicense())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
if req != nil && req.UpdateMask != nil {
params.Add("updateMask", fmt.Sprintf("%v", req.GetUpdateMask()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "license", url.QueryEscape(req.GetLicense()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).Update[0:len((*c.CallOptions).Update):len((*c.CallOptions).Update)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "Update")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
op := &Operation{
&globalOperationsHandle{
c: c.operationClient,
proto: resp,
project: req.GetProject(),
},
}
return op, nil
}

View file

@ -47,6 +47,7 @@ type MachineImagesCallOptions struct {
Insert []gax.CallOption
List []gax.CallOption
SetIamPolicy []gax.CallOption
SetLabels []gax.CallOption
TestIamPermissions []gax.CallOption
}
@ -97,6 +98,9 @@ func defaultMachineImagesRESTCallOptions() *MachineImagesCallOptions {
SetIamPolicy: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
SetLabels: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
TestIamPermissions: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
@ -114,6 +118,7 @@ type internalMachineImagesClient interface {
Insert(context.Context, *computepb.InsertMachineImageRequest, ...gax.CallOption) (*Operation, error)
List(context.Context, *computepb.ListMachineImagesRequest, ...gax.CallOption) *MachineImageIterator
SetIamPolicy(context.Context, *computepb.SetIamPolicyMachineImageRequest, ...gax.CallOption) (*computepb.Policy, error)
SetLabels(context.Context, *computepb.SetLabelsMachineImageRequest, ...gax.CallOption) (*Operation, error)
TestIamPermissions(context.Context, *computepb.TestIamPermissionsMachineImageRequest, ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
}
@ -182,6 +187,11 @@ func (c *MachineImagesClient) SetIamPolicy(ctx context.Context, req *computepb.S
return c.internalClient.SetIamPolicy(ctx, req, opts...)
}
// SetLabels sets the labels on a machine image. To learn more about labels, read the Labeling Resources documentation.
func (c *MachineImagesClient) SetLabels(ctx context.Context, req *computepb.SetLabelsMachineImageRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.SetLabels(ctx, req, opts...)
}
// TestIamPermissions returns permissions that a caller has on the specified resource.
func (c *MachineImagesClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsMachineImageRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error) {
return c.internalClient.TestIamPermissions(ctx, req, opts...)
@ -256,7 +266,7 @@ func defaultMachineImagesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *machineImagesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}
@ -643,6 +653,65 @@ func (c *machineImagesRESTClient) SetIamPolicy(ctx context.Context, req *compute
return resp, nil
}
// SetLabels sets the labels on a machine image. To learn more about labels, read the Labeling Resources documentation.
func (c *machineImagesRESTClient) SetLabels(ctx context.Context, req *computepb.SetLabelsMachineImageRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetGlobalSetLabelsRequestResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/machineImages/%v/setLabels", req.GetProject(), req.GetResource())
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "resource", url.QueryEscape(req.GetResource()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).SetLabels[0:len((*c.CallOptions).SetLabels):len((*c.CallOptions).SetLabels)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SetLabels")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
op := &Operation{
&globalOperationsHandle{
c: c.operationClient,
proto: resp,
project: req.GetProject(),
},
}
return op, nil
}
// TestIamPermissions returns permissions that a caller has on the specified resource.
func (c *machineImagesRESTClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsMachineImageRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error) {
m := protojson.MarshalOptions{AllowPartial: true}

View file

@ -203,7 +203,7 @@ func defaultMachineTypesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *machineTypesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -286,7 +286,7 @@ func defaultNetworkAttachmentsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *networkAttachmentsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -228,7 +228,7 @@ func defaultNetworkEdgeSecurityServicesRESTClientOptions() []option.ClientOption
// use by Google-written clients.
func (c *networkEdgeSecurityServicesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -277,7 +277,7 @@ func defaultNetworkEndpointGroupsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *networkEndpointGroupsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -42,23 +42,27 @@ var newNetworkFirewallPoliciesClientHook clientHook
// NetworkFirewallPoliciesCallOptions contains the retry settings for each method of NetworkFirewallPoliciesClient.
type NetworkFirewallPoliciesCallOptions struct {
AddAssociation []gax.CallOption
AddRule []gax.CallOption
AggregatedList []gax.CallOption
CloneRules []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
GetAssociation []gax.CallOption
GetIamPolicy []gax.CallOption
GetRule []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Patch []gax.CallOption
PatchRule []gax.CallOption
RemoveAssociation []gax.CallOption
RemoveRule []gax.CallOption
SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
AddAssociation []gax.CallOption
AddPacketMirroringRule []gax.CallOption
AddRule []gax.CallOption
AggregatedList []gax.CallOption
CloneRules []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
GetAssociation []gax.CallOption
GetIamPolicy []gax.CallOption
GetPacketMirroringRule []gax.CallOption
GetRule []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Patch []gax.CallOption
PatchPacketMirroringRule []gax.CallOption
PatchRule []gax.CallOption
RemoveAssociation []gax.CallOption
RemovePacketMirroringRule []gax.CallOption
RemoveRule []gax.CallOption
SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
}
func defaultNetworkFirewallPoliciesRESTCallOptions() *NetworkFirewallPoliciesCallOptions {
@ -66,6 +70,9 @@ func defaultNetworkFirewallPoliciesRESTCallOptions() *NetworkFirewallPoliciesCal
AddAssociation: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
AddPacketMirroringRule: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
AddRule: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
@ -123,6 +130,18 @@ func defaultNetworkFirewallPoliciesRESTCallOptions() *NetworkFirewallPoliciesCal
http.StatusServiceUnavailable)
}),
},
GetPacketMirroringRule: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusGatewayTimeout,
http.StatusServiceUnavailable)
}),
},
GetRule: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
@ -153,12 +172,18 @@ func defaultNetworkFirewallPoliciesRESTCallOptions() *NetworkFirewallPoliciesCal
Patch: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
PatchPacketMirroringRule: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
PatchRule: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
RemoveAssociation: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
RemovePacketMirroringRule: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
RemoveRule: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
@ -177,6 +202,7 @@ type internalNetworkFirewallPoliciesClient interface {
setGoogleClientInfo(...string)
Connection() *grpc.ClientConn
AddAssociation(context.Context, *computepb.AddAssociationNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
AddPacketMirroringRule(context.Context, *computepb.AddPacketMirroringRuleNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
AddRule(context.Context, *computepb.AddRuleNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
AggregatedList(context.Context, *computepb.AggregatedListNetworkFirewallPoliciesRequest, ...gax.CallOption) *FirewallPoliciesScopedListPairIterator
CloneRules(context.Context, *computepb.CloneRulesNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
@ -184,12 +210,15 @@ type internalNetworkFirewallPoliciesClient interface {
Get(context.Context, *computepb.GetNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.FirewallPolicy, error)
GetAssociation(context.Context, *computepb.GetAssociationNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.FirewallPolicyAssociation, error)
GetIamPolicy(context.Context, *computepb.GetIamPolicyNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.Policy, error)
GetPacketMirroringRule(context.Context, *computepb.GetPacketMirroringRuleNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.FirewallPolicyRule, error)
GetRule(context.Context, *computepb.GetRuleNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.FirewallPolicyRule, error)
Insert(context.Context, *computepb.InsertNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
List(context.Context, *computepb.ListNetworkFirewallPoliciesRequest, ...gax.CallOption) *FirewallPolicyIterator
Patch(context.Context, *computepb.PatchNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
PatchPacketMirroringRule(context.Context, *computepb.PatchPacketMirroringRuleNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
PatchRule(context.Context, *computepb.PatchRuleNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
RemoveAssociation(context.Context, *computepb.RemoveAssociationNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
RemovePacketMirroringRule(context.Context, *computepb.RemovePacketMirroringRuleNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
RemoveRule(context.Context, *computepb.RemoveRuleNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
SetIamPolicy(context.Context, *computepb.SetIamPolicyNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.Policy, error)
TestIamPermissions(context.Context, *computepb.TestIamPermissionsNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
@ -235,6 +264,11 @@ func (c *NetworkFirewallPoliciesClient) AddAssociation(ctx context.Context, req
return c.internalClient.AddAssociation(ctx, req, opts...)
}
// AddPacketMirroringRule inserts a packet mirroring rule into a firewall policy.
func (c *NetworkFirewallPoliciesClient) AddPacketMirroringRule(ctx context.Context, req *computepb.AddPacketMirroringRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.AddPacketMirroringRule(ctx, req, opts...)
}
// AddRule inserts a rule into a firewall policy.
func (c *NetworkFirewallPoliciesClient) AddRule(ctx context.Context, req *computepb.AddRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.AddRule(ctx, req, opts...)
@ -270,6 +304,11 @@ func (c *NetworkFirewallPoliciesClient) GetIamPolicy(ctx context.Context, req *c
return c.internalClient.GetIamPolicy(ctx, req, opts...)
}
// GetPacketMirroringRule gets a packet mirroring rule of the specified priority.
func (c *NetworkFirewallPoliciesClient) GetPacketMirroringRule(ctx context.Context, req *computepb.GetPacketMirroringRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyRule, error) {
return c.internalClient.GetPacketMirroringRule(ctx, req, opts...)
}
// GetRule gets a rule of the specified priority.
func (c *NetworkFirewallPoliciesClient) GetRule(ctx context.Context, req *computepb.GetRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyRule, error) {
return c.internalClient.GetRule(ctx, req, opts...)
@ -290,6 +329,11 @@ func (c *NetworkFirewallPoliciesClient) Patch(ctx context.Context, req *computep
return c.internalClient.Patch(ctx, req, opts...)
}
// PatchPacketMirroringRule patches a packet mirroring rule of the specified priority.
func (c *NetworkFirewallPoliciesClient) PatchPacketMirroringRule(ctx context.Context, req *computepb.PatchPacketMirroringRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.PatchPacketMirroringRule(ctx, req, opts...)
}
// PatchRule patches a rule of the specified priority.
func (c *NetworkFirewallPoliciesClient) PatchRule(ctx context.Context, req *computepb.PatchRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.PatchRule(ctx, req, opts...)
@ -300,6 +344,11 @@ func (c *NetworkFirewallPoliciesClient) RemoveAssociation(ctx context.Context, r
return c.internalClient.RemoveAssociation(ctx, req, opts...)
}
// RemovePacketMirroringRule deletes a packet mirroring rule of the specified priority.
func (c *NetworkFirewallPoliciesClient) RemovePacketMirroringRule(ctx context.Context, req *computepb.RemovePacketMirroringRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.RemovePacketMirroringRule(ctx, req, opts...)
}
// RemoveRule deletes a rule of the specified priority.
func (c *NetworkFirewallPoliciesClient) RemoveRule(ctx context.Context, req *computepb.RemoveRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.RemoveRule(ctx, req, opts...)
@ -384,7 +433,7 @@ func defaultNetworkFirewallPoliciesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *networkFirewallPoliciesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}
@ -477,6 +526,78 @@ func (c *networkFirewallPoliciesRESTClient) AddAssociation(ctx context.Context,
return op, nil
}
// AddPacketMirroringRule inserts a packet mirroring rule into a firewall policy.
func (c *networkFirewallPoliciesRESTClient) AddPacketMirroringRule(ctx context.Context, req *computepb.AddPacketMirroringRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetFirewallPolicyRuleResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v/addPacketMirroringRule", req.GetProject(), req.GetFirewallPolicy())
params := url.Values{}
if req != nil && req.MaxPriority != nil {
params.Add("maxPriority", fmt.Sprintf("%v", req.GetMaxPriority()))
}
if req != nil && req.MinPriority != nil {
params.Add("minPriority", fmt.Sprintf("%v", req.GetMinPriority()))
}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "firewall_policy", url.QueryEscape(req.GetFirewallPolicy()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).AddPacketMirroringRule[0:len((*c.CallOptions).AddPacketMirroringRule):len((*c.CallOptions).AddPacketMirroringRule)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "AddPacketMirroringRule")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
op := &Operation{
&globalOperationsHandle{
c: c.operationClient,
proto: resp,
project: req.GetProject(),
},
}
return op, nil
}
// AddRule inserts a rule into a firewall policy.
func (c *networkFirewallPoliciesRESTClient) AddRule(ctx context.Context, req *computepb.AddRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
@ -918,6 +1039,58 @@ func (c *networkFirewallPoliciesRESTClient) GetIamPolicy(ctx context.Context, re
return resp, nil
}
// GetPacketMirroringRule gets a packet mirroring rule of the specified priority.
func (c *networkFirewallPoliciesRESTClient) GetPacketMirroringRule(ctx context.Context, req *computepb.GetPacketMirroringRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyRule, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v/getPacketMirroringRule", req.GetProject(), req.GetFirewallPolicy())
params := url.Values{}
if req != nil && req.Priority != nil {
params.Add("priority", fmt.Sprintf("%v", req.GetPriority()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "firewall_policy", url.QueryEscape(req.GetFirewallPolicy()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).GetPacketMirroringRule[0:len((*c.CallOptions).GetPacketMirroringRule):len((*c.CallOptions).GetPacketMirroringRule)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.FirewallPolicyRule{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetPacketMirroringRule")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// GetRule gets a rule of the specified priority.
func (c *networkFirewallPoliciesRESTClient) GetRule(ctx context.Context, req *computepb.GetRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyRule, error) {
baseUrl, err := url.Parse(c.endpoint)
@ -1188,6 +1361,75 @@ func (c *networkFirewallPoliciesRESTClient) Patch(ctx context.Context, req *comp
return op, nil
}
// PatchPacketMirroringRule patches a packet mirroring rule of the specified priority.
func (c *networkFirewallPoliciesRESTClient) PatchPacketMirroringRule(ctx context.Context, req *computepb.PatchPacketMirroringRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetFirewallPolicyRuleResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v/patchPacketMirroringRule", req.GetProject(), req.GetFirewallPolicy())
params := url.Values{}
if req != nil && req.Priority != nil {
params.Add("priority", fmt.Sprintf("%v", req.GetPriority()))
}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "firewall_policy", url.QueryEscape(req.GetFirewallPolicy()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).PatchPacketMirroringRule[0:len((*c.CallOptions).PatchPacketMirroringRule):len((*c.CallOptions).PatchPacketMirroringRule)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "PatchPacketMirroringRule")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
op := &Operation{
&globalOperationsHandle{
c: c.operationClient,
proto: resp,
project: req.GetProject(),
},
}
return op, nil
}
// PatchRule patches a rule of the specified priority.
func (c *networkFirewallPoliciesRESTClient) PatchRule(ctx context.Context, req *computepb.PatchRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
@ -1319,6 +1561,68 @@ func (c *networkFirewallPoliciesRESTClient) RemoveAssociation(ctx context.Contex
return op, nil
}
// RemovePacketMirroringRule deletes a packet mirroring rule of the specified priority.
func (c *networkFirewallPoliciesRESTClient) RemovePacketMirroringRule(ctx context.Context, req *computepb.RemovePacketMirroringRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v/removePacketMirroringRule", req.GetProject(), req.GetFirewallPolicy())
params := url.Values{}
if req != nil && req.Priority != nil {
params.Add("priority", fmt.Sprintf("%v", req.GetPriority()))
}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "firewall_policy", url.QueryEscape(req.GetFirewallPolicy()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).RemovePacketMirroringRule[0:len((*c.CallOptions).RemovePacketMirroringRule):len((*c.CallOptions).RemovePacketMirroringRule)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "RemovePacketMirroringRule")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
op := &Operation{
&globalOperationsHandle{
c: c.operationClient,
proto: resp,
project: req.GetProject(),
},
}
return op, nil
}
// RemoveRule deletes a rule of the specified priority.
func (c *networkFirewallPoliciesRESTClient) RemoveRule(ctx context.Context, req *computepb.RemoveRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
baseUrl, err := url.Parse(c.endpoint)

View file

@ -183,7 +183,7 @@ func defaultNetworkProfilesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *networkProfilesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -305,7 +305,7 @@ func defaultNetworksRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *networksRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -346,7 +346,7 @@ func defaultNodeGroupsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *nodeGroupsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -276,7 +276,7 @@ func defaultNodeTemplatesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *nodeTemplatesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -203,7 +203,7 @@ func defaultNodeTypesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *nodeTypesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -257,7 +257,7 @@ func defaultPacketMirroringsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *packetMirroringsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -326,7 +326,7 @@ func defaultProjectsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *projectsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -247,7 +247,7 @@ func defaultPublicAdvertisedPrefixesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *publicAdvertisedPrefixesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -267,7 +267,7 @@ func defaultPublicDelegatedPrefixesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *publicDelegatedPrefixesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -237,7 +237,7 @@ func defaultRegionAutoscalersRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionAutoscalersRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -315,7 +315,7 @@ func defaultRegionBackendServicesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionBackendServicesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -163,7 +163,7 @@ func (c *RegionCommitmentsClient) List(ctx context.Context, req *computepb.ListR
return c.internalClient.List(ctx, req, opts...)
}
// Update updates the specified commitment with the data included in the request. Update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: auto_renew.
// Update updates the specified commitment with the data included in the request. Update is performed only on selected fields included as part of update-mask. Only the following fields can be updated: auto_renew and plan.
func (c *RegionCommitmentsClient) Update(ctx context.Context, req *computepb.UpdateRegionCommitmentRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.Update(ctx, req, opts...)
}
@ -237,7 +237,7 @@ func defaultRegionCommitmentsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionCommitmentsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}
@ -558,7 +558,7 @@ func (c *regionCommitmentsRESTClient) List(ctx context.Context, req *computepb.L
return it
}
// Update updates the specified commitment with the data included in the request. Update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: auto_renew.
// Update updates the specified commitment with the data included in the request. Update is performed only on selected fields included as part of update-mask. Only the following fields can be updated: auto_renew and plan.
func (c *regionCommitmentsRESTClient) Update(ctx context.Context, req *computepb.UpdateRegionCommitmentRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetCommitmentResource()

View file

@ -183,7 +183,7 @@ func defaultRegionDiskTypesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionDiskTypesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -356,7 +356,7 @@ func defaultRegionDisksRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionDisksRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -227,7 +227,7 @@ func defaultRegionHealthCheckServicesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionHealthCheckServicesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -237,7 +237,7 @@ func defaultRegionHealthChecksRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionHealthChecksRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -416,7 +416,7 @@ func defaultRegionInstanceGroupManagersRESTClientOptions() []option.ClientOption
// use by Google-written clients.
func (c *regionInstanceGroupManagersRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -217,7 +217,7 @@ func defaultRegionInstanceGroupsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionInstanceGroupsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -217,7 +217,7 @@ func defaultRegionInstanceTemplatesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionInstanceTemplatesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -166,7 +166,7 @@ func defaultRegionInstancesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionInstancesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -266,7 +266,7 @@ func defaultRegionInstantSnapshotsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionInstantSnapshotsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -247,7 +247,7 @@ func defaultRegionNetworkEndpointGroupsRESTClientOptions() []option.ClientOption
// use by Google-written clients.
func (c *regionNetworkEndpointGroupsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -383,7 +383,7 @@ func defaultRegionNetworkFirewallPoliciesRESTClientOptions() []option.ClientOpti
// use by Google-written clients.
func (c *regionNetworkFirewallPoliciesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -217,7 +217,7 @@ func defaultRegionNotificationEndpointsRESTClientOptions() []option.ClientOption
// use by Google-written clients.
func (c *regionNotificationEndpointsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -203,7 +203,7 @@ func defaultRegionOperationsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionOperationsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -286,7 +286,7 @@ func defaultRegionSecurityPoliciesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionSecurityPoliciesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -217,7 +217,7 @@ func defaultRegionSslCertificatesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionSslCertificatesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -246,7 +246,7 @@ func defaultRegionSslPoliciesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionSslPoliciesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -227,7 +227,7 @@ func defaultRegionTargetHttpProxiesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionTargetHttpProxiesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -247,7 +247,7 @@ func defaultRegionTargetHttpsProxiesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionTargetHttpsProxiesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -217,7 +217,7 @@ func defaultRegionTargetTcpProxiesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionTargetTcpProxiesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -247,7 +247,7 @@ func defaultRegionUrlMapsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionUrlMapsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -164,7 +164,7 @@ func defaultRegionZonesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionZonesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -183,7 +183,7 @@ func defaultRegionsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *regionsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

View file

@ -0,0 +1,430 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
package compute
import (
"bytes"
"context"
"fmt"
"log/slog"
"math"
"net/http"
"net/url"
"time"
computepb "cloud.google.com/go/compute/apiv1/computepb"
gax "github.com/googleapis/gax-go/v2"
"google.golang.org/api/iterator"
"google.golang.org/api/option"
"google.golang.org/api/option/internaloption"
httptransport "google.golang.org/api/transport/http"
"google.golang.org/grpc"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)
var newReservationBlocksClientHook clientHook
// ReservationBlocksCallOptions contains the retry settings for each method of ReservationBlocksClient.
type ReservationBlocksCallOptions struct {
Get []gax.CallOption
List []gax.CallOption
PerformMaintenance []gax.CallOption
}
func defaultReservationBlocksRESTCallOptions() *ReservationBlocksCallOptions {
return &ReservationBlocksCallOptions{
Get: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusGatewayTimeout,
http.StatusServiceUnavailable)
}),
},
List: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusGatewayTimeout,
http.StatusServiceUnavailable)
}),
},
PerformMaintenance: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
}
}
// internalReservationBlocksClient is an interface that defines the methods available from Google Compute Engine API.
type internalReservationBlocksClient interface {
Close() error
setGoogleClientInfo(...string)
Connection() *grpc.ClientConn
Get(context.Context, *computepb.GetReservationBlockRequest, ...gax.CallOption) (*computepb.ReservationBlocksGetResponse, error)
List(context.Context, *computepb.ListReservationBlocksRequest, ...gax.CallOption) *ReservationBlockIterator
PerformMaintenance(context.Context, *computepb.PerformMaintenanceReservationBlockRequest, ...gax.CallOption) (*Operation, error)
}
// ReservationBlocksClient is a client for interacting with Google Compute Engine API.
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
//
// The ReservationBlocks API.
type ReservationBlocksClient struct {
// The internal transport-dependent client.
internalClient internalReservationBlocksClient
// The call options for this service.
CallOptions *ReservationBlocksCallOptions
}
// Wrapper methods routed to the internal client.
// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *ReservationBlocksClient) Close() error {
return c.internalClient.Close()
}
// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *ReservationBlocksClient) setGoogleClientInfo(keyval ...string) {
c.internalClient.setGoogleClientInfo(keyval...)
}
// Connection returns a connection to the API service.
//
// Deprecated: Connections are now pooled so this method does not always
// return the same resource.
func (c *ReservationBlocksClient) Connection() *grpc.ClientConn {
return c.internalClient.Connection()
}
// Get retrieves information about the specified reservation block.
func (c *ReservationBlocksClient) Get(ctx context.Context, req *computepb.GetReservationBlockRequest, opts ...gax.CallOption) (*computepb.ReservationBlocksGetResponse, error) {
return c.internalClient.Get(ctx, req, opts...)
}
// List retrieves a list of reservation blocks under a single reservation.
func (c *ReservationBlocksClient) List(ctx context.Context, req *computepb.ListReservationBlocksRequest, opts ...gax.CallOption) *ReservationBlockIterator {
return c.internalClient.List(ctx, req, opts...)
}
// PerformMaintenance allows customers to perform maintenance on a reservation block
func (c *ReservationBlocksClient) PerformMaintenance(ctx context.Context, req *computepb.PerformMaintenanceReservationBlockRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.PerformMaintenance(ctx, req, opts...)
}
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
type reservationBlocksRESTClient struct {
// The http endpoint to connect to.
endpoint string
// The http client.
httpClient *http.Client
// operationClient is used to call the operation-specific management service.
operationClient *ZoneOperationsClient
// The x-goog-* headers to be sent with each request.
xGoogHeaders []string
// Points back to the CallOptions field of the containing ReservationBlocksClient
CallOptions **ReservationBlocksCallOptions
logger *slog.Logger
}
// NewReservationBlocksRESTClient creates a new reservation blocks rest client.
//
// The ReservationBlocks API.
func NewReservationBlocksRESTClient(ctx context.Context, opts ...option.ClientOption) (*ReservationBlocksClient, error) {
clientOpts := append(defaultReservationBlocksRESTClientOptions(), opts...)
httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
if err != nil {
return nil, err
}
callOpts := defaultReservationBlocksRESTCallOptions()
c := &reservationBlocksRESTClient{
endpoint: endpoint,
httpClient: httpClient,
CallOptions: &callOpts,
logger: internaloption.GetLogger(opts),
}
c.setGoogleClientInfo()
o := []option.ClientOption{
option.WithHTTPClient(httpClient),
option.WithEndpoint(endpoint),
}
opC, err := NewZoneOperationsRESTClient(ctx, o...)
if err != nil {
return nil, err
}
c.operationClient = opC
return &ReservationBlocksClient{internalClient: c, CallOptions: callOpts}, nil
}
func defaultReservationBlocksRESTClientOptions() []option.ClientOption {
return []option.ClientOption{
internaloption.WithDefaultEndpoint("https://compute.googleapis.com"),
internaloption.WithDefaultEndpointTemplate("https://compute.UNIVERSE_DOMAIN"),
internaloption.WithDefaultMTLSEndpoint("https://compute.mtls.googleapis.com"),
internaloption.WithDefaultUniverseDomain("googleapis.com"),
internaloption.WithDefaultAudience("https://compute.googleapis.com/"),
internaloption.WithDefaultScopes(DefaultAuthScopes()...),
internaloption.EnableNewAuthLibrary(),
}
}
// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *reservationBlocksRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}
}
// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *reservationBlocksRESTClient) Close() error {
// Replace httpClient with nil to force cleanup.
c.httpClient = nil
if err := c.operationClient.Close(); err != nil {
return err
}
return nil
}
// Connection returns a connection to the API service.
//
// Deprecated: This method always returns nil.
func (c *reservationBlocksRESTClient) Connection() *grpc.ClientConn {
return nil
}
// Get retrieves information about the specified reservation block.
func (c *reservationBlocksRESTClient) Get(ctx context.Context, req *computepb.GetReservationBlockRequest, opts ...gax.CallOption) (*computepb.ReservationBlocksGetResponse, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/reservations/%v/reservationBlocks/%v", req.GetProject(), req.GetZone(), req.GetReservation(), req.GetReservationBlock())
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "zone", url.QueryEscape(req.GetZone()), "reservation", url.QueryEscape(req.GetReservation()), "reservation_block", url.QueryEscape(req.GetReservationBlock()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).Get[0:len((*c.CallOptions).Get):len((*c.CallOptions).Get)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.ReservationBlocksGetResponse{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "Get")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// List retrieves a list of reservation blocks under a single reservation.
func (c *reservationBlocksRESTClient) List(ctx context.Context, req *computepb.ListReservationBlocksRequest, opts ...gax.CallOption) *ReservationBlockIterator {
it := &ReservationBlockIterator{}
req = proto.Clone(req).(*computepb.ListReservationBlocksRequest)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
it.InternalFetch = func(pageSize int, pageToken string) ([]*computepb.ReservationBlock, string, error) {
resp := &computepb.ReservationBlocksListResponse{}
if pageToken != "" {
req.PageToken = proto.String(pageToken)
}
if pageSize > math.MaxInt32 {
req.MaxResults = proto.Uint32(uint32(math.MaxInt32))
} else if pageSize != 0 {
req.MaxResults = proto.Uint32(uint32(pageSize))
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, "", err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/reservations/%v/reservationBlocks", req.GetProject(), req.GetZone(), req.GetReservation())
params := url.Values{}
if req != nil && req.Filter != nil {
params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
}
if req != nil && req.MaxResults != nil {
params.Add("maxResults", fmt.Sprintf("%v", req.GetMaxResults()))
}
if req != nil && req.OrderBy != nil {
params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
}
if req != nil && req.PageToken != nil {
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
}
if req != nil && req.ReturnPartialSuccess != nil {
params.Add("returnPartialSuccess", fmt.Sprintf("%v", req.GetReturnPartialSuccess()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := append(c.xGoogHeaders, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "List")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, "", e
}
it.Response = resp
return resp.GetItems(), resp.GetNextPageToken(), nil
}
fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
if err != nil {
return "", err
}
it.items = append(it.items, items...)
return nextPageToken, nil
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
it.pageInfo.MaxSize = int(req.GetMaxResults())
it.pageInfo.Token = req.GetPageToken()
return it
}
// PerformMaintenance allows customers to perform maintenance on a reservation block
func (c *reservationBlocksRESTClient) PerformMaintenance(ctx context.Context, req *computepb.PerformMaintenanceReservationBlockRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetReservationsBlocksPerformMaintenanceRequestResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/reservations/%v/reservationBlocks/%v/performMaintenance", req.GetProject(), req.GetZone(), req.GetReservation(), req.GetReservationBlock())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "zone", url.QueryEscape(req.GetZone()), "reservation", url.QueryEscape(req.GetReservation()), "reservation_block", url.QueryEscape(req.GetReservationBlock()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).PerformMaintenance[0:len((*c.CallOptions).PerformMaintenance):len((*c.CallOptions).PerformMaintenance)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "PerformMaintenance")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
op := &Operation{
&zoneOperationsHandle{
c: c.operationClient,
proto: resp,
project: req.GetProject(),
zone: req.GetZone(),
},
}
return op, nil
}

View file

@ -0,0 +1,336 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
package compute
import (
"context"
"fmt"
"log/slog"
"math"
"net/http"
"net/url"
"time"
computepb "cloud.google.com/go/compute/apiv1/computepb"
gax "github.com/googleapis/gax-go/v2"
"google.golang.org/api/iterator"
"google.golang.org/api/option"
"google.golang.org/api/option/internaloption"
httptransport "google.golang.org/api/transport/http"
"google.golang.org/grpc"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)
var newReservationSubBlocksClientHook clientHook
// ReservationSubBlocksCallOptions contains the retry settings for each method of ReservationSubBlocksClient.
type ReservationSubBlocksCallOptions struct {
Get []gax.CallOption
List []gax.CallOption
}
func defaultReservationSubBlocksRESTCallOptions() *ReservationSubBlocksCallOptions {
return &ReservationSubBlocksCallOptions{
Get: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusGatewayTimeout,
http.StatusServiceUnavailable)
}),
},
List: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnHTTPCodes(gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
},
http.StatusGatewayTimeout,
http.StatusServiceUnavailable)
}),
},
}
}
// internalReservationSubBlocksClient is an interface that defines the methods available from Google Compute Engine API.
type internalReservationSubBlocksClient interface {
Close() error
setGoogleClientInfo(...string)
Connection() *grpc.ClientConn
Get(context.Context, *computepb.GetReservationSubBlockRequest, ...gax.CallOption) (*computepb.ReservationSubBlocksGetResponse, error)
List(context.Context, *computepb.ListReservationSubBlocksRequest, ...gax.CallOption) *ReservationSubBlockIterator
}
// ReservationSubBlocksClient is a client for interacting with Google Compute Engine API.
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
//
// The ReservationSubBlocks API.
type ReservationSubBlocksClient struct {
// The internal transport-dependent client.
internalClient internalReservationSubBlocksClient
// The call options for this service.
CallOptions *ReservationSubBlocksCallOptions
}
// Wrapper methods routed to the internal client.
// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *ReservationSubBlocksClient) Close() error {
return c.internalClient.Close()
}
// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *ReservationSubBlocksClient) setGoogleClientInfo(keyval ...string) {
c.internalClient.setGoogleClientInfo(keyval...)
}
// Connection returns a connection to the API service.
//
// Deprecated: Connections are now pooled so this method does not always
// return the same resource.
func (c *ReservationSubBlocksClient) Connection() *grpc.ClientConn {
return c.internalClient.Connection()
}
// Get retrieves information about the specified reservation subBlock.
func (c *ReservationSubBlocksClient) Get(ctx context.Context, req *computepb.GetReservationSubBlockRequest, opts ...gax.CallOption) (*computepb.ReservationSubBlocksGetResponse, error) {
return c.internalClient.Get(ctx, req, opts...)
}
// List retrieves a list of reservation subBlocks under a single reservation.
func (c *ReservationSubBlocksClient) List(ctx context.Context, req *computepb.ListReservationSubBlocksRequest, opts ...gax.CallOption) *ReservationSubBlockIterator {
return c.internalClient.List(ctx, req, opts...)
}
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
type reservationSubBlocksRESTClient struct {
// The http endpoint to connect to.
endpoint string
// The http client.
httpClient *http.Client
// The x-goog-* headers to be sent with each request.
xGoogHeaders []string
// Points back to the CallOptions field of the containing ReservationSubBlocksClient
CallOptions **ReservationSubBlocksCallOptions
logger *slog.Logger
}
// NewReservationSubBlocksRESTClient creates a new reservation sub blocks rest client.
//
// The ReservationSubBlocks API.
func NewReservationSubBlocksRESTClient(ctx context.Context, opts ...option.ClientOption) (*ReservationSubBlocksClient, error) {
clientOpts := append(defaultReservationSubBlocksRESTClientOptions(), opts...)
httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
if err != nil {
return nil, err
}
callOpts := defaultReservationSubBlocksRESTCallOptions()
c := &reservationSubBlocksRESTClient{
endpoint: endpoint,
httpClient: httpClient,
CallOptions: &callOpts,
logger: internaloption.GetLogger(opts),
}
c.setGoogleClientInfo()
return &ReservationSubBlocksClient{internalClient: c, CallOptions: callOpts}, nil
}
func defaultReservationSubBlocksRESTClientOptions() []option.ClientOption {
return []option.ClientOption{
internaloption.WithDefaultEndpoint("https://compute.googleapis.com"),
internaloption.WithDefaultEndpointTemplate("https://compute.UNIVERSE_DOMAIN"),
internaloption.WithDefaultMTLSEndpoint("https://compute.mtls.googleapis.com"),
internaloption.WithDefaultUniverseDomain("googleapis.com"),
internaloption.WithDefaultAudience("https://compute.googleapis.com/"),
internaloption.WithDefaultScopes(DefaultAuthScopes()...),
internaloption.EnableNewAuthLibrary(),
}
}
// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *reservationSubBlocksRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}
}
// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *reservationSubBlocksRESTClient) Close() error {
// Replace httpClient with nil to force cleanup.
c.httpClient = nil
return nil
}
// Connection returns a connection to the API service.
//
// Deprecated: This method always returns nil.
func (c *reservationSubBlocksRESTClient) Connection() *grpc.ClientConn {
return nil
}
// Get retrieves information about the specified reservation subBlock.
func (c *reservationSubBlocksRESTClient) Get(ctx context.Context, req *computepb.GetReservationSubBlockRequest, opts ...gax.CallOption) (*computepb.ReservationSubBlocksGetResponse, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/%v/reservationSubBlocks/%v", req.GetProject(), req.GetZone(), req.GetParentName(), req.GetReservationSubBlock())
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "zone", url.QueryEscape(req.GetZone()), "parent_name", url.QueryEscape(req.GetParentName()), "reservation_sub_block", url.QueryEscape(req.GetReservationSubBlock()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).Get[0:len((*c.CallOptions).Get):len((*c.CallOptions).Get)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.ReservationSubBlocksGetResponse{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "Get")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
return resp, nil
}
// List retrieves a list of reservation subBlocks under a single reservation.
func (c *reservationSubBlocksRESTClient) List(ctx context.Context, req *computepb.ListReservationSubBlocksRequest, opts ...gax.CallOption) *ReservationSubBlockIterator {
it := &ReservationSubBlockIterator{}
req = proto.Clone(req).(*computepb.ListReservationSubBlocksRequest)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
it.InternalFetch = func(pageSize int, pageToken string) ([]*computepb.ReservationSubBlock, string, error) {
resp := &computepb.ReservationSubBlocksListResponse{}
if pageToken != "" {
req.PageToken = proto.String(pageToken)
}
if pageSize > math.MaxInt32 {
req.MaxResults = proto.Uint32(uint32(math.MaxInt32))
} else if pageSize != 0 {
req.MaxResults = proto.Uint32(uint32(pageSize))
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, "", err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/%v/reservationSubBlocks", req.GetProject(), req.GetZone(), req.GetParentName())
params := url.Values{}
if req != nil && req.Filter != nil {
params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
}
if req != nil && req.MaxResults != nil {
params.Add("maxResults", fmt.Sprintf("%v", req.GetMaxResults()))
}
if req != nil && req.OrderBy != nil {
params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
}
if req != nil && req.PageToken != nil {
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
}
if req != nil && req.ReturnPartialSuccess != nil {
params.Add("returnPartialSuccess", fmt.Sprintf("%v", req.GetReturnPartialSuccess()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := append(c.xGoogHeaders, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return err
}
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "List")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, "", e
}
it.Response = resp
return resp.GetItems(), resp.GetNextPageToken(), nil
}
fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
if err != nil {
return "", err
}
it.items = append(it.items, items...)
return nextPageToken, nil
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
it.pageInfo.MaxSize = int(req.GetMaxResults())
it.pageInfo.Token = req.GetPageToken()
return it
}

View file

@ -48,6 +48,7 @@ type ReservationsCallOptions struct {
GetIamPolicy []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
PerformMaintenance []gax.CallOption
Resize []gax.CallOption
SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
@ -110,6 +111,9 @@ func defaultReservationsRESTCallOptions() *ReservationsCallOptions {
http.StatusServiceUnavailable)
}),
},
PerformMaintenance: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
Resize: []gax.CallOption{
gax.WithTimeout(600000 * time.Millisecond),
},
@ -136,6 +140,7 @@ type internalReservationsClient interface {
GetIamPolicy(context.Context, *computepb.GetIamPolicyReservationRequest, ...gax.CallOption) (*computepb.Policy, error)
Insert(context.Context, *computepb.InsertReservationRequest, ...gax.CallOption) (*Operation, error)
List(context.Context, *computepb.ListReservationsRequest, ...gax.CallOption) *ReservationIterator
PerformMaintenance(context.Context, *computepb.PerformMaintenanceReservationRequest, ...gax.CallOption) (*Operation, error)
Resize(context.Context, *computepb.ResizeReservationRequest, ...gax.CallOption) (*Operation, error)
SetIamPolicy(context.Context, *computepb.SetIamPolicyReservationRequest, ...gax.CallOption) (*computepb.Policy, error)
TestIamPermissions(context.Context, *computepb.TestIamPermissionsReservationRequest, ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
@ -207,6 +212,11 @@ func (c *ReservationsClient) List(ctx context.Context, req *computepb.ListReserv
return c.internalClient.List(ctx, req, opts...)
}
// PerformMaintenance perform maintenance on an extended reservation
func (c *ReservationsClient) PerformMaintenance(ctx context.Context, req *computepb.PerformMaintenanceReservationRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.PerformMaintenance(ctx, req, opts...)
}
// Resize resizes the reservation (applicable to standalone reservations only). For more information, read Modifying reservations.
func (c *ReservationsClient) Resize(ctx context.Context, req *computepb.ResizeReservationRequest, opts ...gax.CallOption) (*Operation, error) {
return c.internalClient.Resize(ctx, req, opts...)
@ -296,7 +306,7 @@ func defaultReservationsRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *reservationsRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}
@ -729,6 +739,73 @@ func (c *reservationsRESTClient) List(ctx context.Context, req *computepb.ListRe
return it
}
// PerformMaintenance perform maintenance on an extended reservation
func (c *reservationsRESTClient) PerformMaintenance(ctx context.Context, req *computepb.PerformMaintenanceReservationRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetReservationsPerformMaintenanceRequestResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/reservations/%v/performMaintenance", req.GetProject(), req.GetZone(), req.GetReservation())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project", url.QueryEscape(req.GetProject()), "zone", url.QueryEscape(req.GetZone()), "reservation", url.QueryEscape(req.GetReservation()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).PerformMaintenance[0:len((*c.CallOptions).PerformMaintenance):len((*c.CallOptions).PerformMaintenance)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &computepb.Operation{}
e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
baseUrl.Path = settings.Path
}
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return err
}
httpReq = httpReq.WithContext(ctx)
httpReq.Header = headers
buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "PerformMaintenance")
if err != nil {
return err
}
if err := unm.Unmarshal(buf, resp); err != nil {
return err
}
return nil
}, opts...)
if e != nil {
return nil, e
}
op := &Operation{
&zoneOperationsHandle{
c: c.operationClient,
proto: resp,
project: req.GetProject(),
zone: req.GetZone(),
},
}
return op, nil
}
// Resize resizes the reservation (applicable to standalone reservations only). For more information, read Modifying reservations.
func (c *reservationsRESTClient) Resize(ctx context.Context, req *computepb.ResizeReservationRequest, opts ...gax.CallOption) (*Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}

View file

@ -286,7 +286,7 @@ func defaultResourcePoliciesRESTClientOptions() []option.ClientOption {
// use by Google-written clients.
func (c *resourcePoliciesRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}

Some files were not shown because too many files have changed in this diff Show more