Google Cloud Service Management V1 Client - Class ServiceManagerClient (1.0.6)

Reference documentation and code samples for the Google Cloud Service Management V1 Client class ServiceManagerClient.

Service Description: Google Service Management API

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:

$serviceManagerClient = new ServiceManagerClient();
try {
    $service = new ManagedService();
    $operationResponse = $serviceManagerClient->createService($service);
    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        $result = $operationResponse->getResult();
    // doSomethingWith($result)
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }
    // Alternatively:
    // start the operation, keep the operation name, and resume later
    $operationResponse = $serviceManagerClient->createService($service);
    $operationName = $operationResponse->getName();
    // ... do other work
    $newOperationResponse = $serviceManagerClient->resumeOperation($operationName, 'createService');
    while (!$newOperationResponse->isDone()) {
        // ... do other work
        $newOperationResponse->reload();
    }
    if ($newOperationResponse->operationSucceeded()) {
        $result = $newOperationResponse->getResult();
    // doSomethingWith($result)
    } else {
        $error = $newOperationResponse->getError();
        // handleError($error)
    }
} finally {
    $serviceManagerClient->close();
}

Methods

getOperationsClient

Return an OperationsClient object with the same endpoint as $this.

Returns
TypeDescription
Google\ApiCore\LongRunning\OperationsClient

resumeOperation

Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.

Parameters
NameDescription
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
TypeDescription
Google\ApiCore\OperationResponse

__construct

Constructor.

Parameters
NameDescription
options array

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials string|array|FetchAuthTokenInterface|CredentialsWrapper

The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|TransportInterface

The transport used for executing network requests. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

createService

Creates a new managed service.

A managed service is immutable, and is subject to mandatory 30-day data retention. You cannot move a service or recreate it within 30 days after deletion.

One producer project can own no more than 500 services. For security and reliability purposes, a production service should be hosted in a dedicated producer project.

Operation<response: ManagedService>

Parameters
NameDescription
service Google\Cloud\ServiceManagement\V1\ManagedService

