Google Cloud Managed Kafka Schema Registry V1 Client - Class ManagedSchemaRegistryClient (0.1.1)

Reference documentation and code samples for the Google Cloud Managed Kafka Schema Registry V1 Client class ManagedSchemaRegistryClient.

Service Description: SchemaRegistry is a service that allows users to manage schemas for their Kafka clusters. It provides APIs to register, list, and delete schemas, as well as to get the schema for a given schema id or a given version id under a subject, to update the global or subject-specific compatibility mode, and to check the compatibility of a schema against a subject or a version. The main resource hierarchy is as follows:

  • SchemaRegistry
  • SchemaRegistry/Context
  • SchemaRegistry/Context/Schema
  • SchemaRegistry/Context/Subject
  • SchemaRegistry/Context/Subject/Version
  • SchemaRegistry/Config
  • SchemaRegistry/Mode

SchemaRegistry is the root resource to represent a schema registry instance. A customer can have multiple schema registry instances in a project.

Context is a context resource that represents a group of schemas, subjects and versions. A schema registry instance can have multiple contexts and always has a 'default' context. Contexts are independent of each other. Context is optional and if not specified, it falls back to the 'default' context.

Schema is a schema resource that represents a unique schema in a context of a schema registry instance. Each schema has a unique schema id, and can be referenced by a version of a subject.

Subject refers to the name under which the schema is registered. A typical subject is the Kafka topic name. A schema registry instance can have multiple subjects.

Version represents a version of a subject. A subject can have multiple versions. Creation of new version of a subject is guarded by the compatibility mode configured globally or for the subject specifically.

Config represents a config at global level cross all registry instances or at subject level. Currently, only compatibility is supported in config.

Mode represents the mode of a schema registry or a specific subject. Three modes are supported:

  • READONLY: The schema registry is in read-only mode, no write operations allowed..
  • READWRITE: The schema registry is in read-write mode, which allows limited write operations on the schema.
  • IMPORT: The schema registry is in import mode, which allows more editing operations on the schema for data importing purposes.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.

Namespace

Google \ Cloud \ ManagedKafka \ SchemaRegistry \ V1 \ Client

Methods

__construct

Constructor.

Parameters
Name Description
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. Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud Platform, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information https://cloud.google.com/docs/authentication/external/externally-sourced-credentials

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

↳ logger false|LoggerInterface

A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag

checkCompatibility

Check compatibility of a schema with all versions or a specific version of a subject.

The async variant is ManagedSchemaRegistryClient::checkCompatibilityAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\CheckCompatibilityRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Cloud\ManagedKafka\SchemaRegistry\V1\CheckCompatibilityResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\CheckCompatibilityRequest;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\CheckCompatibilityResponse;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;

/**
 * @param string $name   The name of the resource to check compatibility for. The format
 *                       is either of following:
 *                       * projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/compatibility/subjects/*/versions: Check compatibility with one or
 *                       more versions of the specified subject.
 *                       * projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/compatibility/subjects/{subject}/versions/{version}: Check
 *                       compatibility with a specific version of the subject.
 * @param string $schema The schema payload
 */
function check_compatibility_sample(string $name, string $schema): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new CheckCompatibilityRequest())
        ->setName($name)
        ->setSchema($schema);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $name = '[NAME]';
    $schema = '[SCHEMA]';

    check_compatibility_sample($name, $schema);
}

createSchemaRegistry

Create a schema registry instance.

The async variant is ManagedSchemaRegistryClient::createSchemaRegistryAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\CreateSchemaRegistryRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaRegistry
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\CreateSchemaRegistryRequest;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaRegistry;

/**
 * @param string $parent           The parent whose schema registry instance is to be created.
 *                                 Structured like: `projects/{project}/locations/{___location}`
 * @param string $schemaRegistryId The schema registry instance ID to use for this schema registry.
 *                                 The ID must contain only letters (a-z, A-Z), numbers (0-9), and underscores
 *                                 (-). The maximum length is 63 characters.
 *                                 The ID must not start with a number.
 */
function create_schema_registry_sample(string $parent, string $schemaRegistryId): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $schemaRegistry = new SchemaRegistry();
    $request = (new CreateSchemaRegistryRequest())
        ->setParent($parent)
        ->setSchemaRegistryId($schemaRegistryId)
        ->setSchemaRegistry($schemaRegistry);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $parent = '[PARENT]';
    $schemaRegistryId = '[SCHEMA_REGISTRY_ID]';

    create_schema_registry_sample($parent, $schemaRegistryId);
}

