Show / Hide Table of Contents

Class ContextsClient

Contexts client wrapper, for convenient use.

Inheritance
System.Object
ContextsClient
ContextsClientImpl
Inherited Members
System.Object.ToString()
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Google.Cloud.Dialogflow.V2
Assembly: Google.Cloud.Dialogflow.V2.dll
Syntax
public abstract class ContextsClient
Remarks

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

Properties

DefaultEndpoint

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

Declaration
public static string DefaultEndpoint { get; }
Property Value
Type Description
System.String

DefaultScopes

The default Contexts scopes.

Declaration
public static IReadOnlyList<string> DefaultScopes { get; }
Property Value
Type Description
System.Collections.Generic.IReadOnlyList<System.String>
Remarks

The default Contexts scopes are:

  • https://www.googleapis.com/auth/cloud-platform
  • https://www.googleapis.com/auth/dialogflow

GrpcClient

The underlying gRPC Contexts client

Declaration
public virtual Contexts.ContextsClient GrpcClient { get; }
Property Value
Type Description
Contexts.ContextsClient

Methods

Create()

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

Declaration
public static ContextsClient Create()
Returns
Type Description
ContextsClient

The created ContextsClient.

CreateAsync(CancellationToken)

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

Declaration
public static Task<ContextsClient> CreateAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.CancellationToken cancellationToken

The System.Threading.CancellationToken to use while creating the client.

Returns
Type Description
System.Threading.Tasks.Task<ContextsClient>

The task representing the created ContextsClient.

CreateContext(CreateContextRequest, CallSettings)

Creates a context.

If the specified context already exists, overrides the context.

