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.
 
 
 

159 lines
4.7 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. // ResumeCallOptions contains the retry settings for each method of ResumeClient.
  26. type ResumeCallOptions struct {
  27. ParseResume []gax.CallOption
  28. }
  29. func defaultResumeClientOptions() []option.ClientOption {
  30. return []option.ClientOption{
  31. option.WithEndpoint("jobs.googleapis.com:443"),
  32. option.WithScopes(DefaultAuthScopes()...),
  33. }
  34. }
  35. func defaultResumeCallOptions() *ResumeCallOptions {
  36. retry := map[[2]string][]gax.CallOption{}
  37. return &ResumeCallOptions{
  38. ParseResume: retry[[2]string{"default", "non_idempotent"}],
  39. }
  40. }
  41. // ResumeClient 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 ResumeClient struct {
  45. // The connection to the service.
  46. conn *grpc.ClientConn
  47. // The gRPC API client.
  48. resumeClient talentpb.ResumeServiceClient
  49. // The call options for this service.
  50. CallOptions *ResumeCallOptions
  51. // The x-goog-* metadata to be sent with each request.
  52. xGoogMetadata metadata.MD
  53. }
  54. // NewResumeClient creates a new resume service client.
  55. //
  56. // A service that handles resume parsing.
  57. func NewResumeClient(ctx context.Context, opts ...option.ClientOption) (*ResumeClient, error) {
  58. conn, err := transport.DialGRPC(ctx, append(defaultResumeClientOptions(), opts...)...)
  59. if err != nil {
  60. return nil, err
  61. }
  62. c := &ResumeClient{
  63. conn: conn,
  64. CallOptions: defaultResumeCallOptions(),
  65. resumeClient: talentpb.NewResumeServiceClient(conn),
  66. }
  67. c.setGoogleClientInfo()
  68. return c, nil
  69. }
  70. // Connection returns the client's connection to the API service.
  71. func (c *ResumeClient) 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 *ResumeClient) 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 *ResumeClient) 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. // ParseResume parses a resume into a [Profile][google.cloud.talent.v4beta1.Profile]. The
  88. // API attempts to fill out the following profile fields if present within the
  89. // resume:
  90. //
  91. // personNames
  92. //
  93. // addresses
  94. //
  95. // emailAddress
  96. //
  97. // phoneNumbers
  98. //
  99. // personalUris
  100. //
  101. // employmentRecords
  102. //
  103. // educationRecords
  104. //
  105. // skills
  106. //
  107. // Note that some attributes in these fields may not be populated if they're
  108. // not present within the resume or unrecognizable by the resume parser.
  109. //
  110. // This API does not save the resume or profile. To create a profile from this
  111. // resume, clients need to call the CreateProfile method again with the
  112. // profile returned.
  113. //
  114. // The following list of formats are supported:
  115. //
  116. // PDF
  117. //
  118. // TXT
  119. //
  120. // DOC
  121. //
  122. // RTF
  123. //
  124. // DOCX
  125. //
  126. // PNG (only when [ParseResumeRequest.enable_ocr][] is set to true,
  127. // otherwise an error is thrown)
  128. func (c *ResumeClient) ParseResume(ctx context.Context, req *talentpb.ParseResumeRequest, opts ...gax.CallOption) (*talentpb.ParseResumeResponse, error) {
  129. ctx = insertMetadata(ctx, c.xGoogMetadata)
  130. opts = append(c.CallOptions.ParseResume[0:len(c.CallOptions.ParseResume):len(c.CallOptions.ParseResume)], opts...)
  131. var resp *talentpb.ParseResumeResponse
  132. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  133. var err error
  134. resp, err = c.resumeClient.ParseResume(ctx, req, settings.GRPC...)
  135. return err
  136. }, opts...)
  137. if err != nil {
  138. return nil, err
  139. }
  140. return resp, nil
  141. }