Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

214 righe
8.1 KiB

  1. // Copyright 2018 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // AUTO-GENERATED CODE. DO NOT EDIT.
  15. package debugger
  16. import (
  17. "time"
  18. "cloud.google.com/go/internal/version"
  19. gax "github.com/googleapis/gax-go"
  20. "golang.org/x/net/context"
  21. "google.golang.org/api/option"
  22. "google.golang.org/api/transport"
  23. clouddebuggerpb "google.golang.org/genproto/googleapis/devtools/clouddebugger/v2"
  24. "google.golang.org/grpc"
  25. "google.golang.org/grpc/codes"
  26. "google.golang.org/grpc/metadata"
  27. )
  28. // Debugger2CallOptions contains the retry settings for each method of Debugger2Client.
  29. type Debugger2CallOptions struct {
  30. SetBreakpoint []gax.CallOption
  31. GetBreakpoint []gax.CallOption
  32. DeleteBreakpoint []gax.CallOption
  33. ListBreakpoints []gax.CallOption
  34. ListDebuggees []gax.CallOption
  35. }
  36. func defaultDebugger2ClientOptions() []option.ClientOption {
  37. return []option.ClientOption{
  38. option.WithEndpoint("clouddebugger.googleapis.com:443"),
  39. option.WithScopes(DefaultAuthScopes()...),
  40. }
  41. }
  42. func defaultDebugger2CallOptions() *Debugger2CallOptions {
  43. retry := map[[2]string][]gax.CallOption{
  44. {"default", "idempotent"}: {
  45. gax.WithRetry(func() gax.Retryer {
  46. return gax.OnCodes([]codes.Code{
  47. codes.DeadlineExceeded,
  48. codes.Unavailable,
  49. }, gax.Backoff{
  50. Initial: 100 * time.Millisecond,
  51. Max: 60000 * time.Millisecond,
  52. Multiplier: 1.3,
  53. })
  54. }),
  55. },
  56. }
  57. return &Debugger2CallOptions{
  58. SetBreakpoint: retry[[2]string{"default", "non_idempotent"}],
  59. GetBreakpoint: retry[[2]string{"default", "idempotent"}],
  60. DeleteBreakpoint: retry[[2]string{"default", "idempotent"}],
  61. ListBreakpoints: retry[[2]string{"default", "idempotent"}],
  62. ListDebuggees: retry[[2]string{"default", "idempotent"}],
  63. }
  64. }
  65. // Debugger2Client is a client for interacting with Stackdriver Debugger API.
  66. //
  67. // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
  68. type Debugger2Client struct {
  69. // The connection to the service.
  70. conn *grpc.ClientConn
  71. // The gRPC API client.
  72. debugger2Client clouddebuggerpb.Debugger2Client
  73. // The call options for this service.
  74. CallOptions *Debugger2CallOptions
  75. // The x-goog-* metadata to be sent with each request.
  76. xGoogMetadata metadata.MD
  77. }
  78. // NewDebugger2Client creates a new debugger2 client.
  79. //
  80. // The Debugger service provides the API that allows users to collect run-time
  81. // information from a running application, without stopping or slowing it down
  82. // and without modifying its state. An application may include one or
  83. // more replicated processes performing the same work.
  84. //
  85. // A debugged application is represented using the Debuggee concept. The
  86. // Debugger service provides a way to query for available debuggees, but does
  87. // not provide a way to create one. A debuggee is created using the Controller
  88. // service, usually by running a debugger agent with the application.
  89. //
  90. // The Debugger service enables the client to set one or more Breakpoints on a
  91. // Debuggee and collect the results of the set Breakpoints.
  92. func NewDebugger2Client(ctx context.Context, opts ...option.ClientOption) (*Debugger2Client, error) {
  93. conn, err := transport.DialGRPC(ctx, append(defaultDebugger2ClientOptions(), opts...)...)
  94. if err != nil {
  95. return nil, err
  96. }
  97. c := &Debugger2Client{
  98. conn: conn,
  99. CallOptions: defaultDebugger2CallOptions(),
  100. debugger2Client: clouddebuggerpb.NewDebugger2Client(conn),
  101. }
  102. c.SetGoogleClientInfo()
  103. return c, nil
  104. }
  105. // Connection returns the client's connection to the API service.
  106. func (c *Debugger2Client) Connection() *grpc.ClientConn {
  107. return c.conn
  108. }
  109. // Close closes the connection to the API service. The user should invoke this when
  110. // the client is no longer required.
  111. func (c *Debugger2Client) Close() error {
  112. return c.conn.Close()
  113. }
  114. // SetGoogleClientInfo sets the name and version of the application in
  115. // the `x-goog-api-client` header passed on each request. Intended for
  116. // use by Google-written clients.
  117. func (c *Debugger2Client) SetGoogleClientInfo(keyval ...string) {
  118. kv := append([]string{"gl-go", version.Go()}, keyval...)
  119. kv = append(kv, "gapic", version.Repo, "gax", gax.Version, "grpc", grpc.Version)
  120. c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
  121. }
  122. // SetBreakpoint sets the breakpoint to the debuggee.
  123. func (c *Debugger2Client) SetBreakpoint(ctx context.Context, req *clouddebuggerpb.SetBreakpointRequest, opts ...gax.CallOption) (*clouddebuggerpb.SetBreakpointResponse, error) {
  124. ctx = insertMetadata(ctx, c.xGoogMetadata)
  125. opts = append(c.CallOptions.SetBreakpoint[0:len(c.CallOptions.SetBreakpoint):len(c.CallOptions.SetBreakpoint)], opts...)
  126. var resp *clouddebuggerpb.SetBreakpointResponse
  127. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  128. var err error
  129. resp, err = c.debugger2Client.SetBreakpoint(ctx, req, settings.GRPC...)
  130. return err
  131. }, opts...)
  132. if err != nil {
  133. return nil, err
  134. }
  135. return resp, nil
  136. }
  137. // GetBreakpoint gets breakpoint information.
  138. func (c *Debugger2Client) GetBreakpoint(ctx context.Context, req *clouddebuggerpb.GetBreakpointRequest, opts ...gax.CallOption) (*clouddebuggerpb.GetBreakpointResponse, error) {
  139. ctx = insertMetadata(ctx, c.xGoogMetadata)
  140. opts = append(c.CallOptions.GetBreakpoint[0:len(c.CallOptions.GetBreakpoint):len(c.CallOptions.GetBreakpoint)], opts...)
  141. var resp *clouddebuggerpb.GetBreakpointResponse
  142. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  143. var err error
  144. resp, err = c.debugger2Client.GetBreakpoint(ctx, req, settings.GRPC...)
  145. return err
  146. }, opts...)
  147. if err != nil {
  148. return nil, err
  149. }
  150. return resp, nil
  151. }
  152. // DeleteBreakpoint deletes the breakpoint from the debuggee.
  153. func (c *Debugger2Client) DeleteBreakpoint(ctx context.Context, req *clouddebuggerpb.DeleteBreakpointRequest, opts ...gax.CallOption) error {
  154. ctx = insertMetadata(ctx, c.xGoogMetadata)
  155. opts = append(c.CallOptions.DeleteBreakpoint[0:len(c.CallOptions.DeleteBreakpoint):len(c.CallOptions.DeleteBreakpoint)], opts...)
  156. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  157. var err error
  158. _, err = c.debugger2Client.DeleteBreakpoint(ctx, req, settings.GRPC...)
  159. return err
  160. }, opts...)
  161. return err
  162. }
  163. // ListBreakpoints lists all breakpoints for the debuggee.
  164. func (c *Debugger2Client) ListBreakpoints(ctx context.Context, req *clouddebuggerpb.ListBreakpointsRequest, opts ...gax.CallOption) (*clouddebuggerpb.ListBreakpointsResponse, error) {
  165. ctx = insertMetadata(ctx, c.xGoogMetadata)
  166. opts = append(c.CallOptions.ListBreakpoints[0:len(c.CallOptions.ListBreakpoints):len(c.CallOptions.ListBreakpoints)], opts...)
  167. var resp *clouddebuggerpb.ListBreakpointsResponse
  168. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  169. var err error
  170. resp, err = c.debugger2Client.ListBreakpoints(ctx, req, settings.GRPC...)
  171. return err
  172. }, opts...)
  173. if err != nil {
  174. return nil, err
  175. }
  176. return resp, nil
  177. }
  178. // ListDebuggees lists all the debuggees that the user has access to.
  179. func (c *Debugger2Client) ListDebuggees(ctx context.Context, req *clouddebuggerpb.ListDebuggeesRequest, opts ...gax.CallOption) (*clouddebuggerpb.ListDebuggeesResponse, error) {
  180. ctx = insertMetadata(ctx, c.xGoogMetadata)
  181. opts = append(c.CallOptions.ListDebuggees[0:len(c.CallOptions.ListDebuggees):len(c.CallOptions.ListDebuggees)], opts...)
  182. var resp *clouddebuggerpb.ListDebuggeesResponse
  183. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  184. var err error
  185. resp, err = c.debugger2Client.ListDebuggees(ctx, req, settings.GRPC...)
  186. return err
  187. }, opts...)
  188. if err != nil {
  189. return nil, err
  190. }
  191. return resp, nil
  192. }