class Google::Cloud::OsConfig::V1::OsConfigZonalService::Client

Client for the OsConfigZonalService service.

Zonal OS Config API

The OS Config service is the server-side component that allows users to manage package installations and patch jobs for Compute Engine VM instances.

Attributes

os_config_zonal_service_stub[R]

@private

Public Class Methods

configure() { |configure| ... } click to toggle source

Configure the OsConfigZonalService Client class.

See {::Google::Cloud::OsConfig::V1::OsConfigZonalService::Client::Configuration} for a description of the configuration fields.

@example

# Modify the configuration for all OsConfigZonalService clients
::Google::Cloud::OsConfig::V1::OsConfigZonalService::Client.configure do |config|
  config.timeout = 10.0
end

@yield [config] Configure the Client client. @yieldparam config [Client::Configuration]

@return [Client::Configuration]

# File lib/google/cloud/os_config/v1/os_config_zonal_service/client.rb, line 59
def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "OsConfig", "V1"]
    parent_config = while namespace.any?
                      parent_name = namespace.join "::"
                      parent_const = const_get parent_name
                      break parent_const.configure if parent_const.respond_to? :configure
                      namespace.pop
                    end
    default_config = Client::Configuration.new parent_config

    default_config.timeout = 60.0
    default_config.retry_policy = {
      initial_delay: 1.0, max_delay: 60.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config
  end
  yield @configure if block_given?
  @configure
end
new() { |config| ... } click to toggle source

Create a new OsConfigZonalService client object.

@example

# Create a client using the default configuration
client = ::Google::Cloud::OsConfig::V1::OsConfigZonalService::Client.new

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

@yield [config] Configure the OsConfigZonalService client. @yieldparam config [Client::Configuration]

# File lib/google/cloud/os_config/v1/os_config_zonal_service/client.rb, line 117
def initialize
  # 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 "gapic/grpc"
  require "google/cloud/osconfig/v1/osconfig_zonal_service_services_pb"

  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  # Use self-signed JWT if the endpoint is unchanged from default,
  # but only if the default endpoint does not have a region prefix.
  enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
                           !@config.endpoint.split(".").first.include?("-")
  credentials ||= Credentials.default scope: @config.scope,
                                      enable_self_signed_jwt: enable_self_signed_jwt
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end
  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @os_config_zonal_service_stub = ::Gapic::ServiceStub.new(
    ::Google::Cloud::OsConfig::V1::OsConfigZonalService::Stub,
    credentials:  credentials,
    endpoint:     @config.endpoint,
    channel_args: @config.channel_args,
    interceptors: @config.interceptors
  )
end

Public Instance Methods

configure() { |config| ... } click to toggle source

Configure the OsConfigZonalService 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 {::Google::Cloud::OsConfig::V1::OsConfigZonalService::Client::Configuration} for a description of the configuration fields.

@yield [config] Configure the Client client. @yieldparam config [Client::Configuration]

@return [Client::Configuration]

# File lib/google/cloud/os_config/v1/os_config_zonal_service/client.rb, line 96
def configure
  yield @config if block_given?
  @config
end
get_inventory(request, options = nil) { |response, operation| ... } click to toggle source

Get inventory data for the specified VM instance. If the VM has no associated inventory, the message `NOT_FOUND` is returned.

@overload get_inventory(request, options = nil)

Pass arguments to `get_inventory` via a request object, either of type
{::Google::Cloud::OsConfig::V1::GetInventoryRequest} or an equivalent Hash.

@param request [::Google::Cloud::OsConfig::V1::GetInventoryRequest, ::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.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload get_inventory(name: nil, view: nil)

Pass arguments to `get_inventory` 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).

@param name [::String]
  Required. API resource name for inventory resource.

  Format:
  `projects/{project}/locations/{location}/instances/{instance}/inventory`

  For `{project}`, either `project-number` or `project-id` can be provided.
  For `{instance}`, either Compute Engine  `instance-id` or `instance-name`
  can be provided.
@param view [::Google::Cloud::OsConfig::V1::InventoryView]
  Inventory view indicating what information should be included in the
  inventory resource. If unspecified, the default view is BASIC.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::OsConfig::V1::Inventory] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::OsConfig::V1::Inventory]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/os_config/v1/os_config_zonal_service/client.rb, line 195
def get_inventory request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OsConfig::V1::GetInventoryRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.get_inventory.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::OsConfig::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "name" => request.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_inventory.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.get_inventory.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @os_config_zonal_service_stub.call_rpc :get_inventory, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
get_vulnerability_report(request, options = nil) { |response, operation| ... } click to toggle source

