Class: Google::Cloud::Talent::V4beta1::CompanyServiceClient

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/talent/v4beta1/company_service_client.rb,
lib/google/cloud/talent/v4beta1/helpers.rb

Overview

A service that handles company management, including CRUD and enumeration.

Constant Summary collapse

SERVICE_ADDRESS =

The default address of the service.

"jobs.googleapis.com".freeze
DEFAULT_SERVICE_PORT =

The default port of the service.

443
GRPC_INTERCEPTORS =

The default set of gRPC interceptors.

[]
DEFAULT_TIMEOUT =
30
ALL_SCOPES =

The scopes needed to make gRPC calls to all of the methods defined in this service.

[
  "https://www.googleapis.com/auth/cloud-platform",
  "https://www.googleapis.com/auth/jobs"
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credentials: nil, scopes: ALL_SCOPES, client_config: {}, timeout: DEFAULT_TIMEOUT, metadata: nil, service_address: nil, service_port: nil, exception_transformer: nil, lib_name: nil, lib_version: "") ⇒ CompanyServiceClient

Returns a new instance of CompanyServiceClient.

Parameters:

  • credentials (Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc) (defaults to: nil)

    Provides the means for authenticating requests made by the client. This parameter can be many types. A Google::Auth::Credentials uses a the properties of its represented keyfile for authenticating requests made by this client. A String will be treated as the path to the keyfile to be used for the construction of credentials for this client. A Hash will be treated as the contents of a keyfile to be used for the construction of credentials for this client. A GRPC::Core::Channel will be used to make calls through. A GRPC::Core::ChannelCredentials for the setting up the RPC client. The channel credentials should already be composed with a GRPC::Core::CallCredentials object. A Proc will be used as an updater_proc for the Grpc channel. The proc transforms the metadata for requests, generally, to give OAuth credentials.

  • scopes (Array<String>) (defaults to: ALL_SCOPES)

    The OAuth scopes for this service. This parameter is ignored if an updater_proc is supplied.

  • client_config (Hash) (defaults to: {})

    A Hash for call options for each method. See Google::Gax#construct_settings for the structure of this data. Falls back to the default config if not specified or the specified config is missing data points.

  • timeout (Numeric) (defaults to: DEFAULT_TIMEOUT)

    The default timeout, in seconds, for calls made through this client.

  • metadata (Hash) (defaults to: nil)

    Default metadata to be sent with each request. This can be overridden on a per call basis.

  • service_address (String) (defaults to: nil)

    Override for the service hostname, or nil to leave as the default.

  • service_port (Integer) (defaults to: nil)

    Override for the service port, or nil to leave as the default.

  • exception_transformer (Proc) (defaults to: nil)

    An optional proc that intercepts any exceptions raised during an API call to inject custom error handling.



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/google/cloud/talent/v4beta1/company_service_client.rb', line 173

