class Google::Cloud::Dataflow::V1beta3::Snapshots::Client

Client for the Snapshots service.

Provides methods to manage snapshots of Google Cloud Dataflow jobs.

Attributes

snapshots_stub[R]

@private

Public Class Methods

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

Configure the Snapshots Client class.

See {::Google::Cloud::Dataflow::V1beta3::Snapshots::Client::Configuration} for a description of the configuration fields.

@example

# Modify the configuration for all Snapshots clients
::Google::Cloud::Dataflow::V1beta3::Snapshots::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/dataflow/v1beta3/snapshots/client.rb, line 54
def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "Dataflow", "V1beta3"]
    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
  end
  yield @configure if block_given?
  @configure
end
new() { |config| ... } click to toggle source

Create a new Snapshots client object.

@example

# Create a client using the default configuration
client = ::Google::Cloud::Dataflow::V1beta3::Snapshots::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Dataflow::V1beta3::Snapshots::Client.new do |config|
  config.timeout = 10.0
end

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

# File lib/google/cloud/dataflow/v1beta3/snapshots/client.rb, line 109
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/dataflow/v1beta3/snapshots_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

  @snapshots_stub = ::Gapic::ServiceStub.new(
    ::Google::Cloud::Dataflow::V1beta3::SnapshotsV1Beta3::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 Snapshots 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::Dataflow::V1beta3::Snapshots::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/dataflow/v1beta3/snapshots/client.rb, line 88
def configure
  yield @config if block_given?
  @config
end
delete_snapshot(request, options = nil) { |response, operation| ... } click to toggle source

Deletes a snapshot.

@overload delete_snapshot(request, options = nil)

Pass arguments to `delete_snapshot` via a request object, either of type
{::Google::Cloud::Dataflow::V1beta3::DeleteSnapshotRequest} or an equivalent Hash.

@param request [::Google::Cloud::Dataflow::V1beta3::DeleteSnapshotRequest, ::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 delete_snapshot(project_id: nil, snapshot_id: nil, location: nil)

Pass arguments to `delete_snapshot` 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 project_id [::String]
  The ID of the Cloud Platform project that the snapshot belongs to.
@param snapshot_id [::String]
  The ID of the snapshot.
@param location [::String]
  The location that contains this snapshot.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Dataflow::V1beta3::DeleteSnapshotResponse] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::Dataflow::V1beta3::DeleteSnapshotResponse]

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

# File lib/google/cloud/dataflow/v1beta3/snapshots/client.rb, line 246
def delete_snapshot request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dataflow::V1beta3::DeleteSnapshotRequest

  # 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.delete_snapshot.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::Dataflow::V1beta3::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

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

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

  @snapshots_stub.call_rpc :delete_snapshot, 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_snapshot(request, options = nil) { |response, operation| ... } click to toggle source

Gets information about a snapshot.

@overload get_snapshot(request, options = nil)

Pass arguments to `get_snapshot` via a request object, either of type
{::Google::Cloud::Dataflow::V1beta3::GetSnapshotRequest} or an equivalent Hash.

@param request [::Google::Cloud::Dataflow::V1beta3::GetSnapshotRequest, ::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_snapshot(project_id: nil, snapshot_id: nil, location: nil)

Pass arguments to `get_snapshot` 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 project_id [::String]
  The ID of the Cloud Platform project that the snapshot belongs to.
@param snapshot_id [::String]
  The ID of the snapshot.
@param location [::String]
  The location that contains this snapshot.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Dataflow::V1beta3::Snapshot] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::Dataflow::V1beta3::Snapshot]

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

# File lib/google/cloud/dataflow/v1beta3/snapshots/client.rb, line 180
def get_snapshot request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dataflow::V1beta3::GetSnapshotRequest

  # 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_snapshot.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::Dataflow::V1beta3::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

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

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

  @snapshots_stub.call_rpc :get_snapshot, 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_snapshots(request, options = nil) { |response, operation| ... } click to toggle source

Lists snapshots.

@overload list_snapshots(request, options = nil)

Pass arguments to `list_snapshots` via a request object, either of type
{::Google::Cloud::Dataflow::V1beta3::ListSnapshotsRequest} or an equivalent Hash.

@param request [::Google::Cloud::Dataflow::V1beta3::ListSnapshotsRequest, ::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_snapshots(project_id: nil, job_id: nil, location: nil)

Pass arguments to `list_snapshots` 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 project_id [::String]
  The project ID to list snapshots for.
@param job_id [::String]
  If specified, list snapshots created from this job.
@param location [::String]
  The location to list snapshots in.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Dataflow::V1beta3::ListSnapshotsResponse] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::Dataflow::V1beta3::ListSnapshotsResponse]

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

# File lib/google/cloud/dataflow/v1beta3/snapshots/client.rb, line 312
def list_snapshots request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dataflow::V1beta3::ListSnapshotsRequest

  # 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_snapshots.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::Dataflow::V1beta3::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

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

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

  @snapshots_stub.call_rpc :list_snapshots, 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