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.
 
 
 

125 lines
4.6 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. "cloud.google.com/go/internal/version"
  18. gax "github.com/googleapis/gax-go"
  19. "golang.org/x/net/context"
  20. "google.golang.org/api/option"
  21. "google.golang.org/api/transport"
  22. clouderrorreportingpb "google.golang.org/genproto/googleapis/devtools/clouderrorreporting/v1beta1"
  23. "google.golang.org/grpc"
  24. "google.golang.org/grpc/metadata"
  25. )
  26. // ReportErrorsCallOptions contains the retry settings for each method of ReportErrorsClient.
  27. type ReportErrorsCallOptions struct {
  28. ReportErrorEvent []gax.CallOption
  29. }
  30. func defaultReportErrorsClientOptions() []option.ClientOption {
  31. return []option.ClientOption{
  32. option.WithEndpoint("clouderrorreporting.googleapis.com:443"),
  33. option.WithScopes(DefaultAuthScopes()...),
  34. }
  35. }
  36. func defaultReportErrorsCallOptions() *ReportErrorsCallOptions {
  37. retry := map[[2]string][]gax.CallOption{}
  38. return &ReportErrorsCallOptions{
  39. ReportErrorEvent: retry[[2]string{"default", "non_idempotent"}],
  40. }
  41. }
  42. // ReportErrorsClient is a client for interacting with Stackdriver Error Reporting API.
  43. //
  44. // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
  45. type ReportErrorsClient struct {
  46. // The connection to the service.
  47. conn *grpc.ClientConn
  48. // The gRPC API client.
  49. reportErrorsClient clouderrorreportingpb.ReportErrorsServiceClient
  50. // The call options for this service.
  51. CallOptions *ReportErrorsCallOptions
  52. // The x-goog-* metadata to be sent with each request.
  53. xGoogMetadata metadata.MD
  54. }
  55. // NewReportErrorsClient creates a new report errors service client.
  56. //
  57. // An API for reporting error events.
  58. func NewReportErrorsClient(ctx context.Context, opts ...option.ClientOption) (*ReportErrorsClient, error) {
  59. conn, err := transport.DialGRPC(ctx, append(defaultReportErrorsClientOptions(), opts...)...)
  60. if err != nil {
  61. return nil, err
  62. }
  63. c := &ReportErrorsClient{
  64. conn: conn,
  65. CallOptions: defaultReportErrorsCallOptions(),
  66. reportErrorsClient: clouderrorreportingpb.NewReportErrorsServiceClient(conn),
  67. }
  68. c.SetGoogleClientInfo()
  69. return c, nil
  70. }
  71. // Connection returns the client's connection to the API service.
  72. func (c *ReportErrorsClient) Connection() *grpc.ClientConn {
  73. return c.conn
  74. }
  75. // Close closes the connection to the API service. The user should invoke this when
  76. // the client is no longer required.
  77. func (c *ReportErrorsClient) Close() error {
  78. return c.conn.Close()
  79. }
  80. // SetGoogleClientInfo sets the name and version of the application in
  81. // the `x-goog-api-client` header passed on each request. Intended for
  82. // use by Google-written clients.
  83. func (c *ReportErrorsClient) SetGoogleClientInfo(keyval ...string) {
  84. kv := append([]string{"gl-go", version.Go()}, keyval...)
  85. kv = append(kv, "gapic", version.Repo, "gax", gax.Version, "grpc", grpc.Version)
  86. c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
  87. }
  88. // ReportErrorEvent report an individual error event.
  89. //
  90. // This endpoint accepts <strong>either</strong> an OAuth token,
  91. // <strong>or</strong> an
  92. // <a href="https://support.google.com/cloud/answer/6158862">API key</a>
  93. // for authentication. To use an API key, append it to the URL as the value of
  94. // a key parameter. For example:<pre>POST https://clouderrorreporting.googleapis.com/v1beta1/projects/example-project/events:report?key=123ABC456</pre>
  95. func (c *ReportErrorsClient) ReportErrorEvent(ctx context.Context, req *clouderrorreportingpb.ReportErrorEventRequest, opts ...gax.CallOption) (*clouderrorreportingpb.ReportErrorEventResponse, error) {
  96. ctx = insertMetadata(ctx, c.xGoogMetadata)
  97. opts = append(c.CallOptions.ReportErrorEvent[0:len(c.CallOptions.ReportErrorEvent):len(c.CallOptions.ReportErrorEvent)], opts...)
  98. var resp *clouderrorreportingpb.ReportErrorEventResponse
  99. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  100. var err error
  101. resp, err = c.reportErrorsClient.ReportErrorEvent(ctx, req, settings.GRPC...)
  102. return err
  103. }, opts...)
  104. if err != nil {
  105. return nil, err
  106. }
  107. return resp, nil
  108. }