# Service Control v1 API - Class ServiceControllerClient (2.5.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.5.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ServiceControllerClient)
- [2.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/2.4.0/Google.Cloud.ServiceControl.V1.ServiceControllerClient)
- [2.3.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/2.3.0/Google.Cloud.ServiceControl.V1.ServiceControllerClient)
- [2.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/2.2.0/Google.Cloud.ServiceControl.V1.ServiceControllerClient)
- [2.1.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/2.1.0/Google.Cloud.ServiceControl.V1.ServiceControllerClient)
- [2.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/2.0.0/Google.Cloud.ServiceControl.V1.ServiceControllerClient)
- [1.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/1.4.0/Google.Cloud.ServiceControl.V1.ServiceControllerClient)
- [1.3.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/1.3.0/Google.Cloud.ServiceControl.V1.ServiceControllerClient)
- [1.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/1.2.0/Google.Cloud.ServiceControl.V1.ServiceControllerClient)
- [1.1.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/1.1.0/Google.Cloud.ServiceControl.V1.ServiceControllerClient)
- [1.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/1.0.0/Google.Cloud.ServiceControl.V1.ServiceControllerClient)

    public abstract class ServiceControllerClient

Reference documentation and code samples for the Service Control v1 API class ServiceControllerClient.

ServiceController client wrapper, for convenient use.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> ServiceControllerClient

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Derived Types

[ServiceControllerClientImpl](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ServiceControllerClientImpl)

## Namespace

[Google.Cloud.ServiceControl.V1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1)

## Assembly

Google.Cloud.ServiceControl.V1.dll

## Remarks

