Apigee Connect v1 API - Class TetherClient (2.2.0)

public abstract class TetherClient

Reference documentation and code samples for the Apigee Connect v1 API class TetherClient.

Tether client wrapper, for convenient use.

Inheritance

object > TetherClient

Derived Types

Namespace

Google.Cloud.ApigeeConnect.V1

Assembly

Google.Cloud.ApigeeConnect.V1.dll

Remarks

Tether provides a way for the control plane to send HTTP API requests to services in data planes that runs in a remote datacenter without requiring customers to open firewalls on their runtime plane.

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

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

Property Value
TypeDescription
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default Tether scopes.

Property Value
TypeDescription
IReadOnlyListstring
Remarks

The default Tether scopes are:

GrpcClient

public virtual Tether.TetherClient GrpcClient { get; }

The underlying gRPC Tether client

Property Value
TypeDescription
TetherTetherClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
TypeDescription
ServiceMetadata

Methods

Create()

public static TetherClient Create()

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

Returns
TypeDescription
TetherClient

The created TetherClient.

CreateAsync(CancellationToken)

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

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

Parameter
NameDescription
cancellationTokenCancellationToken

The CancellationToken to use while creating the client.

Returns
TypeDescription
TaskTetherClient

The task representing the created TetherClient.

Egress(CallSettings, BidirectionalStreamingSettings)

public virtual TetherClient.EgressStream Egress(CallSettings callSettings = null, BidirectionalStreamingSettings streamingSettings = null)

Egress streams egress requests and responses. Logically, this is not actually a streaming request, but uses streaming as a mechanism to flip the client-server relationship of gRPC so that the server can act as a client. The listener, the RPC server, accepts connections from the dialer, the RPC client. The listener streams http requests and the dialer streams http responses.

Parameters
NameDescription
callSettingsCallSettings

If not null, applies overrides to this RPC call.

streamingSettingsBidirectionalStreamingSettings

If not null, applies streaming overrides to this RPC call.

Returns
TypeDescription
TetherClientEgressStream

The client-server stream.

Example
// Create client
gcav::TetherClient tetherClient = gcav::TetherClient.Create();
// Initialize streaming call, retrieving the stream object
using gcav::TetherClient.EgressStream response = tetherClient.Egress();

// Sending requests and retrieving responses can be arbitrarily interleaved
// Exact sequence will depend on client/server behavior

// Create task to do something with responses from server
Task responseHandlerTask = Task.Run(async () =>
{
    // Note that C# 8 code can use await foreach
    AsyncResponseStream<gcav::EgressRequest> responseStream = response.GetResponseStream();
    while (await responseStream.MoveNextAsync())
    {
        gcav::EgressRequest responseItem = responseStream.Current;
        // Do something with streamed response
    }
    // The response stream has completed
});

// Send requests to the server
bool done = false;
while (!done)
{
    // Initialize a request
    gcav::EgressResponse request = new gcav::EgressResponse
    {
        Id = "",
        HttpResponse = new gcav::HttpResponse(),
        Status = new Status(),
        Project = "",
        TraceId = "",
        Endpoint = gcav::TetherEndpoint.Unspecified,
        Name = "",
    };
    // Stream a request to the server
    await response.WriteAsync(request);
    // Set "done" to true when sending requests is complete
}

// Complete writing requests to the stream
await response.WriteCompleteAsync();
// Await the response handler
// This will complete once all server responses have been processed
await responseHandlerTask;

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
TypeDescription
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.