Compute Engine v1 API - Class ZonesClient (3.2.0)

public abstract class ZonesClient

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

Zones client wrapper, for convenient use.

Inheritance

object > ZonesClient

Derived Types

Namespace

Google.Cloud.Compute.V1

Assembly

Google.Cloud.Compute.V1.dll

Remarks

The Zones API.

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

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

Property Value
Type Description
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default Zones scopes.

Property Value
Type Description
IReadOnlyListstring
Remarks

GrpcClient

public virtual Zones.ZonesClient GrpcClient { get; }

The underlying gRPC Zones client

Property Value
Type Description
ZonesZonesClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
Type Description
ServiceMetadata

Methods

Create()

public static ZonesClient Create()

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

Returns
Type Description
ZonesClient

The created ZonesClient.

CreateAsync(CancellationToken)

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

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

Parameter
Name Description
cancellationToken CancellationToken

The CancellationToken to use while creating the client.

Returns
Type Description
TaskZonesClient

The task representing the created ZonesClient.

Get(GetZoneRequest, CallSettings)

public virtual Zone Get(GetZoneRequest request, CallSettings callSettings = null)

Returns the specified Zone resource.

Parameters
Name Description
request GetZoneRequest

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
Zone

The RPC response.

Example
// Create client
ZonesClient zonesClient = ZonesClient.Create();
// Initialize request argument(s)
GetZoneRequest request = new GetZoneRequest
{
    Zone = "",
    Project = "",
};
// Make the request
Zone response = zonesClient.Get(request);

Get(string, string, CallSettings)

public virtual Zone Get(string project, string zone, CallSettings callSettings = null)

Returns the specified Zone resource.

Parameters
Name Description
project string

Project ID for this request.

zone string

Name of the zone resource to return.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Zone

The RPC response.

Example
// Create client
ZonesClient zonesClient = ZonesClient.Create();
// Initialize request argument(s)
string project = "";
string zone = "";
// Make the request
Zone response = zonesClient.Get(project, zone);

GetAsync(GetZoneRequest, CallSettings)

public virtual Task<Zone> GetAsync(GetZoneRequest request, CallSettings callSettings = null)

Returns the specified Zone resource.

Parameters
Name Description
request GetZoneRequest

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
TaskZone

A Task containing the RPC response.

Example
// Create client
ZonesClient zonesClient = await ZonesClient.CreateAsync();
// Initialize request argument(s)
GetZoneRequest request = new GetZoneRequest
{
    Zone = "",
    Project = "",
};
// Make the request
Zone response = await zonesClient.GetAsync(request);

GetAsync(GetZoneRequest, CancellationToken)

public virtual Task<Zone> GetAsync(GetZoneRequest request, CancellationToken cancellationToken)

Returns the specified Zone resource.

Parameters
Name Description
request GetZoneRequest

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskZone

A Task containing the RPC response.

Example
// Create client
ZonesClient zonesClient = await ZonesClient.CreateAsync();
// Initialize request argument(s)
GetZoneRequest request = new GetZoneRequest
{
    Zone = "",
    Project = "",
};
// Make the request
Zone response = await zonesClient.GetAsync(request);

GetAsync(string, string, CallSettings)

public virtual Task<Zone> GetAsync(string project, string zone, CallSettings callSettings = null)

Returns the specified Zone resource.

Parameters
Name Description
project string

Project ID for this request.

zone string

Name of the zone resource to return.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskZone

A Task containing the RPC response.

Example
// Create client
ZonesClient zonesClient = await ZonesClient.CreateAsync();
// Initialize request argument(s)
string project = "";
string zone = "";
// Make the request
Zone response = await zonesClient.GetAsync(project, zone);

GetAsync(string, string, CancellationToken)

public virtual Task<Zone> GetAsync(string project, string zone, CancellationToken cancellationToken)

Returns the specified Zone resource.

Parameters
Name Description
project string

Project ID for this request.

zone string

Name of the zone resource to return.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskZone

A Task containing the RPC response.

Example
// Create client
ZonesClient zonesClient = await ZonesClient.CreateAsync();
// Initialize request argument(s)
string project = "";
string zone = "";
// Make the request
Zone response = await zonesClient.GetAsync(project, zone);

List(ListZonesRequest, CallSettings)

public virtual PagedEnumerable<ZoneList, Zone> List(ListZonesRequest request, CallSettings callSettings = null)

Retrieves the list of Zone resources available to the specified project.

Parameters
Name Description
request ListZonesRequest

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
PagedEnumerableZoneListZone

A pageable sequence of Zone resources.

Example
// Create client
ZonesClient zonesClient = ZonesClient.Create();
// Initialize request argument(s)
ListZonesRequest request = new ListZonesRequest
{
    OrderBy = "",
    Project = "",
    Filter = "",
    ReturnPartialSuccess = false,
};
// Make the request
PagedEnumerable<ZoneList, Zone> response = zonesClient.List(request);

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

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

Retrieves the list of Zone resources available to the specified project.

Parameters
Name Description
project string

Project ID for this request.

pageToken string

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

pageSize int

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
PagedEnumerableZoneListZone

A pageable sequence of Zone resources.

Example
// Create client
ZonesClient zonesClient = ZonesClient.Create();
// Initialize request argument(s)
string project = "";
// Make the request
PagedEnumerable<ZoneList, Zone> response = zonesClient.List(project);

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

public virtual PagedAsyncEnumerable<ZoneList, Zone> ListAsync(ListZonesRequest request, CallSettings callSettings = null)

Retrieves the list of Zone resources available to the specified project.

Parameters
Name Description
request ListZonesRequest

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
PagedAsyncEnumerableZoneListZone

A pageable asynchronous sequence of Zone resources.

Example
// Create client
ZonesClient zonesClient = await ZonesClient.CreateAsync();
// Initialize request argument(s)
ListZonesRequest request = new ListZonesRequest
{
    OrderBy = "",
    Project = "",
    Filter = "",
    ReturnPartialSuccess = false,
};
// Make the request
PagedAsyncEnumerable<ZoneList, Zone> response = zonesClient.ListAsync(request);

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

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

Retrieves the list of Zone resources available to the specified project.

Parameters
Name Description
project string

Project ID for this request.

pageToken string

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

pageSize int

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
PagedAsyncEnumerableZoneListZone

A pageable asynchronous sequence of Zone resources.

Example
// Create client
ZonesClient zonesClient = await ZonesClient.CreateAsync();
// Initialize request argument(s)
string project = "";
// Make the request
PagedAsyncEnumerable<ZoneList, Zone> response = zonesClient.ListAsync(project);

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