Required. Initial values for the service resource.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ServiceManagement\V1\ManagedService;
use Google\Cloud\ServiceManagement\V1\ServiceManagerClient;
use Google\Rpc\Status;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function create_service_sample(): void
{
    // Create a client.
    $serviceManagerClient = new ServiceManagerClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $service = new ManagedService();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $serviceManagerClient->createService($service);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var ManagedService $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

createServiceConfig

Creates a new service configuration (version) for a managed service.

This method only stores the service configuration. To roll out the service configuration to backend systems please call CreateServiceRollout.

Only the 100 most recent service configurations and ones referenced by existing rollouts are kept for each service. The rest will be deleted eventually.

Parameters
NameDescription
serviceName string

Required. The name of the service. See the overview for naming requirements. For example: example.googleapis.com.

serviceConfig Google\Api\Service

Required. The service configuration resource.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Api\Service
Example
use Google\ApiCore\ApiException;
use Google\Api\Service;
use Google\Cloud\ServiceManagement\V1\ServiceManagerClient;

/**
 * @param string $serviceName The name of the service.  See the
 *                            [overview](https://cloud.google.com/service-infrastructure/docs/overview) for naming requirements.  For
 *                            example: `example.googleapis.com`.
 */
function create_service_config_sample(string $serviceName): void
{
    // Create a client.
    $serviceManagerClient = new ServiceManagerClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $serviceConfig = new Service();

    // Call the API and handle any network failures.
    try {
        /** @var Service $response */
        $response = $serviceManagerClient->createServiceConfig($serviceName, $serviceConfig);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $serviceName = '[SERVICE_NAME]';

    create_service_config_sample($serviceName);
}

createServiceRollout

Creates a new service configuration rollout. Based on rollout, the Google Service Management will roll out the service configurations to different backend services. For example, the logging configuration will be pushed to Google Cloud Logging.

Please note that any previous pending and running Rollouts and associated Operations will be automatically cancelled so that the latest Rollout will not be blocked by previous Rollouts.

Only the 100 most recent (in any state) and the last 10 successful (if not already part of the set of 100 most recent) rollouts are kept for each service. The rest will be deleted eventually.

Operation<response: Rollout>

Parameters
NameDescription
serviceName string

Required. The name of the service. See the overview for naming requirements. For example: example.googleapis.com.

rollout Google\Cloud\ServiceManagement\V1\Rollout

Required. The rollout resource. The service_name field is output only.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ServiceManagement\V1\Rollout;
use Google\Cloud\ServiceManagement\V1\ServiceManagerClient;
use Google\Rpc\Status;

/**
 * @param string $serviceName The name of the service.  See the
 *                            [overview](https://cloud.google.com/service-infrastructure/docs/overview) for naming requirements.  For
 *                            example: `example.googleapis.com`.
 */
function create_service_rollout_sample(string $serviceName): void
{
    // Create a client.
    $serviceManagerClient = new ServiceManagerClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $rollout = new Rollout();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $serviceManagerClient->createServiceRollout($serviceName, $rollout);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var Rollout $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $serviceName = '[SERVICE_NAME]';

    create_service_rollout_sample($serviceName);
}

deleteService

Deletes a managed service. This method will change the service to the Soft-Delete state for 30 days. Within this period, service producers may call UndeleteService to restore the service. After 30 days, the service will be permanently deleted.

Operation<response: google.protobuf.Empty>

Parameters
NameDescription
serviceName string

Required. The name of the service. See the overview for naming requirements. For example: example.googleapis.com.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ServiceManagement\V1\ServiceManagerClient;
use Google\Rpc\Status;

/**
 * @param string $serviceName The name of the service.  See the
 *                            [overview](https://cloud.google.com/service-infrastructure/docs/overview) for naming requirements.  For
 *                            example: `example.googleapis.com`.
 */
function delete_service_sample(string $serviceName): void
{
    // Create a client.
    $serviceManagerClient = new ServiceManagerClient();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $serviceManagerClient->deleteService($serviceName);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            printf('Operation completed successfully.' . PHP_EOL);
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $serviceName = '[SERVICE_NAME]';

    delete_service_sample($serviceName);
}

generateConfigReport

Generates and returns a report (errors, warnings and changes from existing configurations) associated with GenerateConfigReportRequest.new_value

If GenerateConfigReportRequest.old_value is specified, GenerateConfigReportRequest will contain a single ChangeReport based on the comparison between GenerateConfigReportRequest.new_value and GenerateConfigReportRequest.old_value. If GenerateConfigReportRequest.old_value is not specified, this method will compare GenerateConfigReportRequest.new_value with the last pushed service configuration.

Parameters
NameDescription
newConfig Google\Protobuf\Any

Required. Service configuration for which we want to generate the report. For this version of API, the supported types are google.api.servicemanagement.v1.ConfigRef, google.api.servicemanagement.v1.ConfigSource, and google.api.Service

optionalArgs array

Optional.

↳ oldConfig Any

Optional. Service configuration against which the comparison will be done. For this version of API, the supported types are google.api.servicemanagement.v1.ConfigRef, google.api.servicemanagement.v1.ConfigSource, and google.api.Service

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\ServiceManagement\V1\GenerateConfigReportResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ServiceManagement\V1\GenerateConfigReportResponse;
use Google\Cloud\ServiceManagement\V1\ServiceManagerClient;
use Google\Protobuf\Any;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function generate_config_report_sample(): void
{
    // Create a client.
    $serviceManagerClient = new ServiceManagerClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $newConfig = new Any();

    // Call the API and handle any network failures.
    try {
        /** @var GenerateConfigReportResponse $response */
        $response = $serviceManagerClient->generateConfigReport($newConfig);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

getService

Gets a managed service. Authentication is required unless the service is public.

Parameters
NameDescription
serviceName string

Required. The name of the service. See the ServiceManager overview for naming requirements. For example: example.googleapis.com.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\ServiceManagement\V1\ManagedService
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ServiceManagement\V1\ManagedService;
use Google\Cloud\ServiceManagement\V1\ServiceManagerClient;

/**
 * @param string $serviceName The name of the service.  See the `ServiceManager` overview for
 *                            naming requirements.  For example: `example.googleapis.com`.
 */
function get_service_sample(string $serviceName): void
{
    // Create a client.
    $serviceManagerClient = new ServiceManagerClient();

    // Call the API and handle any network failures.
    try {
        /** @var ManagedService $response */
        $response = $serviceManagerClient->getService($serviceName);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $serviceName = '[SERVICE_NAME]';

    get_service_sample($serviceName);
}

getServiceConfig

Gets a service configuration (version) for a managed service.

Parameters
NameDescription
serviceName string

Required. The name of the service. See the overview for naming requirements. For example: example.googleapis.com.

configId string

Required. The id of the service configuration resource.

This field must be specified for the server to return all fields, including SourceInfo.

optionalArgs array

Optional.

↳ view int

Specifies which parts of the Service Config should be returned in the response. For allowed values, use constants defined on Google\Cloud\ServiceManagement\V1\GetServiceConfigRequest\ConfigView

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Api\Service
Example
use Google\ApiCore\ApiException;
use Google\Api\Service;
use Google\Cloud\ServiceManagement\V1\ServiceManagerClient;

/**
 * @param string $serviceName The name of the service.  See the
 *                            [overview](https://cloud.google.com/service-infrastructure/docs/overview) for naming requirements.  For
 *                            example: `example.googleapis.com`.
 * @param string $configId    The id of the service configuration resource.
 *
 *                            This field must be specified for the server to return all fields, including
 *                            `SourceInfo`.
 */
function get_service_config_sample(string $serviceName, string $configId): void
{
    // Create a client.
    $serviceManagerClient = new ServiceManagerClient();

    // Call the API and handle any network failures.
    try {
        /** @var Service $response */
        $response = $serviceManagerClient->getServiceConfig($serviceName, $configId);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $serviceName = '[SERVICE_NAME]';
    $configId = '[CONFIG_ID]';

    get_service_config_sample($serviceName, $configId);
}

getServiceRollout

Gets a service configuration rollout.

Parameters
NameDescription
serviceName string

Required. The name of the service. See the overview for naming requirements. For example: example.googleapis.com.

rolloutId string

Required. The id of the rollout resource.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\ServiceManagement\V1\Rollout
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ServiceManagement\V1\Rollout;
use Google\Cloud\ServiceManagement\V1\ServiceManagerClient;

/**
 * @param string $serviceName The name of the service.  See the
 *                            [overview](https://cloud.google.com/service-infrastructure/docs/overview) for naming requirements.  For
 *                            example: `example.googleapis.com`.
 * @param string $rolloutId   The id of the rollout resource.
 */
function get_service_rollout_sample(string $serviceName, string $rolloutId): void
{
    // Create a client.
    $serviceManagerClient = new ServiceManagerClient();

    // Call the API and handle any network failures.
    try {
        /** @var Rollout $response */
        $response = $serviceManagerClient->getServiceRollout($serviceName, $rolloutId);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $serviceName = '[SERVICE_NAME]';
    $rolloutId = '[ROLLOUT_ID]';

    get_service_rollout_sample($serviceName, $rolloutId);
}

listServiceConfigs

Lists the history of the service configuration for a managed service, from the newest to the oldest.

Parameters
NameDescription
serviceName string

Required. The name of the service. See the overview for naming requirements. For example: example.googleapis.com.

optionalArgs array

Optional.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Api\Service;
use Google\Cloud\ServiceManagement\V1\ServiceManagerClient;

/**
 * @param string $serviceName The name of the service.  See the
 *                            [overview](https://cloud.google.com/service-infrastructure/docs/overview) for naming requirements.  For
 *                            example: `example.googleapis.com`.
 */
function list_service_configs_sample(string $serviceName): void
{
    // Create a client.
    $serviceManagerClient = new ServiceManagerClient();

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $serviceManagerClient->listServiceConfigs($serviceName);

        /** @var Service $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $serviceName = '[SERVICE_NAME]';

    list_service_configs_sample($serviceName);
}

listServiceRollouts

Lists the history of the service configuration rollouts for a managed service, from the newest to the oldest.

Parameters
NameDescription
serviceName string

Required. The name of the service. See the overview for naming requirements. For example: example.googleapis.com.

filter string

Required. Use filter to return subset of rollouts. The following filters are supported: -- To limit the results to only those in status (google.api.servicemanagement.v1.RolloutStatus) 'SUCCESS', use filter='status=SUCCESS' -- To limit the results to those in status (google.api.servicemanagement.v1.RolloutStatus) 'CANCELLED' or 'FAILED', use filter='status=CANCELLED OR status=FAILED'

optionalArgs array

Optional.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\ServiceManagement\V1\Rollout;
use Google\Cloud\ServiceManagement\V1\ServiceManagerClient;

/**
 * @param string $serviceName The name of the service.  See the
 *                            [overview](https://cloud.google.com/service-infrastructure/docs/overview) for naming requirements.  For
 *                            example: `example.googleapis.com`.
 * @param string $filter      Use `filter` to return subset of rollouts.
 *                            The following filters are supported:
 *                            -- To limit the results to only those in
 *                            status (google.api.servicemanagement.v1.RolloutStatus) 'SUCCESS',
 *                            use filter='status=SUCCESS'
 *                            -- To limit the results to those in
 *                            status (google.api.servicemanagement.v1.RolloutStatus) 'CANCELLED'
 *                            or 'FAILED', use filter='status=CANCELLED OR status=FAILED'
 */
function list_service_rollouts_sample(string $serviceName, string $filter): void
{
    // Create a client.
    $serviceManagerClient = new ServiceManagerClient();

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $serviceManagerClient->listServiceRollouts($serviceName, $filter);

        /** @var Rollout $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $serviceName = '[SERVICE_NAME]';
    $filter = '[FILTER]';

    list_service_rollouts_sample($serviceName, $filter);
}

listServices

Lists managed services.

Returns all public services. For authenticated users, also returns all services the calling user has "servicemanagement.services.get" permission for.

Parameters
NameDescription
optionalArgs array

Optional.

↳ producerProjectId string

Include services produced by the specified project.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ consumerId string

Include services consumed by the specified consumer. The Google Service Management implementation accepts the following forms: - project:<project_id>

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\ServiceManagement\V1\ManagedService;
use Google\Cloud\ServiceManagement\V1\ServiceManagerClient;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function list_services_sample(): void
{
    // Create a client.
    $serviceManagerClient = new ServiceManagerClient();

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $serviceManagerClient->listServices();

        /** @var ManagedService $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

submitConfigSource

Creates a new service configuration (version) for a managed service based on user-supplied configuration source files (for example: OpenAPI Specification). This method stores the source configurations as well as the generated service configuration. To rollout the service configuration to other services, please call CreateServiceRollout.

Only the 100 most recent configuration sources and ones referenced by existing service configurtions are kept for each service. The rest will be deleted eventually.

Operation<response: SubmitConfigSourceResponse>

Parameters
NameDescription
serviceName string

Required. The name of the service. See the overview for naming requirements. For example: example.googleapis.com.

configSource Google\Cloud\ServiceManagement\V1\ConfigSource

Required. The source configuration for the service.

optionalArgs array

Optional.

↳ validateOnly bool

Optional. If set, this will result in the generation of a google.api.Service configuration based on the ConfigSource provided, but the generated config and the sources will NOT be persisted.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ServiceManagement\V1\ConfigSource;
use Google\Cloud\ServiceManagement\V1\ServiceManagerClient;
use Google\Cloud\ServiceManagement\V1\SubmitConfigSourceResponse;
use Google\Rpc\Status;

/**
 * @param string $serviceName The name of the service.  See the
 *                            [overview](https://cloud.google.com/service-infrastructure/docs/overview) for naming requirements.  For
 *                            example: `example.googleapis.com`.
 */
function submit_config_source_sample(string $serviceName): void
{
    // Create a client.
    $serviceManagerClient = new ServiceManagerClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $configSource = new ConfigSource();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $serviceManagerClient->submitConfigSource($serviceName, $configSource);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var SubmitConfigSourceResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $serviceName = '[SERVICE_NAME]';

    submit_config_source_sample($serviceName);
}

undeleteService

Revives a previously deleted managed service. The method restores the service using the configuration at the time the service was deleted.

The target service must exist and must have been deleted within the last 30 days.

Operation<response: UndeleteServiceResponse>

Parameters
NameDescription
serviceName string

Required. The name of the service. See the overview for naming requirements. For example: example.googleapis.com.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ServiceManagement\V1\ServiceManagerClient;
use Google\Cloud\ServiceManagement\V1\UndeleteServiceResponse;
use Google\Rpc\Status;

/**
 * @param string $serviceName The name of the service. See the
 *                            [overview](https://cloud.google.com/service-infrastructure/docs/overview) for naming requirements. For
 *                            example: `example.googleapis.com`.
 */
function undelete_service_sample(string $serviceName): void
{
    // Create a client.
    $serviceManagerClient = new ServiceManagerClient();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $serviceManagerClient->undeleteService($serviceName);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var UndeleteServiceResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $serviceName = '[SERVICE_NAME]';

    undelete_service_sample($serviceName);
}

Constants

SERVICE_NAME

Value: 'google.api.servicemanagement.v1.ServiceManager'

The name of the service.

SERVICE_ADDRESS

Value: 'servicemanagement.googleapis.com'

The default address of the service.

DEFAULT_SERVICE_PORT

Value: 443

The default port of the service.

CODEGEN_NAME

Value: 'gapic'

The name of the code generator, to be included in the agent header.