Google Cloud Dialogflow v2beta1 API - Class ContextsClient (1.0.0-beta19)

public abstract class ContextsClient

Reference documentation and code samples for the Google Cloud Dialogflow v2beta1 API class ContextsClient.

Contexts client wrapper, for convenient use.

Inheritance

object > ContextsClient

Derived Types

Namespace

Google.Cloud.Dialogflow.V2Beta1

Assembly

Google.Cloud.Dialogflow.V2Beta1.dll

Remarks

Service for managing [Contexts][google.cloud.dialogflow.v2beta1.Context].

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

The default endpoint for the Contexts service, which is a host of "dialogflow.googleapis.com" and a port of 443.

Property Value
Type Description
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default Contexts scopes.

Property Value
Type Description
IReadOnlyListstring
Remarks

GrpcClient

public virtual Contexts.ContextsClient GrpcClient { get; }

The underlying gRPC Contexts client

Property Value
Type Description
ContextsContextsClient

LocationsClient

public virtual LocationsClient LocationsClient { get; }

The LocationsClient associated with this client.

Property Value
Type Description
LocationsClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
Type Description
ServiceMetadata

Methods

Create()

public static ContextsClient Create()

Synchronously creates a ContextsClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use ContextsClientBuilder.

Returns
Type Description
ContextsClient

The created ContextsClient.

CreateAsync(CancellationToken)

public static Task<ContextsClient> CreateAsync(CancellationToken cancellationToken = default)

Asynchronously creates a ContextsClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use ContextsClientBuilder.

Parameter
Name Description
cancellationToken CancellationToken

The CancellationToken to use while creating the client.

Returns
Type Description
TaskContextsClient

The task representing the created ContextsClient.

CreateContext(CreateContextRequest, CallSettings)

public virtual Context CreateContext(CreateContextRequest request, CallSettings callSettings = null)

Creates a context.

If the specified context already exists, overrides the context.

Parameters
Name Description
request CreateContextRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Context

The RPC response.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
CreateContextRequest request = new CreateContextRequest
{
    ParentAsSessionName = SessionName.FromProjectSession("[PROJECT]", "[SESSION]"),
    Context = new Context(),
};
// Make the request
Context response = contextsClient.CreateContext(request);

CreateContext(SessionName, Context, CallSettings)

public virtual Context CreateContext(SessionName parent, Context context, CallSettings callSettings = null)

Creates a context.

If the specified context already exists, overrides the context.

Parameters
Name Description
parent SessionName

Required. The session to create a context for. Supported formats:

  • `projects/<Project ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

context Context

Required. The context to create.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Context

The RPC response.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
SessionName parent = SessionName.FromProjectSession("[PROJECT]", "[SESSION]");
Context context = new Context();
// Make the request
Context response = contextsClient.CreateContext(parent, context);

CreateContext(string, Context, CallSettings)

public virtual Context CreateContext(string parent, Context context, CallSettings callSettings = null)

Creates a context.

If the specified context already exists, overrides the context.

Parameters
Name Description
parent string

Required. The session to create a context for. Supported formats:

  • `projects/<Project ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

context Context

Required. The context to create.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Context

The RPC response.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/agent/sessions/[SESSION]";
Context context = new Context();
// Make the request
Context response = contextsClient.CreateContext(parent, context);

CreateContextAsync(CreateContextRequest, CallSettings)

public virtual Task<Context> CreateContextAsync(CreateContextRequest request, CallSettings callSettings = null)

Creates a context.

If the specified context already exists, overrides the context.

Parameters
Name Description
request CreateContextRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
CreateContextRequest request = new CreateContextRequest
{
    ParentAsSessionName = SessionName.FromProjectSession("[PROJECT]", "[SESSION]"),
    Context = new Context(),
};
// Make the request
Context response = await contextsClient.CreateContextAsync(request);

CreateContextAsync(CreateContextRequest, CancellationToken)

public virtual Task<Context> CreateContextAsync(CreateContextRequest request, CancellationToken cancellationToken)

Creates a context.

If the specified context already exists, overrides the context.

Parameters
Name Description
request CreateContextRequest

The request object containing all of the parameters for the API call.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
CreateContextRequest request = new CreateContextRequest
{
    ParentAsSessionName = SessionName.FromProjectSession("[PROJECT]", "[SESSION]"),
    Context = new Context(),
};
// Make the request
Context response = await contextsClient.CreateContextAsync(request);

CreateContextAsync(SessionName, Context, CallSettings)

public virtual Task<Context> CreateContextAsync(SessionName parent, Context context, CallSettings callSettings = null)

Creates a context.

If the specified context already exists, overrides the context.

Parameters
Name Description
parent SessionName

Required. The session to create a context for. Supported formats:

  • `projects/<Project ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

context Context

Required. The context to create.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
SessionName parent = SessionName.FromProjectSession("[PROJECT]", "[SESSION]");
Context context = new Context();
// Make the request
Context response = await contextsClient.CreateContextAsync(parent, context);

CreateContextAsync(SessionName, Context, CancellationToken)

public virtual Task<Context> CreateContextAsync(SessionName parent, Context context, CancellationToken cancellationToken)

Creates a context.

If the specified context already exists, overrides the context.

Parameters
Name Description
parent SessionName

Required. The session to create a context for. Supported formats:

  • `projects/<Project ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

context Context

Required. The context to create.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
SessionName parent = SessionName.FromProjectSession("[PROJECT]", "[SESSION]");
Context context = new Context();
// Make the request
Context response = await contextsClient.CreateContextAsync(parent, context);

CreateContextAsync(string, Context, CallSettings)

public virtual Task<Context> CreateContextAsync(string parent, Context context, CallSettings callSettings = null)

Creates a context.

If the specified context already exists, overrides the context.

Parameters
Name Description
parent string

Required. The session to create a context for. Supported formats:

  • `projects/<Project ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

context Context

Required. The context to create.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/agent/sessions/[SESSION]";
Context context = new Context();
// Make the request
Context response = await contextsClient.CreateContextAsync(parent, context);

CreateContextAsync(string, Context, CancellationToken)

public virtual Task<Context> CreateContextAsync(string parent, Context context, CancellationToken cancellationToken)

Creates a context.

If the specified context already exists, overrides the context.

Parameters
Name Description
parent string

Required. The session to create a context for. Supported formats:

  • `projects/<Project ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

context Context

Required. The context to create.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/agent/sessions/[SESSION]";
Context context = new Context();
// Make the request
Context response = await contextsClient.CreateContextAsync(parent, context);

DeleteAllContexts(DeleteAllContextsRequest, CallSettings)

public virtual void DeleteAllContexts(DeleteAllContextsRequest request, CallSettings callSettings = null)

Deletes all active contexts in the specified session.

Parameters
Name Description
request DeleteAllContextsRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
DeleteAllContextsRequest request = new DeleteAllContextsRequest
{
    ParentAsSessionName = SessionName.FromProjectSession("[PROJECT]", "[SESSION]"),
};
// Make the request
contextsClient.DeleteAllContexts(request);

DeleteAllContexts(SessionName, CallSettings)

public virtual void DeleteAllContexts(SessionName parent, CallSettings callSettings = null)

Deletes all active contexts in the specified session.

Parameters
Name Description
parent SessionName

Required. The name of the session to delete all contexts from. Supported formats:

  • `projects/<Project ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
SessionName parent = SessionName.FromProjectSession("[PROJECT]", "[SESSION]");
// Make the request
contextsClient.DeleteAllContexts(parent);

DeleteAllContexts(string, CallSettings)

public virtual void DeleteAllContexts(string parent, CallSettings callSettings = null)

Deletes all active contexts in the specified session.

Parameters
Name Description
parent string

Required. The name of the session to delete all contexts from. Supported formats:

  • `projects/<Project ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/agent/sessions/[SESSION]";
// Make the request
contextsClient.DeleteAllContexts(parent);

DeleteAllContextsAsync(DeleteAllContextsRequest, CallSettings)

public virtual Task DeleteAllContextsAsync(DeleteAllContextsRequest request, CallSettings callSettings = null)

Deletes all active contexts in the specified session.

Parameters
Name Description
request DeleteAllContextsRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
DeleteAllContextsRequest request = new DeleteAllContextsRequest
{
    ParentAsSessionName = SessionName.FromProjectSession("[PROJECT]", "[SESSION]"),
};
// Make the request
await contextsClient.DeleteAllContextsAsync(request);

DeleteAllContextsAsync(DeleteAllContextsRequest, CancellationToken)

