Google.Cloud.Location - Class LocationsClient (2.3.0)

public abstract class LocationsClient

Reference documentation and code samples for the Google.Cloud.Location class LocationsClient.

Locations client wrapper, for convenient use.

Inheritance

object > LocationsClient

Derived Types

Namespace

Google.Cloud.Location

Assembly

Google.Cloud.Location.dll

Remarks

An abstract interface that provides location-related information for a service. Service-specific metadata is provided through the [Location.metadata][google.cloud.location.Location.metadata] field.

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

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

Property Value
Type Description
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default Locations scopes.

Property Value
Type Description
IReadOnlyListstring
Remarks

The default Locations scopes are:

GrpcClient

public virtual Locations.LocationsClient GrpcClient { get; }

The underlying gRPC Locations client

Property Value
Type Description
LocationsLocationsClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
Type Description
ServiceMetadata

Methods

Create()

public static LocationsClient Create()

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

Returns
Type Description
LocationsClient

The created LocationsClient.

CreateAsync(CancellationToken)

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

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

Parameter
Name Description
cancellationToken CancellationToken

The CancellationToken to use while creating the client.

Returns
Type Description
TaskLocationsClient

The task representing the created LocationsClient.

GetLocation(GetLocationRequest, CallSettings)

public virtual Location GetLocation(GetLocationRequest request, CallSettings callSettings = null)

Gets information about a location.

Parameters
Name Description
request GetLocationRequest

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
Location

The RPC response.

Example
// Create client
LocationsClient locationsClient = LocationsClient.Create();
// Initialize request argument(s)
GetLocationRequest request = new GetLocationRequest { Name = "", };
// Make the request
Location response = locationsClient.GetLocation(request);

GetLocationAsync(GetLocationRequest, CallSettings)

public virtual Task<Location> GetLocationAsync(GetLocationRequest request, CallSettings callSettings = null)

Gets information about a location.

Parameters
Name Description
request GetLocationRequest

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
TaskLocation

A Task containing the RPC response.

Example
// Create client
LocationsClient locationsClient = await LocationsClient.CreateAsync();
// Initialize request argument(s)
GetLocationRequest request = new GetLocationRequest { Name = "", };
// Make the request
Location response = await locationsClient.GetLocationAsync(request);

GetLocationAsync(GetLocationRequest, CancellationToken)

public virtual Task<Location> GetLocationAsync(GetLocationRequest request, CancellationToken cancellationToken)

Gets information about a location.

Parameters
Name Description
request GetLocationRequest

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskLocation

A Task containing the RPC response.

Example
// Create client
LocationsClient locationsClient = await LocationsClient.CreateAsync();
// Initialize request argument(s)
GetLocationRequest request = new GetLocationRequest { Name = "", };
// Make the request
Location response = await locationsClient.GetLocationAsync(request);

ListLocations(ListLocationsRequest, CallSettings)

public virtual PagedEnumerable<ListLocationsResponse, Location> ListLocations(ListLocationsRequest request, CallSettings callSettings = null)

Lists information about the supported locations for this service.

Parameters
Name Description
request ListLocationsRequest

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
PagedEnumerableListLocationsResponseLocation

A pageable sequence of Location resources.

Example
// Create client
LocationsClient locationsClient = LocationsClient.Create();
// Initialize request argument(s)
ListLocationsRequest request = new ListLocationsRequest { Name = "", Filter = "", };
// Make the request
PagedEnumerable<ListLocationsResponse, Location> response = locationsClient.ListLocations(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (Location 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 (ListLocationsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Location 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<Location> 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 (Location 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;

ListLocationsAsync(ListLocationsRequest, CallSettings)

public virtual PagedAsyncEnumerable<ListLocationsResponse, Location> ListLocationsAsync(ListLocationsRequest request, CallSettings callSettings = null)

Lists information about the supported locations for this service.

Parameters
Name Description
request ListLocationsRequest

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
PagedAsyncEnumerableListLocationsResponseLocation

A pageable asynchronous sequence of Location resources.

Example
// Create client
LocationsClient locationsClient = await LocationsClient.CreateAsync();
// Initialize request argument(s)
ListLocationsRequest request = new ListLocationsRequest { Name = "", Filter = "", };
// Make the request
PagedAsyncEnumerable<ListLocationsResponse, Location> response = locationsClient.ListLocationsAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Location 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((ListLocationsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Location 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<Location> 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 (Location 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.