def initialize \
    credentials: nil,
    scopes: ALL_SCOPES,
    client_config: {},
    timeout: DEFAULT_TIMEOUT,
    metadata: nil,
    service_address: nil,
    service_port: nil,
    exception_transformer: nil,
    lib_name: nil,
    lib_version: ""
  # These require statements are intentionally placed here to initialize
  # the gRPC module only when it's required.
  # See https://github.com/googleapis/toolkit/issues/446
  require "google/gax/grpc"
  require "google/cloud/talent/v4beta1/company_service_services_pb"

  credentials ||= Google::Cloud::Talent::V4beta1::Credentials.default

  if credentials.is_a?(String) || credentials.is_a?(Hash)
    updater_proc = Google::Cloud::Talent::V4beta1::Credentials.new(credentials).updater_proc
  end
  if credentials.is_a?(GRPC::Core::Channel)
    channel = credentials
  end
  if credentials.is_a?(GRPC::Core::ChannelCredentials)
    chan_creds = credentials
  end
  if credentials.is_a?(Proc)
    updater_proc = credentials
  end
  if credentials.is_a?(Google::Auth::Credentials)
    updater_proc = credentials.updater_proc
  end

  package_version = Google::Cloud::Talent::VERSION

  google_api_client = "gl-ruby/#{RUBY_VERSION}"
  google_api_client << " #{lib_name}/#{lib_version}" if lib_name
  google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
  google_api_client << " grpc/#{GRPC::VERSION}"
  google_api_client.freeze

  headers = { :"x-goog-api-client" => google_api_client }
  headers.merge!() unless .nil?
  client_config_file = Pathname.new(__dir__).join(
    "company_service_client_config.json"
  )
  defaults = client_config_file.open do |f|
    Google::Gax.construct_settings(
      "google.cloud.talent.v4beta1.CompanyService",
      JSON.parse(f.read),
      client_config,
      Google::Gax::Grpc::STATUS_CODE_NAMES,
      timeout,
      page_descriptors: PAGE_DESCRIPTORS,
      errors: Google::Gax::Grpc::API_ERRORS,
      metadata: headers
    )
  end

  # Allow overriding the service path/port in subclasses.
  service_path = service_address || self.class::SERVICE_ADDRESS
  port = service_port || self.class::DEFAULT_SERVICE_PORT
  interceptors = self.class::GRPC_INTERCEPTORS
  @company_service_stub = Google::Gax::Grpc.create_stub(
    service_path,
    port,
    chan_creds: chan_creds,
    channel: channel,
    updater_proc: updater_proc,
    scopes: scopes,
    interceptors: interceptors,
    &Google::Cloud::Talent::V4beta1::CompanyService::Stub.method(:new)
  )

  @create_company = Google::Gax.create_api_call(
    @company_service_stub.method(:create_company),
    defaults["create_company"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'parent' => request.parent}
    end
  )
  @get_company = Google::Gax.create_api_call(
    @company_service_stub.method(:get_company),
    defaults["get_company"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @update_company = Google::Gax.create_api_call(
    @company_service_stub.method(:update_company),
    defaults["update_company"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'company.name' => request.company.name}
    end
  )
  @delete_company = Google::Gax.create_api_call(
    @company_service_stub.method(:delete_company),
    defaults["delete_company"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @list_companies = Google::Gax.create_api_call(
    @company_service_stub.method(:list_companies),
    defaults["list_companies"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'parent' => request.parent}
    end
  )
end

Class Method Details

.company_path(project, tenant, company) ⇒ String

Returns a fully-qualified company resource name string.

Parameters:

  • project (String)
  • tenant (String)
  • company (String)

Returns:

  • (String)


101
102
103
104
105
106
107
# File 'lib/google/cloud/talent/v4beta1/company_service_client.rb', line 101

def self.company_path project, tenant, company
  COMPANY_PATH_TEMPLATE.render(
    :"project" => project,
    :"tenant" => tenant,
    :"company" => company
  )
end

.company_without_tenant_path(project, company) ⇒ String

Returns a fully-qualified company_without_tenant resource name string.

Parameters:

  • project (String)
  • company (String)

Returns:

  • (String)


113
114
115
116
117
118
# File 'lib/google/cloud/talent/v4beta1/company_service_client.rb', line 113

def self.company_without_tenant_path project, company
  COMPANY_WITHOUT_TENANT_PATH_TEMPLATE.render(
    :"project" => project,
    :"company" => company
  )
end

.project_path(project) ⇒ String

Returns a fully-qualified project resource name string.

Parameters:

  • project (String)

Returns:

  • (String)


123
124
125
126
127
# File 'lib/google/cloud/talent/v4beta1/company_service_client.rb', line 123

def self.project_path project
  PROJECT_PATH_TEMPLATE.render(
    :"project" => project
  )
end

.tenant_path(project, tenant) ⇒ String

Returns a fully-qualified tenant resource name string.

Parameters:

  • project (String)
  • tenant (String)

Returns:

  • (String)


133
134
135
136
137
138
# File 'lib/google/cloud/talent/v4beta1/company_service_client.rb', line 133

def self.tenant_path project, tenant
  TENANT_PATH_TEMPLATE.render(
    :"project" => project,
    :"tenant" => tenant
  )
end

Instance Method Details

#company_path(project, tenant, company) ⇒ String

Alias for Google::Cloud::Talent::V4beta1::CompanyServiceClient.company_path.

Parameters:

  • project (String)
  • tenant (String)
  • company (String)

Returns:

  • (String)


45
46
47
# File 'lib/google/cloud/talent/v4beta1/helpers.rb', line 45

def company_path project, tenant, company
  self.class.company_path project, tenant, company
end

#company_without_tenant_path(project, company) ⇒ String

Alias for Google::Cloud::Talent::V4beta1::CompanyServiceClient.company_without_tenant_path.

Parameters:

  • project (String)
  • company (String)

Returns:

  • (String)


53
54
55
# File 'lib/google/cloud/talent/v4beta1/helpers.rb', line 53

def company_without_tenant_path project, company
  self.class.company_without_tenant_path project, company
end

#create_company(parent, company, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Talent::V4beta1::Company

Creates a new company entity.

Examples:

require "google/cloud/talent"

company_client = Google::Cloud::Talent::CompanyService.new(version: :v4beta1)
formatted_parent = Google::Cloud::Talent::V4beta1::CompanyServiceClient.tenant_path("[PROJECT]", "[TENANT]")

# TODO: Initialize `company`:
company = {}
response = company_client.create_company(formatted_parent, company)

Parameters:

  • parent (String)

    Required. Resource name of the tenant under which the company is created.

    The format is "projects/project_id/tenants/tenant_id", for example, "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant is created, for example, "projects/foo".

  • company (Google::Cloud::Talent::V4beta1::Company | Hash)

    Required. The company to be created. A hash of the same form as Google::Cloud::Talent::V4beta1::Company can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/google/cloud/talent/v4beta1/company_service_client.rb', line 323

def create_company \
    parent,
    company,
    options: nil,
    &block
  req = {
    parent: parent,
    company: company
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Talent::V4beta1::CreateCompanyRequest)
  @create_company.call(req, options, &block)
end

#delete_company(name, options: nil) {|result, operation| ... } ⇒ Object

Deletes specified company. Prerequisite: The company has no jobs associated with it.

Examples:

require "google/cloud/talent"

company_client = Google::Cloud::Talent::CompanyService.new(version: :v4beta1)
formatted_name = Google::Cloud::Talent::V4beta1::CompanyServiceClient.company_path("[PROJECT]", "[TENANT]", "[COMPANY]")
company_client.delete_company(formatted_name)

Parameters:

  • name (String)

    Required. The resource name of the company to be deleted.

    The format is "projects/project_id/tenants/tenant_id/companies/company_id", for example, "projects/foo/tenants/bar/companies/baz".

    If tenant id is unspecified, the default tenant is used, for example, "projects/foo/companies/bar".

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • result

    []

  • operation (GRPC::ActiveCall::Operation)

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



450
451
452
453
454
455
456
457
458
459
460
# File 'lib/google/cloud/talent/v4beta1/company_service_client.rb', line 450

def delete_company \
    name,
    options: nil,
    &block
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Talent::V4beta1::DeleteCompanyRequest)
  @delete_company.call(req, options, &block)
  nil
end

#get_company(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Talent::V4beta1::Company

Retrieves specified company.

Examples:

require "google/cloud/talent"

company_client = Google::Cloud::Talent::CompanyService.new(version: :v4beta1)
formatted_name = Google::Cloud::Talent::V4beta1::CompanyServiceClient.company_path("[PROJECT]", "[TENANT]", "[COMPANY]")
response = company_client.get_company(formatted_name)

Parameters:

  • name (String)

    Required. The resource name of the company to be retrieved.

    The format is "projects/project_id/tenants/tenant_id/companies/company_id", for example, "projects/api-test-project/tenants/foo/companies/bar".

    If tenant id is unspecified, the default tenant is used, for example, "projects/api-test-project/companies/bar".

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



362
363
364
365
366
367
368
369
370
371
# File 'lib/google/cloud/talent/v4beta1/company_service_client.rb', line 362

def get_company \
    name,
    options: nil,
    &block
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Talent::V4beta1::GetCompanyRequest)
  @get_company.call(req, options, &block)
end

#list_companies(parent, page_size: nil, require_open_jobs: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Cloud::Talent::V4beta1::Company>

Lists all companies associated with the project.

Examples:

require "google/cloud/talent"

company_client = Google::Cloud::Talent::CompanyService.new(version: :v4beta1)
formatted_parent = Google::Cloud::Talent::V4beta1::CompanyServiceClient.tenant_path("[PROJECT]", "[TENANT]")

# Iterate over all results.
company_client.list_companies(formatted_parent).each do |element|
  # Process element.
end

# Or iterate over results one page at a time.
company_client.list_companies(formatted_parent).each_page do |page|
  # Process each page at a time.
  page.each do |element|
    # Process element.
  end
end

Parameters:

  • parent (String)

    Required. Resource name of the tenant under which the company is created.

    The format is "projects/project_id/tenants/tenant_id", for example, "projects/foo/tenant/bar".

    If tenant id is unspecified, the default tenant will be used, for example, "projects/foo".

  • page_size (Integer) (defaults to: nil)

    The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • require_open_jobs (true, false) (defaults to: nil)

    Set to true if the companies requested must have open jobs.

    Defaults to false.

    If true, at most page_size of companies are fetched, among which only those with open jobs are returned.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

  • (Google::Gax::PagedEnumerable<Google::Cloud::Talent::V4beta1::Company>)

    An enumerable of Google::Cloud::Talent::V4beta1::Company instances. See Google::Gax::PagedEnumerable documentation for other operations such as per-page iteration or access to the response object.

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



517
518
519
520
521
522
523
524
525
526
527
528
529
530
# File 'lib/google/cloud/talent/v4beta1/company_service_client.rb', line 517

def list_companies \
    parent,
    page_size: nil,
    require_open_jobs: nil,
    options: nil,
    &block
  req = {
    parent: parent,
    page_size: page_size,
    require_open_jobs: require_open_jobs
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Talent::V4beta1::ListCompaniesRequest)
  @list_companies.call(req, options, &block)
end

#project_path(project) ⇒ String

Alias for Google::Cloud::Talent::V4beta1::CompanyServiceClient.project_path.

Parameters:

  • project (String)

Returns:

  • (String)


60
61
62
# File 'lib/google/cloud/talent/v4beta1/helpers.rb', line 60

def project_path project
  self.class.project_path project
end

#tenant_path(project, tenant) ⇒ String

Alias for Google::Cloud::Talent::V4beta1::CompanyServiceClient.tenant_path.

Parameters:

  • project (String)
  • tenant (String)

Returns:

  • (String)


68
69
70
# File 'lib/google/cloud/talent/v4beta1/helpers.rb', line 68

def tenant_path project, tenant
  self.class.tenant_path project, tenant
end

#update_company(company, update_mask: nil, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Talent::V4beta1::Company

Updates specified company.

Examples:

require "google/cloud/talent"

company_client = Google::Cloud::Talent::CompanyService.new(version: :v4beta1)

# TODO: Initialize `company`:
company = {}
response = company_client.update_company(company)

Parameters:

  • company (Google::Cloud::Talent::V4beta1::Company | Hash)

    Required. The company resource to replace the current resource in the system. A hash of the same form as Google::Cloud::Talent::V4beta1::Company can also be provided.

  • update_mask (Google::Protobuf::FieldMask | Hash) (defaults to: nil)

    Strongly recommended for the best service experience.

    If update_mask is provided, only the specified fields in company are updated. Otherwise all the fields are updated.

    A field mask to specify the company fields to be updated. Only top level fields of Company are supported. A hash of the same form as Google::Protobuf::FieldMask can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



411
412
413
414
415
416
417
418
419
420
421
422
# File 'lib/google/cloud/talent/v4beta1/company_service_client.rb', line 411

def update_company \
    company,
    update_mask: nil,
    options: nil,
    &block
  req = {
    company: company,
    update_mask: update_mask
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Talent::V4beta1::UpdateCompanyRequest)
  @update_company.call(req, options, &block)
end