class Grafeas::V1::Grafeas::Client

Client for the Grafeas service.

[Grafeas](grafeas.io) API.

Retrieves analysis results of Cloud components such as Docker container images.

Analysis results are stored as a series of occurrences. An `Occurrence` contains information about a specific analysis instance on a resource. An occurrence refers to a `Note`. A note contains details describing the analysis and is generally stored in a separate project, called a `Provider`. Multiple occurrences can refer to the same note.

For example, an SSL vulnerability could affect multiple images. In this case, there would be one note for the vulnerability and an occurrence for each image with the vulnerability referring to that note.

Attributes

grafeas_stub[R]

@private

Public Class Methods

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

Configure the Grafeas Client class.

See {::Grafeas::V1::Grafeas::Client::Configuration} for a description of the configuration fields.

@example

# Modify the configuration for all Grafeas clients
::Grafeas::V1::Grafeas::Client.configure do |config|
  config.timeout = 10.0
end

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

@return [Client::Configuration]

# File lib/grafeas/v1/grafeas/client.rb, line 67
def self.configure
  @configure ||= begin
    namespace = ["Grafeas", "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.rpcs.get_occurrence.timeout = 30.0
    default_config.rpcs.get_occurrence.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.list_occurrences.timeout = 30.0
    default_config.rpcs.list_occurrences.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.delete_occurrence.timeout = 30.0
    default_config.rpcs.delete_occurrence.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.create_occurrence.timeout = 30.0

    default_config.rpcs.batch_create_occurrences.timeout = 30.0

    default_config.rpcs.update_occurrence.timeout = 30.0

    default_config.rpcs.get_occurrence_note.timeout = 30.0
    default_config.rpcs.get_occurrence_note.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.get_note.timeout = 30.0
    default_config.rpcs.get_note.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.list_notes.timeout = 30.0
    default_config.rpcs.list_notes.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.delete_note.timeout = 30.0
    default_config.rpcs.delete_note.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.create_note.timeout = 30.0

    default_config.rpcs.batch_create_notes.timeout = 30.0

    default_config.rpcs.update_note.timeout = 30.0

    default_config.rpcs.list_note_occurrences.timeout = 30.0
    default_config.rpcs.list_note_occurrences.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

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

Create a new Grafeas client object.

@example

# Create a client using the default configuration
client = ::Grafeas::V1::Grafeas::Client.new

# Create a client using a custom configuration
client = ::Grafeas::V1::Grafeas::Client.new do |config|
  config.timeout = 10.0
end

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

# File lib/grafeas/v1/grafeas/client.rb, line 172
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 "grafeas/v1/grafeas_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
  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @grafeas_stub = ::Gapic::ServiceStub.new(
    ::Grafeas::V1::Grafeas::Stub,
    credentials:  credentials,
    endpoint:     @config.endpoint,
    channel_args: @config.channel_args,
    interceptors: @config.interceptors
  )
end

Public Instance Methods

batch_create_notes(request, options = nil) { |response, operation| ... } click to toggle source

Creates new notes in batch.

@overload batch_create_notes(request, options = nil)

Pass arguments to `batch_create_notes` via a request object, either of type
{::Grafeas::V1::BatchCreateNotesRequest} or an equivalent Hash.

@param request [::Grafeas::V1::BatchCreateNotesRequest, ::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 batch_create_notes(parent: nil, notes: nil)

Pass arguments to `batch_create_notes` 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]
  The name of the project in the form of `projects/[PROJECT_ID]`, under which
  the notes are to be created.
@param notes [::Hash{::String => ::Grafeas::V1::Note, ::Hash}]
  The notes to create. Max allowed length is 1000.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Grafeas::V1::BatchCreateNotesResponse] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Grafeas::V1::BatchCreateNotesResponse]

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

# File lib/grafeas/v1/grafeas/client.rb, line 1023
def batch_create_notes request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Grafeas::V1::BatchCreateNotesRequest

  # 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.batch_create_notes.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: ::Grafeas::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.batch_create_notes.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.batch_create_notes.retry_policy

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

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

Creates new occurrences in batch.

@overload batch_create_occurrences(request, options = nil)

Pass arguments to `batch_create_occurrences` via a request object, either of type
{::Grafeas::V1::BatchCreateOccurrencesRequest} or an equivalent Hash.

@param request [::Grafeas::V1::BatchCreateOccurrencesRequest, ::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 batch_create_occurrences(parent: nil, occurrences: nil)

Pass arguments to `batch_create_occurrences` 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]
  The name of the project in the form of `projects/[PROJECT_ID]`, under which
  the occurrences are to be created.
@param occurrences [::Array<::Grafeas::V1::Occurrence, ::Hash>]
  The occurrences to create. Max allowed length is 1000.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Grafeas::V1::BatchCreateOccurrencesResponse] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Grafeas::V1::BatchCreateOccurrencesResponse]

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

# File lib/grafeas/v1/grafeas/client.rb, line 521
def batch_create_occurrences request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Grafeas::V1::BatchCreateOccurrencesRequest

  # 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.batch_create_occurrences.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: ::Grafeas::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.batch_create_occurrences.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.batch_create_occurrences.retry_policy

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

  @grafeas_stub.call_rpc :batch_create_occurrences, 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
configure() { |config| ... } click to toggle source

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

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

@return [Client::Configuration]

# File lib/grafeas/v1/grafeas/client.rb, line 151
def configure
  yield @config if block_given?
  @config
end
create_note(request, options = nil) { |response, operation| ... } click to toggle source

Creates a new note.

@overload create_note(request, options = nil)

Pass arguments to `create_note` via a request object, either of type
{::Grafeas::V1::CreateNoteRequest} or an equivalent Hash.

@param request [::Grafeas::V1::CreateNoteRequest, ::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 create_note(parent: nil, note_id: nil, note: nil)

Pass arguments to `create_note` 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]
  The name of the project in the form of `projects/[PROJECT_ID]`, under which
  the note is to be created.
@param note_id [::String]
  The ID to use for this note.
@param note [::Grafeas::V1::Note, ::Hash]
  The note to create.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Grafeas::V1::Note] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Grafeas::V1::Note]

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

# File lib/grafeas/v1/grafeas/client.rb, line 952
def create_note request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Grafeas::V1::CreateNoteRequest

  # 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.create_note.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: ::Grafeas::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.create_note.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.create_note.retry_policy

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

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

Creates a new occurrence.

@overload create_occurrence(request, options = nil)

Pass arguments to `create_occurrence` via a request object, either of type
{::Grafeas::V1::CreateOccurrenceRequest} or an equivalent Hash.

@param request [::Grafeas::V1::CreateOccurrenceRequest, ::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 create_occurrence(parent: nil, occurrence: nil)

Pass arguments to `create_occurrence` 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]
  The name of the project in the form of `projects/[PROJECT_ID]`, under which
  the occurrence is to be created.
@param occurrence [::Grafeas::V1::Occurrence, ::Hash]
  The occurrence to create.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Grafeas::V1::Occurrence] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Grafeas::V1::Occurrence]

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

# File lib/grafeas/v1/grafeas/client.rb, line 450
def create_occurrence request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Grafeas::V1::CreateOccurrenceRequest

  # 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.create_occurrence.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: ::Grafeas::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.create_occurrence.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.create_occurrence.retry_policy

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

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

Deletes the specified note.

@overload delete_note(request, options = nil)

Pass arguments to `delete_note` via a request object, either of type
{::Grafeas::V1::DeleteNoteRequest} or an equivalent Hash.

@param request [::Grafeas::V1::DeleteNoteRequest, ::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_note(name: nil)

Pass arguments to `delete_note` 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]
  The name of the note in the form of
  `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Protobuf::Empty] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Protobuf::Empty]

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

# File lib/grafeas/v1/grafeas/client.rb, line 879
def delete_note request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Grafeas::V1::DeleteNoteRequest

  # 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_note.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: ::Grafeas::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.delete_note.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.delete_note.retry_policy

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

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

Deletes the specified occurrence. For example, use this method to delete an occurrence when the occurrence is no longer applicable for the given resource.

@overload delete_occurrence(request, options = nil)

Pass arguments to `delete_occurrence` via a request object, either of type
{::Grafeas::V1::DeleteOccurrenceRequest} or an equivalent Hash.

@param request [::Grafeas::V1::DeleteOccurrenceRequest, ::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_occurrence(name: nil)

Pass arguments to `delete_occurrence` 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]
  The name of the occurrence in the form of
  `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Protobuf::Empty] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Protobuf::Empty]

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

# File lib/grafeas/v1/grafeas/client.rb, line 379
def delete_occurrence request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Grafeas::V1::DeleteOccurrenceRequest

  # 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_occurrence.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: ::Grafeas::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.delete_occurrence.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.delete_occurrence.retry_policy

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

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

Gets the specified note.

@overload get_note(request, options = nil)

Pass arguments to `get_note` via a request object, either of type
{::Grafeas::V1::GetNoteRequest} or an equivalent Hash.

@param request [::Grafeas::V1::GetNoteRequest, ::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_note(name: nil)

Pass arguments to `get_note` 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]
  The name of the note in the form of
  `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Grafeas::V1::Note] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Grafeas::V1::Note]

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

# File lib/grafeas/v1/grafeas/client.rb, line 733
def get_note request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Grafeas::V1::GetNoteRequest

  # 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_note.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: ::Grafeas::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_note.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.get_note.retry_policy

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

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

Gets the specified occurrence.

@overload get_occurrence(request, options = nil)

Pass arguments to `get_occurrence` via a request object, either of type
{::Grafeas::V1::GetOccurrenceRequest} or an equivalent Hash.

@param request [::Grafeas::V1::GetOccurrenceRequest, ::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_occurrence(name: nil)

Pass arguments to `get_occurrence` 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]
  The name of the occurrence in the form of
  `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Grafeas::V1::Occurrence] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Grafeas::V1::Occurrence]

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

# File lib/grafeas/v1/grafeas/client.rb, line 231
def get_occurrence request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Grafeas::V1::GetOccurrenceRequest

  # 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_occurrence.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: ::Grafeas::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_occurrence.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.get_occurrence.retry_policy

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

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

Gets the note attached to the specified occurrence. Consumer projects can use this method to get a note that belongs to a provider project.

@overload get_occurrence_note(request, options = nil)

Pass arguments to `get_occurrence_note` via a request object, either of type
{::Grafeas::V1::GetOccurrenceNoteRequest} or an equivalent Hash.

@param request [::Grafeas::V1::GetOccurrenceNoteRequest, ::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_occurrence_note(name: nil)

Pass arguments to `get_occurrence_note` 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]
  The name of the occurrence in the form of
  `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Grafeas::V1::Note] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Grafeas::V1::Note]

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

# File lib/grafeas/v1/grafeas/client.rb, line 664
def get_occurrence_note request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Grafeas::V1::GetOccurrenceNoteRequest

  # 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_occurrence_note.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: ::Grafeas::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_occurrence_note.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.get_occurrence_note.retry_policy

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

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

Lists occurrences referencing the specified note. Provider projects can use this method to get all occurrences across consumer projects referencing the specified note.

@overload list_note_occurrences(request, options = nil)

Pass arguments to `list_note_occurrences` via a request object, either of type
{::Grafeas::V1::ListNoteOccurrencesRequest} or an equivalent Hash.

@param request [::Grafeas::V1::ListNoteOccurrencesRequest, ::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_note_occurrences(name: nil, filter: nil, page_size: nil, page_token: nil)

Pass arguments to `list_note_occurrences` 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]
  The name of the note to list occurrences for in the form of
  `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
@param filter [::String]
  The filter expression.
@param page_size [::Integer]
  Number of occurrences to return in the list.
@param page_token [::String]
  Token to provide to skip to a particular spot in the list.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Grafeas::V1::Occurrence>] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::PagedEnumerable<::Grafeas::V1::Occurrence>]

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

# File lib/grafeas/v1/grafeas/client.rb, line 1173
def list_note_occurrences request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Grafeas::V1::ListNoteOccurrencesRequest

  # 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_note_occurrences.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: ::Grafeas::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.list_note_occurrences.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.list_note_occurrences.retry_policy

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

  @grafeas_stub.call_rpc :list_note_occurrences, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @grafeas_stub, :list_note_occurrences, 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_notes(request, options = nil) { |response, operation| ... } click to toggle source

Lists notes for the specified project.

@overload list_notes(request, options = nil)

Pass arguments to `list_notes` via a request object, either of type
{::Grafeas::V1::ListNotesRequest} or an equivalent Hash.

@param request [::Grafeas::V1::ListNotesRequest, ::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_notes(parent: nil, filter: nil, page_size: nil, page_token: nil)

Pass arguments to `list_notes` 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]
  The name of the project to list notes for in the form of
  `projects/[PROJECT_ID]`.
@param filter [::String]
  The filter expression.
@param page_size [::Integer]
  Number of notes to return in the list. Must be positive. Max allowed page
  size is 1000. If not specified, page size defaults to 20.
@param page_token [::String]
  Token to provide to skip to a particular spot in the list.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Grafeas::V1::Note>] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::PagedEnumerable<::Grafeas::V1::Note>]

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

# File lib/grafeas/v1/grafeas/client.rb, line 809
def list_notes request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Grafeas::V1::ListNotesRequest

  # 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_notes.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: ::Grafeas::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_notes.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.list_notes.retry_policy

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

  @grafeas_stub.call_rpc :list_notes, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @grafeas_stub, :list_notes, 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_occurrences(request, options = nil) { |response, operation| ... } click to toggle source

Lists occurrences for the specified project.

@overload list_occurrences(request, options = nil)

Pass arguments to `list_occurrences` via a request object, either of type
{::Grafeas::V1::ListOccurrencesRequest} or an equivalent Hash.

@param request [::Grafeas::V1::ListOccurrencesRequest, ::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_occurrences(parent: nil, filter: nil, page_size: nil, page_token: nil)

Pass arguments to `list_occurrences` 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]
  The name of the project to list occurrences for in the form of
  `projects/[PROJECT_ID]`.
@param filter [::String]
  The filter expression.
@param page_size [::Integer]
  Number of occurrences to return in the list. Must be positive. Max allowed
  page size is 1000. If not specified, page size defaults to 20.
@param page_token [::String]
  Token to provide to skip to a particular spot in the list.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Grafeas::V1::Occurrence>] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::PagedEnumerable<::Grafeas::V1::Occurrence>]

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

# File lib/grafeas/v1/grafeas/client.rb, line 307
def list_occurrences request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Grafeas::V1::ListOccurrencesRequest

  # 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_occurrences.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: ::Grafeas::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_occurrences.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.list_occurrences.retry_policy

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

  @grafeas_stub.call_rpc :list_occurrences, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @grafeas_stub, :list_occurrences, 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
update_note(request, options = nil) { |response, operation| ... } click to toggle source

Updates the specified note.

@overload update_note(request, options = nil)

Pass arguments to `update_note` via a request object, either of type
{::Grafeas::V1::UpdateNoteRequest} or an equivalent Hash.

@param request [::Grafeas::V1::UpdateNoteRequest, ::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 update_note(name: nil, note: nil, update_mask: nil)

Pass arguments to `update_note` 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]
  The name of the note in the form of
  `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
@param note [::Grafeas::V1::Note, ::Hash]
  The updated note.
@param update_mask [::Google::Protobuf::FieldMask, ::Hash]
  The fields to update.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Grafeas::V1::Note] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Grafeas::V1::Note]

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

# File lib/grafeas/v1/grafeas/client.rb, line 1096
def update_note request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Grafeas::V1::UpdateNoteRequest

  # 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.update_note.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: ::Grafeas::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.update_note.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.update_note.retry_policy

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

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

Updates the specified occurrence.

@overload update_occurrence(request, options = nil)

Pass arguments to `update_occurrence` via a request object, either of type
{::Grafeas::V1::UpdateOccurrenceRequest} or an equivalent Hash.

@param request [::Grafeas::V1::UpdateOccurrenceRequest, ::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 update_occurrence(name: nil, occurrence: nil, update_mask: nil)

Pass arguments to `update_occurrence` 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]
  The name of the occurrence in the form of
  `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
@param occurrence [::Grafeas::V1::Occurrence, ::Hash]
  The updated occurrence.
@param update_mask [::Google::Protobuf::FieldMask, ::Hash]
  The fields to update.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Grafeas::V1::Occurrence] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Grafeas::V1::Occurrence]

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

# File lib/grafeas/v1/grafeas/client.rb, line 594
def update_occurrence request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Grafeas::V1::UpdateOccurrenceRequest

  # 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.update_occurrence.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: ::Grafeas::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.update_occurrence.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.update_occurrence.retry_policy

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

  @grafeas_stub.call_rpc :update_occurrence, 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