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

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

Overview

Service Control API

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 Cloud IAM. NOTE: The client must fail-open on server errors INTERNAL, UNKNOWN, DEADLINE_EXCEEDED, and UNAVAILABLE. To ensure system reliability, the server may inject these errors to prohibit any hard dependency on the quota functionality.

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:


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

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 whether an operation on a service should be allowed to proceed based on the configuration of the service and related policies. It must 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 any server errors, the client should rely on the cached results for much longer time to avoid outage. WARNING: There is general 60s delay for the configuration and policy propagation, therefore callers MUST NOT depend on the Check method having the latest policy information. 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 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:


132
133
134
135
136
137
138
139
140
141
142
# File 'generated/google/apis/servicecontrol_v1/service.rb', line 132

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

#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:


180
181
182
183
184
185
186
187
188
189
190
# File 'generated/google/apis/servicecontrol_v1/service.rb', line 180

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