Declaration
public virtual Context CreateContext(CreateContextRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
CreateContextRequest request

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.

Sample code
// 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)

Creates a context.

If the specified context already exists, overrides the context.

Declaration
public virtual Context CreateContext(SessionName parent, Context context, CallSettings callSettings = null)
Parameters
Type Name Description
SessionName parent

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;. 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.

Sample code
// 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)

Creates a context.

If the specified context already exists, overrides the context.

Declaration
public virtual Context CreateContext(string parent, Context context, CallSettings callSettings = null)
Parameters
Type Name Description
System.String parent

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;. 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.

Sample code
// 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)

Creates a context.

If the specified context already exists, overrides the context.

Declaration
public virtual Task<Context> CreateContextAsync(CreateContextRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
CreateContextRequest request

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
System.Threading.Tasks.Task<Context>

A Task containing the RPC response.

Sample code
// 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)

Creates a context.

If the specified context already exists, overrides the context.

Declaration
public virtual Task<Context> CreateContextAsync(CreateContextRequest request, CancellationToken cancellationToken)
Parameters
Type Name Description
CreateContextRequest request

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

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<Context>

A Task containing the RPC response.

Sample code
// 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)

Creates a context.

If the specified context already exists, overrides the context.

Declaration
public virtual Task<Context> CreateContextAsync(SessionName parent, Context context, CallSettings callSettings = null)
Parameters
Type Name Description
SessionName parent

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;. 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
System.Threading.Tasks.Task<Context>

A Task containing the RPC response.

Sample code
// 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)

Creates a context.

If the specified context already exists, overrides the context.

Declaration
public virtual Task<Context> CreateContextAsync(SessionName parent, Context context, CancellationToken cancellationToken)
Parameters
Type Name Description
SessionName parent

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;. 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.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<Context>

A Task containing the RPC response.

Sample code
// 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)

Creates a context.

If the specified context already exists, overrides the context.

Declaration
public virtual Task<Context> CreateContextAsync(string parent, Context context, CallSettings callSettings = null)
Parameters
Type Name Description
System.String parent

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;. 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
System.Threading.Tasks.Task<Context>

A Task containing the RPC response.

Sample code
// 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)

Creates a context.

If the specified context already exists, overrides the context.

Declaration
public virtual Task<Context> CreateContextAsync(string parent, Context context, CancellationToken cancellationToken)
Parameters
Type Name Description
System.String parent

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;. 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.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<Context>

A Task containing the RPC response.

Sample code
// 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)

Deletes all active contexts in the specified session.

Declaration
public virtual void DeleteAllContexts(DeleteAllContextsRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
DeleteAllContextsRequest request

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

CallSettings callSettings

If not null, applies overrides to this RPC call.

Sample code
// 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)

Deletes all active contexts in the specified session.

Declaration
public virtual void DeleteAllContexts(SessionName parent, CallSettings callSettings = null)
Parameters
Type Name Description
SessionName parent

Required. The name of the session to delete all contexts from. Format: projects/{Project ID}/agent/sessions/{Session ID} or projects/{Project ID&amp;gt;/agent/environments/&amp;lt;Environment ID&amp;gt;/users/&amp;lt;User ID&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;. 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.

Sample code
// 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)

Deletes all active contexts in the specified session.

Declaration
public virtual void DeleteAllContexts(string parent, CallSettings callSettings = null)
Parameters
Type Name Description
System.String parent

Required. The name of the session to delete all contexts from. Format: projects/{Project ID}/agent/sessions/{Session ID} or projects/{Project ID&amp;gt;/agent/environments/&amp;lt;Environment ID&amp;gt;/users/&amp;lt;User ID&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;. 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.

Sample code
// 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)

Deletes all active contexts in the specified session.

Declaration
public virtual Task DeleteAllContextsAsync(DeleteAllContextsRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
DeleteAllContextsRequest request

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
System.Threading.Tasks.Task

A Task containing the RPC response.

Sample code
// 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)

Deletes all active contexts in the specified session.

Declaration
public virtual Task DeleteAllContextsAsync(DeleteAllContextsRequest request, CancellationToken cancellationToken)
Parameters
Type Name Description
DeleteAllContextsRequest request

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

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task

A Task containing the RPC response.

Sample code
// 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)

Deletes all active contexts in the specified session.

Declaration
public virtual Task DeleteAllContextsAsync(SessionName parent, CallSettings callSettings = null)
Parameters
Type Name Description
SessionName parent

Required. The name of the session to delete all contexts from. Format: projects/{Project ID}/agent/sessions/{Session ID} or projects/{Project ID&amp;gt;/agent/environments/&amp;lt;Environment ID&amp;gt;/users/&amp;lt;User ID&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;. 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
System.Threading.Tasks.Task

A Task containing the RPC response.

Sample code
// 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)

Deletes all active contexts in the specified session.

Declaration
public virtual Task DeleteAllContextsAsync(SessionName parent, CancellationToken cancellationToken)
Parameters
Type Name Description
SessionName parent

Required. The name of the session to delete all contexts from. Format: projects/{Project ID}/agent/sessions/{Session ID} or projects/{Project ID&amp;gt;/agent/environments/&amp;lt;Environment ID&amp;gt;/users/&amp;lt;User ID&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;. If Environment ID is not specified we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task

A Task containing the RPC response.

Sample code
// 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)

Deletes all active contexts in the specified session.

Declaration
public virtual Task DeleteAllContextsAsync(string parent, CallSettings callSettings = null)
Parameters
Type Name Description
System.String parent

Required. The name of the session to delete all contexts from. Format: projects/{Project ID}/agent/sessions/{Session ID} or projects/{Project ID&amp;gt;/agent/environments/&amp;lt;Environment ID&amp;gt;/users/&amp;lt;User ID&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;. 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
System.Threading.Tasks.Task

A Task containing the RPC response.

Sample code
// 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)

Deletes all active contexts in the specified session.

Declaration
public virtual Task DeleteAllContextsAsync(string parent, CancellationToken cancellationToken)
Parameters
Type Name Description
System.String parent

Required. The name of the session to delete all contexts from. Format: projects/{Project ID}/agent/sessions/{Session ID} or projects/{Project ID&amp;gt;/agent/environments/&amp;lt;Environment ID&amp;gt;/users/&amp;lt;User ID&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;. If Environment ID is not specified we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task

A Task containing the RPC response.

Sample code
// 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)

Deletes the specified context.

Declaration
public virtual void DeleteContext(ContextName name, CallSettings callSettings = null)
Parameters
Type Name Description
ContextName name

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;/contexts/&amp;lt;Context ID&amp;gt;. 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.

Sample code
// 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)

Deletes the specified context.

Declaration
public virtual void DeleteContext(DeleteContextRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
DeleteContextRequest request

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

CallSettings callSettings

If not null, applies overrides to this RPC call.

Sample code
// 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)

Deletes the specified context.

Declaration
public virtual void DeleteContext(string name, CallSettings callSettings = null)
Parameters
Type Name Description
System.String name

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;/contexts/&amp;lt;Context ID&amp;gt;. 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.

Sample code
// 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)

Deletes the specified context.

Declaration
public virtual Task DeleteContextAsync(ContextName name, CallSettings callSettings = null)
Parameters
Type Name Description
ContextName name

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;/contexts/&amp;lt;Context ID&amp;gt;. 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
System.Threading.Tasks.Task

A Task containing the RPC response.

Sample code
// 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)

Deletes the specified context.

Declaration
public virtual Task DeleteContextAsync(ContextName name, CancellationToken cancellationToken)
Parameters
Type Name Description
ContextName name

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;/contexts/&amp;lt;Context ID&amp;gt;. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task

A Task containing the RPC response.

Sample code
// 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)

Deletes the specified context.

Declaration
public virtual Task DeleteContextAsync(DeleteContextRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
DeleteContextRequest request

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
System.Threading.Tasks.Task

A Task containing the RPC response.

Sample code
// 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)

Deletes the specified context.

Declaration
public virtual Task DeleteContextAsync(DeleteContextRequest request, CancellationToken cancellationToken)
Parameters
Type Name Description
DeleteContextRequest request

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

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task

A Task containing the RPC response.

Sample code
// 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)

Deletes the specified context.

Declaration
public virtual Task DeleteContextAsync(string name, CallSettings callSettings = null)
Parameters
Type Name Description
System.String name

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;/contexts/&amp;lt;Context ID&amp;gt;. 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
System.Threading.Tasks.Task

A Task containing the RPC response.

Sample code
// 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)

Deletes the specified context.

Declaration
public virtual Task DeleteContextAsync(string name, CancellationToken cancellationToken)
Parameters
Type Name Description
System.String name

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;/contexts/&amp;lt;Context ID&amp;gt;. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task

A Task containing the RPC response.

Sample code
// 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)

Retrieves the specified context.

Declaration
public virtual Context GetContext(ContextName name, CallSettings callSettings = null)
Parameters
Type Name Description
ContextName name

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;/contexts/&amp;lt;Context ID&amp;gt;. 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.

Sample code
// 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)

Retrieves the specified context.

Declaration
public virtual Context GetContext(GetContextRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
GetContextRequest request

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.

Sample code
// 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)

Retrieves the specified context.

Declaration
public virtual Context GetContext(string name, CallSettings callSettings = null)
Parameters
Type Name Description
System.String name

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;/contexts/&amp;lt;Context ID&amp;gt;. 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.

Sample code
// 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)

Retrieves the specified context.

Declaration
public virtual Task<Context> GetContextAsync(ContextName name, CallSettings callSettings = null)
Parameters
Type Name Description
ContextName name

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;/contexts/&amp;lt;Context ID&amp;gt;. 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
System.Threading.Tasks.Task<Context>

A Task containing the RPC response.

Sample code
// 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)

Retrieves the specified context.

Declaration
public virtual Task<Context> GetContextAsync(ContextName name, CancellationToken cancellationToken)
Parameters
Type Name Description
ContextName name

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;/contexts/&amp;lt;Context ID&amp;gt;. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<Context>

A Task containing the RPC response.

Sample code
// 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)

Retrieves the specified context.

Declaration
public virtual Task<Context> GetContextAsync(GetContextRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
GetContextRequest request

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
System.Threading.Tasks.Task<Context>

A Task containing the RPC response.

Sample code
// 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)

Retrieves the specified context.

Declaration
public virtual Task<Context> GetContextAsync(GetContextRequest request, CancellationToken cancellationToken)
Parameters
Type Name Description
GetContextRequest request

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

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<Context>

A Task containing the RPC response.

Sample code
// 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)

Retrieves the specified context.

Declaration
public virtual Task<Context> GetContextAsync(string name, CallSettings callSettings = null)
Parameters
Type Name Description
System.String name

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;/contexts/&amp;lt;Context ID&amp;gt;. 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
System.Threading.Tasks.Task<Context>

A Task containing the RPC response.

Sample code
// 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)

Retrieves the specified context.

Declaration
public virtual Task<Context> GetContextAsync(string name, CancellationToken cancellationToken)
Parameters
Type Name Description
System.String name

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;/contexts/&amp;lt;Context ID&amp;gt;. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<Context>

A Task containing the RPC response.

Sample code
// 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)

Returns the list of all contexts in the specified session.

Declaration
public virtual PagedEnumerable<ListContextsResponse, Context> ListContexts(ListContextsRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
ListContextsRequest request

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
PagedEnumerable<ListContextsResponse, Context>

A pageable sequence of Context resources.

Sample code
// 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, Nullable<Int32>, CallSettings)

Returns the list of all contexts in the specified session.

Declaration
public virtual PagedEnumerable<ListContextsResponse, Context> ListContexts(SessionName parent, string pageToken = null, int? pageSize = default(int? ), CallSettings callSettings = null)
Parameters
Type Name Description
SessionName parent

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

System.String pageToken

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

System.Nullable<System.Int32> pageSize

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
PagedEnumerable<ListContextsResponse, Context>

A pageable sequence of Context resources.

Sample code
// 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, Nullable<Int32>, CallSettings)

Returns the list of all contexts in the specified session.

Declaration
public virtual PagedEnumerable<ListContextsResponse, Context> ListContexts(string parent, string pageToken = null, int? pageSize = default(int? ), CallSettings callSettings = null)
Parameters
Type Name Description
System.String parent

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

System.String pageToken

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

System.Nullable<System.Int32> pageSize

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
PagedEnumerable<ListContextsResponse, Context>

A pageable sequence of Context resources.

Sample code
// 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)

Returns the list of all contexts in the specified session.

Declaration
public virtual PagedAsyncEnumerable<ListContextsResponse, Context> ListContextsAsync(ListContextsRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
ListContextsRequest request

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
PagedAsyncEnumerable<ListContextsResponse, Context>

A pageable asynchronous sequence of Context resources.

Sample code
// 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, Nullable<Int32>, CallSettings)

Returns the list of all contexts in the specified session.

Declaration
public virtual PagedAsyncEnumerable<ListContextsResponse, Context> ListContextsAsync(SessionName parent, string pageToken = null, int? pageSize = default(int? ), CallSettings callSettings = null)
Parameters
Type Name Description
SessionName parent

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

System.String pageToken

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

System.Nullable<System.Int32> pageSize

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
PagedAsyncEnumerable<ListContextsResponse, Context>

A pageable asynchronous sequence of Context resources.

Sample code
// 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, Nullable<Int32>, CallSettings)

Returns the list of all contexts in the specified session.

Declaration
public virtual PagedAsyncEnumerable<ListContextsResponse, Context> ListContextsAsync(string parent, string pageToken = null, int? pageSize = default(int? ), CallSettings callSettings = null)
Parameters
Type Name Description
System.String parent

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&amp;gt;/sessions/&amp;lt;Session ID&amp;gt;. If Environment ID is not specified, we assume default 'draft' environment. If User ID is not specified, we assume default '-' user.

System.String pageToken

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

System.Nullable<System.Int32> pageSize

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
PagedAsyncEnumerable<ListContextsResponse, Context>

A pageable asynchronous sequence of Context resources.

Sample code
// 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()

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

Declaration
public static Task ShutdownDefaultChannelsAsync()
Returns
Type Description
System.Threading.Tasks.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, FieldMask, CallSettings)

Updates the specified context.

Declaration
public virtual Context UpdateContext(Context context, FieldMask updateMask, CallSettings callSettings = null)
Parameters
Type Name Description
Context context

Required. The context to update.

FieldMask updateMask

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.

Sample code
// 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)

Updates the specified context.

Declaration
public virtual Context UpdateContext(UpdateContextRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
UpdateContextRequest request

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.

Sample code
// 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, FieldMask, CallSettings)

Updates the specified context.

Declaration
public virtual Task<Context> UpdateContextAsync(Context context, FieldMask updateMask, CallSettings callSettings = null)
Parameters
Type Name Description
Context context

Required. The context to update.

FieldMask updateMask

Optional. The mask to control which fields get updated.

CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
System.Threading.Tasks.Task<Context>

A Task containing the RPC response.

Sample code
// 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)

Updates the specified context.

Declaration
public virtual Task<Context> UpdateContextAsync(Context context, FieldMask updateMask, CancellationToken cancellationToken)
Parameters
Type Name Description
Context context

Required. The context to update.

FieldMask updateMask

Optional. The mask to control which fields get updated.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<Context>

A Task containing the RPC response.

Sample code
// 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(UpdateContextRequest, CallSettings)

Updates the specified context.

Declaration
public virtual Task<Context> UpdateContextAsync(UpdateContextRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
UpdateContextRequest request

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
System.Threading.Tasks.Task<Context>

A Task containing the RPC response.

Sample code
// 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)

Updates the specified context.

Declaration
public virtual Task<Context> UpdateContextAsync(UpdateContextRequest request, CancellationToken cancellationToken)
Parameters
Type Name Description
UpdateContextRequest request

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

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<Context>

A Task containing the RPC response.

Sample code
// 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);
Back to top