createVersion

Register a new version under a given subject with the given schema.

The async variant is ManagedSchemaRegistryClient::createVersionAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\CreateVersionRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Cloud\ManagedKafka\SchemaRegistry\V1\CreateVersionResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\CreateVersionRequest;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\CreateVersionResponse;

/**
 * @param string $formattedParent The subject to create the version for. Structured like:
 *                                `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/subjects/{subject}`
 *                                or
 *                                `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/subjects/{subject}`
 *                                Please see {@see ManagedSchemaRegistryClient::schemaSubjectName()} for help formatting this field.
 * @param string $schema          The schema payload
 */
function create_version_sample(string $formattedParent, string $schema): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new CreateVersionRequest())
        ->setParent($formattedParent)
        ->setSchema($schema);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedParent = ManagedSchemaRegistryClient::schemaSubjectName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]',
        '[SUBJECT]'
    );
    $schema = '[SCHEMA]';

    create_version_sample($formattedParent, $schema);
}

deleteSchemaConfig

Delete schema config for a subject.

The async variant is ManagedSchemaRegistryClient::deleteSchemaConfigAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\DeleteSchemaConfigRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaConfig
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\DeleteSchemaConfigRequest;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaConfig;

/**
 * @param string $formattedName The resource name of subject to delete the config for. The format
 *                              is
 *                              * projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/config/{subject}
 *                              Please see {@see ManagedSchemaRegistryClient::schemaConfigName()} for help formatting this field.
 */
function delete_schema_config_sample(string $formattedName): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new DeleteSchemaConfigRequest())
        ->setName($formattedName);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedName = ManagedSchemaRegistryClient::schemaConfigName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]'
    );

    delete_schema_config_sample($formattedName);
}

deleteSchemaMode

Delete schema mode for a subject.

The async variant is ManagedSchemaRegistryClient::deleteSchemaModeAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\DeleteSchemaModeRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaMode
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\DeleteSchemaModeRequest;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaMode;

/**
 * @param string $formattedName The resource name of subject to delete the mode for. The format
 *                              is
 *                              * projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/mode/{subject}
 *                              * projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/mode/{subject}
 *                              Please see {@see ManagedSchemaRegistryClient::schemaModeName()} for help formatting this field.
 */
function delete_schema_mode_sample(string $formattedName): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new DeleteSchemaModeRequest())
        ->setName($formattedName);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedName = ManagedSchemaRegistryClient::schemaModeName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]'
    );

    delete_schema_mode_sample($formattedName);
}

deleteSchemaRegistry

Delete a schema registry instance.

The async variant is ManagedSchemaRegistryClient::deleteSchemaRegistryAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\DeleteSchemaRegistryRequest

A request to house fields associated with the call.

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

Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\DeleteSchemaRegistryRequest;

/**
 * @param string $formattedName The name of the schema registry instance to delete. Structured
 *                              like:
 *                              `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}`
 *                              Please see {@see ManagedSchemaRegistryClient::schemaRegistryName()} for help formatting this field.
 */
function delete_schema_registry_sample(string $formattedName): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new DeleteSchemaRegistryRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        $managedSchemaRegistryClient->deleteSchemaRegistry($request);
        printf('Call completed successfully.' . PHP_EOL);
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedName = ManagedSchemaRegistryClient::schemaRegistryName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]'
    );

    delete_schema_registry_sample($formattedName);
}

deleteSubject

Delete a subject.

The response will be an array of versions of the deleted subject.

The async variant is ManagedSchemaRegistryClient::deleteSubjectAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\DeleteSubjectRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Api\HttpBody
Example
use Google\ApiCore\ApiException;
use Google\Api\HttpBody;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\DeleteSubjectRequest;

/**
 * @param string $formattedName The name of the subject to delete. Structured like:
 *                              `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/subjects/{subject}`
 *                              or
 *                              `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/subjects/{subject}`
 *                              Please see {@see ManagedSchemaRegistryClient::schemaSubjectName()} for help formatting this field.
 */
function delete_subject_sample(string $formattedName): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new DeleteSubjectRequest())
        ->setName($formattedName);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedName = ManagedSchemaRegistryClient::schemaSubjectName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]',
        '[SUBJECT]'
    );

    delete_subject_sample($formattedName);
}

deleteVersion

Delete a version of a subject.

The response will be the deleted version id.

The async variant is ManagedSchemaRegistryClient::deleteVersionAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\DeleteVersionRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Api\HttpBody
Example
use Google\ApiCore\ApiException;
use Google\Api\HttpBody;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\DeleteVersionRequest;

/**
 * @param string $formattedName The name of the subject version to delete. Structured like:
 *                              `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/subjects/{subject}/versions/{version}`
 *                              or
 *                              `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/subjects/{subject}/versions/{version}`
 *                              Please see {@see ManagedSchemaRegistryClient::schemaVersionName()} for help formatting this field.
 */
function delete_version_sample(string $formattedName): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new DeleteVersionRequest())
        ->setName($formattedName);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedName = ManagedSchemaRegistryClient::schemaVersionName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]',
        '[SUBJECT]',
        '[VERSION]'
    );

    delete_version_sample($formattedName);
}

getContext

Get the context.

The async variant is ManagedSchemaRegistryClient::getContextAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetContextRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Cloud\ManagedKafka\SchemaRegistry\V1\Context
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Context;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetContextRequest;

/**
 * @param string $formattedName The name of the context to return. Structured like:
 *                              `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}`
 *                              Please see {@see ManagedSchemaRegistryClient::schemaContextName()} for help formatting this field.
 */
function get_context_sample(string $formattedName): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new GetContextRequest())
        ->setName($formattedName);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedName = ManagedSchemaRegistryClient::schemaContextName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]',
        '[CONTEXT]'
    );

    get_context_sample($formattedName);
}

getRawSchema

Get the schema string for the given schema id.

The response will be the schema string.

The async variant is ManagedSchemaRegistryClient::getRawSchemaAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetSchemaRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Api\HttpBody
Example
use Google\ApiCore\ApiException;
use Google\Api\HttpBody;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetSchemaRequest;

/**
 * @param string $formattedName The name of the schema to return. Structured like:
 *                              `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/schemas/ids/{schema}`
 *                              Please see {@see ManagedSchemaRegistryClient::schemaName()} for help formatting this field.
 */
function get_raw_schema_sample(string $formattedName): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new GetSchemaRequest())
        ->setName($formattedName);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedName = ManagedSchemaRegistryClient::schemaName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]',
        '[SCHEMA]'
    );

    get_raw_schema_sample($formattedName);
}

getRawSchemaVersion

Get the schema string only for a version of a subject.

The response will be the schema string.

The async variant is ManagedSchemaRegistryClient::getRawSchemaVersionAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetVersionRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Api\HttpBody
Example
use Google\ApiCore\ApiException;
use Google\Api\HttpBody;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetVersionRequest;

/**
 * @param string $formattedName The name of the subject to return versions. Structured like:
 *                              `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/subjects/{subject}/versions/{version}`
 *                              or
 *                              `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/subjects/{subject}/versions/{version}`
 *                              Please see {@see ManagedSchemaRegistryClient::schemaVersionName()} for help formatting this field.
 */
function get_raw_schema_version_sample(string $formattedName): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new GetVersionRequest())
        ->setName($formattedName);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedName = ManagedSchemaRegistryClient::schemaVersionName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]',
        '[SUBJECT]',
        '[VERSION]'
    );

    get_raw_schema_version_sample($formattedName);
}

getSchema

Get the schema for the given schema id.

The async variant is ManagedSchemaRegistryClient::getSchemaAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetSchemaRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Cloud\ManagedKafka\SchemaRegistry\V1\Schema
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetSchemaRequest;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Schema;

/**
 * @param string $formattedName The name of the schema to return. Structured like:
 *                              `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/schemas/ids/{schema}`
 *                              Please see {@see ManagedSchemaRegistryClient::schemaName()} for help formatting this field.
 */
function get_schema_sample(string $formattedName): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new GetSchemaRequest())
        ->setName($formattedName);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedName = ManagedSchemaRegistryClient::schemaName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]',
        '[SCHEMA]'
    );

    get_schema_sample($formattedName);
}

getSchemaConfig

Get schema config at global level or for a subject.

The async variant is ManagedSchemaRegistryClient::getSchemaConfigAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetSchemaConfigRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaConfig
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetSchemaConfigRequest;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaConfig;

/**
 * @param string $formattedName The resource name to get the config for. It can be either of
 *                              following:
 *                              * projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/config: Get config at global level.
 *                              * projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/config/{subject}: Get config for a specific subject. Please see
 *                              {@see ManagedSchemaRegistryClient::schemaConfigName()} for help formatting this field.
 */
function get_schema_config_sample(string $formattedName): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new GetSchemaConfigRequest())
        ->setName($formattedName);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedName = ManagedSchemaRegistryClient::schemaConfigName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]'
    );

    get_schema_config_sample($formattedName);
}

getSchemaMode

Get mode at global level or for a subject.

The async variant is ManagedSchemaRegistryClient::getSchemaModeAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetSchemaModeRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaMode
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetSchemaModeRequest;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaMode;

/**
 * @param string $formattedName The resource name of the mode. The format is
 *                              * projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/mode/{subject}: mode for a schema registry, or
 *                              * projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/mode/{subject}: mode for a specific subject in a specific context
 *                              Please see {@see ManagedSchemaRegistryClient::schemaModeName()} for help formatting this field.
 */
function get_schema_mode_sample(string $formattedName): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new GetSchemaModeRequest())
        ->setName($formattedName);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedName = ManagedSchemaRegistryClient::schemaModeName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]'
    );

    get_schema_mode_sample($formattedName);
}

getSchemaRegistry

Get the schema registry instance.

The async variant is ManagedSchemaRegistryClient::getSchemaRegistryAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetSchemaRegistryRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaRegistry
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetSchemaRegistryRequest;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaRegistry;

/**
 * @param string $formattedName The name of the schema registry instance to return. Structured
 *                              like:
 *                              `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}`
 *                              Please see {@see ManagedSchemaRegistryClient::schemaRegistryName()} for help formatting this field.
 */
function get_schema_registry_sample(string $formattedName): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new GetSchemaRegistryRequest())
        ->setName($formattedName);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedName = ManagedSchemaRegistryClient::schemaRegistryName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]'
    );

    get_schema_registry_sample($formattedName);
}

getVersion

Get a versioned schema (schema with subject/version) of a subject.

The async variant is ManagedSchemaRegistryClient::getVersionAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetVersionRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaVersion
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetVersionRequest;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaVersion;

/**
 * @param string $formattedName The name of the subject to return versions. Structured like:
 *                              `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/subjects/{subject}/versions/{version}`
 *                              or
 *                              `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/subjects/{subject}/versions/{version}`
 *                              Please see {@see ManagedSchemaRegistryClient::schemaVersionName()} for help formatting this field.
 */
function get_version_sample(string $formattedName): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new GetVersionRequest())
        ->setName($formattedName);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedName = ManagedSchemaRegistryClient::schemaVersionName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]',
        '[SUBJECT]',
        '[VERSION]'
    );

    get_version_sample($formattedName);
}

listContexts

List contexts for a schema registry.

The async variant is ManagedSchemaRegistryClient::listContextsAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListContextsRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Api\HttpBody
Example
use Google\ApiCore\ApiException;
use Google\Api\HttpBody;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListContextsRequest;

/**
 * @param string $formattedParent The parent of the contexts. Structured like:
 *                                `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}`
 *                                Please see {@see ManagedSchemaRegistryClient::schemaRegistryName()} for help formatting this field.
 */
function list_contexts_sample(string $formattedParent): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new ListContextsRequest())
        ->setParent($formattedParent);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedParent = ManagedSchemaRegistryClient::schemaRegistryName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]'
    );

    list_contexts_sample($formattedParent);
}

listReferencedSchemas

Get a list of IDs of schemas that reference the schema with the given subject and version.

The async variant is ManagedSchemaRegistryClient::listReferencedSchemasAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListReferencedSchemasRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Api\HttpBody
Example
use Google\ApiCore\ApiException;
use Google\Api\HttpBody;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListReferencedSchemasRequest;

/**
 * @param string $formattedParent The version to list referenced by. Structured like:
 *                                `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/subjects/{subject}/versions/{version}`
 *                                or
 *                                `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/subjects/{subject}/versions/{version}`
 *                                Please see {@see ManagedSchemaRegistryClient::schemaVersionName()} for help formatting this field.
 */
function list_referenced_schemas_sample(string $formattedParent): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new ListReferencedSchemasRequest())
        ->setParent($formattedParent);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedParent = ManagedSchemaRegistryClient::schemaVersionName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]',
        '[SUBJECT]',
        '[VERSION]'
    );

    list_referenced_schemas_sample($formattedParent);
}

listSchemaRegistries

List schema registries.

The async variant is ManagedSchemaRegistryClient::listSchemaRegistriesAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSchemaRegistriesRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSchemaRegistriesResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSchemaRegistriesRequest;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSchemaRegistriesResponse;

/**
 * @param string $parent The parent whose schema registry instances are to be listed.
 *                       Structured like: `projects/{project}/locations/{___location}`
 */
function list_schema_registries_sample(string $parent): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new ListSchemaRegistriesRequest())
        ->setParent($parent);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $parent = '[PARENT]';

    list_schema_registries_sample($parent);
}

listSchemaTypes

List the supported schema types.

The response will be an array of schema types.

The async variant is ManagedSchemaRegistryClient::listSchemaTypesAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSchemaTypesRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Api\HttpBody
Example
use Google\ApiCore\ApiException;
use Google\Api\HttpBody;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSchemaTypesRequest;

/**
 * @param string $parent The parent schema registry whose schema types are to be listed.
 *                       Structured like:
 *                       `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}`
 */
function list_schema_types_sample(string $parent): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new ListSchemaTypesRequest())
        ->setParent($parent);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $parent = '[PARENT]';

    list_schema_types_sample($parent);
}

listSchemaVersions

List the schema versions for the given schema id.

The response will be an array of subject-version pairs as: [{"subject":"subject1", "version":1}, {"subject":"subject2", "version":2}].

The async variant is ManagedSchemaRegistryClient::listSchemaVersionsAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSchemaVersionsRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Api\HttpBody
Example
use Google\ApiCore\ApiException;
use Google\Api\HttpBody;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSchemaVersionsRequest;

/**
 * @param string $formattedParent The schema whose schema versions are to be listed. Structured
 *                                like:
 *                                `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/schemas/ids/{schema}`
 *                                or
 *                                `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/schemas/ids/{schema}`
 *                                Please see {@see ManagedSchemaRegistryClient::schemaName()} for help formatting this field.
 */
function list_schema_versions_sample(string $formattedParent): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new ListSchemaVersionsRequest())
        ->setParent($formattedParent);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedParent = ManagedSchemaRegistryClient::schemaName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]',
        '[SCHEMA]'
    );

    list_schema_versions_sample($formattedParent);
}

listSubjects

List subjects in the schema registry.

The response will be an array of subject names.

The async variant is ManagedSchemaRegistryClient::listSubjectsAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSubjectsRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Api\HttpBody
Example
use Google\ApiCore\ApiException;
use Google\Api\HttpBody;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSubjectsRequest;

/**
 * @param string $parent The parent schema registry/context whose subjects are to be
 *                       listed. Structured like:
 *                       `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}`
 *                       or
 *                       `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}`
 */
function list_subjects_sample(string $parent): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new ListSubjectsRequest())
        ->setParent($parent);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $parent = '[PARENT]';

    list_subjects_sample($parent);
}

listSubjectsBySchemaId

List subjects which reference a particular schema id.

The response will be an array of subject names.

The async variant is ManagedSchemaRegistryClient::listSubjectsBySchemaIdAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSubjectsBySchemaIdRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Api\HttpBody
Example
use Google\ApiCore\ApiException;
use Google\Api\HttpBody;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSubjectsBySchemaIdRequest;

/**
 * @param string $parent The schema resource whose associated subjects are to be listed.
 *                       Structured like:
 *                       `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/schemas/ids/{schema}`
 *                       or
 *                       `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/schemas/ids/{schema}`
 */
function list_subjects_by_schema_id_sample(string $parent): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new ListSubjectsBySchemaIdRequest())
        ->setParent($parent);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $parent = '[PARENT]';

    list_subjects_by_schema_id_sample($parent);
}

listVersions

Get all versions of a subject.

The response will be an array of versions of the subject.