Gets the vulnerability report for the specified VM instance. Only VMs with inventory data have vulnerability reports associated with them.

@overload get_vulnerability_report(request, options = nil)

Pass arguments to `get_vulnerability_report` via a request object, either of type
{::Google::Cloud::OsConfig::V1::GetVulnerabilityReportRequest} or an equivalent Hash.

@param request [::Google::Cloud::OsConfig::V1::GetVulnerabilityReportRequest, ::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.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload get_vulnerability_report(name: nil)

Pass arguments to `get_vulnerability_report` 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).

@param name [::String]
  Required. API resource name for vulnerability resource.

  Format:
  `projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport`

  For `{project}`, either `project-number` or `project-id` can be provided.
  For `{instance}`, either Compute Engine `instance-id` or `instance-name`
  can be provided.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::OsConfig::V1::VulnerabilityReport] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::OsConfig::V1::VulnerabilityReport]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/os_config/v1/os_config_zonal_service/client.rb, line 356
def get_vulnerability_report request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OsConfig::V1::GetVulnerabilityReportRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.get_vulnerability_report.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::OsConfig::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "name" => request.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_vulnerability_report.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.get_vulnerability_report.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @os_config_zonal_service_stub.call_rpc :get_vulnerability_report, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
list_inventories(request, options = nil) { |response, operation| ... } click to toggle source

List inventory data for all VM instances in the specified zone.

@overload list_inventories(request, options = nil)

Pass arguments to `list_inventories` via a request object, either of type
{::Google::Cloud::OsConfig::V1::ListInventoriesRequest} or an equivalent Hash.

@param request [::Google::Cloud::OsConfig::V1::ListInventoriesRequest, ::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.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload list_inventories(parent: nil, view: nil, page_size: nil, page_token: nil, filter: nil)

Pass arguments to `list_inventories` 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).

@param parent [::String]
  Required. The parent resource name.

  Format: `projects/{project}/locations/{location}/instances/-`

  For `{project}`, either `project-number` or `project-id` can be provided.
@param view [::Google::Cloud::OsConfig::V1::InventoryView]
  Inventory view indicating what information should be included in the
  inventory resource. If unspecified, the default view is BASIC.
@param page_size [::Integer]
  The maximum number of results to return.
@param page_token [::String]
  A pagination token returned from a previous call to
  `ListInventories` that indicates where this listing
  should continue from.
@param filter [::String]
  If provided, this field specifies the criteria that must be met by a
  `Inventory` API resource to be included in the response.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::OsConfig::V1::Inventory>] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::PagedEnumerable<::Google::Cloud::OsConfig::V1::Inventory>]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/os_config/v1/os_config_zonal_service/client.rb, line 279
def list_inventories request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OsConfig::V1::ListInventoriesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.list_inventories.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::OsConfig::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_inventories.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.list_inventories.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @os_config_zonal_service_stub.call_rpc :list_inventories, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @os_config_zonal_service_stub, :list_inventories, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
list_vulnerability_reports(request, options = nil) { |response, operation| ... } click to toggle source

List vulnerability reports for all VM instances in the specified zone.

@overload list_vulnerability_reports(request, options = nil)

Pass arguments to `list_vulnerability_reports` via a request object, either of type
{::Google::Cloud::OsConfig::V1::ListVulnerabilityReportsRequest} or an equivalent Hash.

@param request [::Google::Cloud::OsConfig::V1::ListVulnerabilityReportsRequest, ::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.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload list_vulnerability_reports(parent: nil, page_size: nil, page_token: nil, filter: nil)

Pass arguments to `list_vulnerability_reports` 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).

@param parent [::String]
  Required. The parent resource name.

  Format: `projects/{project}/locations/{location}/instances/-`

  For `{project}`, either `project-number` or `project-id` can be provided.
@param page_size [::Integer]
  The maximum number of results to return.
@param page_token [::String]
  A pagination token returned from a previous call to
  `ListVulnerabilityReports` that indicates where this listing
  should continue from.
@param filter [::String]
  If provided, this field specifies the criteria that must be met by a
  `vulnerabilityReport` API resource to be included in the response.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::OsConfig::V1::VulnerabilityReport>] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::PagedEnumerable<::Google::Cloud::OsConfig::V1::VulnerabilityReport>]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/os_config/v1/os_config_zonal_service/client.rb, line 437
def list_vulnerability_reports request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OsConfig::V1::ListVulnerabilityReportsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.list_vulnerability_reports.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::OsConfig::V1::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_vulnerability_reports.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.list_vulnerability_reports.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @os_config_zonal_service_stub.call_rpc :list_vulnerability_reports, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @os_config_zonal_service_stub, :list_vulnerability_reports, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end