Dialogflow V2 API - Class Google::Cloud::Dialogflow::V2::Contexts::Rest::Client (v1.5.0)

Reference documentation and code samples for the Dialogflow V2 API class Google::Cloud::Dialogflow::V2::Contexts::Rest::Client.

REST client for the Contexts service.

Service for managing Contexts.

Inherits

  • Object

Methods

.configure

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

Configure the Contexts 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 Contexts clients
::Google::Cloud::Dialogflow::V2::Contexts::Rest::Client.configure do |config|
  config.timeout = 10.0
end

#configure

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

Configure the Contexts 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_context

def create_context(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Context
def create_context(parent: nil, context: nil) -> ::Google::Cloud::Dialogflow::V2::Context

Creates a context.

If the specified context already exists, overrides the context.

Overloads
def create_context(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Context
Pass arguments to create_context via a request object, either of type Google::Cloud::Dialogflow::V2::CreateContextRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Dialogflow::V2::CreateContextRequest, ::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 create_context(parent: nil, context: nil) -> ::Google::Cloud::Dialogflow::V2::Context
Pass arguments to create_context 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 session to create a context for. Format: projects/<Project ID>/agent/sessions/<Session ID> or projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.
  • context (::Google::Cloud::Dialogflow::V2::Context, ::Hash) — Required. The context to create.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Contexts::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::CreateContextRequest.new

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

# The returned object is of type Google::Cloud::Dialogflow::V2::Context.
p result

#delete_all_contexts

def delete_all_contexts(request, options = nil) -> ::Google::Protobuf::Empty
def delete_all_contexts(parent: nil) -> ::Google::Protobuf::Empty

Deletes all active contexts in the specified session.

Overloads
def delete_all_contexts(request, options = nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_all_contexts via a request object, either of type DeleteAllContextsRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Dialogflow::V2::DeleteAllContextsRequest, ::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 delete_all_contexts(parent: nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_all_contexts 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
  • parent (::String) — Required. The name of the session to delete all contexts from. Format: projects/<Project ID>/agent/sessions/<Session ID> or projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>. If Environment ID is not specified we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Contexts::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::DeleteAllContextsRequest.new

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

# The returned object is of type Google::Protobuf::Empty.
p result

#delete_context

def delete_context(request, options = nil) -> ::Google::Protobuf::Empty
def delete_context(name: nil) -> ::Google::Protobuf::Empty

Deletes the specified context.

Overloads
def delete_context(request, options = nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_context via a request object, either of type DeleteContextRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Dialogflow::V2::DeleteContextRequest, ::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 delete_context(name: nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_context 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 name of the context to delete. Format: projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID> or projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Contexts::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::DeleteContextRequest.new

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

# The returned object is of type Google::Protobuf::Empty.
p result

#get_context

def get_context(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Context
def get_context(name: nil) -> ::Google::Cloud::Dialogflow::V2::Context

Retrieves the specified context.

Overloads
def get_context(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Context
Pass arguments to get_context via a request object, either of type GetContextRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Dialogflow::V2::GetContextRequest, ::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_context(name: nil) -> ::Google::Cloud::Dialogflow::V2::Context
Pass arguments to get_context 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 name of the context. Format: projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID> or projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Contexts::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::GetContextRequest.new

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

# The returned object is of type Google::Cloud::Dialogflow::V2::Context.
p result

#initialize

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

Create a new Contexts REST client object.

Yields
  • (config) — Configure the Contexts client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# Create a client using the default configuration
client = ::Google::Cloud::Dialogflow::V2::Contexts::Rest::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Dialogflow::V2::Contexts::Rest::Client.new do |config|
  config.timeout = 10.0
end

#list_contexts

def list_contexts(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Context>
def list_contexts(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Context>

Returns the list of all contexts in the specified session.

Overloads
def list_contexts(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Context>
Pass arguments to list_contexts via a request object, either of type ListContextsRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Dialogflow::V2::ListContextsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def list_contexts(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Context>
Pass arguments to list_contexts 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 session to list all contexts from. Format: projects/<Project ID>/agent/sessions/<Session ID> or projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.
  • page_size (::Integer) — Optional. The maximum number of items to return in a single page. By default 100 and at most 1000.
  • page_token (::String) — Optional. The next_page_token value returned from a previous list request.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Contexts::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::ListContextsRequest.new

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

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Dialogflow::V2::Context.
  p item
end

#location_client

def location_client() -> Google::Cloud::Location::Locations::Rest::Client

Get the associated client for mix-in of the Locations.

Returns
  • (Google::Cloud::Location::Locations::Rest::Client)

#logger

def logger() -> Logger

The logger used for request/response debug logging.

Returns
  • (Logger)

#universe_domain

def universe_domain() -> String

The effective universe domain

Returns
  • (String)

#update_context

def update_context(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Context
def update_context(context: nil, update_mask: nil) -> ::Google::Cloud::Dialogflow::V2::Context

Updates the specified context.

Overloads
def update_context(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Context
Pass arguments to update_context via a request object, either of type UpdateContextRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Dialogflow::V2::UpdateContextRequest, ::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 update_context(context: nil, update_mask: nil) -> ::Google::Cloud::Dialogflow::V2::Context
Pass arguments to update_context 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
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Contexts::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::UpdateContextRequest.new

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

# The returned object is of type Google::Cloud::Dialogflow::V2::Context.
p result