[Google Service Control API](https://docs.cloud.google.com/service-control/overview)

Lets clients check and report operations against a [managed
service](https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService).

## Properties

### DefaultEndpoint

    public static string DefaultEndpoint { get; }

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

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### DefaultScopes

    public static IReadOnlyList<string> DefaultScopes { get; }

The default ServiceController scopes.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist-1https://learn.microsoft.com/dotnet/api/system.string` |   |

**Remarks** The default ServiceController scopes are:

- <https://www.googleapis.com/auth/cloud-platform>
- <https://www.googleapis.com/auth/servicecontrol>

<br />

### GrpcClient

    public virtual ServiceController.ServiceControllerClient GrpcClient { get; }

The underlying gRPC ServiceController client

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ServiceControllerhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ServiceController.ServiceControllerClient` |   |

### ServiceMetadata

    public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ServiceMetadata.html` |   |

## Methods

### Check(CheckRequest, CallSettings)

    public virtual CheckResponse Check(CheckRequest request, CallSettings callSettings = null)

Checks whether an operation on a service should be allowed to proceed
based on the configuration of the service and related policies. It must be
called before the operation is executed.

If feasible, the client should cache the check results and reuse them for
60 seconds. In case of any server errors, the client should rely on the
cached results for much longer time to avoid outage.
WARNING: There is general 60s delay for the configuration and policy
propagation, therefore callers MUST NOT depend on the `Check` method having
the latest policy information.

NOTE: the \[CheckRequest\]\[google.api.servicecontrol.v1.CheckRequest\] has
the size limit (wire-format byte size) of 1MB.

This method requires the `servicemanagement.services.check` permission
on the specified service. For more information, see
[Cloud IAM](https://cloud.google.com/iam).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.CheckRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.CheckResponse` | The RPC response. |

**Example**

    // Create client
    ServiceControllerClient serviceControllerClient = ServiceControllerClient.Create();
    // Initialize request argument(s)
    CheckRequest request = new CheckRequest
    {
        ServiceName = "",
        Operation = new Operation(),
        ServiceConfigId = "",
    };
    // Make the request
    CheckResponse response = serviceControllerClient.Check(request);

### CheckAsync(CheckRequest, CallSettings)

    public virtual Task<CheckResponse> CheckAsync(CheckRequest request, CallSettings callSettings = null)

Checks whether an operation on a service should be allowed to proceed
based on the configuration of the service and related policies. It must be
called before the operation is executed.

If feasible, the client should cache the check results and reuse them for
60 seconds. In case of any server errors, the client should rely on the
cached results for much longer time to avoid outage.
WARNING: There is general 60s delay for the configuration and policy
propagation, therefore callers MUST NOT depend on the `Check` method having
the latest policy information.

NOTE: the \[CheckRequest\]\[google.api.servicecontrol.v1.CheckRequest\] has
the size limit (wire-format byte size) of 1MB.

This method requires the `servicemanagement.services.check` permission
on the specified service. For more information, see
[Cloud IAM](https://cloud.google.com/iam).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.CheckRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.CheckResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    ServiceControllerClient serviceControllerClient = await ServiceControllerClient.CreateAsync();
    // Initialize request argument(s)
    CheckRequest request = new CheckRequest
    {
        ServiceName = "",
        Operation = new Operation(),
        ServiceConfigId = "",
    };
    // Make the request
    CheckResponse response = await serviceControllerClient.CheckAsync(request);

### CheckAsync(CheckRequest, CancellationToken)

    public virtual Task<CheckResponse> CheckAsync(CheckRequest request, CancellationToken cancellationToken)

Checks whether an operation on a service should be allowed to proceed
based on the configuration of the service and related policies. It must be
called before the operation is executed.

If feasible, the client should cache the check results and reuse them for
60 seconds. In case of any server errors, the client should rely on the
cached results for much longer time to avoid outage.
WARNING: There is general 60s delay for the configuration and policy
propagation, therefore callers MUST NOT depend on the `Check` method having
the latest policy information.

NOTE: the \[CheckRequest\]\[google.api.servicecontrol.v1.CheckRequest\] has
the size limit (wire-format byte size) of 1MB.

This method requires the `servicemanagement.services.check` permission
on the specified service. For more information, see
[Cloud IAM](https://cloud.google.com/iam).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.CheckRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.CheckResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    ServiceControllerClient serviceControllerClient = await ServiceControllerClient.CreateAsync();
    // Initialize request argument(s)
    CheckRequest request = new CheckRequest
    {
        ServiceName = "",
        Operation = new Operation(),
        ServiceConfigId = "",
    };
    // Make the request
    CheckResponse response = await serviceControllerClient.CheckAsync(request);

### Create()

    public static ServiceControllerClient Create()

Synchronously creates a [ServiceControllerClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ServiceControllerClient) using the default credentials, endpoint and
settings. To specify custom credentials or other settings, use [ServiceControllerClientBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ServiceControllerClientBuilder).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ServiceControllerClient` | The created [ServiceControllerClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ServiceControllerClient). |

### CreateAsync(CancellationToken)

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

Asynchronously creates a [ServiceControllerClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ServiceControllerClient) using the default credentials, endpoint and
settings. To specify custom credentials or other settings, use [ServiceControllerClientBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ServiceControllerClientBuilder).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use while creating the client. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ServiceControllerClient` | The task representing the created [ServiceControllerClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ServiceControllerClient). |

### Report(ReportRequest, CallSettings)

    public virtual ReportResponse Report(ReportRequest request, CallSettings callSettings = null)

Reports operation results to Google Service Control, such as logs and
metrics. It should be called after an operation is completed.

If feasible, the client should aggregate reporting data for up to 5
seconds to reduce API traffic. Limiting aggregation to 5 seconds is to
reduce data loss during client crashes. Clients should carefully choose
the aggregation time window to avoid data loss risk more than 0.01%
for business and compliance reasons.

NOTE: the \[ReportRequest\]\[google.api.servicecontrol.v1.ReportRequest\] has
the size limit (wire-format byte size) of 1MB.

This method requires the `servicemanagement.services.report` permission
on the specified service. For more information, see
[Google Cloud IAM](https://cloud.google.com/iam).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ReportRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ReportResponse` | The RPC response. |

**Example**

    // Create client
    ServiceControllerClient serviceControllerClient = ServiceControllerClient.Create();
    // Initialize request argument(s)
    ReportRequest request = new ReportRequest
    {
        ServiceName = "",
        Operations = { new Operation(), },
        ServiceConfigId = "",
    };
    // Make the request
    ReportResponse response = serviceControllerClient.Report(request);

### ReportAsync(ReportRequest, CallSettings)

    public virtual Task<ReportResponse> ReportAsync(ReportRequest request, CallSettings callSettings = null)

Reports operation results to Google Service Control, such as logs and
metrics. It should be called after an operation is completed.

If feasible, the client should aggregate reporting data for up to 5
seconds to reduce API traffic. Limiting aggregation to 5 seconds is to
reduce data loss during client crashes. Clients should carefully choose
the aggregation time window to avoid data loss risk more than 0.01%
for business and compliance reasons.

NOTE: the \[ReportRequest\]\[google.api.servicecontrol.v1.ReportRequest\] has
the size limit (wire-format byte size) of 1MB.

This method requires the `servicemanagement.services.report` permission
on the specified service. For more information, see
[Google Cloud IAM](https://cloud.google.com/iam).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ReportRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ReportResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    ServiceControllerClient serviceControllerClient = await ServiceControllerClient.CreateAsync();
    // Initialize request argument(s)
    ReportRequest request = new ReportRequest
    {
        ServiceName = "",
        Operations = { new Operation(), },
        ServiceConfigId = "",
    };
    // Make the request
    ReportResponse response = await serviceControllerClient.ReportAsync(request);

### ReportAsync(ReportRequest, CancellationToken)

    public virtual Task<ReportResponse> ReportAsync(ReportRequest request, CancellationToken cancellationToken)

Reports operation results to Google Service Control, such as logs and
metrics. It should be called after an operation is completed.

If feasible, the client should aggregate reporting data for up to 5
seconds to reduce API traffic. Limiting aggregation to 5 seconds is to
reduce data loss during client crashes. Clients should carefully choose
the aggregation time window to avoid data loss risk more than 0.01%
for business and compliance reasons.

NOTE: the \[ReportRequest\]\[google.api.servicecontrol.v1.ReportRequest\] has
the size limit (wire-format byte size) of 1MB.

This method requires the `servicemanagement.services.report` permission
on the specified service. For more information, see
[Google Cloud IAM](https://cloud.google.com/iam).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ReportRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ReportResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    ServiceControllerClient serviceControllerClient = await ServiceControllerClient.CreateAsync();
    // Initialize request argument(s)
    ReportRequest request = new ReportRequest
    {
        ServiceName = "",
        Operations = { new Operation(), },
        ServiceConfigId = "",
    };
    // Make the request
    ReportResponse response = await serviceControllerClient.ReportAsync(request);

### ShutdownDefaultChannelsAsync()

    public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by [Create()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ServiceControllerClient#Google_Cloud_ServiceControl_V1_ServiceControllerClient_Create) and
[CreateAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ServiceControllerClient#Google_Cloud_ServiceControl_V1_ServiceControllerClient_CreateAsync_System_Threading_CancellationToken_). Channels which weren't automatically created are not
affected.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A task representing the asynchronous shutdown operation. |

**Remarks** After calling this method, further calls to [Create()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ServiceControllerClient#Google_Cloud_ServiceControl_V1_ServiceControllerClient_Create) and
[CreateAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.ServiceControl.V1/latest/Google.Cloud.ServiceControl.V1.ServiceControllerClient#Google_Cloud_ServiceControl_V1_ServiceControllerClient_CreateAsync_System_Threading_CancellationToken_) will create new channels, which could in turn be shut down
by another call to this method.