Class LocationsClient (2.0.0)

public abstract 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
TypeDescription
String

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default Locations scopes.

Property Value
TypeDescription
IReadOnlyList<String>
Remarks

The default Locations scopes are:

GrpcClient

public virtual Locations.LocationsClient GrpcClient { get; }

The underlying gRPC Locations client

Property Value
TypeDescription
Locations.LocationsClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
TypeDescription
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
TypeDescription
LocationsClient

The created LocationsClient.

CreateAsync(CancellationToken)

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

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

Parameter
NameDescription
cancellationTokenCancellationToken

The CancellationToken to use while creating the client.

Returns
TypeDescription
Task<LocationsClient>

The task representing the created LocationsClient.

GetLocation(GetLocationRequest, CallSettings)

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

Gets information about a location.

Parameters
NameDescription
requestGetLocationRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestGetLocationRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task<Location>

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
NameDescription
requestGetLocationRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
Task<Location>

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
NameDescription
requestListLocationsRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedEnumerable<ListLocationsResponse, Location>

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
NameDescription
requestListLocationsRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedAsyncEnumerable<ListLocationsResponse, Location>

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