The async variant is ManagedSchemaRegistryClient::listVersionsAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListVersionsRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Api\HttpBody
Example
use Google\ApiCore\ApiException;
use Google\Api\HttpBody;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListVersionsRequest;

/**
 * @param string $formattedParent The subject whose versions are to be listed. Structured like:
 *                                `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/subjects/{subject}`
 *                                or
 *                                `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/subjects/{subject}`
 *                                Please see {@see ManagedSchemaRegistryClient::schemaSubjectName()} for help formatting this field.
 */
function list_versions_sample(string $formattedParent): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new ListVersionsRequest())
        ->setParent($formattedParent);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedParent = ManagedSchemaRegistryClient::schemaSubjectName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]',
        '[SUBJECT]'
    );

    list_versions_sample($formattedParent);
}

lookupVersion

Lookup a schema under the specified subject.

The async variant is ManagedSchemaRegistryClient::lookupVersionAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\LookupVersionRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaVersion
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\LookupVersionRequest;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaVersion;

/**
 * @param string $formattedParent The subject to lookup the schema in. Structured like:
 *                                `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/subjects/{subject}`
 *                                or
 *                                `projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/subjects/{subject}`
 *                                Please see {@see ManagedSchemaRegistryClient::schemaSubjectName()} for help formatting this field.
 * @param string $schema          The schema payload
 */
function lookup_version_sample(string $formattedParent, string $schema): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new LookupVersionRequest())
        ->setParent($formattedParent)
        ->setSchema($schema);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedParent = ManagedSchemaRegistryClient::schemaSubjectName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]',
        '[SUBJECT]'
    );
    $schema = '[SCHEMA]';

    lookup_version_sample($formattedParent, $schema);
}

updateSchemaConfig

Update config at global level or for a subject.

Creates a SchemaSubject-level SchemaConfig if it does not exist.

The async variant is ManagedSchemaRegistryClient::updateSchemaConfigAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\UpdateSchemaConfigRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaConfig
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaConfig;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaConfig\CompatibilityType;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\UpdateSchemaConfigRequest;

/**
 * @param string $formattedName The resource name to update the config for. It can be either of
 *                              following:
 *                              * projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/config: Update config at global level.
 *                              * projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/config/{subject}: Update config for a specific subject. Please see
 *                              {@see ManagedSchemaRegistryClient::schemaConfigName()} for help formatting this field.
 * @param int    $compatibility The compatibility type of the schemas.
 *                              Cannot be unset for a SchemaRegistry-level SchemaConfig.
 *                              If unset on a SchemaSubject-level SchemaConfig, removes the compatibility
 *                              field for the SchemaConfig.
 */
function update_schema_config_sample(string $formattedName, int $compatibility): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new UpdateSchemaConfigRequest())
        ->setName($formattedName)
        ->setCompatibility($compatibility);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedName = ManagedSchemaRegistryClient::schemaConfigName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]'
    );
    $compatibility = CompatibilityType::NONE;

    update_schema_config_sample($formattedName, $compatibility);
}

updateSchemaMode

Update mode at global level or for a subject.

The async variant is ManagedSchemaRegistryClient::updateSchemaModeAsync() .

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\UpdateSchemaModeRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaMode
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaMode;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaMode\ModeType;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\UpdateSchemaModeRequest;

/**
 * @param string $formattedName The resource name of the mode. The format is
 *                              * projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/mode/{subject}: mode for a schema registry, or
 *                              * projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/mode/{subject}: mode for a specific subject in a specific context
 *                              Please see {@see ManagedSchemaRegistryClient::schemaModeName()} for help formatting this field.
 * @param int    $mode          The mode type.
 */
function update_schema_mode_sample(string $formattedName, int $mode): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = (new UpdateSchemaModeRequest())
        ->setName($formattedName)
        ->setMode($mode);

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

