Compute Engine v1 API - Class RegionsClient (2.6.0)

public abstract class RegionsClient

Reference documentation and code samples for the Compute Engine v1 API class RegionsClient.

Regions client wrapper, for convenient use.

Inheritance

Object > RegionsClient

Derived Types

Namespace

Google.Cloud.Compute.V1

Assembly

Google.Cloud.Compute.V1.dll

Remarks

The Regions API.

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

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

Property Value
TypeDescription
String

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default Regions scopes.

Property Value
TypeDescription
IReadOnlyList<String>
Remarks

GrpcClient

public virtual Regions.RegionsClient GrpcClient { get; }

The underlying gRPC Regions client

Property Value
TypeDescription
Regions.RegionsClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
TypeDescription
ServiceMetadata

Methods

Create()

public static RegionsClient Create()

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

Returns
TypeDescription
RegionsClient

The created RegionsClient.

CreateAsync(CancellationToken)

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

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

Parameter
NameDescription
cancellationTokenCancellationToken

The CancellationToken to use while creating the client.

Returns
TypeDescription
Task<RegionsClient>

The task representing the created RegionsClient.

Get(GetRegionRequest, CallSettings)

public virtual Region Get(GetRegionRequest request, CallSettings callSettings = null)

Returns the specified Region resource. Gets a list of available regions by making a list() request. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the quotas field). To exclude one or more fields, set your request's fields query parameter to only include the fields you need. For example, to only include the id and selfLink fields, add the query parameter ?fields=id,selfLink to your request.

Parameters
NameDescription
requestGetRegionRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Region

The RPC response.

Example
// Create client
RegionsClient regionsClient = RegionsClient.Create();
// Initialize request argument(s)
GetRegionRequest request = new GetRegionRequest
{
    Region = "",
    Project = "",
};
// Make the request
Region response = regionsClient.Get(request);

Get(String, String, CallSettings)

public virtual Region Get(string project, string region, CallSettings callSettings = null)

Returns the specified Region resource. Gets a list of available regions by making a list() request. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the quotas field). To exclude one or more fields, set your request's fields query parameter to only include the fields you need. For example, to only include the id and selfLink fields, add the query parameter ?fields=id,selfLink to your request.

Parameters
NameDescription
projectString

Project ID for this request.

regionString

Name of the region resource to return.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Region

The RPC response.

Example
// Create client
RegionsClient regionsClient = RegionsClient.Create();
// Initialize request argument(s)
string project = "";
string region = "";
// Make the request
Region response = regionsClient.Get(project, region);

GetAsync(GetRegionRequest, CallSettings)

public virtual Task<Region> GetAsync(GetRegionRequest request, CallSettings callSettings = null)

Returns the specified Region resource. Gets a list of available regions by making a list() request. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the quotas field). To exclude one or more fields, set your request's fields query parameter to only include the fields you need. For example, to only include the id and selfLink fields, add the query parameter ?fields=id,selfLink to your request.

Parameters
NameDescription
requestGetRegionRequest

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

A Task containing the RPC response.

Example
// Create client
RegionsClient regionsClient = await RegionsClient.CreateAsync();
// Initialize request argument(s)
GetRegionRequest request = new GetRegionRequest
{
    Region = "",
    Project = "",
};
// Make the request
Region response = await regionsClient.GetAsync(request);

GetAsync(GetRegionRequest, CancellationToken)

public virtual Task<Region> GetAsync(GetRegionRequest request, CancellationToken cancellationToken)

Returns the specified Region resource. Gets a list of available regions by making a list() request. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the quotas field). To exclude one or more fields, set your request's fields query parameter to only include the fields you need. For example, to only include the id and selfLink fields, add the query parameter ?fields=id,selfLink to your request.

Parameters
NameDescription
requestGetRegionRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
Task<Region>

A Task containing the RPC response.

Example
// Create client
RegionsClient regionsClient = await RegionsClient.CreateAsync();
// Initialize request argument(s)
GetRegionRequest request = new GetRegionRequest
{
    Region = "",
    Project = "",
};
// Make the request
Region response = await regionsClient.GetAsync(request);

GetAsync(String, String, CallSettings)

public virtual Task<Region> GetAsync(string project, string region, CallSettings callSettings = null)

Returns the specified Region resource. Gets a list of available regions by making a list() request. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the quotas field). To exclude one or more fields, set your request's fields query parameter to only include the fields you need. For example, to only include the id and selfLink fields, add the query parameter ?fields=id,selfLink to your request.

Parameters
NameDescription
projectString

Project ID for this request.

