diff --git a/DataCatalogLineage/.OwlBot.yaml b/DataCatalogLineage/.OwlBot.yaml index 937e6caa9e13..9c30682bfaeb 100644 --- a/DataCatalogLineage/.OwlBot.yaml +++ b/DataCatalogLineage/.OwlBot.yaml @@ -1,4 +1,6 @@ deep-copy-regex: - source: /google/cloud/datacatalog/lineage/(v1)/.*-php/(.*) dest: /owl-bot-staging/DataCatalogLineage/$1/$2 + - source: /google/cloud/datacatalog/lineage/configmanagement/(v1)/.*-php/(.*) + dest: /owl-bot-staging/DataCatalogLineage/ConfigManagement/$1/$2 api-name: DataCatalogLineage diff --git a/DataCatalogLineage/metadata/Configmanagement/V1/Configmanagement.php b/DataCatalogLineage/metadata/Configmanagement/V1/Configmanagement.php new file mode 100644 index 000000000000..abbac778d03a --- /dev/null +++ b/DataCatalogLineage/metadata/Configmanagement/V1/Configmanagement.php @@ -0,0 +1,28 @@ +internalAddGeneratedFile( + "\x0A\xAA\x14\x0AKgoogle/cloud/datacatalog/lineage/configmanagement/v1/configmanagement.proto\x124google.cloud.datacatalog.lineage.configmanagement.v1\x1A\x17google/api/client.proto\x1A\x1Fgoogle/api/field_behavior.proto\x1A\x19google/api/resource.proto\"K\x0A\x10GetConfigRequest\x127\x0A\x04name\x18\x01 \x01(\x09B)\xE0A\x02\xFAA#\x0A!datalineage.googleapis.com/Config\"h\x0A\x13UpdateConfigRequest\x12Q\x0A\x06config\x18\x01 \x01(\x0B2<.google.cloud.datacatalog.lineage.configmanagement.v1.ConfigB\x03\xE0A\x02\"\xB3\x08\x0A\x06Config\x12\x11\x0A\x04name\x18\x01 \x01(\x09B\x03\xE0A\x08\x12^\x0A\x09ingestion\x18\x02 \x01(\x0B2F.google.cloud.datacatalog.lineage.configmanagement.v1.Config.IngestionB\x03\xE0A\x01\x12\x11\x0A\x04etag\x18\x03 \x01(\x09B\x03\xE0A\x01\x1A\xCF\x05\x0A\x09Ingestion\x12h\x0A\x05rules\x18\x01 \x03(\x0B2T.google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRuleB\x03\xE0A\x01\x1A\xD7\x04\x0A\x0DIngestionRule\x12\x8B\x01\x0A\x14integration_selector\x18\x01 \x01(\x0B2h.google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.IntegrationSelectorB\x03\xE0A\x02\x12\x87\x01\x0A\x12lineage_enablement\x18\x03 \x01(\x0B2f.google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.LineageEnablementB\x03\xE0A\x02\x1A\xF1\x01\x0A\x13IntegrationSelector\x12\x8E\x01\x0A\x0Bintegration\x18\x01 \x01(\x0E2t.google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.IntegrationSelector.IntegrationB\x03\xE0A\x02\"I\x0A\x0BIntegration\x12\x1B\x0A\x17INTEGRATION_UNSPECIFIED\x10\x00\x12\x0C\x0A\x08DATAPROC\x10\x02\x12\x0F\x0A\x0BLOOKER_CORE\x10\x03\x1A:\x0A\x11LineageEnablement\x12\x19\x0A\x07enabled\x18\x01 \x01(\x08B\x03\xE0A\x01H\x00\x88\x01\x01B\x0A\x0A\x08_enabled:\xD0\x01\xEAA\xCC\x01\x0A!datalineage.googleapis.com/Config\x12.projects/{project}/locations/{location}/config\x12,folders/{folder}/locations/{location}/config\x128organizations/{organization}/locations/{location}/config*\x07configs2\x06config2\xF4\x05\x0A\x17ConfigManagementService\x12\xA8\x02\x0A\x09GetConfig\x12F.google.cloud.datacatalog.lineage.configmanagement.v1.GetConfigRequest\x1A<.google.cloud.datacatalog.lineage.configmanagement.v1.Config\"\x94\x01\xDAA\x04name\x82\xD3\xE4\x93\x02\x86\x01\x12(/v1/{name=projects/*/locations/*/config}Z)\x12'/v1/{name=folders/*/locations/*/config}Z/\x12-/v1/{name=organizations/*/locations/*/config}\x12\xDD\x02\x0A\x0CUpdateConfig\x12I.google.cloud.datacatalog.lineage.configmanagement.v1.UpdateConfigRequest\x1A<.google.cloud.datacatalog.lineage.configmanagement.v1.Config\"\xC3\x01\xDAA\x06config\x82\xD3\xE4\x93\x02\xB3\x012//v1/{config.name=projects/*/locations/*/config}:\x06configZ82./v1/{config.name=folders/*/locations/*/config}:\x06configZ>24/v1/{config.name=organizations/*/locations/*/config}:\x06config\x1AN\xCAA\x1Adatalineage.googleapis.com\xD2A.https://www.googleapis.com/auth/cloud-platformB\xE3\x02\x0A8com.google.cloud.datacatalog.lineage.configmanagement.v1B\x15ConfigManagementProtoP\x01Zdcloud.google.com/go/datacatalog/lineage/configmanagement/apiv1/configmanagementpb;configmanagementpb\xAA\x024Google.Cloud.DataCatalog.Lineage.ConfigManagement.V1\xCA\x024Google\\Cloud\\DataCatalog\\Lineage\\ConfigManagement\\V1\xEA\x029Google::Cloud::DataCatalog::Lineage::ConfigManagement::V1b\x06proto3" + , true); + + static::$is_initialized = true; + } +} + diff --git a/DataCatalogLineage/owlbot.py b/DataCatalogLineage/owlbot.py index 3a20abb44048..96e4d0f66bb7 100644 --- a/DataCatalogLineage/owlbot.py +++ b/DataCatalogLineage/owlbot.py @@ -27,9 +27,48 @@ src = Path(f"../{php.STAGING_DIR}/DataCatalogLineage").resolve() dest = Path().resolve() -# Added so that we can pass copy_excludes in the owlbot_main() call -_tracked_paths.add(src) +# copy over configmanagement (gapic src, samples, and tests, proto src and metadata) +configmanagement_src = Path(f"../{php.STAGING_DIR}/DataCatalogLineage/ConfigManagement/v1").resolve() +#executions_library = Path(f"../{php.STAGING_DIR}/Workflows/Executions/v1").resolve() +# copy all src including partial veneer classes +#s.move( +# executions_library / 'src', +# 'src/Executions', +# merge=preserve_copyright_year, +#) +## copy proto files to src also +#s.move( +# executions_library / 'proto/src/Google/Cloud/Workflows', +# 'src/', +# merge=preserve_copyright_year, +# excludes=[ +# executions_library / "**/*_*.php" +# ] +#) +#s.move( +# executions_library / 'tests/Unit', +# 'tests/Unit/Executions', +# merge=preserve_copyright_year, +#) +## copy GPBMetadata file to metadata +#s.move(executions_library / 'proto/src/GPBMetadata/Google/Cloud/Workflows', +# 'metadata/', +# merge=preserve_copyright_year, +#) +# +## Fix test namespaces +#s.replace( +# 'tests/Unit/Executions/*/*.php', +# r'namespace Google\\Cloud\\Workflows\\Executions\\Tests\\Unit', +# r'namespace Google\\Cloud\\Workflows\\Tests\\Unit\\Executions') +s.move(configmanagement_src / f'src', 'src/ConfigManagement') +s.move(configmanagement_src / f'samples', 'samples/ConfigManagement') +s.move(configmanagement_src / f'tests/Unit', 'tests/Unit/ConfigManagement') +s.move(configmanagement_src / f'proto/src/Google/Cloud/DataCatalog/Lineage', f'src') +s.move(configmanagement_src / f'proto/src/GPBMetadata/Google/Cloud/Datacatalog/Lineage', f'metadata') + +# copy over the standard files php.owlbot_main(src=src, dest=dest) # format generated clients diff --git a/DataCatalogLineage/samples/ConfigManagement/V1/ConfigManagementServiceClient/get_config.php b/DataCatalogLineage/samples/ConfigManagement/V1/ConfigManagementServiceClient/get_config.php new file mode 100644 index 000000000000..50e0f2611a83 --- /dev/null +++ b/DataCatalogLineage/samples/ConfigManagement/V1/ConfigManagementServiceClient/get_config.php @@ -0,0 +1,76 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var Config $response */ + $response = $configManagementServiceClient->getConfig($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 = ConfigManagementServiceClient::configName('[PROJECT]', '[LOCATION]'); + + get_config_sample($formattedName); +} +// [END datalineage_v1_generated_ConfigManagementService_GetConfig_sync] diff --git a/DataCatalogLineage/samples/ConfigManagement/V1/ConfigManagementServiceClient/update_config.php b/DataCatalogLineage/samples/ConfigManagement/V1/ConfigManagementServiceClient/update_config.php new file mode 100644 index 000000000000..05d7e4b3d94f --- /dev/null +++ b/DataCatalogLineage/samples/ConfigManagement/V1/ConfigManagementServiceClient/update_config.php @@ -0,0 +1,59 @@ +setConfig($config); + + // Call the API and handle any network failures. + try { + /** @var Config $response */ + $response = $configManagementServiceClient->updateConfig($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END datalineage_v1_generated_ConfigManagementService_UpdateConfig_sync] diff --git a/DataCatalogLineage/src/ConfigManagement/V1/Client/ConfigManagementServiceClient.php b/DataCatalogLineage/src/ConfigManagement/V1/Client/ConfigManagementServiceClient.php new file mode 100644 index 000000000000..ca9a576dbd9c --- /dev/null +++ b/DataCatalogLineage/src/ConfigManagement/V1/Client/ConfigManagementServiceClient.php @@ -0,0 +1,338 @@ + getConfigAsync(GetConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateConfigAsync(UpdateConfigRequest $request, array $optionalArgs = []) + */ +final class ConfigManagementServiceClient +{ + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.datacatalog.lineage.configmanagement.v1.ConfigManagementService'; + + /** + * The default address of the service. + * + * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. + */ + private const SERVICE_ADDRESS = 'datalineage.googleapis.com'; + + /** The address template of the service. */ + private const SERVICE_ADDRESS_TEMPLATE = 'datalineage.UNIVERSE_DOMAIN'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/config_management_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/config_management_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/config_management_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => + __DIR__ . '/../resources/config_management_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a config + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted config resource. + */ + public static function configName(string $project, string $location): string + { + return self::getPathTemplate('config')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_location_config resource. + * + * @param string $folder + * @param string $location + * + * @return string The formatted folder_location_config resource. + */ + public static function folderLocationConfigName(string $folder, string $location): string + { + return self::getPathTemplate('folderLocationConfig')->render([ + 'folder' => $folder, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_config resource. + * + * @param string $organization + * @param string $location + * + * @return string The formatted organization_location_config resource. + */ + public static function organizationLocationConfigName(string $organization, string $location): string + { + return self::getPathTemplate('organizationLocationConfig')->render([ + 'organization' => $organization, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_config resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted project_location_config resource. + */ + public static function projectLocationConfigName(string $project, string $location): string + { + return self::getPathTemplate('projectLocationConfig')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - config: projects/{project}/locations/{location}/config + * - folderLocationConfig: folders/{folder}/locations/{location}/config + * - organizationLocationConfig: organizations/{organization}/locations/{location}/config + * - projectLocationConfig: projects/{project}/locations/{location}/config + * + * 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. + * + * @param string $formattedName The formatted name string + * @param ?string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + */ + public static function parseName(string $formattedName, ?string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * Constructor. + * + * @param array|ClientOptions $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'datalineage.googleapis.com:443'. + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use + * Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\ConfigManagementServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ConfigManagementServiceClient(['credentials' => $creds]); + * ``` + * {@see + * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * 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. + * @type string|TransportInterface $transport + * 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 {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $apiEndpoint setting, will be ignored. + * @type array $transportConfig + * 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 {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * @type callable $clientCertSource + * 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. + * @type false|LoggerInterface $logger + * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the + * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. + * } + * + * @throws ValidationException + */ + public function __construct(array|ClientOptions $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Get the Config for a given resource. + * + * The async variant is {@see ConfigManagementServiceClient::getConfigAsync()} . + * + * @example samples/V1/ConfigManagementServiceClient/get_config.php + * + * @param GetConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return Config + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConfig(GetConfigRequest $request, array $callOptions = []): Config + { + return $this->startApiCall('GetConfig', $request, $callOptions)->wait(); + } + + /** + * Update the Config for a given resource. + * + * The async variant is {@see ConfigManagementServiceClient::updateConfigAsync()} . + * + * @example samples/V1/ConfigManagementServiceClient/update_config.php + * + * @param UpdateConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return Config + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateConfig(UpdateConfigRequest $request, array $callOptions = []): Config + { + return $this->startApiCall('UpdateConfig', $request, $callOptions)->wait(); + } +} diff --git a/DataCatalogLineage/src/ConfigManagement/V1/Config.php b/DataCatalogLineage/src/ConfigManagement/V1/Config.php new file mode 100644 index 000000000000..259235552668 --- /dev/null +++ b/DataCatalogLineage/src/ConfigManagement/V1/Config.php @@ -0,0 +1,198 @@ +google.cloud.datacatalog.lineage.configmanagement.v1.Config + */ +class Config extends \Google\Protobuf\Internal\Message +{ + /** + * Identifier. The resource name of the config. + * Format: + * `organizations/{organization_id}/locations/global/config` + * `folders/{folder_id}/locations/global/config` + * `projects/{project_id}/locations/global/config` + * `projects/{project_number}/locations/global/config` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + */ + protected $name = ''; + /** + * Optional. Ingestion rule for Data Lineage ingestion. + * + * Generated from protobuf field .google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion ingestion = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $ingestion = null; + /** + * Optional. `etag` is used for optimistic concurrency control as a way + * to help prevent simultaneous updates of a config from overwriting each + * other. It is required that systems make use of the `etag` in the + * read-modify-write cycle to perform config updates in order to avoid race + * conditions: An `etag` is returned in the response to `GetConfig`, and + * systems are expected to put that etag in the request to `UpdateConfig` to + * ensure that their change will be applied to the same version of the config. + * If an `etag` is not provided in the call to `UpdateConfig`, then the + * existing config, if any, will be overwritten. + * + * Generated from protobuf field string etag = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $etag = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Identifier. The resource name of the config. + * Format: + * `organizations/{organization_id}/locations/global/config` + * `folders/{folder_id}/locations/global/config` + * `projects/{project_id}/locations/global/config` + * `projects/{project_number}/locations/global/config` + * @type \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config\Ingestion $ingestion + * Optional. Ingestion rule for Data Lineage ingestion. + * @type string $etag + * Optional. `etag` is used for optimistic concurrency control as a way + * to help prevent simultaneous updates of a config from overwriting each + * other. It is required that systems make use of the `etag` in the + * read-modify-write cycle to perform config updates in order to avoid race + * conditions: An `etag` is returned in the response to `GetConfig`, and + * systems are expected to put that etag in the request to `UpdateConfig` to + * ensure that their change will be applied to the same version of the config. + * If an `etag` is not provided in the call to `UpdateConfig`, then the + * existing config, if any, will be overwritten. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Datacatalog\Lineage\Configmanagement\V1\Configmanagement::initOnce(); + parent::__construct($data); + } + + /** + * Identifier. The resource name of the config. + * Format: + * `organizations/{organization_id}/locations/global/config` + * `folders/{folder_id}/locations/global/config` + * `projects/{project_id}/locations/global/config` + * `projects/{project_number}/locations/global/config` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Identifier. The resource name of the config. + * Format: + * `organizations/{organization_id}/locations/global/config` + * `folders/{folder_id}/locations/global/config` + * `projects/{project_id}/locations/global/config` + * `projects/{project_number}/locations/global/config` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Optional. Ingestion rule for Data Lineage ingestion. + * + * Generated from protobuf field .google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion ingestion = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config\Ingestion|null + */ + public function getIngestion() + { + return $this->ingestion; + } + + public function hasIngestion() + { + return isset($this->ingestion); + } + + public function clearIngestion() + { + unset($this->ingestion); + } + + /** + * Optional. Ingestion rule for Data Lineage ingestion. + * + * Generated from protobuf field .google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion ingestion = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config\Ingestion $var + * @return $this + */ + public function setIngestion($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config\Ingestion::class); + $this->ingestion = $var; + + return $this; + } + + /** + * Optional. `etag` is used for optimistic concurrency control as a way + * to help prevent simultaneous updates of a config from overwriting each + * other. It is required that systems make use of the `etag` in the + * read-modify-write cycle to perform config updates in order to avoid race + * conditions: An `etag` is returned in the response to `GetConfig`, and + * systems are expected to put that etag in the request to `UpdateConfig` to + * ensure that their change will be applied to the same version of the config. + * If an `etag` is not provided in the call to `UpdateConfig`, then the + * existing config, if any, will be overwritten. + * + * Generated from protobuf field string etag = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getEtag() + { + return $this->etag; + } + + /** + * Optional. `etag` is used for optimistic concurrency control as a way + * to help prevent simultaneous updates of a config from overwriting each + * other. It is required that systems make use of the `etag` in the + * read-modify-write cycle to perform config updates in order to avoid race + * conditions: An `etag` is returned in the response to `GetConfig`, and + * systems are expected to put that etag in the request to `UpdateConfig` to + * ensure that their change will be applied to the same version of the config. + * If an `etag` is not provided in the call to `UpdateConfig`, then the + * existing config, if any, will be overwritten. + * + * Generated from protobuf field string etag = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setEtag($var) + { + GPBUtil::checkString($var, True); + $this->etag = $var; + + return $this; + } + +} + diff --git a/DataCatalogLineage/src/ConfigManagement/V1/Config/Ingestion.php b/DataCatalogLineage/src/ConfigManagement/V1/Config/Ingestion.php new file mode 100644 index 000000000000..3512c1d80bd3 --- /dev/null +++ b/DataCatalogLineage/src/ConfigManagement/V1/Config/Ingestion.php @@ -0,0 +1,67 @@ +google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion + */ +class Ingestion extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. List of rules for Data Lineage ingestion. + * + * Generated from protobuf field repeated .google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule rules = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $rules; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config\Ingestion\IngestionRule[] $rules + * Optional. List of rules for Data Lineage ingestion. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Datacatalog\Lineage\Configmanagement\V1\Configmanagement::initOnce(); + parent::__construct($data); + } + + /** + * Optional. List of rules for Data Lineage ingestion. + * + * Generated from protobuf field repeated .google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule rules = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return RepeatedField<\Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config\Ingestion\IngestionRule> + */ + public function getRules() + { + return $this->rules; + } + + /** + * Optional. List of rules for Data Lineage ingestion. + * + * Generated from protobuf field repeated .google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule rules = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config\Ingestion\IngestionRule[] $var + * @return $this + */ + public function setRules($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config\Ingestion\IngestionRule::class); + $this->rules = $arr; + + return $this; + } + +} + diff --git a/DataCatalogLineage/src/ConfigManagement/V1/Config/Ingestion/IngestionRule.php b/DataCatalogLineage/src/ConfigManagement/V1/Config/Ingestion/IngestionRule.php new file mode 100644 index 000000000000..2943aee10630 --- /dev/null +++ b/DataCatalogLineage/src/ConfigManagement/V1/Config/Ingestion/IngestionRule.php @@ -0,0 +1,137 @@ +google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule + */ +class IngestionRule extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Integration selector of the rule. The rule is only applied to + * the Integration selected by the selector. + * + * Generated from protobuf field .google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.IntegrationSelector integration_selector = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $integration_selector = null; + /** + * Required. Lineage enablement configuration. Defines configurations for + * the ingestion of lineage for the resource and its children. If + * unspecified, the ingestion will be enabled only if it was configured in + * the resource's parent. + * + * Generated from protobuf field .google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.LineageEnablement lineage_enablement = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $lineage_enablement = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config\Ingestion\IngestionRule\IntegrationSelector $integration_selector + * Required. Integration selector of the rule. The rule is only applied to + * the Integration selected by the selector. + * @type \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config\Ingestion\IngestionRule\LineageEnablement $lineage_enablement + * Required. Lineage enablement configuration. Defines configurations for + * the ingestion of lineage for the resource and its children. If + * unspecified, the ingestion will be enabled only if it was configured in + * the resource's parent. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Datacatalog\Lineage\Configmanagement\V1\Configmanagement::initOnce(); + parent::__construct($data); + } + + /** + * Required. Integration selector of the rule. The rule is only applied to + * the Integration selected by the selector. + * + * Generated from protobuf field .google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.IntegrationSelector integration_selector = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config\Ingestion\IngestionRule\IntegrationSelector|null + */ + public function getIntegrationSelector() + { + return $this->integration_selector; + } + + public function hasIntegrationSelector() + { + return isset($this->integration_selector); + } + + public function clearIntegrationSelector() + { + unset($this->integration_selector); + } + + /** + * Required. Integration selector of the rule. The rule is only applied to + * the Integration selected by the selector. + * + * Generated from protobuf field .google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.IntegrationSelector integration_selector = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config\Ingestion\IngestionRule\IntegrationSelector $var + * @return $this + */ + public function setIntegrationSelector($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config\Ingestion\IngestionRule\IntegrationSelector::class); + $this->integration_selector = $var; + + return $this; + } + + /** + * Required. Lineage enablement configuration. Defines configurations for + * the ingestion of lineage for the resource and its children. If + * unspecified, the ingestion will be enabled only if it was configured in + * the resource's parent. + * + * Generated from protobuf field .google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.LineageEnablement lineage_enablement = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config\Ingestion\IngestionRule\LineageEnablement|null + */ + public function getLineageEnablement() + { + return $this->lineage_enablement; + } + + public function hasLineageEnablement() + { + return isset($this->lineage_enablement); + } + + public function clearLineageEnablement() + { + unset($this->lineage_enablement); + } + + /** + * Required. Lineage enablement configuration. Defines configurations for + * the ingestion of lineage for the resource and its children. If + * unspecified, the ingestion will be enabled only if it was configured in + * the resource's parent. + * + * Generated from protobuf field .google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.LineageEnablement lineage_enablement = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config\Ingestion\IngestionRule\LineageEnablement $var + * @return $this + */ + public function setLineageEnablement($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config\Ingestion\IngestionRule\LineageEnablement::class); + $this->lineage_enablement = $var; + + return $this; + } + +} + diff --git a/DataCatalogLineage/src/ConfigManagement/V1/Config/Ingestion/IngestionRule/IntegrationSelector.php b/DataCatalogLineage/src/ConfigManagement/V1/Config/Ingestion/IngestionRule/IntegrationSelector.php new file mode 100644 index 000000000000..5b4a164e5e26 --- /dev/null +++ b/DataCatalogLineage/src/ConfigManagement/V1/Config/Ingestion/IngestionRule/IntegrationSelector.php @@ -0,0 +1,76 @@ +google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.IntegrationSelector + */ +class IntegrationSelector extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Integration to which the rule applies. + * This field can be used to specify the integration against which the + * ingestion rule should be applied. + * + * Generated from protobuf field .google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.IntegrationSelector.Integration integration = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $integration = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $integration + * Required. Integration to which the rule applies. + * This field can be used to specify the integration against which the + * ingestion rule should be applied. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Datacatalog\Lineage\Configmanagement\V1\Configmanagement::initOnce(); + parent::__construct($data); + } + + /** + * Required. Integration to which the rule applies. + * This field can be used to specify the integration against which the + * ingestion rule should be applied. + * + * Generated from protobuf field .google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.IntegrationSelector.Integration integration = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return int + */ + public function getIntegration() + { + return $this->integration; + } + + /** + * Required. Integration to which the rule applies. + * This field can be used to specify the integration against which the + * ingestion rule should be applied. + * + * Generated from protobuf field .google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.IntegrationSelector.Integration integration = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param int $var + * @return $this + */ + public function setIntegration($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config\Ingestion\IngestionRule\IntegrationSelector\Integration::class); + $this->integration = $var; + + return $this; + } + +} + diff --git a/DataCatalogLineage/src/ConfigManagement/V1/Config/Ingestion/IngestionRule/IntegrationSelector/Integration.php b/DataCatalogLineage/src/ConfigManagement/V1/Config/Ingestion/IngestionRule/IntegrationSelector/Integration.php new file mode 100644 index 000000000000..b9d70edb3b7d --- /dev/null +++ b/DataCatalogLineage/src/ConfigManagement/V1/Config/Ingestion/IngestionRule/IntegrationSelector/Integration.php @@ -0,0 +1,62 @@ +google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.IntegrationSelector.Integration + */ +class Integration +{ + /** + * Integration is Unspecified + * + * Generated from protobuf enum INTEGRATION_UNSPECIFIED = 0; + */ + const INTEGRATION_UNSPECIFIED = 0; + /** + * Dataproc + * + * Generated from protobuf enum DATAPROC = 2; + */ + const DATAPROC = 2; + /** + * Looker Core + * + * Generated from protobuf enum LOOKER_CORE = 3; + */ + const LOOKER_CORE = 3; + + private static $valueToName = [ + self::INTEGRATION_UNSPECIFIED => 'INTEGRATION_UNSPECIFIED', + self::DATAPROC => 'DATAPROC', + self::LOOKER_CORE => 'LOOKER_CORE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/DataCatalogLineage/src/ConfigManagement/V1/Config/Ingestion/IngestionRule/LineageEnablement.php b/DataCatalogLineage/src/ConfigManagement/V1/Config/Ingestion/IngestionRule/LineageEnablement.php new file mode 100644 index 000000000000..f0e661db8ac3 --- /dev/null +++ b/DataCatalogLineage/src/ConfigManagement/V1/Config/Ingestion/IngestionRule/LineageEnablement.php @@ -0,0 +1,86 @@ +google.cloud.datacatalog.lineage.configmanagement.v1.Config.Ingestion.IngestionRule.LineageEnablement + */ +class LineageEnablement extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. If true, ingestion of lineage should be enabled. If false, + * it should be disabled. If unspecified, the system default value is + * used. + * + * Generated from protobuf field optional bool enabled = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $enabled = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type bool $enabled + * Optional. If true, ingestion of lineage should be enabled. If false, + * it should be disabled. If unspecified, the system default value is + * used. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Datacatalog\Lineage\Configmanagement\V1\Configmanagement::initOnce(); + parent::__construct($data); + } + + /** + * Optional. If true, ingestion of lineage should be enabled. If false, + * it should be disabled. If unspecified, the system default value is + * used. + * + * Generated from protobuf field optional bool enabled = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getEnabled() + { + return isset($this->enabled) ? $this->enabled : false; + } + + public function hasEnabled() + { + return isset($this->enabled); + } + + public function clearEnabled() + { + unset($this->enabled); + } + + /** + * Optional. If true, ingestion of lineage should be enabled. If false, + * it should be disabled. If unspecified, the system default value is + * used. + * + * Generated from protobuf field optional bool enabled = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setEnabled($var) + { + GPBUtil::checkBool($var); + $this->enabled = $var; + + return $this; + } + +} + diff --git a/DataCatalogLineage/src/ConfigManagement/V1/GetConfigRequest.php b/DataCatalogLineage/src/ConfigManagement/V1/GetConfigRequest.php new file mode 100644 index 000000000000..f9141689aa4f --- /dev/null +++ b/DataCatalogLineage/src/ConfigManagement/V1/GetConfigRequest.php @@ -0,0 +1,106 @@ +google.cloud.datacatalog.lineage.configmanagement.v1.GetConfigRequest + */ +class GetConfigRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. REQUIRED: The resource name of the config to be fetched. + * Format: + * `organizations/{organization_id}/locations/global/config` + * `folders/{folder_id}/locations/global/config` + * `projects/{project_id}/locations/global/config` + * `projects/{project_number}/locations/global/config` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. REQUIRED: The resource name of the config to be fetched. + * Format: + * `organizations/{organization_id}/locations/global/config` + * `folders/{folder_id}/locations/global/config` + * `projects/{project_id}/locations/global/config` + * `projects/{project_number}/locations/global/config` + * Please see {@see ConfigManagementServiceClient::configName()} for help formatting this field. + * + * @return \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\GetConfigRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. REQUIRED: The resource name of the config to be fetched. + * Format: + * `organizations/{organization_id}/locations/global/config` + * `folders/{folder_id}/locations/global/config` + * `projects/{project_id}/locations/global/config` + * `projects/{project_number}/locations/global/config` + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Datacatalog\Lineage\Configmanagement\V1\Configmanagement::initOnce(); + parent::__construct($data); + } + + /** + * Required. REQUIRED: The resource name of the config to be fetched. + * Format: + * `organizations/{organization_id}/locations/global/config` + * `folders/{folder_id}/locations/global/config` + * `projects/{project_id}/locations/global/config` + * `projects/{project_number}/locations/global/config` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. REQUIRED: The resource name of the config to be fetched. + * Format: + * `organizations/{organization_id}/locations/global/config` + * `folders/{folder_id}/locations/global/config` + * `projects/{project_id}/locations/global/config` + * `projects/{project_number}/locations/global/config` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/DataCatalogLineage/src/ConfigManagement/V1/UpdateConfigRequest.php b/DataCatalogLineage/src/ConfigManagement/V1/UpdateConfigRequest.php new file mode 100644 index 000000000000..df3192a31278 --- /dev/null +++ b/DataCatalogLineage/src/ConfigManagement/V1/UpdateConfigRequest.php @@ -0,0 +1,95 @@ +google.cloud.datacatalog.lineage.configmanagement.v1.UpdateConfigRequest + */ +class UpdateConfigRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. REQUIRED: The config to be applied to the resource and all its + * descendants. + * + * Generated from protobuf field .google.cloud.datacatalog.lineage.configmanagement.v1.Config config = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $config = null; + + /** + * @param \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config $config Required. REQUIRED: The config to be applied to the resource and all its + * descendants. + * + * @return \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\UpdateConfigRequest + * + * @experimental + */ + public static function build(\Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config $config): self + { + return (new self()) + ->setConfig($config); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config $config + * Required. REQUIRED: The config to be applied to the resource and all its + * descendants. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Datacatalog\Lineage\Configmanagement\V1\Configmanagement::initOnce(); + parent::__construct($data); + } + + /** + * Required. REQUIRED: The config to be applied to the resource and all its + * descendants. + * + * Generated from protobuf field .google.cloud.datacatalog.lineage.configmanagement.v1.Config config = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config|null + */ + public function getConfig() + { + return $this->config; + } + + public function hasConfig() + { + return isset($this->config); + } + + public function clearConfig() + { + unset($this->config); + } + + /** + * Required. REQUIRED: The config to be applied to the resource and all its + * descendants. + * + * Generated from protobuf field .google.cloud.datacatalog.lineage.configmanagement.v1.Config config = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config $var + * @return $this + */ + public function setConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config::class); + $this->config = $var; + + return $this; + } + +} + diff --git a/DataCatalogLineage/src/ConfigManagement/V1/gapic_metadata.json b/DataCatalogLineage/src/ConfigManagement/V1/gapic_metadata.json new file mode 100644 index 000000000000..72064069a600 --- /dev/null +++ b/DataCatalogLineage/src/ConfigManagement/V1/gapic_metadata.json @@ -0,0 +1,28 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services\/RPCs to the corresponding library clients\/methods", + "language": "php", + "protoPackage": "google.cloud.datacatalog.lineage.configmanagement.v1", + "libraryPackage": "Google\\Cloud\\DataCatalog\\Lineage\\ConfigManagement\\V1", + "services": { + "ConfigManagementService": { + "clients": { + "grpc": { + "libraryClient": "ConfigManagementServiceGapicClient", + "rpcs": { + "GetConfig": { + "methods": [ + "getConfig" + ] + }, + "UpdateConfig": { + "methods": [ + "updateConfig" + ] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/DataCatalogLineage/src/ConfigManagement/V1/resources/config_management_service_client_config.json b/DataCatalogLineage/src/ConfigManagement/V1/resources/config_management_service_client_config.json new file mode 100644 index 000000000000..3c5e7dbeb2eb --- /dev/null +++ b/DataCatalogLineage/src/ConfigManagement/V1/resources/config_management_service_client_config.json @@ -0,0 +1,44 @@ +{ + "interfaces": { + "google.cloud.datacatalog.lineage.configmanagement.v1.ConfigManagementService": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_1_codes": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "no_retry_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 0, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 0, + "total_timeout_millis": 0 + }, + "retry_policy_1_params": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 60000 + } + }, + "methods": { + "GetConfig": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "UpdateConfig": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + } + } + } + } +} diff --git a/DataCatalogLineage/src/ConfigManagement/V1/resources/config_management_service_descriptor_config.php b/DataCatalogLineage/src/ConfigManagement/V1/resources/config_management_service_descriptor_config.php new file mode 100644 index 000000000000..fdefeabcfd15 --- /dev/null +++ b/DataCatalogLineage/src/ConfigManagement/V1/resources/config_management_service_descriptor_config.php @@ -0,0 +1,59 @@ + [ + 'google.cloud.datacatalog.lineage.configmanagement.v1.ConfigManagementService' => [ + 'GetConfig' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'UpdateConfig' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\DataCatalog\Lineage\ConfigManagement\V1\Config', + 'headerParams' => [ + [ + 'keyName' => 'config.name', + 'fieldAccessors' => [ + 'getConfig', + 'getName', + ], + ], + ], + ], + 'templateMap' => [ + 'config' => 'projects/{project}/locations/{location}/config', + 'folderLocationConfig' => 'folders/{folder}/locations/{location}/config', + 'organizationLocationConfig' => 'organizations/{organization}/locations/{location}/config', + 'projectLocationConfig' => 'projects/{project}/locations/{location}/config', + ], + ], + ], +]; diff --git a/DataCatalogLineage/src/ConfigManagement/V1/resources/config_management_service_rest_client_config.php b/DataCatalogLineage/src/ConfigManagement/V1/resources/config_management_service_rest_client_config.php new file mode 100644 index 000000000000..2aec096ffea9 --- /dev/null +++ b/DataCatalogLineage/src/ConfigManagement/V1/resources/config_management_service_rest_client_config.php @@ -0,0 +1,122 @@ + [ + 'google.cloud.datacatalog.lineage.configmanagement.v1.ConfigManagementService' => [ + 'GetConfig' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/config}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=folders/*/locations/*/config}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=organizations/*/locations/*/config}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'UpdateConfig' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{config.name=projects/*/locations/*/config}', + 'body' => 'config', + 'additionalBindings' => [ + [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{config.name=folders/*/locations/*/config}', + 'body' => 'config', + ], + [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{config.name=organizations/*/locations/*/config}', + 'body' => 'config', + ], + ], + 'placeholders' => [ + 'config.name' => [ + 'getters' => [ + 'getConfig', + 'getName', + ], + ], + ], + ], + ], + 'google.longrunning.Operations' => [ + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/operations/*}:cancel', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*}/operations', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/DataCatalogLineage/tests/Unit/ConfigManagement/V1/Client/ConfigManagementServiceClientTest.php b/DataCatalogLineage/tests/Unit/ConfigManagement/V1/Client/ConfigManagementServiceClientTest.php new file mode 100644 index 000000000000..0373f5b5322e --- /dev/null +++ b/DataCatalogLineage/tests/Unit/ConfigManagement/V1/Client/ConfigManagementServiceClientTest.php @@ -0,0 +1,238 @@ +getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); + } + + /** @return ConfigManagementServiceClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new ConfigManagementServiceClient($options); + } + + /** @test */ + public function getConfigTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $etag = 'etag3123477'; + $expectedResponse = new Config(); + $expectedResponse->setName($name2); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->configName('[PROJECT]', '[LOCATION]'); + $request = (new GetConfigRequest())->setName($formattedName); + $response = $gapicClient->getConfig($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame( + '/google.cloud.datacatalog.lineage.configmanagement.v1.ConfigManagementService/GetConfig', + $actualFuncCall + ); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getConfigExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->configName('[PROJECT]', '[LOCATION]'); + $request = (new GetConfigRequest())->setName($formattedName); + try { + $gapicClient->getConfig($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateConfigTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $etag = 'etag3123477'; + $expectedResponse = new Config(); + $expectedResponse->setName($name); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $config = new Config(); + $request = (new UpdateConfigRequest())->setConfig($config); + $response = $gapicClient->updateConfig($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame( + '/google.cloud.datacatalog.lineage.configmanagement.v1.ConfigManagementService/UpdateConfig', + $actualFuncCall + ); + $actualValue = $actualRequestObject->getConfig(); + $this->assertProtobufEquals($config, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateConfigExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $transport->addResponse(null, $status); + // Mock request + $config = new Config(); + $request = (new UpdateConfigRequest())->setConfig($config); + try { + $gapicClient->updateConfig($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getConfigAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $etag = 'etag3123477'; + $expectedResponse = new Config(); + $expectedResponse->setName($name2); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->configName('[PROJECT]', '[LOCATION]'); + $request = (new GetConfigRequest())->setName($formattedName); + $response = $gapicClient->getConfigAsync($request)->wait(); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame( + '/google.cloud.datacatalog.lineage.configmanagement.v1.ConfigManagementService/GetConfig', + $actualFuncCall + ); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } +}