Source File
option.go
Belonging Package
google.golang.org/api/option
package option
import (
)
type ClientOption interface {
Apply(*internal.DialSettings)
}
func ( oauth2.TokenSource) ClientOption {
return withTokenSource{}
}
type withTokenSource struct{ ts oauth2.TokenSource }
func ( withTokenSource) ( *internal.DialSettings) {
.TokenSource = .ts
}
type withCredFile string
func ( withCredFile) ( *internal.DialSettings) {
.CredentialsFile = string()
}
func ( string) ClientOption {
return withCredFile()
}
func ( string) ClientOption {
return WithCredentialsFile()
}
func ( []byte) ClientOption {
return withCredentialsJSON()
}
type withCredentialsJSON []byte
func ( withCredentialsJSON) ( *internal.DialSettings) {
.CredentialsJSON = make([]byte, len())
copy(.CredentialsJSON, )
}
func ( string) ClientOption {
return withEndpoint()
}
type withEndpoint string
func ( withEndpoint) ( *internal.DialSettings) {
.Endpoint = string()
}
func ( ...string) ClientOption {
return withScopes()
}
type withScopes []string
func ( withScopes) ( *internal.DialSettings) {
.Scopes = make([]string, len())
copy(.Scopes, )
}
func ( string) ClientOption {
return withUA()
}
type withUA string
func ( withUA) ( *internal.DialSettings) { .UserAgent = string() }
func ( *http.Client) ClientOption {
return withHTTPClient{}
}
type withHTTPClient struct{ client *http.Client }
func ( withHTTPClient) ( *internal.DialSettings) {
.HTTPClient = .client
}
func ( *grpc.ClientConn) ClientOption {
return withGRPCConn{}
}
type withGRPCConn struct{ conn *grpc.ClientConn }
func ( withGRPCConn) ( *internal.DialSettings) {
.GRPCConn = .conn
}
func ( grpc.DialOption) ClientOption {
return withGRPCDialOption{}
}
type withGRPCDialOption struct{ opt grpc.DialOption }
func ( withGRPCDialOption) ( *internal.DialSettings) {
.GRPCDialOpts = append(.GRPCDialOpts, .opt)
}
func ( int) ClientOption {
return withGRPCConnectionPool()
}
type withGRPCConnectionPool int
func ( withGRPCConnectionPool) ( *internal.DialSettings) {
.GRPCConnPoolSize = int()
}
func ( string) ClientOption {
return withAPIKey()
}
type withAPIKey string
func ( withAPIKey) ( *internal.DialSettings) { .APIKey = string() }
func ( ...string) ClientOption {
return withAudiences()
}
type withAudiences []string
func ( withAudiences) ( *internal.DialSettings) {
.Audiences = make([]string, len())
copy(.Audiences, )
}
func () ClientOption {
return withoutAuthentication{}
}
type withoutAuthentication struct{}
func ( withoutAuthentication) ( *internal.DialSettings) { .NoAuth = true }
func ( string) ClientOption {
return withQuotaProject()
}
type withQuotaProject string
func ( withQuotaProject) ( *internal.DialSettings) {
.QuotaProject = string()
}
func ( string) ClientOption {
return withRequestReason()
}
type withRequestReason string
func ( withRequestReason) ( *internal.DialSettings) {
.RequestReason = string()
}
func () ClientOption {
return withTelemetryDisabled{}
}
type withTelemetryDisabled struct{}
func ( withTelemetryDisabled) ( *internal.DialSettings) {
.TelemetryDisabled = true
}
type ClientCertSource = func(*tls.CertificateRequestInfo) (*tls.Certificate, error)
func ( ClientCertSource) ClientOption {
return withClientCertSource{}
}
type withClientCertSource struct{ s ClientCertSource }
func ( withClientCertSource) ( *internal.DialSettings) {
.ClientCertSource = .s
}
func ( string, ...string) ClientOption {
return impersonateServiceAccount{
target: ,
delegates: ,
}
}
type impersonateServiceAccount struct {
target string
delegates []string
}
func ( impersonateServiceAccount) ( *internal.DialSettings) {
.ImpersonationConfig = &impersonate.Config{
Target: .target,
}
.ImpersonationConfig.Delegates = make([]string, len(.delegates))
copy(.ImpersonationConfig.Delegates, .delegates)
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |