Movatterモバイル変換


[0]ホーム

URL:


internaloption

package
v0.257.0Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License:BSD-3-ClauseImports:7Imported by:2,565

Details

Repository

github.com/googleapis/google-api-go-client

Links

Documentation

Overview

Package internaloption contains options used internally by Google client code.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

funcAllowHardBoundTokensadded inv0.221.0

func AllowHardBoundTokens(protocol ...string)option.ClientOption

AllowHardBoundTokens returns a ClientOption that allows libraries to request a hard-bound token.Obtaining hard-bound tokens requires the connection to be established using either ApplicationLayer Transport Security (ALTS) or mutual TLS (mTLS) with S2A. For more information on ALTS,see:https://cloud.google.com/docs/security/encryption-in-transit/application-layer-transport-security

The AllowHardBoundTokens option accepts the following values (or a combination thereof):

  • "MTLS_S2A": Allows obtaining hard-bound tokens when the connection uses mutual TLS with S2A.
  • "ALTS": Allows obtaining hard-bound tokens when the connection uses ALTS.

For example, to allow obtaining hard-bound tokens with either MTLS_S2A or ALTS, you wouldprovide both values (e.g., {"MTLS_S2A","ALTS"}). If no value is provided, hard-bound tokenswill not be requested.

It should only be used internally by generated clients.This is an EXPERIMENTAL API and may be changed or removed in the future.

funcAllowNonDefaultServiceAccountadded inv0.55.0

func AllowNonDefaultServiceAccount(ndbool)option.ClientOption

AllowNonDefaultServiceAccount returns a ClientOption that overrides the defaultrequirement for using the default service account for DirectPath.

It should only be used internally by generated clients.This is an EXPERIMENTAL API and may be changed or removed in the future.

funcAuthCredsadded inv0.210.0

func AuthCreds(ctxcontext.Context, opts []option.ClientOption) (*auth.Credentials,error)

AuthCreds returnscloud.google.com/go/auth.Credentials using the followingoptions provided viaoption.ClientOption, including legacy oauth2/googleoptions, in this order:

If there are no applicable credentials options, then it passes thefollowing options tocloud.google.com/go/auth/credentials.DetectDefault andreturns the result:

This function should only be used internally by generated clients. This is anEXPERIMENTAL API and may be changed or removed in the future.

funcEnableAsyncRefreshDryRunadded inv0.210.0

func EnableAsyncRefreshDryRun(errHandler func())option.ClientOption

EnableAsyncRefreshDryRun returns a ClientOption that specifies if libraries in thismodule should asynchronously refresh auth token in parallel to sync refresh.

This option can be used to determine whether refreshing the token asymnchronouslyprior to its actual expiry works without any issues in a particular environment.

errHandler function will be called when there is an error while refreshingthe token asynchronously.

This is an EXPERIMENTAL option and will be removed in the future.TODO(b/372244283): Remove after b/358175516 has been fixed

funcEnableDirectPathadded inv0.35.0

func EnableDirectPath(dpbool)option.ClientOption

EnableDirectPath returns a ClientOption that overrides the defaultattempt to use DirectPath.

It should only be used internally by generated clients.This is an EXPERIMENTAL API and may be changed or removed in the future.

funcEnableDirectPathXdsadded inv0.119.0

func EnableDirectPathXds()option.ClientOption

EnableDirectPathXds returns a ClientOption that overrides the defaultDirectPath type. It is only valid when DirectPath is enabled.

It should only be used internally by generated clients.This is an EXPERIMENTAL API and may be changed or removed in the future.

funcEnableJwtWithScopeadded inv0.49.0

func EnableJwtWithScope()option.ClientOption

EnableJwtWithScope returns a ClientOption that specifies if scope can be usedwith self-signed JWT.

EnableJwtWithScope is ignored when option.WithUniverseDomain is setto a value other than the Google Default Universe (GDU) of "googleapis.com".For non-GDU domains, token exchange is impossible and services mustsupport self-signed JWTs with scopes.

funcEnableNewAuthLibraryadded inv0.142.0

func EnableNewAuthLibrary()option.ClientOption

EnableNewAuthLibrary returns a ClientOption that specifies if libraries in thismodule to delegate auth to our new library. This option will be removed inthe future once all clients have been moved to the new auth layer.

funcGetLoggeradded inv0.206.0

func GetLogger(opts []option.ClientOption) *slog.Logger

GetLogger is a helper for client libraries to extract theslog.Logger fromthe provided options or return a default logger if one is not found.

It should only be used internally by generated clients. This is an EXPERIMENTAL APIand may be changed or removed in the future.

funcSkipDialSettingsValidationadded inv0.30.0

func SkipDialSettingsValidation()option.ClientOption

SkipDialSettingsValidation bypasses validation on ClientOptions.

It should only be used internally.

funcWithCredentialsadded inv0.56.0

func WithCredentials(creds *google.Credentials)option.ClientOption

WithCredentials returns a client option to specify credentials which will be used to authenticate API calls.This credential takes precedence over all other credential options.

funcWithDefaultAudienceadded inv0.36.0

func WithDefaultAudience(audiencestring)option.ClientOption

WithDefaultAudience returns a ClientOption that specifies a default audienceto be used as the audience field ("aud") for the JWT token authentication.

It should only be used internally by generated clients.

funcWithDefaultEndpointdeprecated

func WithDefaultEndpoint(urlstring)option.ClientOption

WithDefaultEndpoint is an option that indicates the default endpoint.

It should only be used internally by generated clients.

This is similar to WithEndpoint, but allows us to determine whether the user has overridden the default endpoint.

Deprecated: WithDefaultEndpoint does not support setting the universe domain.Use WithDefaultEndpointTemplate and WithDefaultUniverseDomain to compose thedefault endpoint instead.

funcWithDefaultEndpointTemplateadded inv0.155.0

func WithDefaultEndpointTemplate(urlstring)option.ClientOption

WithDefaultEndpointTemplate provides a template for creating the endpointusing a universe domain. See also WithDefaultUniverseDomain andoption.WithUniverseDomain. The placeholder UNIVERSE_DOMAIN should be usedinstead of a concrete universe domain such as "googleapis.com".

Example: WithDefaultEndpointTemplate("https://logging.UNIVERSE_DOMAIN/")

It should only be used internally by generated clients.

funcWithDefaultMTLSEndpointadded inv0.29.0

func WithDefaultMTLSEndpoint(urlstring)option.ClientOption

WithDefaultMTLSEndpoint is an option that indicates the default mTLS endpoint.

It should only be used internally by generated clients.

funcWithDefaultScopesadded inv0.36.0

func WithDefaultScopes(scope ...string)option.ClientOption

WithDefaultScopes returns a ClientOption that overrides the default OAuth2scopes to be used for a service.

It should only be used internally by generated clients.

funcWithDefaultUniverseDomainadded inv0.153.0

func WithDefaultUniverseDomain(udstring)option.ClientOption

WithDefaultUniverseDomain returns a ClientOption that sets the default universe domain.

It should only be used internally by generated clients.

This is similar to the public WithUniverse, but allows us to determine whether the user hasoverridden the default universe.

Types

typeEmbeddableAdapteradded inv0.106.0

type EmbeddableAdapter struct{}

EmbeddableAdapter is a no-op option.ClientOption that allow libraries tocreate their own client options by embedding this type into their ownclient-specific option wrapper. See example for usage.

Example
package mainimport ("context""fmt""google.golang.org/api/option""google.golang.org/api/option/internaloption")type config struct {i int}type clientSpecificOption interface {option.ClientOptionApplyOpt(*config)}func WithFavoriteNumber(i int) option.ClientOption {return &withFavoriteNumber{i: i}}type withFavoriteNumber struct {internaloption.EmbeddableAdapteri int}func (w *withFavoriteNumber) ApplyOpt(c *config) {c.i = w.i}type Foo struct {i int}func NewFoo(ctx context.Context, opts ...option.ClientOption) (*Foo, error) {var conf configfor _, opt := range opts {if fooOpt, ok := opt.(clientSpecificOption); ok {fooOpt.ApplyOpt(&conf)}}// Pass options to internals for dialing. All client-specific options will// be no-ops.return &Foo{i: conf.i}, nil}func (f *Foo) Number() int { return f.i }func main() {f, err := NewFoo(context.Background(), WithFavoriteNumber(42))if err != nil {// TODO: handle error}fmt.Println(f.Number())}
Output:42

func (*EmbeddableAdapter)Applyadded inv0.106.0

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp