Class: Google::Apis::ServicecontrolV1::ServiceControlService

Inherits:
Core::BaseService show all
Defined in:
generated/google/apis/servicecontrol_v1/service.rb

Overview

Google Service Control API

Google Service Control provides control plane functionality to managed services, such as logging, monitoring, and status checks.

Examples:

require 'google/apis/servicecontrol_v1'

Servicecontrol = Google::Apis::ServicecontrolV1 # Alias the module
service = Servicecontrol::ServiceControlService.new

See Also:

Instance Attribute Summary collapse

Attributes inherited from Core::BaseService

#authorization, #base_path, #batch_path, #client, #client_options, #request_options, #root_url, #upload_path

Instance Method Summary collapse

Methods inherited from Core::BaseService

#batch, #batch_upload, #fetch_all, #http

Methods included from Core::Logging

#logger

Constructor Details

#initializeServiceControlService

Returns a new instance of ServiceControlService



46
47
48
49
# File 'generated/google/apis/servicecontrol_v1/service.rb', line 46

def initialize
  super('https://servicecontrol.googleapis.com/', '')
  @batch_path = 'batch'
end

Instance Attribute Details

#keyString

Returns API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.

Returns:

  • (String)

    API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.



39
40
41
# File 'generated/google/apis/servicecontrol_v1/service.rb', line 39

def key
  @key
end

#quota_userString

Returns Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

Returns:

  • (String)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.



44
45
46
# File 'generated/google/apis/servicecontrol_v1/service.rb', line 44

def quota_user
  @quota_user
end

Instance Method Details

#allocate_service_quota(service_name, allocate_quota_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::ServicecontrolV1::AllocateQuotaResponse

Attempts to allocate quota for the specified consumer. It should be called before the operation is executed. This method requires the servicemanagement.services.quota permission on the specified service. For more information, see Google Cloud IAM. NOTE: the client code must fail-open if the server returns one of the following quota errors:

  • PROJECT_STATUS_UNAVAILABLE
  • SERVICE_STATUS_UNAVAILABLE
  • BILLING_STATUS_UNAVAILABLE
  • QUOTA_SYSTEM_UNAVAILABLE The server may inject above errors to prohibit any hard dependency on the quota system.

Parameters:

  • service_name (String)

    Name of the service as specified in the service configuration. For example, "pubsub.googleapis.com". See google.api.Service for the definition of a service name.

  • allocate_quota_request_object (Google::Apis::ServicecontrolV1::AllocateQuotaRequest) (defaults to: nil)
  • fields (String)

    Selector specifying which fields to include in a partial response.

  • quota_user (String)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:



260
261
262
263
264
265
266
267
268
269
270
# File 'generated/google/apis/servicecontrol_v1/service.rb', line 260

def allocate_service_quota(service_name, allocate_quota_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command =  make_simple_command(:post, 'v1/services/{serviceName}:allocateQuota', options)
  command.request_representation = Google::Apis::ServicecontrolV1::AllocateQuotaRequest::Representation
  command.request_object = allocate_quota_request_object
  command.response_representation = Google::Apis::ServicecontrolV1::AllocateQuotaResponse::Representation
  command.response_class = Google::Apis::ServicecontrolV1::AllocateQuotaResponse
  command.params['serviceName'] = service_name unless service_name.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#check_service(service_name, check_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::ServicecontrolV1::CheckResponse

Checks an operation with Google Service Control to decide whether the given operation should proceed. It should be called before the operation is executed. If feasible, the client should cache the check results and reuse them for 60 seconds. In case of server errors, the client can rely on the cached results for longer time. NOTE: the CheckRequest has the size limit of 64KB. This method requires the servicemanagement.services.check permission on the specified service. For more information, see Google Cloud IAM.

Parameters:

  • service_name (String)

    The service name as specified in its service configuration. For example, "pubsub.googleapis.com". See google.api.Service for the definition of a service name.

  • check_request_object (Google::Apis::ServicecontrolV1::CheckRequest) (defaults to: nil)
  • fields (String)

    Selector specifying which fields to include in a partial response.

  • quota_user (String)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:



83
84
85
86
87
88
89
90
91
92
93
# File 'generated/google/apis/servicecontrol_v1/service.rb', line 83

def check_service(service_name, check_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command =  make_simple_command(:post, 'v1/services/{serviceName}:check', options)
  command.request_representation = Google::Apis::ServicecontrolV1::CheckRequest::Representation
  command.request_object = check_request_object
  command.response_representation = Google::Apis::ServicecontrolV1::CheckResponse::Representation
  command.response_class = Google::Apis::ServicecontrolV1::CheckResponse
  command.params['serviceName'] = service_name unless service_name.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#end_service_reconciliation(service_name, end_reconciliation_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::ServicecontrolV1::EndReconciliationResponse

Signals the quota controller that service ends the ongoing usage reconciliation. This method requires the servicemanagement.services.quota permission on the specified service. For more information, see Google Cloud IAM.

Parameters:

  • service_name (String)

    Name of the service as specified in the service configuration. For example, "pubsub.googleapis.com". See google.api.Service for the definition of a service name.

  • end_reconciliation_request_object (Google::Apis::ServicecontrolV1::EndReconciliationRequest) (defaults to: nil)
  • fields (String)

    Selector specifying which fields to include in a partial response.

  • quota_user (String)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:



168
169
170
171
172
173
174
175
176
177
178
# File 'generated/google/apis/servicecontrol_v1/service.rb', line 168

def end_service_reconciliation(service_name, end_reconciliation_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command =  make_simple_command(:post, 'v1/services/{serviceName}:endReconciliation', options)
  command.request_representation = Google::Apis::ServicecontrolV1::EndReconciliationRequest::Representation
  command.request_object = end_reconciliation_request_object
  command.response_representation = Google::Apis::ServicecontrolV1::EndReconciliationResponse::Representation
  command.response_class = Google::Apis::ServicecontrolV1::EndReconciliationResponse
  command.params['serviceName'] = service_name unless service_name.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#release_service_quota(service_name, release_quota_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::ServicecontrolV1::ReleaseQuotaResponse

Releases previously allocated quota done through AllocateQuota method. This method requires the servicemanagement.services.quota permission on the specified service. For more information, see Google Cloud IAM. NOTE: the client code must fail-open if the server returns one of the following quota errors:

  • PROJECT_STATUS_UNAVAILABLE
  • SERVICE_STATUS_UNAVAILABLE
  • BILLING_STATUS_UNAVAILABLE
  • QUOTA_SYSTEM_UNAVAILABLE The server may inject above errors to prohibit any hard dependency on the quota system.

Parameters:

  • service_name (String)

    Name of the service as specified in the service configuration. For example, "pubsub.googleapis.com". See google.api.Service for the definition of a service name.

  • release_quota_request_object (Google::Apis::ServicecontrolV1::ReleaseQuotaRequest) (defaults to: nil)
  • fields (String)

    Selector specifying which fields to include in a partial response.

  • quota_user (String)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:



129
130
131
132
133
134
135
136
137
138
139
# File 'generated/google/apis/servicecontrol_v1/service.rb', line 129

def release_service_quota(service_name, release_quota_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command =  make_simple_command(:post, 'v1/services/{serviceName}:releaseQuota', options)
  command.request_representation = Google::Apis::ServicecontrolV1::ReleaseQuotaRequest::Representation
  command.request_object = release_quota_request_object
  command.response_representation = Google::Apis::ServicecontrolV1::ReleaseQuotaResponse::Representation
  command.response_class = Google::Apis::ServicecontrolV1::ReleaseQuotaResponse
  command.params['serviceName'] = service_name unless service_name.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#report_service(service_name, report_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::ServicecontrolV1::ReportResponse

Reports operation results to Google Service Control, such as logs and metrics. It should be called after an operation is completed. If feasible, the client should aggregate reporting data for up to 5 seconds to reduce API traffic. Limiting aggregation to 5 seconds is to reduce data loss during client crashes. Clients should carefully choose the aggregation time window to avoid data loss risk more than 0.01% for business and compliance reasons. NOTE: the ReportRequest has the size limit of 1MB. This method requires the servicemanagement.services.report permission on the specified service. For more information, see Google Cloud IAM.

Parameters:

  • service_name (String)

    The service name as specified in its service configuration. For example, "pubsub.googleapis.com". See google.api.Service for the definition of a service name.

  • report_request_object (Google::Apis::ServicecontrolV1::ReportRequest) (defaults to: nil)
  • fields (String)

    Selector specifying which fields to include in a partial response.

  • quota_user (String)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:



213
214
215
216
217
218
219
220
221
222
223
# File 'generated/google/apis/servicecontrol_v1/service.rb', line 213

def report_service(service_name, report_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command =  make_simple_command(:post, 'v1/services/{serviceName}:report', options)
  command.request_representation = Google::Apis::ServicecontrolV1::ReportRequest::Representation
  command.request_object = report_request_object
  command.response_representation = Google::Apis::ServicecontrolV1::ReportResponse::Representation
  command.response_class = Google::Apis::ServicecontrolV1::ReportResponse
  command.params['serviceName'] = service_name unless service_name.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#start_service_reconciliation(service_name, start_reconciliation_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::ServicecontrolV1::StartReconciliationResponse

Unlike rate quota, allocation quota does not get refilled periodically. So, it is possible that the quota usage as seen by the service differs from what the One Platform considers the usage is. This is expected to happen only rarely, but over time this can accumulate. Services can invoke StartReconciliation and EndReconciliation to correct this usage drift, as described below:

  1. Service sends StartReconciliation with a timestamp in future for each metric that needs to be reconciled. The timestamp being in future allows to account for in-flight AllocateQuota and ReleaseQuota requests for the same metric.
  2. One Platform records this timestamp and starts tracking subsequent AllocateQuota and ReleaseQuota requests until EndReconciliation is called.
  3. At or after the time specified in the StartReconciliation, service sends EndReconciliation with the usage that needs to be reconciled to.
  4. One Platform adjusts its own record of usage for that metric to the value specified in EndReconciliation by taking in to account any allocation or release between StartReconciliation and EndReconciliation. Signals the quota controller that the service wants to perform a usage reconciliation as specified in the request. This method requires the servicemanagement.services.quota permission on the specified service. For more information, see Google Cloud IAM.

Parameters:

  • service_name (String)

    Name of the service as specified in the service configuration. For example, "pubsub.googleapis.com". See google.api.Service for the definition of a service name.

  • start_reconciliation_request_object (Google::Apis::ServicecontrolV1::StartReconciliationRequest) (defaults to: nil)
  • fields (String)

    Selector specifying which fields to include in a partial response.

  • quota_user (String)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:



317
318
319
320
321
322
323
324
325
326
327
# File 'generated/google/apis/servicecontrol_v1/service.rb', line 317

def start_service_reconciliation(service_name, start_reconciliation_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command =  make_simple_command(:post, 'v1/services/{serviceName}:startReconciliation', options)
  command.request_representation = Google::Apis::ServicecontrolV1::StartReconciliationRequest::Representation
  command.request_object = start_reconciliation_request_object
  command.response_representation = Google::Apis::ServicecontrolV1::StartReconciliationResponse::Representation
  command.response_class = Google::Apis::ServicecontrolV1::StartReconciliationResponse
  command.params['serviceName'] = service_name unless service_name.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end