/**
 * Helper to execute the sample.
 *
 * 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
{
    $formattedName = ManagedSchemaRegistryClient::schemaModeName(
        '[PROJECT]',
        '[LOCATION]',
        '[SCHEMA_REGISTRY]'
    );
    $mode = ModeType::NONE;

    update_schema_mode_sample($formattedName, $mode);
}

getLocation

Gets information about a ___location.

The async variant is ManagedSchemaRegistryClient::getLocationAsync() .

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\Cloud\Location\Location
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Location\GetLocationRequest;
use Google\Cloud\Location\Location;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;

/**
 * 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 get_location_sample(): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = new GetLocationRequest();

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

listLocations

Lists information about the supported locations for this service.

The async variant is ManagedSchemaRegistryClient::listLocationsAsync() .

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest

A request to house fields associated with the call.

callOptions 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
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Location\ListLocationsRequest;
use Google\Cloud\Location\Location;
use Google\Cloud\ManagedKafka\SchemaRegistry\V1\Client\ManagedSchemaRegistryClient;

/**
 * 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_locations_sample(): void
{
    // Create a client.
    $managedSchemaRegistryClient = new ManagedSchemaRegistryClient();

    // Prepare the request message.
    $request = new ListLocationsRequest();

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

        /** @var Location $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());
    }
}

checkCompatibilityAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\CheckCompatibilityRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ManagedKafka\SchemaRegistry\V1\CheckCompatibilityResponse>

createSchemaRegistryAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\CreateSchemaRegistryRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaRegistry>

createVersionAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\CreateVersionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ManagedKafka\SchemaRegistry\V1\CreateVersionResponse>

deleteSchemaConfigAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\DeleteSchemaConfigRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaConfig>

deleteSchemaModeAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\DeleteSchemaModeRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaMode>

deleteSchemaRegistryAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\DeleteSchemaRegistryRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<void>

deleteSubjectAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\DeleteSubjectRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Api\HttpBody>

deleteVersionAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\DeleteVersionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Api\HttpBody>

getContextAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetContextRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ManagedKafka\SchemaRegistry\V1\Context>

getRawSchemaAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetSchemaRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Api\HttpBody>

getRawSchemaVersionAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetVersionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Api\HttpBody>

getSchemaAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetSchemaRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ManagedKafka\SchemaRegistry\V1\Schema>

getSchemaConfigAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetSchemaConfigRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaConfig>

getSchemaModeAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetSchemaModeRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaMode>

getSchemaRegistryAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetSchemaRegistryRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaRegistry>

getVersionAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\GetVersionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaVersion>

listContextsAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListContextsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Api\HttpBody>

listReferencedSchemasAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListReferencedSchemasRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Api\HttpBody>

listSchemaRegistriesAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSchemaRegistriesRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSchemaRegistriesResponse>

listSchemaTypesAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSchemaTypesRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Api\HttpBody>

listSchemaVersionsAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSchemaVersionsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Api\HttpBody>

listSubjectsAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSubjectsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Api\HttpBody>

listSubjectsBySchemaIdAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListSubjectsBySchemaIdRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Api\HttpBody>

listVersionsAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\ListVersionsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Api\HttpBody>

lookupVersionAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\LookupVersionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaVersion>

updateSchemaConfigAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\UpdateSchemaConfigRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaConfig>

updateSchemaModeAsync

Parameters
Name Description
request Google\Cloud\ManagedKafka\SchemaRegistry\V1\UpdateSchemaModeRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ManagedKafka\SchemaRegistry\V1\SchemaMode>

getLocationAsync

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Location\Location>

listLocationsAsync

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

static::projectLocationSchemaRegistryConfigName

Formats a string containing the fully-qualified path to represent a project_location_schema_registry_config resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
Returns
Type Description
string The formatted project_location_schema_registry_config resource.

static::projectLocationSchemaRegistryContextConfigName

Formats a string containing the fully-qualified path to represent a project_location_schema_registry_context_config resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
context string
Returns
Type Description
string The formatted project_location_schema_registry_context_config resource.

static::projectLocationSchemaRegistryContextModeName

Formats a string containing the fully-qualified path to represent a project_location_schema_registry_context_mode resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
context string
Returns
Type Description
string The formatted project_location_schema_registry_context_mode resource.

static::projectLocationSchemaRegistryContextSchemaName

Formats a string containing the fully-qualified path to represent a project_location_schema_registry_context_schema resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
context string
schema string
Returns
Type Description
string The formatted project_location_schema_registry_context_schema resource.

static::projectLocationSchemaRegistryContextSubjectName

Formats a string containing the fully-qualified path to represent a project_location_schema_registry_context_subject resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
context string
subject string
Returns
Type Description
string The formatted project_location_schema_registry_context_subject resource.

static::projectLocationSchemaRegistryContextSubjectVersionName

Formats a string containing the fully-qualified path to represent a project_location_schema_registry_context_subject_version resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
context string
subject string
version string
Returns
Type Description
string The formatted project_location_schema_registry_context_subject_version resource.

static::projectLocationSchemaRegistryContextSubjectVersionsName

Formats a string containing the fully-qualified path to represent a project_location_schema_registry_context_subject_versions resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
context string
subject string
Returns
Type Description
string The formatted project_location_schema_registry_context_subject_versions resource.

static::projectLocationSchemaRegistryModeName

Formats a string containing the fully-qualified path to represent a project_location_schema_registry_mode resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
Returns
Type Description
string The formatted project_location_schema_registry_mode resource.

static::projectLocationSchemaRegistrySchemaName

Formats a string containing the fully-qualified path to represent a project_location_schema_registry_schema resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
schema string
Returns
Type Description
string The formatted project_location_schema_registry_schema resource.

static::projectLocationSchemaRegistrySubjectName

Formats a string containing the fully-qualified path to represent a project_location_schema_registry_subject resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
subject string
Returns
Type Description
string The formatted project_location_schema_registry_subject resource.

static::projectLocationSchemaRegistrySubjectVersionName

Formats a string containing the fully-qualified path to represent a project_location_schema_registry_subject_version resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
subject string
version string
Returns
Type Description
string The formatted project_location_schema_registry_subject_version resource.

static::projectLocationSchemaRegistrySubjectVersionsName

Formats a string containing the fully-qualified path to represent a project_location_schema_registry_subject_versions resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
subject string
Returns
Type Description
string The formatted project_location_schema_registry_subject_versions resource.

static::schemaName

Formats a string containing the fully-qualified path to represent a schema resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
schema string
Returns
Type Description
string The formatted schema resource.

static::schemaConfigName

Formats a string containing the fully-qualified path to represent a schema_config resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
Returns
Type Description
string The formatted schema_config resource.

static::schemaContextName

Formats a string containing the fully-qualified path to represent a schema_context resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
context string
Returns
Type Description
string The formatted schema_context resource.

static::schemaModeName

Formats a string containing the fully-qualified path to represent a schema_mode resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
Returns
Type Description
string The formatted schema_mode resource.

static::schemaRegistryName

Formats a string containing the fully-qualified path to represent a schema_registry resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
Returns
Type Description
string The formatted schema_registry resource.

static::schemaSubjectName

Formats a string containing the fully-qualified path to represent a schema_subject resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
subject string
Returns
Type Description
string The formatted schema_subject resource.

static::schemaVersionName

Formats a string containing the fully-qualified path to represent a schema_version resource.

Parameters
Name Description
project string
___location string
schemaRegistry string
subject string
version string
Returns
Type Description
string The formatted schema_version resource.

static::parseName

Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported: Template: Pattern

  • projectLocationSchemaRegistryConfig: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/config
  • projectLocationSchemaRegistryContextConfig: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/config
  • projectLocationSchemaRegistryContextMode: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/mode
  • projectLocationSchemaRegistryContextSchema: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/schemas/ids/{schema}
  • projectLocationSchemaRegistryContextSubject: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/subjects/{subject}
  • projectLocationSchemaRegistryContextSubjectVersion: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/subjects/{subject}/versions/{version}
  • projectLocationSchemaRegistryContextSubjectVersions: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}/compatibility/subjects/{subject}/versions
  • projectLocationSchemaRegistryMode: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/mode
  • projectLocationSchemaRegistrySchema: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/schemas/ids/{schema}
  • projectLocationSchemaRegistrySubject: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/subjects/{subject}
  • projectLocationSchemaRegistrySubjectVersion: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/subjects/{subject}/versions/{version}
  • projectLocationSchemaRegistrySubjectVersions: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/compatibility/subjects/{subject}/versions
  • schema: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/schemas/ids/{schema}
  • schemaConfig: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/config
  • schemaContext: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/contexts/{context}
  • schemaMode: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/mode
  • schemaRegistry: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}
  • schemaSubject: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/subjects/{subject}
  • schemaVersion: projects/{project}/locations/{___location}/schemaRegistries/{schema_registry}/subjects/{subject}/versions/{version}

The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.

Parameters
Name Description
formattedName string

The formatted name string

template ?string

Optional name of template to match

Returns
Type Description
array An associative array from name component IDs to component values.