Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

154 rader
5.2 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 errorreporting
  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. clouderrorreportingpb "google.golang.org/genproto/googleapis/devtools/clouderrorreporting/v1beta1"
  24. "google.golang.org/grpc"
  25. "google.golang.org/grpc/codes"
  26. "google.golang.org/grpc/metadata"
  27. )
  28. // ErrorGroupCallOptions contains the retry settings for each method of ErrorGroupClient.
  29. type ErrorGroupCallOptions struct {
  30. GetGroup []gax.CallOption
  31. UpdateGroup []gax.CallOption
  32. }
  33. func defaultErrorGroupClientOptions() []option.ClientOption {
  34. return []option.ClientOption{
  35. option.WithEndpoint("clouderrorreporting.googleapis.com:443"),
  36. option.WithScopes(DefaultAuthScopes()...),
  37. }
  38. }
  39. func defaultErrorGroupCallOptions() *ErrorGroupCallOptions {
  40. retry := map[[2]string][]gax.CallOption{
  41. {"default", "idempotent"}: {
  42. gax.WithRetry(func() gax.Retryer {
  43. return gax.OnCodes([]codes.Code{
  44. codes.DeadlineExceeded,
  45. codes.Unavailable,
  46. }, gax.Backoff{
  47. Initial: 100 * time.Millisecond,
  48. Max: 60000 * time.Millisecond,
  49. Multiplier: 1.3,
  50. })
  51. }),
  52. },
  53. }
  54. return &ErrorGroupCallOptions{
  55. GetGroup: retry[[2]string{"default", "idempotent"}],
  56. UpdateGroup: retry[[2]string{"default", "idempotent"}],
  57. }
  58. }
  59. // ErrorGroupClient is a client for interacting with Stackdriver Error Reporting API.
  60. //
  61. // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
  62. type ErrorGroupClient struct {
  63. // The connection to the service.
  64. conn *grpc.ClientConn
  65. // The gRPC API client.
  66. errorGroupClient clouderrorreportingpb.ErrorGroupServiceClient
  67. // The call options for this service.
  68. CallOptions *ErrorGroupCallOptions
  69. // The x-goog-* metadata to be sent with each request.
  70. xGoogMetadata metadata.MD
  71. }
  72. // NewErrorGroupClient creates a new error group service client.
  73. //
  74. // Service for retrieving and updating individual error groups.
  75. func NewErrorGroupClient(ctx context.Context, opts ...option.ClientOption) (*ErrorGroupClient, error) {
  76. conn, err := transport.DialGRPC(ctx, append(defaultErrorGroupClientOptions(), opts...)...)
  77. if err != nil {
  78. return nil, err
  79. }
  80. c := &ErrorGroupClient{
  81. conn: conn,
  82. CallOptions: defaultErrorGroupCallOptions(),
  83. errorGroupClient: clouderrorreportingpb.NewErrorGroupServiceClient(conn),
  84. }
  85. c.SetGoogleClientInfo()
  86. return c, nil
  87. }
  88. // Connection returns the client's connection to the API service.
  89. func (c *ErrorGroupClient) Connection() *grpc.ClientConn {
  90. return c.conn
  91. }
  92. // Close closes the connection to the API service. The user should invoke this when
  93. // the client is no longer required.
  94. func (c *ErrorGroupClient) Close() error {
  95. return c.conn.Close()
  96. }
  97. // SetGoogleClientInfo sets the name and version of the application in
  98. // the `x-goog-api-client` header passed on each request. Intended for
  99. // use by Google-written clients.
  100. func (c *ErrorGroupClient) SetGoogleClientInfo(keyval ...string) {
  101. kv := append([]string{"gl-go", version.Go()}, keyval...)
  102. kv = append(kv, "gapic", version.Repo, "gax", gax.Version, "grpc", grpc.Version)
  103. c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
  104. }
  105. // GetGroup get the specified group.
  106. func (c *ErrorGroupClient) GetGroup(ctx context.Context, req *clouderrorreportingpb.GetGroupRequest, opts ...gax.CallOption) (*clouderrorreportingpb.ErrorGroup, error) {
  107. ctx = insertMetadata(ctx, c.xGoogMetadata)
  108. opts = append(c.CallOptions.GetGroup[0:len(c.CallOptions.GetGroup):len(c.CallOptions.GetGroup)], opts...)
  109. var resp *clouderrorreportingpb.ErrorGroup
  110. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  111. var err error
  112. resp, err = c.errorGroupClient.GetGroup(ctx, req, settings.GRPC...)
  113. return err
  114. }, opts...)
  115. if err != nil {
  116. return nil, err
  117. }
  118. return resp, nil
  119. }
  120. // UpdateGroup replace the data for the specified group.
  121. // Fails if the group does not exist.
  122. func (c *ErrorGroupClient) UpdateGroup(ctx context.Context, req *clouderrorreportingpb.UpdateGroupRequest, opts ...gax.CallOption) (*clouderrorreportingpb.ErrorGroup, error) {
  123. ctx = insertMetadata(ctx, c.xGoogMetadata)
  124. opts = append(c.CallOptions.UpdateGroup[0:len(c.CallOptions.UpdateGroup):len(c.CallOptions.UpdateGroup)], opts...)
  125. var resp *clouderrorreportingpb.ErrorGroup
  126. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  127. var err error
  128. resp, err = c.errorGroupClient.UpdateGroup(ctx, req, settings.GRPC...)
  129. return err
  130. }, opts...)
  131. if err != nil {
  132. return nil, err
  133. }
  134. return resp, nil
  135. }