Cloud Monitoring Metrics Scopes V1 API - Class Google::Cloud::Monitoring::MetricsScope::V1::MetricsScopes::Client (v0.3.0)

Reference documentation and code samples for the Cloud Monitoring Metrics Scopes V1 API class Google::Cloud::Monitoring::MetricsScope::V1::MetricsScopes::Client.

Client for the MetricsScopes service.

Manages Cloud Monitoring Metrics Scopes, and the monitoring of Google Cloud projects and AWS accounts.

Inherits

  • Object

Methods

.configure

def self.configure() { |config| ... } -> Client::Configuration

Configure the MetricsScopes Client class.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter
Example
# Modify the configuration for all MetricsScopes clients
::Google::Cloud::Monitoring::MetricsScope::V1::MetricsScopes::Client.configure do |config|
  config.timeout = 10.0
end

#configure

def configure() { |config| ... } -> Client::Configuration

Configure the MetricsScopes 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.

Yields
  • (config) — Configure the Client client.
Yield Parameter

#create_monitored_project

def create_monitored_project(request, options = nil) -> ::Gapic::Operation
def create_monitored_project(parent: nil, monitored_project: nil) -> ::Gapic::Operation

Adds a MonitoredProject with the given project ID to the specified Metrics Scope.

Overloads
def create_monitored_project(request, options = nil) -> ::Gapic::Operation
Pass arguments to create_monitored_project via a request object, either of type CreateMonitoredProjectRequest or an equivalent Hash.
Parameters
def create_monitored_project(parent: nil, monitored_project: nil) -> ::Gapic::Operation
Pass arguments to create_monitored_project 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).
Parameters
  • parent (::String) — Required. The resource name of the existing Metrics Scope that will monitor this project. Example: locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}
  • monitored_project (::Google::Cloud::Monitoring::MetricsScope::V1::MonitoredProject, ::Hash) — Required. The initial MonitoredProject configuration. Specify only the monitored_project.name field. All other fields are ignored. The monitored_project.name must be in the format: locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}/projects/{MONITORED_PROJECT_ID_OR_NUMBER}
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/monitoring/metrics_scope/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Monitoring::MetricsScope::V1::MetricsScopes::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Monitoring::MetricsScope::V1::CreateMonitoredProjectRequest.new

# Call the create_monitored_project method.
result = client.create_monitored_project request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

#delete_monitored_project

def delete_monitored_project(request, options = nil) -> ::Gapic::Operation
def delete_monitored_project(name: nil) -> ::Gapic::Operation

Deletes a MonitoredProject from the specified Metrics Scope.

Overloads
def delete_monitored_project(request, options = nil) -> ::Gapic::Operation
Pass arguments to delete_monitored_project via a request object, either of type DeleteMonitoredProjectRequest or an equivalent Hash.
Parameters
def delete_monitored_project(name: nil) -> ::Gapic::Operation
Pass arguments to delete_monitored_project 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).
Parameter
  • name (::String) — Required. The resource name of the MonitoredProject. Example: locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}/projects/{MONITORED_PROJECT_ID_OR_NUMBER}

    Authorization requires the following Google IAM permissions on both the Metrics Scope and on the MonitoredProject: monitoring.metricsScopes.link

Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/monitoring/metrics_scope/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Monitoring::MetricsScope::V1::MetricsScopes::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Monitoring::MetricsScope::V1::DeleteMonitoredProjectRequest.new

# Call the delete_monitored_project method.
result = client.delete_monitored_project request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

#get_metrics_scope

def get_metrics_scope(request, options = nil) -> ::Google::Cloud::Monitoring::MetricsScope::V1::MetricsScope
def get_metrics_scope(name: nil) -> ::Google::Cloud::Monitoring::MetricsScope::V1::MetricsScope

Returns a specific Metrics Scope.

Overloads
def get_metrics_scope(request, options = nil) -> ::Google::Cloud::Monitoring::MetricsScope::V1::MetricsScope
Pass arguments to get_metrics_scope via a request object, either of type GetMetricsScopeRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Monitoring::MetricsScope::V1::GetMetricsScopeRequest, ::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_metrics_scope(name: nil) -> ::Google::Cloud::Monitoring::MetricsScope::V1::MetricsScope
Pass arguments to get_metrics_scope 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).
Parameter
  • name (::String) — Required. The resource name of the Metrics Scope. Example: locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/monitoring/metrics_scope/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Monitoring::MetricsScope::V1::MetricsScopes::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Monitoring::MetricsScope::V1::GetMetricsScopeRequest.new

# Call the get_metrics_scope method.
result = client.get_metrics_scope request

# The returned object is of type Google::Cloud::Monitoring::MetricsScope::V1::MetricsScope.
p result

#initialize

def initialize() { |config| ... } -> Client

Create a new MetricsScopes client object.

Yields
  • (config) — Configure the MetricsScopes client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# Create a client using the default configuration
client = ::Google::Cloud::Monitoring::MetricsScope::V1::MetricsScopes::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Monitoring::MetricsScope::V1::MetricsScopes::Client.new do |config|
  config.timeout = 10.0
end

#list_metrics_scopes_by_monitored_project

def list_metrics_scopes_by_monitored_project(request, options = nil) -> ::Google::Cloud::Monitoring::MetricsScope::V1::ListMetricsScopesByMonitoredProjectResponse
def list_metrics_scopes_by_monitored_project(monitored_resource_container: nil) -> ::Google::Cloud::Monitoring::MetricsScope::V1::ListMetricsScopesByMonitoredProjectResponse

Returns a list of every Metrics Scope that a specific MonitoredProject has been added to. The metrics scope representing the specified monitored project will always be the first entry in the response.

Overloads
def list_metrics_scopes_by_monitored_project(request, options = nil) -> ::Google::Cloud::Monitoring::MetricsScope::V1::ListMetricsScopesByMonitoredProjectResponse
Pass arguments to list_metrics_scopes_by_monitored_project via a request object, either of type ListMetricsScopesByMonitoredProjectRequest or an equivalent Hash.
Parameters
def list_metrics_scopes_by_monitored_project(monitored_resource_container: nil) -> ::Google::Cloud::Monitoring::MetricsScope::V1::ListMetricsScopesByMonitoredProjectResponse
Pass arguments to list_metrics_scopes_by_monitored_project 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).
Parameter
  • monitored_resource_container (::String) — Required. The resource name of the Monitored Project being requested. Example: projects/{MONITORED_PROJECT_ID_OR_NUMBER}
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/monitoring/metrics_scope/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Monitoring::MetricsScope::V1::MetricsScopes::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Monitoring::MetricsScope::V1::ListMetricsScopesByMonitoredProjectRequest.new

# Call the list_metrics_scopes_by_monitored_project method.
result = client.list_metrics_scopes_by_monitored_project request

# The returned object is of type Google::Cloud::Monitoring::MetricsScope::V1::ListMetricsScopesByMonitoredProjectResponse.
p result

#operations_client

def operations_client() -> ::Google::Cloud::Monitoring::MetricsScope::V1::MetricsScopes::Operations

Get the associated client for long-running operations.