regionString

Name of the region resource to return.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task<Region>

A Task containing the RPC response.

Example
// Create client
RegionsClient regionsClient = await RegionsClient.CreateAsync();
// Initialize request argument(s)
string project = "";
string region = "";
// Make the request
Region response = await regionsClient.GetAsync(project, region);

GetAsync(String, String, CancellationToken)

public virtual Task<Region> GetAsync(string project, string region, CancellationToken cancellationToken)

Returns the specified Region resource. Gets a list of available regions by making a list() request. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the quotas field). To exclude one or more fields, set your request's fields query parameter to only include the fields you need. For example, to only include the id and selfLink fields, add the query parameter ?fields=id,selfLink to your request.

Parameters
NameDescription
projectString

Project ID for this request.

regionString

Name of the region resource to return.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
Task<Region>

A Task containing the RPC response.

Example
// Create client
RegionsClient regionsClient = await RegionsClient.CreateAsync();
// Initialize request argument(s)
string project = "";
string region = "";
// Make the request
Region response = await regionsClient.GetAsync(project, region);

List(ListRegionsRequest, CallSettings)

public virtual PagedEnumerable<RegionList, Region> List(ListRegionsRequest request, CallSettings callSettings = null)

Retrieves the list of region resources available to the specified project. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the items.quotas field). To exclude one or more fields, set your request's fields query parameter to only include the fields you need. For example, to only include the id and selfLink fields, add the query parameter ?fields=id,selfLink to your request.

Parameters
NameDescription
requestListRegionsRequest

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<RegionList, Region>

A pageable sequence of Region resources.

Example
// Create client
RegionsClient regionsClient = RegionsClient.Create();
// Initialize request argument(s)
ListRegionsRequest request = new ListRegionsRequest
{
    OrderBy = "",
    Project = "",
    Filter = "",
    ReturnPartialSuccess = false,
};
// Make the request
PagedEnumerable<RegionList, Region> response = regionsClient.List(request);

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

List(String, String, Nullable<Int32>, CallSettings)

public virtual PagedEnumerable<RegionList, Region> List(string project, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Retrieves the list of region resources available to the specified project. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the items.quotas field). To exclude one or more fields, set your request's fields query parameter to only include the fields you need. For example, to only include the id and selfLink fields, add the query parameter ?fields=id,selfLink to your request.

Parameters
NameDescription
projectString

Project ID for this request.

pageTokenString

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

pageSizeNullable<Int32>

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedEnumerable<RegionList, Region>

A pageable sequence of Region resources.

Example
// Create client
RegionsClient regionsClient = RegionsClient.Create();
// Initialize request argument(s)
string project = "";
// Make the request
PagedEnumerable<RegionList, Region> response = regionsClient.List(project);

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

ListAsync(ListRegionsRequest, CallSettings)

public virtual PagedAsyncEnumerable<RegionList, Region> ListAsync(ListRegionsRequest request, CallSettings callSettings = null)

Retrieves the list of region resources available to the specified project. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the items.quotas field). To exclude one or more fields, set your request's fields query parameter to only include the fields you need. For example, to only include the id and selfLink fields, add the query parameter ?fields=id,selfLink to your request.

Parameters
NameDescription
requestListRegionsRequest

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<RegionList, Region>

A pageable asynchronous sequence of Region resources.

Example
// Create client
RegionsClient regionsClient = await RegionsClient.CreateAsync();
// Initialize request argument(s)
ListRegionsRequest request = new ListRegionsRequest
{
    OrderBy = "",
    Project = "",
    Filter = "",
    ReturnPartialSuccess = false,
};
// Make the request
PagedAsyncEnumerable<RegionList, Region> response = regionsClient.ListAsync(request);

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

ListAsync(String, String, Nullable<Int32>, CallSettings)

public virtual PagedAsyncEnumerable<RegionList, Region> ListAsync(string project, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Retrieves the list of region resources available to the specified project. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the items.quotas field). To exclude one or more fields, set your request's fields query parameter to only include the fields you need. For example, to only include the id and selfLink fields, add the query parameter ?fields=id,selfLink to your request.

Parameters
NameDescription
projectString

Project ID for this request.

pageTokenString

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

pageSizeNullable<Int32>

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedAsyncEnumerable<RegionList, Region>

A pageable asynchronous sequence of Region resources.

Example
// Create client
RegionsClient regionsClient = await RegionsClient.CreateAsync();
// Initialize request argument(s)
string project = "";
// Make the request
PagedAsyncEnumerable<RegionList, Region> response = regionsClient.ListAsync(project);

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