Reference documentation and code samples for the Service Usage V1 API class Google::Cloud::ServiceUsage::V1::ServiceUsage::Client.
Client for the ServiceUsage service.
Enables services that service consumers want to use on Google Cloud Platform, lists the available or enabled services, or disables services that service consumers no longer use.
Inherits
- Object
Methods
.configure
def self.configure() { |config| ... } -> Client::Configuration
Configure the ServiceUsage Client class.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
# Modify the configuration for all ServiceUsage clients ::Google::Cloud::ServiceUsage::V1::ServiceUsage::Client.configure do |config| config.timeout = 10.0 end
#batch_enable_services
def batch_enable_services(request, options = nil) -> ::Gapic::Operation
def batch_enable_services(parent: nil, service_ids: nil) -> ::Gapic::Operation
Enable multiple services on a project. The operation is atomic: if enabling
any service fails, then the entire batch fails, and no state changes occur.
To enable a single service, use the EnableService
method instead.
def batch_enable_services(request, options = nil) -> ::Gapic::Operation
batch_enable_services
via a request object, either of type
BatchEnableServicesRequest or an equivalent Hash.
- request (::Google::Cloud::ServiceUsage::V1::BatchEnableServicesRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def batch_enable_services(parent: nil, service_ids: nil) -> ::Gapic::Operation
batch_enable_services
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
parent (::String) — Parent to enable services on.
An example name would be:
projects/123
where123
is the project number.The
BatchEnableServices
method currently only supports projects. -
service_ids (::Array<::String>) — The identifiers of the services to enable on the project.
A valid identifier would be: serviceusage.googleapis.com
Enabling services requires that each service is public or is shared with the user enabling the service.
A single request can enable a maximum of 20 services at a time. If more than 20 services are specified, the request will fail, and no state changes will occur.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/service_usage/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::ServiceUsage::V1::ServiceUsage::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::ServiceUsage::V1::BatchEnableServicesRequest.new # Call the batch_enable_services method. result = client.batch_enable_services request # The returned object is of type Gapic::Operation. You can use this # object to check the status of an operation, cancel it, or wait # for results. Here is how to block until completion: result.wait_until_done! timeout: 60 if result.response? p result.response else puts "Error!" end
#batch_get_services
def batch_get_services(request, options = nil) -> ::Google::Cloud::ServiceUsage::V1::BatchGetServicesResponse
def batch_get_services(parent: nil, names: nil) -> ::Google::Cloud::ServiceUsage::V1::BatchGetServicesResponse
Returns the service configurations and enabled states for a given list of services.
def batch_get_services(request, options = nil) -> ::Google::Cloud::ServiceUsage::V1::BatchGetServicesResponse
batch_get_services
via a request object, either of type
BatchGetServicesRequest or an equivalent Hash.
- request (::Google::Cloud::ServiceUsage::V1::BatchGetServicesRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def batch_get_services(parent: nil, names: nil) -> ::Google::Cloud::ServiceUsage::V1::BatchGetServicesResponse
batch_get_services
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
parent (::String) — Parent to retrieve services from.
If this is set, the parent of all of the services specified in
names
must match this field. An example name would be:projects/123
where123
is the project number. TheBatchGetServices
method currently only supports projects. -
names (::Array<::String>) — Names of the services to retrieve.
An example name would be:
projects/123/services/serviceusage.googleapis.com
where123
is the project number. A single request can get a maximum of 30 services at a time.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::ServiceUsage::V1::BatchGetServicesResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/service_usage/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::ServiceUsage::V1::ServiceUsage::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::ServiceUsage::V1::BatchGetServicesRequest.new # Call the batch_get_services method. result = client.batch_get_services request # The returned object is of type Google::Cloud::ServiceUsage::V1::BatchGetServicesResponse. p result
#configure
def configure() { |config| ... } -> Client::Configuration
Configure the ServiceUsage Client instance.
The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
#disable_service
def disable_service(request, options = nil) -> ::Gapic::Operation
def disable_service(name: nil, disable_dependent_services: nil, check_if_service_has_usage: nil) -> ::Gapic::Operation
Disable a service so that it can no longer be used with a project. This prevents unintended usage that may cause unexpected billing charges or security leaks.
It is not valid to call the disable method on a service that is not
currently enabled. Callers will receive a FAILED_PRECONDITION
status if
the target service is not currently enabled.
def disable_service(request, options = nil) -> ::Gapic::Operation
disable_service
via a request object, either of type
DisableServiceRequest or an equivalent Hash.
- request (::Google::Cloud::ServiceUsage::V1::DisableServiceRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def disable_service(name: nil, disable_dependent_services: nil, check_if_service_has_usage: nil) -> ::Gapic::Operation
disable_service
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
name (::String) — Name of the consumer and service to disable the service on.
The enable and disable methods currently only support projects.
An example name would be:
projects/123/services/serviceusage.googleapis.com
where123
is the project number. - disable_dependent_services (::Boolean) — Indicates if services that are enabled and which depend on this service should also be disabled. If not set, an error will be generated if any enabled services depend on the service to be disabled. When set, the service, and any enabled services that depend on it, will be disabled together.
- check_if_service_has_usage (::Google::Cloud::ServiceUsage::V1::DisableServiceRequest::CheckIfServiceHasUsage) — Defines the behavior for checking service usage when disabling a service.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/service_usage/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::ServiceUsage::V1::ServiceUsage::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::ServiceUsage::V1::DisableServiceRequest.new # Call the disable_service method. result = client.disable_service request # The returned object is of type Gapic::Operation. You can use this # object to check the status of an operation, cancel it, or wait # for results. Here is how to block until completion: result.wait_until_done! timeout: 60 if result.response? p result.response else puts "Error!" end
#enable_service
def enable_service(request, options = nil) -> ::Gapic::Operation
def enable_service(name: nil) -> ::Gapic::Operation
Enable a service so that it can be used with a project.
def enable_service(request, options = nil) -> ::Gapic::Operation
enable_service
via a request object, either of type
EnableServiceRequest or an equivalent Hash.
- request (::Google::Cloud::ServiceUsage::V1::EnableServiceRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def enable_service(name: nil) -> ::Gapic::Operation
enable_service
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
name (::String) — Name of the consumer and service to enable the service on.
The
EnableService
andDisableService
methods currently only support projects.Enabling a service requires that the service is public or is shared with the user enabling the service.
An example name would be:
projects/123/services/serviceusage.googleapis.com
where123
is the project number.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/service_usage/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::ServiceUsage::V1::ServiceUsage::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::ServiceUsage::V1::EnableServiceRequest.new # Call the enable_service method. result = client.enable_service request # The returned object is of type Gapic::Operation. You can use this # object to check the status of an operation, cancel it, or wait # for results. Here is how to block until completion: result.wait_until_done! timeout: 60 if result.response? p result.response else puts "Error!" end
#get_service
def get_service(request, options = nil) -> ::Google::Cloud::ServiceUsage::V1::Service
def get_service(name: nil) -> ::Google::Cloud::ServiceUsage::V1::Service
Returns the service configuration and enabled state for a given service.
def get_service(request, options = nil) -> ::Google::Cloud::ServiceUsage::V1::Service
get_service
via a request object, either of type
GetServiceRequest or an equivalent Hash.
- request (::Google::Cloud::ServiceUsage::V1::GetServiceRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_service(name: nil) -> ::Google::Cloud::ServiceUsage::V1::Service
get_service
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
name (::String) — Name of the consumer and service to get the
ConsumerState
for.An example name would be:
projects/123/services/serviceusage.googleapis.com
where123
is the project number.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::ServiceUsage::V1::Service)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/service_usage/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::ServiceUsage::V1::ServiceUsage::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::ServiceUsage::V1::GetServiceRequest.new # Call the get_service method. result = client.get_service request # The returned object is of type Google::Cloud::ServiceUsage::V1::Service. p result
#initialize
def initialize() { |config| ... } -> Client
Create a new ServiceUsage client object.
- (config) — Configure the ServiceUsage client.
- config (Client::Configuration)
- (Client) — a new instance of Client
# Create a client using the default configuration client = ::Google::Cloud::ServiceUsage::V1::ServiceUsage::Client.new # Create a client using a custom configuration client = ::Google::Cloud::ServiceUsage::V1::ServiceUsage::Client.new do |config| config.timeout = 10.0 end
#list_services
def list_services(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::ServiceUsage::V1::Service>
def list_services(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::ServiceUsage::V1::Service>
List all services available to the specified project, and the current
state of those services with respect to the project. The list includes
all public services, all services for which the calling user has the
servicemanagement.services.bind
permission, and all services that have
already been enabled on the project. The list can be filtered to
only include services in a specific state, for example to only include
services enabled on the project.
WARNING: If you need to query enabled services frequently or across an organization, you should use Cloud Asset Inventory API, which provides higher throughput and richer filtering capability.
def list_services(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::ServiceUsage::V1::Service>
list_services
via a request object, either of type
ListServicesRequest or an equivalent Hash.
- request (::Google::Cloud::ServiceUsage::V1::ListServicesRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def list_services(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::ServiceUsage::V1::Service>
list_services
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
parent (::String) — Parent to search for services on.
An example name would be:
projects/123
where123
is the project number. - page_size (::Integer) — Requested size of the next page of data. Requested page size cannot exceed 200. If not set, the default page size is 50.
- page_token (::String) — Token identifying which result to start with, which is returned by a previous list call.
-
filter (::String) — Only list services that conform to the given filter.
The allowed filter strings are
state:ENABLED
andstate:DISABLED
.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::PagedEnumerable<::Google::Cloud::ServiceUsage::V1::Service>)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::PagedEnumerable<::Google::Cloud::ServiceUsage::V1::Service>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/service_usage/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::ServiceUsage::V1::ServiceUsage::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::ServiceUsage::V1::ListServicesRequest.new # Call the list_services method. result = client.list_services request # The returned object is of type Gapic::PagedEnumerable. You can # iterate over all elements by calling #each, and the enumerable # will lazily make API calls to fetch subsequent pages. Other # methods are also available for managing paging directly. result.each do |response| # Each element is of type ::Google::Cloud::ServiceUsage::V1::Service. p response end
#operations_client
def operations_client() -> ::Google::Cloud::ServiceUsage::V1::ServiceUsage::Operations
Get the associated client for long-running operations.