Add autogenerated clients: debugger, iam, and trace
Previous approval at
https://github.com/googleapis/api-client-staging/pull/80
Change-Id: I901aa5e017fa2e3973a7e0dfdd9cc6666ae5c19d
Reviewed-on: https://code-review.googlesource.com/8291
Reviewed-by: John Dethridge <jcd@google.com>
diff --git a/debugger/apiv2/controller2_client.go b/debugger/apiv2/controller2_client.go
new file mode 100644
index 0000000..2ee74c3
--- /dev/null
+++ b/debugger/apiv2/controller2_client.go
@@ -0,0 +1,220 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// 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
+//
+// http://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.
+
+// AUTO-GENERATED CODE. DO NOT EDIT.
+
+package debugger
+
+import (
+ "fmt"
+ "runtime"
+ "time"
+
+ gax "github.com/googleapis/gax-go"
+ "golang.org/x/net/context"
+ "google.golang.org/api/option"
+ "google.golang.org/api/transport"
+ clouddebuggerpb "google.golang.org/genproto/googleapis/devtools/clouddebugger/v2"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/metadata"
+)
+
+// Controller2CallOptions contains the retry settings for each method of Controller2Client.
+type Controller2CallOptions struct {
+ RegisterDebuggee []gax.CallOption
+ ListActiveBreakpoints []gax.CallOption
+ UpdateActiveBreakpoint []gax.CallOption
+}
+
+func defaultController2ClientOptions() []option.ClientOption {
+ return []option.ClientOption{
+ option.WithEndpoint("clouddebugger.googleapis.com:443"),
+ option.WithScopes(
+ "https://www.googleapis.com/auth/cloud-platform",
+ "https://www.googleapis.com/auth/cloud_debugger",
+ ),
+ }
+}
+
+func defaultController2CallOptions() *Controller2CallOptions {
+ retry := map[[2]string][]gax.CallOption{
+ {"default", "idempotent"}: {
+ gax.WithRetry(func() gax.Retryer {
+ return gax.OnCodes([]codes.Code{
+ codes.DeadlineExceeded,
+ codes.Unavailable,
+ }, gax.Backoff{
+ Initial: 100 * time.Millisecond,
+ Max: 60000 * time.Millisecond,
+ Multiplier: 1.3,
+ })
+ }),
+ },
+ }
+ return &Controller2CallOptions{
+ RegisterDebuggee: retry[[2]string{"default", "non_idempotent"}],
+ ListActiveBreakpoints: retry[[2]string{"default", "idempotent"}],
+ UpdateActiveBreakpoint: retry[[2]string{"default", "idempotent"}],
+ }
+}
+
+// Controller2Client is a client for interacting with Stackdriver Debugger API.
+type Controller2Client struct {
+ // The connection to the service.
+ conn *grpc.ClientConn
+
+ // The gRPC API client.
+ controller2Client clouddebuggerpb.Controller2Client
+
+ // The call options for this service.
+ CallOptions *Controller2CallOptions
+
+ // The metadata to be sent with each request.
+ metadata map[string][]string
+}
+
+// NewController2Client creates a new controller2 client.
+//
+// The Controller service provides the API for orchestrating a collection of
+// debugger agents to perform debugging tasks. These agents are each attached
+// to a process of an application which may include one or more replicas.
+//
+// The debugger agents register with the Controller to identify the application
+// being debugged, the Debuggee. All agents that register with the same data,
+// represent the same Debuggee, and are assigned the same `debuggee_id`.
+//
+// The debugger agents call the Controller to retrieve the list of active
+// Breakpoints. Agents with the same `debuggee_id` get the same breakpoints
+// list. An agent that can fulfill the breakpoint request updates the
+// Controller with the breakpoint result. The controller selects the first
+// result received and discards the rest of the results.
+// Agents that poll again for active breakpoints will no longer have
+// the completed breakpoint in the list and should remove that breakpoint from
+// their attached process.
+//
+// The Controller service does not provide a way to retrieve the results of
+// a completed breakpoint. This functionality is available using the Debugger
+// service.
+func NewController2Client(ctx context.Context, opts ...option.ClientOption) (*Controller2Client, error) {
+ conn, err := transport.DialGRPC(ctx, append(defaultController2ClientOptions(), opts...)...)
+ if err != nil {
+ return nil, err
+ }
+ c := &Controller2Client{
+ conn: conn,
+ CallOptions: defaultController2CallOptions(),
+
+ controller2Client: clouddebuggerpb.NewController2Client(conn),
+ }
+ c.SetGoogleClientInfo("gax", gax.Version)
+ return c, nil
+}
+
+// Connection returns the client's connection to the API service.
+func (c *Controller2Client) Connection() *grpc.ClientConn {
+ return c.conn
+}
+
+// Close closes the connection to the API service. The user should invoke this when
+// the client is no longer required.
+func (c *Controller2Client) Close() error {
+ return c.conn.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 *Controller2Client) SetGoogleClientInfo(name, version string) {
+ c.metadata = map[string][]string{
+ "x-goog-api-client": {fmt.Sprintf("%s/%s %s gax/%s go/%s", name, version, gapicNameVersion, gax.Version, runtime.Version())},
+ }
+}
+
+// RegisterDebuggee registers the debuggee with the controller service.
+//
+// All agents attached to the same application should call this method with
+// the same request content to get back the same stable `debuggee_id`. Agents
+// should call this method again whenever `google.rpc.Code.NOT_FOUND` is
+// returned from any controller method.
+//
+// This allows the controller service to disable the agent or recover from any
+// data loss. If the debuggee is disabled by the server, the response will
+// have `is_disabled` set to `true`.
+func (c *Controller2Client) RegisterDebuggee(ctx context.Context, req *clouddebuggerpb.RegisterDebuggeeRequest) (*clouddebuggerpb.RegisterDebuggeeResponse, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *clouddebuggerpb.RegisterDebuggeeResponse
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.controller2Client.RegisterDebuggee(ctx, req)
+ return err
+ }, c.CallOptions.RegisterDebuggee...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// ListActiveBreakpoints returns the list of all active breakpoints for the debuggee.
+//
+// The breakpoint specification (location, condition, and expression
+// fields) is semantically immutable, although the field values may
+// change. For example, an agent may update the location line number
+// to reflect the actual line where the breakpoint was set, but this
+// doesn't change the breakpoint semantics.
+//
+// This means that an agent does not need to check if a breakpoint has changed
+// when it encounters the same breakpoint on a successive call.
+// Moreover, an agent should remember the breakpoints that are completed
+// until the controller removes them from the active list to avoid
+// setting those breakpoints again.
+func (c *Controller2Client) ListActiveBreakpoints(ctx context.Context, req *clouddebuggerpb.ListActiveBreakpointsRequest) (*clouddebuggerpb.ListActiveBreakpointsResponse, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *clouddebuggerpb.ListActiveBreakpointsResponse
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.controller2Client.ListActiveBreakpoints(ctx, req)
+ return err
+ }, c.CallOptions.ListActiveBreakpoints...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// UpdateActiveBreakpoint updates the breakpoint state or mutable fields.
+// The entire Breakpoint message must be sent back to the controller
+// service.
+//
+// Updates to active breakpoint fields are only allowed if the new value
+// does not change the breakpoint specification. Updates to the `location`,
+// `condition` and `expression` fields should not alter the breakpoint
+// semantics. These may only make changes such as canonicalizing a value
+// or snapping the location to the correct line of code.
+func (c *Controller2Client) UpdateActiveBreakpoint(ctx context.Context, req *clouddebuggerpb.UpdateActiveBreakpointRequest) (*clouddebuggerpb.UpdateActiveBreakpointResponse, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *clouddebuggerpb.UpdateActiveBreakpointResponse
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.controller2Client.UpdateActiveBreakpoint(ctx, req)
+ return err
+ }, c.CallOptions.UpdateActiveBreakpoint...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
diff --git a/debugger/apiv2/controller2_client_example_test.go b/debugger/apiv2/controller2_client_example_test.go
new file mode 100644
index 0000000..3d6f530
--- /dev/null
+++ b/debugger/apiv2/controller2_client_example_test.go
@@ -0,0 +1,87 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// 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
+//
+// http://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.
+
+// AUTO-GENERATED CODE. DO NOT EDIT.
+
+package debugger_test
+
+import (
+ "cloud.google.com/go/debugger/apiv2"
+ "golang.org/x/net/context"
+ clouddebuggerpb "google.golang.org/genproto/googleapis/devtools/clouddebugger/v2"
+)
+
+func ExampleNewController2Client() {
+ ctx := context.Background()
+ c, err := debugger.NewController2Client(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use client.
+ _ = c
+}
+
+func ExampleController2Client_RegisterDebuggee() {
+ ctx := context.Background()
+ c, err := debugger.NewController2Client(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &clouddebuggerpb.RegisterDebuggeeRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.RegisterDebuggee(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
+func ExampleController2Client_ListActiveBreakpoints() {
+ ctx := context.Background()
+ c, err := debugger.NewController2Client(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &clouddebuggerpb.ListActiveBreakpointsRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.ListActiveBreakpoints(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
+func ExampleController2Client_UpdateActiveBreakpoint() {
+ ctx := context.Background()
+ c, err := debugger.NewController2Client(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &clouddebuggerpb.UpdateActiveBreakpointRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.UpdateActiveBreakpoint(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
diff --git a/debugger/apiv2/debugger2_client.go b/debugger/apiv2/debugger2_client.go
new file mode 100644
index 0000000..2a9db29
--- /dev/null
+++ b/debugger/apiv2/debugger2_client.go
@@ -0,0 +1,215 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// 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
+//
+// http://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.
+
+// AUTO-GENERATED CODE. DO NOT EDIT.
+
+package debugger
+
+import (
+ "fmt"
+ "runtime"
+ "time"
+
+ gax "github.com/googleapis/gax-go"
+ "golang.org/x/net/context"
+ "google.golang.org/api/option"
+ "google.golang.org/api/transport"
+ clouddebuggerpb "google.golang.org/genproto/googleapis/devtools/clouddebugger/v2"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/metadata"
+)
+
+// Debugger2CallOptions contains the retry settings for each method of Debugger2Client.
+type Debugger2CallOptions struct {
+ SetBreakpoint []gax.CallOption
+ GetBreakpoint []gax.CallOption
+ DeleteBreakpoint []gax.CallOption
+ ListBreakpoints []gax.CallOption
+ ListDebuggees []gax.CallOption
+}
+
+func defaultDebugger2ClientOptions() []option.ClientOption {
+ return []option.ClientOption{
+ option.WithEndpoint("clouddebugger.googleapis.com:443"),
+ option.WithScopes(
+ "https://www.googleapis.com/auth/cloud-platform",
+ "https://www.googleapis.com/auth/cloud_debugger",
+ ),
+ }
+}
+
+func defaultDebugger2CallOptions() *Debugger2CallOptions {
+ retry := map[[2]string][]gax.CallOption{
+ {"default", "idempotent"}: {
+ gax.WithRetry(func() gax.Retryer {
+ return gax.OnCodes([]codes.Code{
+ codes.DeadlineExceeded,
+ codes.Unavailable,
+ }, gax.Backoff{
+ Initial: 100 * time.Millisecond,
+ Max: 60000 * time.Millisecond,
+ Multiplier: 1.3,
+ })
+ }),
+ },
+ }
+ return &Debugger2CallOptions{
+ SetBreakpoint: retry[[2]string{"default", "non_idempotent"}],
+ GetBreakpoint: retry[[2]string{"default", "idempotent"}],
+ DeleteBreakpoint: retry[[2]string{"default", "idempotent"}],
+ ListBreakpoints: retry[[2]string{"default", "idempotent"}],
+ ListDebuggees: retry[[2]string{"default", "idempotent"}],
+ }
+}
+
+// Debugger2Client is a client for interacting with Stackdriver Debugger API.
+type Debugger2Client struct {
+ // The connection to the service.
+ conn *grpc.ClientConn
+
+ // The gRPC API client.
+ debugger2Client clouddebuggerpb.Debugger2Client
+
+ // The call options for this service.
+ CallOptions *Debugger2CallOptions
+
+ // The metadata to be sent with each request.
+ metadata map[string][]string
+}
+
+// NewDebugger2Client creates a new debugger2 client.
+//
+// The Debugger service provides the API that allows users to collect run-time
+// information from a running application, without stopping or slowing it down
+// and without modifying its state. An application may include one or
+// more replicated processes performing the same work.
+//
+// The application is represented using the Debuggee concept. The Debugger
+// service provides a way to query for available Debuggees, but does not
+// provide a way to create one. A debuggee is created using the Controller
+// service, usually by running a debugger agent with the application.
+//
+// The Debugger service enables the client to set one or more Breakpoints on a
+// Debuggee and collect the results of the set Breakpoints.
+func NewDebugger2Client(ctx context.Context, opts ...option.ClientOption) (*Debugger2Client, error) {
+ conn, err := transport.DialGRPC(ctx, append(defaultDebugger2ClientOptions(), opts...)...)
+ if err != nil {
+ return nil, err
+ }
+ c := &Debugger2Client{
+ conn: conn,
+ CallOptions: defaultDebugger2CallOptions(),
+
+ debugger2Client: clouddebuggerpb.NewDebugger2Client(conn),
+ }
+ c.SetGoogleClientInfo("gax", gax.Version)
+ return c, nil
+}
+
+// Connection returns the client's connection to the API service.
+func (c *Debugger2Client) Connection() *grpc.ClientConn {
+ return c.conn
+}
+
+// Close closes the connection to the API service. The user should invoke this when
+// the client is no longer required.
+func (c *Debugger2Client) Close() error {
+ return c.conn.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 *Debugger2Client) SetGoogleClientInfo(name, version string) {
+ c.metadata = map[string][]string{
+ "x-goog-api-client": {fmt.Sprintf("%s/%s %s gax/%s go/%s", name, version, gapicNameVersion, gax.Version, runtime.Version())},
+ }
+}
+
+// SetBreakpoint sets the breakpoint to the debuggee.
+func (c *Debugger2Client) SetBreakpoint(ctx context.Context, req *clouddebuggerpb.SetBreakpointRequest) (*clouddebuggerpb.SetBreakpointResponse, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *clouddebuggerpb.SetBreakpointResponse
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.debugger2Client.SetBreakpoint(ctx, req)
+ return err
+ }, c.CallOptions.SetBreakpoint...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// GetBreakpoint gets breakpoint information.
+func (c *Debugger2Client) GetBreakpoint(ctx context.Context, req *clouddebuggerpb.GetBreakpointRequest) (*clouddebuggerpb.GetBreakpointResponse, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *clouddebuggerpb.GetBreakpointResponse
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.debugger2Client.GetBreakpoint(ctx, req)
+ return err
+ }, c.CallOptions.GetBreakpoint...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// DeleteBreakpoint deletes the breakpoint from the debuggee.
+func (c *Debugger2Client) DeleteBreakpoint(ctx context.Context, req *clouddebuggerpb.DeleteBreakpointRequest) error {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ _, err = c.debugger2Client.DeleteBreakpoint(ctx, req)
+ return err
+ }, c.CallOptions.DeleteBreakpoint...)
+ return err
+}
+
+// ListBreakpoints lists all breakpoints for the debuggee.
+func (c *Debugger2Client) ListBreakpoints(ctx context.Context, req *clouddebuggerpb.ListBreakpointsRequest) (*clouddebuggerpb.ListBreakpointsResponse, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *clouddebuggerpb.ListBreakpointsResponse
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.debugger2Client.ListBreakpoints(ctx, req)
+ return err
+ }, c.CallOptions.ListBreakpoints...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// ListDebuggees lists all the debuggees that the user can set breakpoints to.
+func (c *Debugger2Client) ListDebuggees(ctx context.Context, req *clouddebuggerpb.ListDebuggeesRequest) (*clouddebuggerpb.ListDebuggeesResponse, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *clouddebuggerpb.ListDebuggeesResponse
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.debugger2Client.ListDebuggees(ctx, req)
+ return err
+ }, c.CallOptions.ListDebuggees...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
diff --git a/debugger/apiv2/debugger2_client_example_test.go b/debugger/apiv2/debugger2_client_example_test.go
new file mode 100644
index 0000000..c75c6c6
--- /dev/null
+++ b/debugger/apiv2/debugger2_client_example_test.go
@@ -0,0 +1,121 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// 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
+//
+// http://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.
+
+// AUTO-GENERATED CODE. DO NOT EDIT.
+
+package debugger_test
+
+import (
+ "cloud.google.com/go/debugger/apiv2"
+ "golang.org/x/net/context"
+ clouddebuggerpb "google.golang.org/genproto/googleapis/devtools/clouddebugger/v2"
+)
+
+func ExampleNewDebugger2Client() {
+ ctx := context.Background()
+ c, err := debugger.NewDebugger2Client(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use client.
+ _ = c
+}
+
+func ExampleDebugger2Client_SetBreakpoint() {
+ ctx := context.Background()
+ c, err := debugger.NewDebugger2Client(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &clouddebuggerpb.SetBreakpointRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.SetBreakpoint(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
+func ExampleDebugger2Client_GetBreakpoint() {
+ ctx := context.Background()
+ c, err := debugger.NewDebugger2Client(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &clouddebuggerpb.GetBreakpointRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.GetBreakpoint(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
+func ExampleDebugger2Client_DeleteBreakpoint() {
+ ctx := context.Background()
+ c, err := debugger.NewDebugger2Client(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &clouddebuggerpb.DeleteBreakpointRequest{
+ // TODO: Fill request struct fields.
+ }
+ err = c.DeleteBreakpoint(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+}
+
+func ExampleDebugger2Client_ListBreakpoints() {
+ ctx := context.Background()
+ c, err := debugger.NewDebugger2Client(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &clouddebuggerpb.ListBreakpointsRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.ListBreakpoints(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
+func ExampleDebugger2Client_ListDebuggees() {
+ ctx := context.Background()
+ c, err := debugger.NewDebugger2Client(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &clouddebuggerpb.ListDebuggeesRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.ListDebuggees(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
diff --git a/debugger/apiv2/doc.go b/debugger/apiv2/doc.go
new file mode 100644
index 0000000..730fa6b
--- /dev/null
+++ b/debugger/apiv2/doc.go
@@ -0,0 +1,25 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// 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
+//
+// http://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.
+
+// AUTO-GENERATED CODE. DO NOT EDIT.
+
+// Package debugger is an experimental, auto-generated package for the
+// debugger API.
+//
+// Examines the call stack and variables of a running application
+// without stopping or slowing it down.
+//
+package debugger // import "cloud.google.com/go/debugger/apiv2"
+
+const gapicNameVersion = "gapic/0.1.0"
diff --git a/iam/admin/apiv1/doc.go b/iam/admin/apiv1/doc.go
new file mode 100644
index 0000000..8c16da8
--- /dev/null
+++ b/iam/admin/apiv1/doc.go
@@ -0,0 +1,25 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// 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
+//
+// http://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.
+
+// AUTO-GENERATED CODE. DO NOT EDIT.
+
+// Package admin is an experimental, auto-generated package for the
+// admin API.
+//
+// Manages identity and access control for Google Cloud Platform resources,
+// including the creation of service accounts, which you can use to authenticate
+// to Google and make API calls.
+package admin // import "cloud.google.com/go/iam/admin/apiv1"
+
+const gapicNameVersion = "gapic/0.1.0"
diff --git a/iam/admin/apiv1/iam_client.go b/iam/admin/apiv1/iam_client.go
new file mode 100644
index 0000000..4161ed7
--- /dev/null
+++ b/iam/admin/apiv1/iam_client.go
@@ -0,0 +1,477 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// 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
+//
+// http://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.
+
+// AUTO-GENERATED CODE. DO NOT EDIT.
+
+package admin
+
+import (
+ "fmt"
+ "math"
+ "runtime"
+ "time"
+
+ gax "github.com/googleapis/gax-go"
+ "golang.org/x/net/context"
+ "google.golang.org/api/iterator"
+ "google.golang.org/api/option"
+ "google.golang.org/api/transport"
+ adminpb "google.golang.org/genproto/googleapis/iam/admin/v1"
+ iampb "google.golang.org/genproto/googleapis/iam/v1"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/metadata"
+)
+
+var (
+ iamProjectPathTemplate = gax.MustCompilePathTemplate("projects/{project}")
+ iamServiceAccountPathTemplate = gax.MustCompilePathTemplate("projects/{project}/serviceAccounts/{service_account}")
+ iamKeyPathTemplate = gax.MustCompilePathTemplate("projects/{project}/serviceAccounts/{service_account}/keys/{key}")
+)
+
+// IamCallOptions contains the retry settings for each method of IamClient.
+type IamCallOptions struct {
+ ListServiceAccounts []gax.CallOption
+ GetServiceAccount []gax.CallOption
+ CreateServiceAccount []gax.CallOption
+ UpdateServiceAccount []gax.CallOption
+ DeleteServiceAccount []gax.CallOption
+ ListServiceAccountKeys []gax.CallOption
+ GetServiceAccountKey []gax.CallOption
+ CreateServiceAccountKey []gax.CallOption
+ DeleteServiceAccountKey []gax.CallOption
+ SignBlob []gax.CallOption
+ GetIamPolicy []gax.CallOption
+ SetIamPolicy []gax.CallOption
+ TestIamPermissions []gax.CallOption
+ QueryGrantableRoles []gax.CallOption
+}
+
+func defaultIamClientOptions() []option.ClientOption {
+ return []option.ClientOption{
+ option.WithEndpoint("iam.googleapis.com:443"),
+ option.WithScopes(
+ "https://www.googleapis.com/auth/cloud-platform",
+ "https://www.googleapis.com/auth/iam",
+ ),
+ }
+}
+
+func defaultIamCallOptions() *IamCallOptions {
+ retry := map[[2]string][]gax.CallOption{
+ {"default", "idempotent"}: {
+ gax.WithRetry(func() gax.Retryer {
+ return gax.OnCodes([]codes.Code{
+ codes.DeadlineExceeded,
+ codes.Unavailable,
+ }, gax.Backoff{
+ Initial: 100 * time.Millisecond,
+ Max: 60000 * time.Millisecond,
+ Multiplier: 1.3,
+ })
+ }),
+ },
+ }
+ return &IamCallOptions{
+ ListServiceAccounts: retry[[2]string{"default", "idempotent"}],
+ GetServiceAccount: retry[[2]string{"default", "idempotent"}],
+ CreateServiceAccount: retry[[2]string{"default", "non_idempotent"}],
+ UpdateServiceAccount: retry[[2]string{"default", "idempotent"}],
+ DeleteServiceAccount: retry[[2]string{"default", "idempotent"}],
+ ListServiceAccountKeys: retry[[2]string{"default", "idempotent"}],
+ GetServiceAccountKey: retry[[2]string{"default", "idempotent"}],
+ CreateServiceAccountKey: retry[[2]string{"default", "non_idempotent"}],
+ DeleteServiceAccountKey: retry[[2]string{"default", "idempotent"}],
+ SignBlob: retry[[2]string{"default", "non_idempotent"}],
+ GetIamPolicy: retry[[2]string{"default", "non_idempotent"}],
+ SetIamPolicy: retry[[2]string{"default", "non_idempotent"}],
+ TestIamPermissions: retry[[2]string{"default", "non_idempotent"}],
+ QueryGrantableRoles: retry[[2]string{"default", "non_idempotent"}],
+ }
+}
+
+// IamClient is a client for interacting with Google Identity and Access Management (IAM) API.
+type IamClient struct {
+ // The connection to the service.
+ conn *grpc.ClientConn
+
+ // The gRPC API client.
+ iamClient adminpb.IAMClient
+
+ // The call options for this service.
+ CallOptions *IamCallOptions
+
+ // The metadata to be sent with each request.
+ metadata map[string][]string
+}
+
+// NewIamClient creates a new iam client.
+//
+// Creates and manages service account objects.
+//
+// Service account is an account that belongs to your project instead
+// of to an individual end user. It is used to authenticate calls
+// to a Google API.
+//
+// To create a service account, specify the `project_id` and `account_id`
+// for the account. The `account_id` is unique within the project, and used
+// to generate the service account email address and a stable
+// `unique_id`.
+//
+// All other methods can identify accounts using the format
+// `projects/{project}/serviceAccounts/{account}`.
+// Using `-` as a wildcard for the project will infer the project from
+// the account. The `account` value can be the `email` address or the
+// `unique_id` of the service account.
+func NewIamClient(ctx context.Context, opts ...option.ClientOption) (*IamClient, error) {
+ conn, err := transport.DialGRPC(ctx, append(defaultIamClientOptions(), opts...)...)
+ if err != nil {
+ return nil, err
+ }
+ c := &IamClient{
+ conn: conn,
+ CallOptions: defaultIamCallOptions(),
+
+ iamClient: adminpb.NewIAMClient(conn),
+ }
+ c.SetGoogleClientInfo("gax", gax.Version)
+ return c, nil
+}
+
+// Connection returns the client's connection to the API service.
+func (c *IamClient) Connection() *grpc.ClientConn {
+ return c.conn
+}
+
+// Close closes the connection to the API service. The user should invoke this when
+// the client is no longer required.
+func (c *IamClient) Close() error {
+ return c.conn.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 *IamClient) SetGoogleClientInfo(name, version string) {
+ c.metadata = map[string][]string{
+ "x-goog-api-client": {fmt.Sprintf("%s/%s %s gax/%s go/%s", name, version, gapicNameVersion, gax.Version, runtime.Version())},
+ }
+}
+
+// IamProjectPath returns the path for the project resource.
+func IamProjectPath(project string) string {
+ path, err := iamProjectPathTemplate.Render(map[string]string{
+ "project": project,
+ })
+ if err != nil {
+ panic(err)
+ }
+ return path
+}
+
+// IamServiceAccountPath returns the path for the service account resource.
+func IamServiceAccountPath(project, serviceAccount string) string {
+ path, err := iamServiceAccountPathTemplate.Render(map[string]string{
+ "project": project,
+ "service_account": serviceAccount,
+ })
+ if err != nil {
+ panic(err)
+ }
+ return path
+}
+
+// IamKeyPath returns the path for the key resource.
+func IamKeyPath(project, serviceAccount, key string) string {
+ path, err := iamKeyPathTemplate.Render(map[string]string{
+ "project": project,
+ "service_account": serviceAccount,
+ "key": key,
+ })
+ if err != nil {
+ panic(err)
+ }
+ return path
+}
+
+// ListServiceAccounts lists [ServiceAccounts][google.iam.admin.v1.ServiceAccount] for a project.
+func (c *IamClient) ListServiceAccounts(ctx context.Context, req *adminpb.ListServiceAccountsRequest) *ServiceAccountIterator {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ it := &ServiceAccountIterator{}
+
+ fetch := func(pageSize int, pageToken string) (string, error) {
+ var resp *adminpb.ListServiceAccountsResponse
+ req.PageToken = pageToken
+ if pageSize > math.MaxInt32 {
+ req.PageSize = math.MaxInt32
+ } else {
+ req.PageSize = int32(pageSize)
+ }
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.iamClient.ListServiceAccounts(ctx, req)
+ return err
+ }, c.CallOptions.ListServiceAccounts...)
+ if err != nil {
+ return "", err
+ }
+ it.items = append(it.items, resp.Accounts...)
+ return resp.NextPageToken, nil
+ }
+ bufLen := func() int { return len(it.items) }
+ takeBuf := func() interface{} {
+ b := it.items
+ it.items = nil
+ return b
+ }
+
+ it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, bufLen, takeBuf)
+ return it
+}
+
+// GetServiceAccount gets a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
+func (c *IamClient) GetServiceAccount(ctx context.Context, req *adminpb.GetServiceAccountRequest) (*adminpb.ServiceAccount, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *adminpb.ServiceAccount
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.iamClient.GetServiceAccount(ctx, req)
+ return err
+ }, c.CallOptions.GetServiceAccount...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// CreateServiceAccount creates a [ServiceAccount][google.iam.admin.v1.ServiceAccount]
+// and returns it.
+func (c *IamClient) CreateServiceAccount(ctx context.Context, req *adminpb.CreateServiceAccountRequest) (*adminpb.ServiceAccount, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *adminpb.ServiceAccount
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.iamClient.CreateServiceAccount(ctx, req)
+ return err
+ }, c.CallOptions.CreateServiceAccount...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// UpdateServiceAccount updates a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
+//
+// Currently, only the following fields are updatable:
+// `display_name` .
+// The `etag` is mandatory.
+func (c *IamClient) UpdateServiceAccount(ctx context.Context, req *adminpb.ServiceAccount) (*adminpb.ServiceAccount, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *adminpb.ServiceAccount
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.iamClient.UpdateServiceAccount(ctx, req)
+ return err
+ }, c.CallOptions.UpdateServiceAccount...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// DeleteServiceAccount deletes a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
+func (c *IamClient) DeleteServiceAccount(ctx context.Context, req *adminpb.DeleteServiceAccountRequest) error {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ _, err = c.iamClient.DeleteServiceAccount(ctx, req)
+ return err
+ }, c.CallOptions.DeleteServiceAccount...)
+ return err
+}
+
+// ListServiceAccountKeys lists [ServiceAccountKeys][google.iam.admin.v1.ServiceAccountKey].
+func (c *IamClient) ListServiceAccountKeys(ctx context.Context, req *adminpb.ListServiceAccountKeysRequest) (*adminpb.ListServiceAccountKeysResponse, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *adminpb.ListServiceAccountKeysResponse
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.iamClient.ListServiceAccountKeys(ctx, req)
+ return err
+ }, c.CallOptions.ListServiceAccountKeys...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// GetServiceAccountKey gets the [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey]
+// by key id.
+func (c *IamClient) GetServiceAccountKey(ctx context.Context, req *adminpb.GetServiceAccountKeyRequest) (*adminpb.ServiceAccountKey, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *adminpb.ServiceAccountKey
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.iamClient.GetServiceAccountKey(ctx, req)
+ return err
+ }, c.CallOptions.GetServiceAccountKey...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// CreateServiceAccountKey creates a [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey]
+// and returns it.
+func (c *IamClient) CreateServiceAccountKey(ctx context.Context, req *adminpb.CreateServiceAccountKeyRequest) (*adminpb.ServiceAccountKey, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *adminpb.ServiceAccountKey
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.iamClient.CreateServiceAccountKey(ctx, req)
+ return err
+ }, c.CallOptions.CreateServiceAccountKey...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// DeleteServiceAccountKey deletes a [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey].
+func (c *IamClient) DeleteServiceAccountKey(ctx context.Context, req *adminpb.DeleteServiceAccountKeyRequest) error {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ _, err = c.iamClient.DeleteServiceAccountKey(ctx, req)
+ return err
+ }, c.CallOptions.DeleteServiceAccountKey...)
+ return err
+}
+
+// SignBlob signs a blob using a service account's system-managed private key.
+func (c *IamClient) SignBlob(ctx context.Context, req *adminpb.SignBlobRequest) (*adminpb.SignBlobResponse, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *adminpb.SignBlobResponse
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.iamClient.SignBlob(ctx, req)
+ return err
+ }, c.CallOptions.SignBlob...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// GetIamPolicy returns the IAM access control policy for a
+// [ServiceAccount][google.iam.admin.v1.ServiceAccount].
+func (c *IamClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest) (*iampb.Policy, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *iampb.Policy
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.iamClient.GetIamPolicy(ctx, req)
+ return err
+ }, c.CallOptions.GetIamPolicy...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// SetIamPolicy sets the IAM access control policy for a
+// [ServiceAccount][google.iam.admin.v1.ServiceAccount].
+func (c *IamClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest) (*iampb.Policy, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *iampb.Policy
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.iamClient.SetIamPolicy(ctx, req)
+ return err
+ }, c.CallOptions.SetIamPolicy...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// TestIamPermissions tests the specified permissions against the IAM access control policy
+// for a [ServiceAccount][google.iam.admin.v1.ServiceAccount].
+func (c *IamClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest) (*iampb.TestIamPermissionsResponse, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *iampb.TestIamPermissionsResponse
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.iamClient.TestIamPermissions(ctx, req)
+ return err
+ }, c.CallOptions.TestIamPermissions...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// QueryGrantableRoles queries roles that can be granted on a particular resource.
+// A role is grantable if it can be used as the role in a binding for a policy
+// for that resource.
+func (c *IamClient) QueryGrantableRoles(ctx context.Context, req *adminpb.QueryGrantableRolesRequest) (*adminpb.QueryGrantableRolesResponse, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *adminpb.QueryGrantableRolesResponse
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.iamClient.QueryGrantableRoles(ctx, req)
+ return err
+ }, c.CallOptions.QueryGrantableRoles...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// ServiceAccountIterator manages a stream of *adminpb.ServiceAccount.
+type ServiceAccountIterator struct {
+ items []*adminpb.ServiceAccount
+ pageInfo *iterator.PageInfo
+ nextFunc func() error
+}
+
+// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
+func (it *ServiceAccountIterator) 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 *ServiceAccountIterator) Next() (*adminpb.ServiceAccount, error) {
+ if err := it.nextFunc(); err != nil {
+ return nil, err
+ }
+ item := it.items[0]
+ it.items = it.items[1:]
+ return item, nil
+}
diff --git a/iam/admin/apiv1/iam_client_example_test.go b/iam/admin/apiv1/iam_client_example_test.go
new file mode 100644
index 0000000..8ea815d
--- /dev/null
+++ b/iam/admin/apiv1/iam_client_example_test.go
@@ -0,0 +1,286 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// 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
+//
+// http://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.
+
+// AUTO-GENERATED CODE. DO NOT EDIT.
+
+package admin_test
+
+import (
+ "cloud.google.com/go/iam/admin/apiv1"
+ "golang.org/x/net/context"
+ adminpb "google.golang.org/genproto/googleapis/iam/admin/v1"
+ iampb "google.golang.org/genproto/googleapis/iam/v1"
+)
+
+func ExampleNewIamClient() {
+ ctx := context.Background()
+ c, err := admin.NewIamClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use client.
+ _ = c
+}
+
+func ExampleIamClient_ListServiceAccounts() {
+ ctx := context.Background()
+ c, err := admin.NewIamClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &adminpb.ListServiceAccountsRequest{
+ // TODO: Fill request struct fields.
+ }
+ it := c.ListServiceAccounts(ctx, req)
+ for {
+ resp, err := it.Next()
+ if err != nil {
+ // TODO: Handle error.
+ break
+ }
+ // TODO: Use resp.
+ _ = resp
+ }
+}
+
+func ExampleIamClient_GetServiceAccount() {
+ ctx := context.Background()
+ c, err := admin.NewIamClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &adminpb.GetServiceAccountRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.GetServiceAccount(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
+func ExampleIamClient_CreateServiceAccount() {
+ ctx := context.Background()
+ c, err := admin.NewIamClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &adminpb.CreateServiceAccountRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.CreateServiceAccount(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
+func ExampleIamClient_UpdateServiceAccount() {
+ ctx := context.Background()
+ c, err := admin.NewIamClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &adminpb.ServiceAccount{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.UpdateServiceAccount(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
+func ExampleIamClient_DeleteServiceAccount() {
+ ctx := context.Background()
+ c, err := admin.NewIamClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &adminpb.DeleteServiceAccountRequest{
+ // TODO: Fill request struct fields.
+ }
+ err = c.DeleteServiceAccount(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+}
+
+func ExampleIamClient_ListServiceAccountKeys() {
+ ctx := context.Background()
+ c, err := admin.NewIamClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &adminpb.ListServiceAccountKeysRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.ListServiceAccountKeys(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
+func ExampleIamClient_GetServiceAccountKey() {
+ ctx := context.Background()
+ c, err := admin.NewIamClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &adminpb.GetServiceAccountKeyRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.GetServiceAccountKey(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
+func ExampleIamClient_CreateServiceAccountKey() {
+ ctx := context.Background()
+ c, err := admin.NewIamClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &adminpb.CreateServiceAccountKeyRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.CreateServiceAccountKey(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
+func ExampleIamClient_DeleteServiceAccountKey() {
+ ctx := context.Background()
+ c, err := admin.NewIamClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &adminpb.DeleteServiceAccountKeyRequest{
+ // TODO: Fill request struct fields.
+ }
+ err = c.DeleteServiceAccountKey(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+}
+
+func ExampleIamClient_SignBlob() {
+ ctx := context.Background()
+ c, err := admin.NewIamClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &adminpb.SignBlobRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.SignBlob(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
+func ExampleIamClient_GetIamPolicy() {
+ ctx := context.Background()
+ c, err := admin.NewIamClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &iampb.GetIamPolicyRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.GetIamPolicy(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
+func ExampleIamClient_SetIamPolicy() {
+ ctx := context.Background()
+ c, err := admin.NewIamClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &iampb.SetIamPolicyRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.SetIamPolicy(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
+func ExampleIamClient_TestIamPermissions() {
+ ctx := context.Background()
+ c, err := admin.NewIamClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &iampb.TestIamPermissionsRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.TestIamPermissions(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
+func ExampleIamClient_QueryGrantableRoles() {
+ ctx := context.Background()
+ c, err := admin.NewIamClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &adminpb.QueryGrantableRolesRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.QueryGrantableRoles(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
diff --git a/trace/apiv1/doc.go b/trace/apiv1/doc.go
new file mode 100644
index 0000000..91d8846
--- /dev/null
+++ b/trace/apiv1/doc.go
@@ -0,0 +1,27 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// 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
+//
+// http://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.
+
+// AUTO-GENERATED CODE. DO NOT EDIT.
+
+// Package trace is an experimental, auto-generated package for the
+// trace API.
+//
+// Send and retrieve trace data from Stackdriver Trace. Data is generated
+// and available by default for all App Engine applications. Data from other
+// applications can be written to Stackdriver Trace for display, reporting,
+// and analysis.
+//
+package trace // import "cloud.google.com/go/trace/apiv1"
+
+const gapicNameVersion = "gapic/0.1.0"
diff --git a/trace/apiv1/trace_client.go b/trace/apiv1/trace_client.go
new file mode 100644
index 0000000..d630a33
--- /dev/null
+++ b/trace/apiv1/trace_client.go
@@ -0,0 +1,222 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// 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
+//
+// http://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.
+
+// AUTO-GENERATED CODE. DO NOT EDIT.
+
+package trace
+
+import (
+ "fmt"
+ "math"
+ "runtime"
+ "time"
+
+ gax "github.com/googleapis/gax-go"
+ "golang.org/x/net/context"
+ "google.golang.org/api/iterator"
+ "google.golang.org/api/option"
+ "google.golang.org/api/transport"
+ cloudtracepb "google.golang.org/genproto/googleapis/devtools/cloudtrace/v1"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/metadata"
+)
+
+// CallOptions contains the retry settings for each method of Client.
+type CallOptions struct {
+ PatchTraces []gax.CallOption
+ GetTrace []gax.CallOption
+ ListTraces []gax.CallOption
+}
+
+func defaultClientOptions() []option.ClientOption {
+ return []option.ClientOption{
+ option.WithEndpoint("cloudtrace.googleapis.com:443"),
+ option.WithScopes(
+ "https://www.googleapis.com/auth/cloud-platform",
+ "https://www.googleapis.com/auth/trace.append",
+ "https://www.googleapis.com/auth/trace.readonly",
+ ),
+ }
+}
+
+func defaultCallOptions() *CallOptions {
+ retry := map[[2]string][]gax.CallOption{
+ {"default", "idempotent"}: {
+ gax.WithRetry(func() gax.Retryer {
+ return gax.OnCodes([]codes.Code{
+ codes.DeadlineExceeded,
+ codes.Unavailable,
+ }, gax.Backoff{
+ Initial: 100 * time.Millisecond,
+ Max: 1000 * time.Millisecond,
+ Multiplier: 1.2,
+ })
+ }),
+ },
+ }
+ return &CallOptions{
+ PatchTraces: retry[[2]string{"default", "non_idempotent"}],
+ GetTrace: retry[[2]string{"default", "idempotent"}],
+ ListTraces: retry[[2]string{"default", "idempotent"}],
+ }
+}
+
+// Client is a client for interacting with Stackdriver Trace API.
+type Client struct {
+ // The connection to the service.
+ conn *grpc.ClientConn
+
+ // The gRPC API client.
+ client cloudtracepb.TraceServiceClient
+
+ // The call options for this service.
+ CallOptions *CallOptions
+
+ // The metadata to be sent with each request.
+ metadata map[string][]string
+}
+
+// NewClient creates a new trace service client.
+//
+// This file describes an API for collecting and viewing traces and spans
+// within a trace. A Trace is a collection of spans corresponding to a single
+// operation or set of operations for an application. A span is an individual
+// timed event which forms a node of the trace tree. Spans for a single trace
+// may span multiple services.
+func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
+ conn, err := transport.DialGRPC(ctx, append(defaultClientOptions(), opts...)...)
+ if err != nil {
+ return nil, err
+ }
+ c := &Client{
+ conn: conn,
+ CallOptions: defaultCallOptions(),
+
+ client: cloudtracepb.NewTraceServiceClient(conn),
+ }
+ c.SetGoogleClientInfo("gax", gax.Version)
+ return c, nil
+}
+
+// Connection returns the client's connection to the API service.
+func (c *Client) Connection() *grpc.ClientConn {
+ return c.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.conn.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(name, version string) {
+ c.metadata = map[string][]string{
+ "x-goog-api-client": {fmt.Sprintf("%s/%s %s gax/%s go/%s", name, version, gapicNameVersion, gax.Version, runtime.Version())},
+ }
+}
+
+// PatchTraces sends new traces to Stackdriver Trace or updates existing traces. If the ID
+// of a trace that you send matches that of an existing trace, any fields
+// in the existing trace and its spans are overwritten by the provided values,
+// and any new fields provided are merged with the existing trace data. If the
+// ID does not match, a new trace is created.
+func (c *Client) PatchTraces(ctx context.Context, req *cloudtracepb.PatchTracesRequest) error {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ _, err = c.client.PatchTraces(ctx, req)
+ return err
+ }, c.CallOptions.PatchTraces...)
+ return err
+}
+
+// GetTrace gets a single trace by its ID.
+func (c *Client) GetTrace(ctx context.Context, req *cloudtracepb.GetTraceRequest) (*cloudtracepb.Trace, error) {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ var resp *cloudtracepb.Trace
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.client.GetTrace(ctx, req)
+ return err
+ }, c.CallOptions.GetTrace...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// ListTraces returns of a list of traces that match the specified filter conditions.
+func (c *Client) ListTraces(ctx context.Context, req *cloudtracepb.ListTracesRequest) *TraceIterator {
+ md, _ := metadata.FromContext(ctx)
+ ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
+ it := &TraceIterator{}
+
+ fetch := func(pageSize int, pageToken string) (string, error) {
+ var resp *cloudtracepb.ListTracesResponse
+ req.PageToken = pageToken
+ if pageSize > math.MaxInt32 {
+ req.PageSize = math.MaxInt32
+ } else {
+ req.PageSize = int32(pageSize)
+ }
+ err := gax.Invoke(ctx, func(ctx context.Context) error {
+ var err error
+ resp, err = c.client.ListTraces(ctx, req)
+ return err
+ }, c.CallOptions.ListTraces...)
+ if err != nil {
+ return "", err
+ }
+ it.items = append(it.items, resp.Traces...)
+ return resp.NextPageToken, nil
+ }
+ bufLen := func() int { return len(it.items) }
+ takeBuf := func() interface{} {
+ b := it.items
+ it.items = nil
+ return b
+ }
+
+ it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, bufLen, takeBuf)
+ return it
+}
+
+// TraceIterator manages a stream of *cloudtracepb.Trace.
+type TraceIterator struct {
+ items []*cloudtracepb.Trace
+ pageInfo *iterator.PageInfo
+ nextFunc func() error
+}
+
+// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
+func (it *TraceIterator) 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 *TraceIterator) Next() (*cloudtracepb.Trace, error) {
+ if err := it.nextFunc(); err != nil {
+ return nil, err
+ }
+ item := it.items[0]
+ it.items = it.items[1:]
+ return item, nil
+}
diff --git a/trace/apiv1/trace_client_example_test.go b/trace/apiv1/trace_client_example_test.go
new file mode 100644
index 0000000..570eb90
--- /dev/null
+++ b/trace/apiv1/trace_client_example_test.go
@@ -0,0 +1,89 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// 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
+//
+// http://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.
+
+// AUTO-GENERATED CODE. DO NOT EDIT.
+
+package trace_test
+
+import (
+ "cloud.google.com/go/trace/apiv1"
+ "golang.org/x/net/context"
+ cloudtracepb "google.golang.org/genproto/googleapis/devtools/cloudtrace/v1"
+)
+
+func ExampleNewClient() {
+ ctx := context.Background()
+ c, err := trace.NewClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use client.
+ _ = c
+}
+
+func ExampleClient_PatchTraces() {
+ ctx := context.Background()
+ c, err := trace.NewClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &cloudtracepb.PatchTracesRequest{
+ // TODO: Fill request struct fields.
+ }
+ err = c.PatchTraces(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+}
+
+func ExampleClient_GetTrace() {
+ ctx := context.Background()
+ c, err := trace.NewClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &cloudtracepb.GetTraceRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.GetTrace(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
+func ExampleClient_ListTraces() {
+ ctx := context.Background()
+ c, err := trace.NewClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &cloudtracepb.ListTracesRequest{
+ // TODO: Fill request struct fields.
+ }
+ it := c.ListTraces(ctx, req)
+ for {
+ resp, err := it.Next()
+ if err != nil {
+ // TODO: Handle error.
+ break
+ }
+ // TODO: Use resp.
+ _ = resp
+ }
+}