You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

213 lines
8.0 KiB

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