diff --git a/gsuiteaddons/apiv1/doc.go b/gsuiteaddons/apiv1/doc.go new file mode 100644 index 00000000000..6825ab71ecd --- /dev/null +++ b/gsuiteaddons/apiv1/doc.go @@ -0,0 +1,114 @@ +// Copyright 2021 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 gsuiteaddons is an auto-generated package for the +// Google Workspace Add-ons API. +// +// Use of Context +// +// The ctx passed to NewClient is used for authentication requests and +// for creating the underlying connection, but is not used for subsequent calls. +// Individual methods on the client use the ctx given to them. +// +// To close the open connection, use the Close() method. +// +// For information about setting deadlines, reusing contexts, and more +// please visit pkg.go.dev/cloud.google.com/go. +package gsuiteaddons // import "cloud.google.com/go/gsuiteaddons/apiv1" + +import ( + "context" + "os" + "runtime" + "strconv" + "strings" + "unicode" + + "google.golang.org/api/option" + "google.golang.org/grpc/metadata" +) + +// For more information on implementing a client constructor hook, see +// https://github.com/googleapis/google-cloud-go/wiki/Customizing-constructors. +type clientHookParams struct{} +type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) + +const versionClient = "20210510" + +func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { + out, _ := metadata.FromOutgoingContext(ctx) + out = out.Copy() + for _, md := range mds { + for k, v := range md { + out[k] = append(out[k], v...) + } + } + return metadata.NewOutgoingContext(ctx, out) +} + +func checkDisableDeadlines() (bool, error) { + raw, ok := os.LookupEnv("GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE") + if !ok { + return false, nil + } + + b, err := strconv.ParseBool(raw) + return b, err +} + +// DefaultAuthScopes reports the default set of authentication scopes to use with this package. +func DefaultAuthScopes() []string { + return []string{ + "https://www.googleapis.com/auth/cloud-platform", + } +} + +// versionGo returns the Go runtime version. The returned string +// has no whitespace, suitable for reporting in header. +func versionGo() string { + const develPrefix = "devel +" + + s := runtime.Version() + if strings.HasPrefix(s, develPrefix) { + s = s[len(develPrefix):] + if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 { + s = s[:p] + } + return s + } + + notSemverRune := func(r rune) bool { + return !strings.ContainsRune("0123456789.", r) + } + + if strings.HasPrefix(s, "go1") { + s = s[2:] + var prerelease string + if p := strings.IndexFunc(s, notSemverRune); p >= 0 { + s, prerelease = s[:p], s[p:] + } + if strings.HasSuffix(s, ".") { + s += "0" + } else if strings.Count(s, ".") < 2 { + s += ".0" + } + if prerelease != "" { + s += "-" + prerelease + } + return s + } + return "UNKNOWN" +} diff --git a/gsuiteaddons/apiv1/g_suite_add_ons_client.go b/gsuiteaddons/apiv1/g_suite_add_ons_client.go new file mode 100644 index 00000000000..49254f814af --- /dev/null +++ b/gsuiteaddons/apiv1/g_suite_add_ons_client.go @@ -0,0 +1,503 @@ +// Copyright 2021 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 gsuiteaddons + +import ( + "context" + "fmt" + "math" + "net/url" + "time" + + "github.com/golang/protobuf/proto" + gax "github.com/googleapis/gax-go/v2" + "google.golang.org/api/iterator" + "google.golang.org/api/option" + "google.golang.org/api/option/internaloption" + gtransport "google.golang.org/api/transport/grpc" + gsuiteaddonspb "google.golang.org/genproto/googleapis/cloud/gsuiteaddons/v1" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" +) + +var newClientHook clientHook + +// CallOptions contains the retry settings for each method of Client. +type CallOptions struct { + GetAuthorization []gax.CallOption + CreateDeployment []gax.CallOption + ReplaceDeployment []gax.CallOption + GetDeployment []gax.CallOption + ListDeployments []gax.CallOption + DeleteDeployment []gax.CallOption + InstallDeployment []gax.CallOption + UninstallDeployment []gax.CallOption + GetInstallStatus []gax.CallOption +} + +func defaultClientOptions() []option.ClientOption { + return []option.ClientOption{ + internaloption.WithDefaultEndpoint("gsuiteaddons.googleapis.com:443"), + internaloption.WithDefaultMTLSEndpoint("gsuiteaddons.mtls.googleapis.com:443"), + internaloption.WithDefaultAudience("https://gsuiteaddons.googleapis.com/"), + internaloption.WithDefaultScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultCallOptions() *CallOptions { + return &CallOptions{ + GetAuthorization: []gax.CallOption{}, + CreateDeployment: []gax.CallOption{}, + ReplaceDeployment: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + codes.Unknown, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + GetDeployment: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + codes.Unknown, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + ListDeployments: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + codes.Unknown, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + DeleteDeployment: []gax.CallOption{}, + InstallDeployment: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + codes.Unknown, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + UninstallDeployment: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + codes.Unknown, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + GetInstallStatus: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + codes.Unknown, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + } +} + +// Client is a client for interacting with Google Workspace Add-ons API. +// +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type Client struct { + // Connection pool of gRPC connections to the service. + connPool gtransport.ConnPool + + // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE + disableDeadlines bool + + // The gRPC API client. + client gsuiteaddonspb.GSuiteAddOnsClient + + // The call options for this service. + CallOptions *CallOptions + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewClient creates a new g suite add ons client. +// +// A service for managing Google Workspace Add-ons deployments. +// +// A Google Workspace Add-on is a third-party embedded component that can be +// installed in Google Workspace Applications like Gmail, Calendar, Drive, and +// the Google Docs, Sheets, and Slides editors. Google Workspace Add-ons can +// display UI cards, receive contextual information from the host application, +// and perform actions in the host application (See: +// https://developers.google.com/gsuite/add-ons/overview (at https://developers.google.com/gsuite/add-ons/overview) for more information). +// +// A Google Workspace Add-on deployment resource specifies metadata about the +// add-on, including a specification of the entry points in the host application +// that trigger add-on executions (see: +// https://developers.google.com/gsuite/add-ons/concepts/gsuite-manifests (at https://developers.google.com/gsuite/add-ons/concepts/gsuite-manifests)). +// Add-on deployments defined via the Google Workspace Add-ons API define their +// entrypoints using HTTPS URLs (See: +// https://developers.google.com/gsuite/add-ons/guides/alternate-runtimes (at https://developers.google.com/gsuite/add-ons/guides/alternate-runtimes)), +// +// A Google Workspace Add-on deployment can be installed in developer mode, +// which allows an add-on developer to test the experience an end-user would see +// when installing and running the add-on in their G Suite applications. When +// running in developer mode, more detailed error messages are exposed in the +// add-on UI to aid in debugging. +// +// A Google Workspace Add-on deployment can be published to Google Workspace +// Marketplace, which allows other Google Workspace users to discover and +// install the add-on. See: +// https://developers.google.com/gsuite/add-ons/how-tos/publish-add-on-overview (at https://developers.google.com/gsuite/add-ons/how-tos/publish-add-on-overview) +// for details. +func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) { + clientOpts := defaultClientOptions() + + if newClientHook != nil { + hookOpts, err := newClientHook(ctx, clientHookParams{}) + if err != nil { + return nil, err + } + clientOpts = append(clientOpts, hookOpts...) + } + + disableDeadlines, err := checkDisableDeadlines() + if err != nil { + return nil, err + } + + connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) + if err != nil { + return nil, err + } + c := &Client{ + connPool: connPool, + disableDeadlines: disableDeadlines, + CallOptions: defaultCallOptions(), + + client: gsuiteaddonspb.NewGSuiteAddOnsClient(connPool), + } + c.setGoogleClientInfo() + + return c, nil +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *Client) Connection() *grpc.ClientConn { + return c.connPool.Conn() +} + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *Client) Close() error { + return c.connPool.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 *Client) setGoogleClientInfo(keyval ...string) { + kv := append([]string{"gl-go", versionGo()}, keyval...) + kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) + c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) +} + +// GetAuthorization gets the authorization information for deployments in a given project. +func (c *Client) GetAuthorization(ctx context.Context, req *gsuiteaddonspb.GetAuthorizationRequest, opts ...gax.CallOption) (*gsuiteaddonspb.Authorization, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 120000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetAuthorization[0:len(c.CallOptions.GetAuthorization):len(c.CallOptions.GetAuthorization)], opts...) + var resp *gsuiteaddonspb.Authorization + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetAuthorization(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// CreateDeployment creates a deployment with the specified name and configuration. +func (c *Client) CreateDeployment(ctx context.Context, req *gsuiteaddonspb.CreateDeploymentRequest, opts ...gax.CallOption) (*gsuiteaddonspb.Deployment, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.CreateDeployment[0:len(c.CallOptions.CreateDeployment):len(c.CallOptions.CreateDeployment)], opts...) + var resp *gsuiteaddonspb.Deployment + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.CreateDeployment(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ReplaceDeployment creates or replaces a deployment with the specified name. +func (c *Client) ReplaceDeployment(ctx context.Context, req *gsuiteaddonspb.ReplaceDeploymentRequest, opts ...gax.CallOption) (*gsuiteaddonspb.Deployment, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "deployment.name", url.QueryEscape(req.GetDeployment().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ReplaceDeployment[0:len(c.CallOptions.ReplaceDeployment):len(c.CallOptions.ReplaceDeployment)], opts...) + var resp *gsuiteaddonspb.Deployment + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.ReplaceDeployment(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// GetDeployment gets the deployment with the specified name. +func (c *Client) GetDeployment(ctx context.Context, req *gsuiteaddonspb.GetDeploymentRequest, opts ...gax.CallOption) (*gsuiteaddonspb.Deployment, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetDeployment[0:len(c.CallOptions.GetDeployment):len(c.CallOptions.GetDeployment)], opts...) + var resp *gsuiteaddonspb.Deployment + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetDeployment(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListDeployments lists all deployments in a particular project. +func (c *Client) ListDeployments(ctx context.Context, req *gsuiteaddonspb.ListDeploymentsRequest, opts ...gax.CallOption) *DeploymentIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ListDeployments[0:len(c.CallOptions.ListDeployments):len(c.CallOptions.ListDeployments)], opts...) + it := &DeploymentIterator{} + req = proto.Clone(req).(*gsuiteaddonspb.ListDeploymentsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*gsuiteaddonspb.Deployment, string, error) { + var resp *gsuiteaddonspb.ListDeploymentsResponse + req.PageToken = pageToken + if pageSize > math.MaxInt32 { + req.PageSize = math.MaxInt32 + } else { + req.PageSize = int32(pageSize) + } + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.ListDeployments(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetDeployments(), 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.GetPageSize()) + it.pageInfo.Token = req.GetPageToken() + return it +} + +// DeleteDeployment deletes the deployment with the given name. +func (c *Client) DeleteDeployment(ctx context.Context, req *gsuiteaddonspb.DeleteDeploymentRequest, opts ...gax.CallOption) error { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.DeleteDeployment[0:len(c.CallOptions.DeleteDeployment):len(c.CallOptions.DeleteDeployment)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.client.DeleteDeployment(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +// InstallDeployment installs a deployment in developer mode. +// See: +// https://developers.google.com/gsuite/add-ons/how-tos/testing-gsuite-addons (at https://developers.google.com/gsuite/add-ons/how-tos/testing-gsuite-addons). +func (c *Client) InstallDeployment(ctx context.Context, req *gsuiteaddonspb.InstallDeploymentRequest, opts ...gax.CallOption) error { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.InstallDeployment[0:len(c.CallOptions.InstallDeployment):len(c.CallOptions.InstallDeployment)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.client.InstallDeployment(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +// UninstallDeployment uninstalls a developer mode deployment. +// See: +// https://developers.google.com/gsuite/add-ons/how-tos/testing-gsuite-addons (at https://developers.google.com/gsuite/add-ons/how-tos/testing-gsuite-addons). +func (c *Client) UninstallDeployment(ctx context.Context, req *gsuiteaddonspb.UninstallDeploymentRequest, opts ...gax.CallOption) error { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.UninstallDeployment[0:len(c.CallOptions.UninstallDeployment):len(c.CallOptions.UninstallDeployment)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.client.UninstallDeployment(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +// GetInstallStatus fetches the install status of a developer mode deployment. +func (c *Client) GetInstallStatus(ctx context.Context, req *gsuiteaddonspb.GetInstallStatusRequest, opts ...gax.CallOption) (*gsuiteaddonspb.InstallStatus, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 10000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetInstallStatus[0:len(c.CallOptions.GetInstallStatus):len(c.CallOptions.GetInstallStatus)], opts...) + var resp *gsuiteaddonspb.InstallStatus + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetInstallStatus(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// DeploymentIterator manages a stream of *gsuiteaddonspb.Deployment. +type DeploymentIterator struct { + items []*gsuiteaddonspb.Deployment + 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 []*gsuiteaddonspb.Deployment, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *DeploymentIterator) 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 *DeploymentIterator) Next() (*gsuiteaddonspb.Deployment, error) { + var item *gsuiteaddonspb.Deployment + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *DeploymentIterator) bufLen() int { + return len(it.items) +} + +func (it *DeploymentIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} diff --git a/gsuiteaddons/apiv1/g_suite_add_ons_client_example_test.go b/gsuiteaddons/apiv1/g_suite_add_ons_client_example_test.go new file mode 100644 index 00000000000..c903b757a0e --- /dev/null +++ b/gsuiteaddons/apiv1/g_suite_add_ons_client_example_test.go @@ -0,0 +1,210 @@ +// Copyright 2021 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 gsuiteaddons_test + +import ( + "context" + + gsuiteaddons "cloud.google.com/go/gsuiteaddons/apiv1" + "google.golang.org/api/iterator" + gsuiteaddonspb "google.golang.org/genproto/googleapis/cloud/gsuiteaddons/v1" +) + +func ExampleNewClient() { + ctx := context.Background() + c, err := gsuiteaddons.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use client. + _ = c +} + +func ExampleClient_GetAuthorization() { + // import gsuiteaddonspb "google.golang.org/genproto/googleapis/cloud/gsuiteaddons/v1" + + ctx := context.Background() + c, err := gsuiteaddons.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gsuiteaddonspb.GetAuthorizationRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetAuthorization(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_CreateDeployment() { + // import gsuiteaddonspb "google.golang.org/genproto/googleapis/cloud/gsuiteaddons/v1" + + ctx := context.Background() + c, err := gsuiteaddons.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gsuiteaddonspb.CreateDeploymentRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.CreateDeployment(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ReplaceDeployment() { + // import gsuiteaddonspb "google.golang.org/genproto/googleapis/cloud/gsuiteaddons/v1" + + ctx := context.Background() + c, err := gsuiteaddons.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gsuiteaddonspb.ReplaceDeploymentRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.ReplaceDeployment(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_GetDeployment() { + // import gsuiteaddonspb "google.golang.org/genproto/googleapis/cloud/gsuiteaddons/v1" + + ctx := context.Background() + c, err := gsuiteaddons.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gsuiteaddonspb.GetDeploymentRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetDeployment(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListDeployments() { + // import gsuiteaddonspb "google.golang.org/genproto/googleapis/cloud/gsuiteaddons/v1" + // import "google.golang.org/api/iterator" + + ctx := context.Background() + c, err := gsuiteaddons.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gsuiteaddonspb.ListDeploymentsRequest{ + // TODO: Fill request struct fields. + } + it := c.ListDeployments(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleClient_DeleteDeployment() { + ctx := context.Background() + c, err := gsuiteaddons.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gsuiteaddonspb.DeleteDeploymentRequest{ + // TODO: Fill request struct fields. + } + err = c.DeleteDeployment(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_InstallDeployment() { + ctx := context.Background() + c, err := gsuiteaddons.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gsuiteaddonspb.InstallDeploymentRequest{ + // TODO: Fill request struct fields. + } + err = c.InstallDeployment(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_UninstallDeployment() { + ctx := context.Background() + c, err := gsuiteaddons.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gsuiteaddonspb.UninstallDeploymentRequest{ + // TODO: Fill request struct fields. + } + err = c.UninstallDeployment(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_GetInstallStatus() { + // import gsuiteaddonspb "google.golang.org/genproto/googleapis/cloud/gsuiteaddons/v1" + + ctx := context.Background() + c, err := gsuiteaddons.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gsuiteaddonspb.GetInstallStatusRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetInstallStatus(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} diff --git a/gsuiteaddons/apiv1/gapic_metadata.json b/gsuiteaddons/apiv1/gapic_metadata.json new file mode 100644 index 00000000000..178d0b85085 --- /dev/null +++ b/gsuiteaddons/apiv1/gapic_metadata.json @@ -0,0 +1,63 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods.", + "language": "go", + "protoPackage": "google.cloud.gsuiteaddons.v1", + "libraryPackage": "cloud.google.com/go/gsuiteaddons/apiv1", + "services": { + "GSuiteAddOns": { + "clients": { + "grpc": { + "libraryClient": "Client", + "rpcs": { + "CreateDeployment": { + "methods": [ + "CreateDeployment" + ] + }, + "DeleteDeployment": { + "methods": [ + "DeleteDeployment" + ] + }, + "GetAuthorization": { + "methods": [ + "GetAuthorization" + ] + }, + "GetDeployment": { + "methods": [ + "GetDeployment" + ] + }, + "GetInstallStatus": { + "methods": [ + "GetInstallStatus" + ] + }, + "InstallDeployment": { + "methods": [ + "InstallDeployment" + ] + }, + "ListDeployments": { + "methods": [ + "ListDeployments" + ] + }, + "ReplaceDeployment": { + "methods": [ + "ReplaceDeployment" + ] + }, + "UninstallDeployment": { + "methods": [ + "UninstallDeployment" + ] + } + } + } + } + } + } +} diff --git a/internal/.repo-metadata-full.json b/internal/.repo-metadata-full.json index 895bf512bf2..8987f0c59e5 100644 --- a/internal/.repo-metadata-full.json +++ b/internal/.repo-metadata-full.json @@ -566,6 +566,15 @@ "release_level": "beta", "library_type": "" }, + "cloud.google.com/go/gsuiteaddons/apiv1": { + "distribution_name": "cloud.google.com/go/gsuiteaddons/apiv1", + "description": "Google Workspace Add-ons API", + "language": "Go", + "client_library_type": "generated", + "docs_url": "https://pkg.go.dev/cloud.google.com/go/gsuiteaddons/apiv1", + "release_level": "beta", + "library_type": "" + }, "cloud.google.com/go/iam": { "distribution_name": "cloud.google.com/go/iam", "description": "Cloud IAM", diff --git a/internal/gapicgen/generator/config.go b/internal/gapicgen/generator/config.go index f1ec4d55528..e37bbe088dc 100644 --- a/internal/gapicgen/generator/config.go +++ b/internal/gapicgen/generator/config.go @@ -1125,4 +1125,13 @@ var microgenGapicConfigs = []*microgenConfig{ apiServiceConfigPath: "google/area120/tables/v1alpha1/area120tables_v1alpha1.yaml", releaseLevel: "alpha", }, + { + inputDirectoryPath: "google/cloud/gsuiteaddons/v1", + pkg: "gsuiteaddons", + importPath: "cloud.google.com/go/gsuiteaddons/apiv1", + gRPCServiceConfigPath: "google/cloud/gsuiteaddons/v1/gsuiteaddons_grpc_service_config.json", + apiServiceConfigPath: "google/cloud/gsuiteaddons/v1/gsuiteaddons_v1.yaml", + // GA after 2021/06/10 + releaseLevel: "beta", + }, } diff --git a/internal/godocfx/main.go b/internal/godocfx/main.go index ff7fb7b0281..b9fc2aa2565 100644 --- a/internal/godocfx/main.go +++ b/internal/godocfx/main.go @@ -151,6 +151,7 @@ func process(mod indexEntry, tempDir, outDir string, print bool) error { filter := []string{ "cloud.google.com/go/analytics", "cloud.google.com/go/area120", + "cloud.google.com/go/gsuiteaddons", } r, err := parse(mod.Path+"/...", tempDir, optionalExtraFiles, filter) if err != nil {