public virtual Task DeleteAllContextsAsync(DeleteAllContextsRequest request, CancellationToken cancellationToken)

Deletes all active contexts in the specified session.

Parameters
Name Description
request DeleteAllContextsRequest

The request object containing all of the parameters for the API call.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
DeleteAllContextsRequest request = new DeleteAllContextsRequest
{
    ParentAsSessionName = SessionName.FromProjectSession("[PROJECT]", "[SESSION]"),
};
// Make the request
await contextsClient.DeleteAllContextsAsync(request);

DeleteAllContextsAsync(SessionName, CallSettings)

public virtual Task DeleteAllContextsAsync(SessionName parent, CallSettings callSettings = null)

Deletes all active contexts in the specified session.

Parameters
Name Description
parent SessionName

Required. The name of the session to delete all contexts from. Supported formats:

  • `projects/<Project ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
SessionName parent = SessionName.FromProjectSession("[PROJECT]", "[SESSION]");
// Make the request
await contextsClient.DeleteAllContextsAsync(parent);

DeleteAllContextsAsync(SessionName, CancellationToken)

public virtual Task DeleteAllContextsAsync(SessionName parent, CancellationToken cancellationToken)

Deletes all active contexts in the specified session.

Parameters
Name Description
parent SessionName

Required. The name of the session to delete all contexts from. Supported formats:

  • `projects/<Project ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
SessionName parent = SessionName.FromProjectSession("[PROJECT]", "[SESSION]");
// Make the request
await contextsClient.DeleteAllContextsAsync(parent);

DeleteAllContextsAsync(string, CallSettings)

public virtual Task DeleteAllContextsAsync(string parent, CallSettings callSettings = null)

Deletes all active contexts in the specified session.

Parameters
Name Description
parent string

Required. The name of the session to delete all contexts from. Supported formats:

  • `projects/<Project ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/agent/sessions/[SESSION]";
// Make the request
await contextsClient.DeleteAllContextsAsync(parent);

DeleteAllContextsAsync(string, CancellationToken)

public virtual Task DeleteAllContextsAsync(string parent, CancellationToken cancellationToken)

Deletes all active contexts in the specified session.

Parameters
Name Description
parent string

Required. The name of the session to delete all contexts from. Supported formats:

  • `projects/<Project ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/agent/sessions/[SESSION]";
// Make the request
await contextsClient.DeleteAllContextsAsync(parent);

DeleteContext(ContextName, CallSettings)

public virtual void DeleteContext(ContextName name, CallSettings callSettings = null)

Deletes the specified context.

Parameters
Name Description
name ContextName

Required. The name of the context to delete. Supported formats:

  • projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
ContextName name = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]");
// Make the request
contextsClient.DeleteContext(name);

DeleteContext(DeleteContextRequest, CallSettings)

public virtual void DeleteContext(DeleteContextRequest request, CallSettings callSettings = null)

Deletes the specified context.

Parameters
Name Description
request DeleteContextRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
DeleteContextRequest request = new DeleteContextRequest
{
    ContextName = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
};
// Make the request
contextsClient.DeleteContext(request);

DeleteContext(string, CallSettings)

public virtual void DeleteContext(string name, CallSettings callSettings = null)

Deletes the specified context.

Parameters
Name Description
name string

Required. The name of the context to delete. Supported formats:

  • projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
string name = "projects/[PROJECT]/agent/sessions/[SESSION]/contexts/[CONTEXT]";
// Make the request
contextsClient.DeleteContext(name);

DeleteContextAsync(ContextName, CallSettings)

public virtual Task DeleteContextAsync(ContextName name, CallSettings callSettings = null)

Deletes the specified context.

Parameters
Name Description
name ContextName

Required. The name of the context to delete. Supported formats:

  • projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
ContextName name = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]");
// Make the request
await contextsClient.DeleteContextAsync(name);

DeleteContextAsync(ContextName, CancellationToken)

public virtual Task DeleteContextAsync(ContextName name, CancellationToken cancellationToken)

Deletes the specified context.

Parameters
Name Description
name ContextName

Required. The name of the context to delete. Supported formats:

  • projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
ContextName name = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]");
// Make the request
await contextsClient.DeleteContextAsync(name);

DeleteContextAsync(DeleteContextRequest, CallSettings)

public virtual Task DeleteContextAsync(DeleteContextRequest request, CallSettings callSettings = null)

