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.2 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 talent
  16. import (
  17. "context"
  18. gax "github.com/googleapis/gax-go/v2"
  19. "google.golang.org/api/option"
  20. "google.golang.org/api/transport"
  21. talentpb "google.golang.org/genproto/googleapis/cloud/talent/v4beta1"
  22. "google.golang.org/grpc"
  23. "google.golang.org/grpc/metadata"
  24. )
  25. // EventCallOptions contains the retry settings for each method of EventClient.
  26. type EventCallOptions struct {
  27. CreateClientEvent []gax.CallOption
  28. }
  29. func defaultEventClientOptions() []option.ClientOption {
  30. return []option.ClientOption{
  31. option.WithEndpoint("jobs.googleapis.com:443"),
  32. option.WithScopes(DefaultAuthScopes()...),
  33. }
  34. }
  35. func defaultEventCallOptions() *EventCallOptions {
  36. retry := map[[2]string][]gax.CallOption{}
  37. return &EventCallOptions{
  38. CreateClientEvent: retry[[2]string{"default", "non_idempotent"}],
  39. }
  40. }
  41. // EventClient is a client for interacting with Cloud Talent Solution API.
  42. //
  43. // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
  44. type EventClient struct {
  45. // The connection to the service.
  46. conn *grpc.ClientConn
  47. // The gRPC API client.
  48. eventClient talentpb.EventServiceClient
  49. // The call options for this service.
  50. CallOptions *EventCallOptions
  51. // The x-goog-* metadata to be sent with each request.
  52. xGoogMetadata metadata.MD
  53. }
  54. // NewEventClient creates a new event service client.
  55. //
  56. // A service handles client event report.
  57. func NewEventClient(ctx context.Context, opts ...option.ClientOption) (*EventClient, error) {
  58. conn, err := transport.DialGRPC(ctx, append(defaultEventClientOptions(), opts...)...)
  59. if err != nil {
  60. return nil, err
  61. }
  62. c := &EventClient{
  63. conn: conn,
  64. CallOptions: defaultEventCallOptions(),
  65. eventClient: talentpb.NewEventServiceClient(conn),
  66. }
  67. c.setGoogleClientInfo()
  68. return c, nil
  69. }
  70. // Connection returns the client's connection to the API service.
  71. func (c *EventClient) Connection() *grpc.ClientConn {
  72. return c.conn
  73. }
  74. // Close closes the connection to the API service. The user should invoke this when
  75. // the client is no longer required.
  76. func (c *EventClient) Close() error {
  77. return c.conn.Close()
  78. }
  79. // setGoogleClientInfo sets the name and version of the application in
  80. // the `x-goog-api-client` header passed on each request. Intended for
  81. // use by Google-written clients.
  82. func (c *EventClient) setGoogleClientInfo(keyval ...string) {
  83. kv := append([]string{"gl-go", versionGo()}, keyval...)
  84. kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
  85. c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
  86. }
  87. // CreateClientEvent report events issued when end user interacts with customer's application
  88. // that uses Cloud Talent Solution. You may inspect the created events in
  89. // self service
  90. // tools (at https://console.cloud.google.com/talent-solution/overview).
  91. // Learn
  92. // more (at https://cloud.google.com/talent-solution/job-search/docs/management-tools)
  93. // about self service tools.
  94. func (c *EventClient) CreateClientEvent(ctx context.Context, req *talentpb.CreateClientEventRequest, opts ...gax.CallOption) (*talentpb.ClientEvent, error) {
  95. ctx = insertMetadata(ctx, c.xGoogMetadata)
  96. opts = append(c.CallOptions.CreateClientEvent[0:len(c.CallOptions.CreateClientEvent):len(c.CallOptions.CreateClientEvent)], opts...)
  97. var resp *talentpb.ClientEvent
  98. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  99. var err error
  100. resp, err = c.eventClient.CreateClientEvent(ctx, req, settings.GRPC...)
  101. return err
  102. }, opts...)
  103. if err != nil {
  104. return nil, err
  105. }
  106. return resp, nil
  107. }