Deletes the specified context.

Parameters
Name Description
request DeleteContextRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
DeleteContextRequest request = new DeleteContextRequest
{
    ContextName = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
};
// Make the request
await contextsClient.DeleteContextAsync(request);

DeleteContextAsync(DeleteContextRequest, CancellationToken)

public virtual Task DeleteContextAsync(DeleteContextRequest request, CancellationToken cancellationToken)

Deletes the specified context.

Parameters
Name Description
request DeleteContextRequest

The request object containing all of the parameters for the API call.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
DeleteContextRequest request = new DeleteContextRequest
{
    ContextName = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
};
// Make the request
await contextsClient.DeleteContextAsync(request);

DeleteContextAsync(string, CallSettings)

public virtual Task DeleteContextAsync(string name, CallSettings callSettings = null)

Deletes the specified context.

Parameters
Name Description
name string

Required. The name of the context to delete. Supported formats:

  • projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/agent/sessions/[SESSION]/contexts/[CONTEXT]";
// Make the request
await contextsClient.DeleteContextAsync(name);

DeleteContextAsync(string, CancellationToken)

public virtual Task DeleteContextAsync(string name, CancellationToken cancellationToken)

Deletes the specified context.

Parameters
Name Description
name string

Required. The name of the context to delete. Supported formats:

  • projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/agent/sessions/[SESSION]/contexts/[CONTEXT]";
// Make the request
await contextsClient.DeleteContextAsync(name);

GetContext(ContextName, CallSettings)

public virtual Context GetContext(ContextName name, CallSettings callSettings = null)

Retrieves the specified context.

Parameters
Name Description
name ContextName

Required. The name of the context. Supported formats:

  • projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Context

The RPC response.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
ContextName name = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]");
// Make the request
Context response = contextsClient.GetContext(name);

GetContext(GetContextRequest, CallSettings)

public virtual Context GetContext(GetContextRequest request, CallSettings callSettings = null)

Retrieves the specified context.

Parameters
Name Description
request GetContextRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Context

The RPC response.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
GetContextRequest request = new GetContextRequest
{
    ContextName = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
};
// Make the request
Context response = contextsClient.GetContext(request);

GetContext(string, CallSettings)

public virtual Context GetContext(string name, CallSettings callSettings = null)

Retrieves the specified context.

Parameters
Name Description
name string

Required. The name of the context. Supported formats:

  • projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Context

The RPC response.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
string name = "projects/[PROJECT]/agent/sessions/[SESSION]/contexts/[CONTEXT]";
// Make the request
Context response = contextsClient.GetContext(name);

GetContextAsync(ContextName, CallSettings)

public virtual Task<Context> GetContextAsync(ContextName name, CallSettings callSettings = null)

Retrieves the specified context.

Parameters
Name Description
name ContextName

Required. The name of the context. Supported formats:

  • projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
ContextName name = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]");
// Make the request
Context response = await contextsClient.GetContextAsync(name);

GetContextAsync(ContextName, CancellationToken)

public virtual Task<Context> GetContextAsync(ContextName name, CancellationToken cancellationToken)

Retrieves the specified context.

Parameters
Name Description
name ContextName

Required. The name of the context. Supported formats:

  • projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
ContextName name = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]");
// Make the request
Context response = await contextsClient.GetContextAsync(name);

GetContextAsync(GetContextRequest, CallSettings)

public virtual Task<Context> GetContextAsync(GetContextRequest request, CallSettings callSettings = null)

Retrieves the specified context.

Parameters
Name Description
request GetContextRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
GetContextRequest request = new GetContextRequest
{
    ContextName = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
};
// Make the request
Context response = await contextsClient.GetContextAsync(request);

GetContextAsync(GetContextRequest, CancellationToken)

public virtual Task<Context> GetContextAsync(GetContextRequest request, CancellationToken cancellationToken)

Retrieves the specified context.

Parameters
Name Description
request GetContextRequest

The request object containing all of the parameters for the API call.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
GetContextRequest request = new GetContextRequest
{
    ContextName = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
};
// Make the request
Context response = await contextsClient.GetContextAsync(request);

GetContextAsync(string, CallSettings)

public virtual Task<Context> GetContextAsync(string name, CallSettings callSettings = null)

Retrieves the specified context.

Parameters
Name Description
name string

Required. The name of the context. Supported formats:

  • projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/agent/sessions/[SESSION]/contexts/[CONTEXT]";
// Make the request
Context response = await contextsClient.GetContextAsync(name);

GetContextAsync(string, CancellationToken)

public virtual Task<Context> GetContextAsync(string name, CancellationToken cancellationToken)

Retrieves the specified context.

Parameters
Name Description
name string

Required. The name of the context. Supported formats:

  • projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/agent/sessions/[SESSION]/contexts/[CONTEXT]";
// Make the request
Context response = await contextsClient.GetContextAsync(name);

ListContexts(ListContextsRequest, CallSettings)

public virtual PagedEnumerable<ListContextsResponse, Context> ListContexts(ListContextsRequest request, CallSettings callSettings = null)

Returns the list of all contexts in the specified session.

Parameters
Name Description
request ListContextsRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListContextsResponseContext

A pageable sequence of Context resources.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
ListContextsRequest request = new ListContextsRequest
{
    ParentAsSessionName = SessionName.FromProjectSession("[PROJECT]", "[SESSION]"),
};
// Make the request
PagedEnumerable<ListContextsResponse, Context> response = contextsClient.ListContexts(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (Context item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListContextsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Context item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Context> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Context item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListContexts(SessionName, string, int?, CallSettings)

public virtual PagedEnumerable<ListContextsResponse, Context> ListContexts(SessionName parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Returns the list of all contexts in the specified session.

Parameters
Name Description
parent SessionName

Required. The session to list all contexts from. Supported formats:

  • `projects/<Project ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListContextsResponseContext

A pageable sequence of Context resources.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
SessionName parent = SessionName.FromProjectSession("[PROJECT]", "[SESSION]");
// Make the request
PagedEnumerable<ListContextsResponse, Context> response = contextsClient.ListContexts(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (Context item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListContextsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Context item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Context> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Context item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListContexts(string, string, int?, CallSettings)

public virtual PagedEnumerable<ListContextsResponse, Context> ListContexts(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Returns the list of all contexts in the specified session.

Parameters
Name Description
parent string

Required. The session to list all contexts from. Supported formats:

  • `projects/<Project ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListContextsResponseContext

A pageable sequence of Context resources.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/agent/sessions/[SESSION]";
// Make the request
PagedEnumerable<ListContextsResponse, Context> response = contextsClient.ListContexts(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (Context item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListContextsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Context item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Context> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Context item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListContextsAsync(ListContextsRequest, CallSettings)

public virtual PagedAsyncEnumerable<ListContextsResponse, Context> ListContextsAsync(ListContextsRequest request, CallSettings callSettings = null)

Returns the list of all contexts in the specified session.

Parameters
Name Description
request ListContextsRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListContextsResponseContext

A pageable asynchronous sequence of Context resources.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
ListContextsRequest request = new ListContextsRequest
{
    ParentAsSessionName = SessionName.FromProjectSession("[PROJECT]", "[SESSION]"),
};
// Make the request
PagedAsyncEnumerable<ListContextsResponse, Context> response = contextsClient.ListContextsAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Context item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListContextsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Context item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Context> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Context item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListContextsAsync(SessionName, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListContextsResponse, Context> ListContextsAsync(SessionName parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Returns the list of all contexts in the specified session.

Parameters
Name Description
parent SessionName

Required. The session to list all contexts from. Supported formats:

  • `projects/<Project ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListContextsResponseContext

A pageable asynchronous sequence of Context resources.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
SessionName parent = SessionName.FromProjectSession("[PROJECT]", "[SESSION]");
// Make the request
PagedAsyncEnumerable<ListContextsResponse, Context> response = contextsClient.ListContextsAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Context item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListContextsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Context item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Context> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Context item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListContextsAsync(string, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListContextsResponse, Context> ListContextsAsync(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Returns the list of all contexts in the specified session.

Parameters
Name Description
parent string

Required. The session to list all contexts from. Supported formats:

  • `projects/<Project ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session ID>,
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,
  • projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>,

If Location ID is not specified we assume default 'us' location. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListContextsResponseContext

A pageable asynchronous sequence of Context resources.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/agent/sessions/[SESSION]";
// Make the request
PagedAsyncEnumerable<ListContextsResponse, Context> response = contextsClient.ListContextsAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Context item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListContextsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Context item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Context> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Context item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ShutdownDefaultChannelsAsync()

public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.

Returns
Type Description
Task

A task representing the asynchronous shutdown operation.

Remarks

After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.

UpdateContext(Context, CallSettings)

public virtual Context UpdateContext(Context context, CallSettings callSettings = null)

Updates the specified context.

Parameters
Name Description
context Context

Required. The context to update.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Context

The RPC response.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
Context context = new Context();
// Make the request
Context response = contextsClient.UpdateContext(context);

UpdateContext(Context, FieldMask, CallSettings)

public virtual Context UpdateContext(Context context, FieldMask updateMask, CallSettings callSettings = null)

Updates the specified context.

Parameters
Name Description
context Context

Required. The context to update.

updateMask FieldMask

Optional. The mask to control which fields get updated.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Context

The RPC response.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
Context context = new Context();
FieldMask updateMask = new FieldMask();
// Make the request
Context response = contextsClient.UpdateContext(context, updateMask);

UpdateContext(UpdateContextRequest, CallSettings)

public virtual Context UpdateContext(UpdateContextRequest request, CallSettings callSettings = null)

Updates the specified context.

Parameters
Name Description
request UpdateContextRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Context

The RPC response.

Example
// Create client
ContextsClient contextsClient = ContextsClient.Create();
// Initialize request argument(s)
UpdateContextRequest request = new UpdateContextRequest
{
    Context = new Context(),
    UpdateMask = new FieldMask(),
};
// Make the request
Context response = contextsClient.UpdateContext(request);

UpdateContextAsync(Context, CallSettings)

public virtual Task<Context> UpdateContextAsync(Context context, CallSettings callSettings = null)

Updates the specified context.

Parameters
Name Description
context Context

Required. The context to update.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
Context context = new Context();
// Make the request
Context response = await contextsClient.UpdateContextAsync(context);

UpdateContextAsync(Context, FieldMask, CallSettings)

public virtual Task<Context> UpdateContextAsync(Context context, FieldMask updateMask, CallSettings callSettings = null)

Updates the specified context.

Parameters
Name Description
context Context

Required. The context to update.

updateMask FieldMask

Optional. The mask to control which fields get updated.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
Context context = new Context();
FieldMask updateMask = new FieldMask();
// Make the request
Context response = await contextsClient.UpdateContextAsync(context, updateMask);

UpdateContextAsync(Context, FieldMask, CancellationToken)

public virtual Task<Context> UpdateContextAsync(Context context, FieldMask updateMask, CancellationToken cancellationToken)

Updates the specified context.

Parameters
Name Description
context Context

Required. The context to update.

updateMask FieldMask

Optional. The mask to control which fields get updated.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
Context context = new Context();
FieldMask updateMask = new FieldMask();
// Make the request
Context response = await contextsClient.UpdateContextAsync(context, updateMask);

UpdateContextAsync(Context, CancellationToken)

public virtual Task<Context> UpdateContextAsync(Context context, CancellationToken cancellationToken)

Updates the specified context.

Parameters
Name Description
context Context

Required. The context to update.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
Context context = new Context();
// Make the request
Context response = await contextsClient.UpdateContextAsync(context);

UpdateContextAsync(UpdateContextRequest, CallSettings)

public virtual Task<Context> UpdateContextAsync(UpdateContextRequest request, CallSettings callSettings = null)

Updates the specified context.

Parameters
Name Description
request UpdateContextRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
UpdateContextRequest request = new UpdateContextRequest
{
    Context = new Context(),
    UpdateMask = new FieldMask(),
};
// Make the request
Context response = await contextsClient.UpdateContextAsync(request);

UpdateContextAsync(UpdateContextRequest, CancellationToken)

public virtual Task<Context> UpdateContextAsync(UpdateContextRequest request, CancellationToken cancellationToken)

Updates the specified context.

Parameters
Name Description
request UpdateContextRequest

The request object containing all of the parameters for the API call.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskContext

A Task containing the RPC response.

Example
// Create client
ContextsClient contextsClient = await ContextsClient.CreateAsync();
// Initialize request argument(s)
UpdateContextRequest request = new UpdateContextRequest
{
    Context = new Context(),
    UpdateMask = new FieldMask(),
};
// Make the request
Context response = await contextsClient.UpdateContextAsync(request);