diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Database/V1/Backup.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Database/V1/Backup.php new file mode 100644 index 000000000000..57f9f9202109 Binary files /dev/null and b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Database/V1/Backup.php differ diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Database/V1/BackupSchedule.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Database/V1/BackupSchedule.php new file mode 100644 index 000000000000..cb0825c4e2d4 Binary files /dev/null and b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Database/V1/BackupSchedule.php differ diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Database/V1/Common.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Database/V1/Common.php new file mode 100644 index 000000000000..121b65ff92ab Binary files /dev/null and b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Database/V1/Common.php differ diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Database/V1/SpannerDatabaseAdmin.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Database/V1/SpannerDatabaseAdmin.php new file mode 100644 index 000000000000..adb707cc73e3 Binary files /dev/null and b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Database/V1/SpannerDatabaseAdmin.php differ diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/Backup.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/Backup.php new file mode 100644 index 000000000000..bd024eb7bfdc --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/Backup.php @@ -0,0 +1,1013 @@ +google.spanner.admin.database.v1.Backup + */ +class Backup extends \Google\Protobuf\Internal\Message +{ + /** + * Required for the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * operation. Name of the database from which this backup was created. This + * needs to be in the same instance as the backup. Values are of the form + * `projects//instances//databases/`. + * + * Generated from protobuf field string database = 2 [(.google.api.resource_reference) = { + */ + protected $database = ''; + /** + * The backup will contain an externally consistent copy of the database at + * the timestamp specified by `version_time`. If `version_time` is not + * specified, the system will set `version_time` to the `create_time` of the + * backup. + * + * Generated from protobuf field .google.protobuf.Timestamp version_time = 9; + */ + protected $version_time = null; + /** + * Required for the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * operation. The expiration time of the backup, with microseconds + * granularity that must be at least 6 hours and at most 366 days + * from the time the CreateBackup request is processed. Once the `expire_time` + * has passed, the backup is eligible to be automatically deleted by Cloud + * Spanner to free the resources used by the backup. + * + * Generated from protobuf field .google.protobuf.Timestamp expire_time = 3; + */ + protected $expire_time = null; + /** + * Output only for the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * operation. Required for the + * [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup] + * operation. + * A globally unique identifier for the backup which cannot be + * changed. Values are of the form + * `projects//instances//backups/[a-z][a-z0-9_\-]*[a-z0-9]` + * The final segment of the name must be between 2 and 60 characters + * in length. + * The backup is stored in the location(s) specified in the instance + * configuration of the instance containing the backup, identified + * by the prefix of the backup name of the form + * `projects//instances/`. + * + * Generated from protobuf field string name = 1; + */ + protected $name = ''; + /** + * Output only. The time the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * request is received. If the request does not specify `version_time`, the + * `version_time` of the backup will be equivalent to the `create_time`. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $create_time = null; + /** + * Output only. Size of the backup in bytes. + * + * Generated from protobuf field int64 size_bytes = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $size_bytes = 0; + /** + * Output only. The number of bytes that will be freed by deleting this + * backup. This value will be zero if, for example, this backup is part of an + * incremental backup chain and younger backups in the chain require that we + * keep its data. For backups not in an incremental backup chain, this is + * always the size of the backup. This value may change if backups on the same + * chain get created, deleted or expired. + * + * Generated from protobuf field int64 freeable_size_bytes = 15 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $freeable_size_bytes = 0; + /** + * Output only. For a backup in an incremental backup chain, this is the + * storage space needed to keep the data that has changed since the previous + * backup. For all other backups, this is always the size of the backup. This + * value may change if backups on the same chain get deleted or expired. + * This field can be used to calculate the total storage space used by a set + * of backups. For example, the total space used by all backups of a database + * can be computed by summing up this field. + * + * Generated from protobuf field int64 exclusive_size_bytes = 16 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $exclusive_size_bytes = 0; + /** + * Output only. The current state of the backup. + * + * Generated from protobuf field .google.spanner.admin.database.v1.Backup.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $state = 0; + /** + * Output only. The names of the restored databases that reference the backup. + * The database names are of + * the form `projects//instances//databases/`. + * Referencing databases may exist in different instances. The existence of + * any referencing database prevents the backup from being deleted. When a + * restored database from the backup enters the `READY` state, the reference + * to the backup is removed. + * + * Generated from protobuf field repeated string referencing_databases = 7 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + */ + private $referencing_databases; + /** + * Output only. The encryption information for the backup. + * + * Generated from protobuf field .google.spanner.admin.database.v1.EncryptionInfo encryption_info = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $encryption_info = null; + /** + * Output only. The encryption information for the backup, whether it is + * protected by one or more KMS keys. The information includes all Cloud + * KMS key versions used to encrypt the backup. The `encryption_status' field + * inside of each `EncryptionInfo` is not populated. At least one of the key + * versions must be available for the backup to be restored. If a key version + * is revoked in the middle of a restore, the restore behavior is undefined. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.EncryptionInfo encryption_information = 13 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $encryption_information; + /** + * Output only. The database dialect information for the backup. + * + * Generated from protobuf field .google.spanner.admin.database.v1.DatabaseDialect database_dialect = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $database_dialect = 0; + /** + * Output only. The names of the destination backups being created by copying + * this source backup. The backup names are of the form + * `projects//instances//backups/`. + * Referencing backups may exist in different instances. The existence of + * any referencing backup prevents the backup from being deleted. When the + * copy operation is done (either successfully completed or cancelled or the + * destination backup is deleted), the reference to the backup is removed. + * + * Generated from protobuf field repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + */ + private $referencing_backups; + /** + * Output only. The max allowed expiration time of the backup, with + * microseconds granularity. A backup's expiration time can be configured in + * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or + * copying an existing backup, the expiration time specified must be + * less than `Backup.max_expire_time`. + * + * Generated from protobuf field .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $max_expire_time = null; + /** + * Output only. List of backup schedule URIs that are associated with + * creating this backup. This is only applicable for scheduled backups, and + * is empty for on-demand backups. + * To optimize for storage, whenever possible, multiple schedules are + * collapsed together to create one backup. In such cases, this field captures + * the list of all backup schedule URIs that are associated with creating + * this backup. If collapsing is not done, then this field captures the + * single backup schedule URI associated with creating this backup. + * + * Generated from protobuf field repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + */ + private $backup_schedules; + /** + * Output only. Populated only for backups in an incremental backup chain. + * Backups share the same chain id if and only if they belong to the same + * incremental backup chain. Use this field to determine which backups are + * part of the same incremental backup chain. The ordering of backups in the + * chain can be determined by ordering the backup `version_time`. + * + * Generated from protobuf field string incremental_backup_chain_id = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $incremental_backup_chain_id = ''; + /** + * Output only. Data deleted at a time older than this is guaranteed not to be + * retained in order to support this backup. For a backup in an incremental + * backup chain, this is the version time of the oldest backup that exists or + * ever existed in the chain. For all other backups, this is the version time + * of the backup. This field can be used to understand what data is being + * retained by the backup system. + * + * Generated from protobuf field .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $oldest_version_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $database + * Required for the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * operation. Name of the database from which this backup was created. This + * needs to be in the same instance as the backup. Values are of the form + * `projects//instances//databases/`. + * @type \Google\Protobuf\Timestamp $version_time + * The backup will contain an externally consistent copy of the database at + * the timestamp specified by `version_time`. If `version_time` is not + * specified, the system will set `version_time` to the `create_time` of the + * backup. + * @type \Google\Protobuf\Timestamp $expire_time + * Required for the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * operation. The expiration time of the backup, with microseconds + * granularity that must be at least 6 hours and at most 366 days + * from the time the CreateBackup request is processed. Once the `expire_time` + * has passed, the backup is eligible to be automatically deleted by Cloud + * Spanner to free the resources used by the backup. + * @type string $name + * Output only for the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * operation. Required for the + * [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup] + * operation. + * A globally unique identifier for the backup which cannot be + * changed. Values are of the form + * `projects//instances//backups/[a-z][a-z0-9_\-]*[a-z0-9]` + * The final segment of the name must be between 2 and 60 characters + * in length. + * The backup is stored in the location(s) specified in the instance + * configuration of the instance containing the backup, identified + * by the prefix of the backup name of the form + * `projects//instances/`. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. The time the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * request is received. If the request does not specify `version_time`, the + * `version_time` of the backup will be equivalent to the `create_time`. + * @type int|string $size_bytes + * Output only. Size of the backup in bytes. + * @type int|string $freeable_size_bytes + * Output only. The number of bytes that will be freed by deleting this + * backup. This value will be zero if, for example, this backup is part of an + * incremental backup chain and younger backups in the chain require that we + * keep its data. For backups not in an incremental backup chain, this is + * always the size of the backup. This value may change if backups on the same + * chain get created, deleted or expired. + * @type int|string $exclusive_size_bytes + * Output only. For a backup in an incremental backup chain, this is the + * storage space needed to keep the data that has changed since the previous + * backup. For all other backups, this is always the size of the backup. This + * value may change if backups on the same chain get deleted or expired. + * This field can be used to calculate the total storage space used by a set + * of backups. For example, the total space used by all backups of a database + * can be computed by summing up this field. + * @type int $state + * Output only. The current state of the backup. + * @type array|\Google\Protobuf\Internal\RepeatedField $referencing_databases + * Output only. The names of the restored databases that reference the backup. + * The database names are of + * the form `projects//instances//databases/`. + * Referencing databases may exist in different instances. The existence of + * any referencing database prevents the backup from being deleted. When a + * restored database from the backup enters the `READY` state, the reference + * to the backup is removed. + * @type \Google\Cloud\Spanner\Admin\Database\V1\EncryptionInfo $encryption_info + * Output only. The encryption information for the backup. + * @type array<\Google\Cloud\Spanner\Admin\Database\V1\EncryptionInfo>|\Google\Protobuf\Internal\RepeatedField $encryption_information + * Output only. The encryption information for the backup, whether it is + * protected by one or more KMS keys. The information includes all Cloud + * KMS key versions used to encrypt the backup. The `encryption_status' field + * inside of each `EncryptionInfo` is not populated. At least one of the key + * versions must be available for the backup to be restored. If a key version + * is revoked in the middle of a restore, the restore behavior is undefined. + * @type int $database_dialect + * Output only. The database dialect information for the backup. + * @type array|\Google\Protobuf\Internal\RepeatedField $referencing_backups + * Output only. The names of the destination backups being created by copying + * this source backup. The backup names are of the form + * `projects//instances//backups/`. + * Referencing backups may exist in different instances. The existence of + * any referencing backup prevents the backup from being deleted. When the + * copy operation is done (either successfully completed or cancelled or the + * destination backup is deleted), the reference to the backup is removed. + * @type \Google\Protobuf\Timestamp $max_expire_time + * Output only. The max allowed expiration time of the backup, with + * microseconds granularity. A backup's expiration time can be configured in + * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or + * copying an existing backup, the expiration time specified must be + * less than `Backup.max_expire_time`. + * @type array|\Google\Protobuf\Internal\RepeatedField $backup_schedules + * Output only. List of backup schedule URIs that are associated with + * creating this backup. This is only applicable for scheduled backups, and + * is empty for on-demand backups. + * To optimize for storage, whenever possible, multiple schedules are + * collapsed together to create one backup. In such cases, this field captures + * the list of all backup schedule URIs that are associated with creating + * this backup. If collapsing is not done, then this field captures the + * single backup schedule URI associated with creating this backup. + * @type string $incremental_backup_chain_id + * Output only. Populated only for backups in an incremental backup chain. + * Backups share the same chain id if and only if they belong to the same + * incremental backup chain. Use this field to determine which backups are + * part of the same incremental backup chain. The ordering of backups in the + * chain can be determined by ordering the backup `version_time`. + * @type \Google\Protobuf\Timestamp $oldest_version_time + * Output only. Data deleted at a time older than this is guaranteed not to be + * retained in order to support this backup. For a backup in an incremental + * backup chain, this is the version time of the oldest backup that exists or + * ever existed in the chain. For all other backups, this is the version time + * of the backup. This field can be used to understand what data is being + * retained by the backup system. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Backup::initOnce(); + parent::__construct($data); + } + + /** + * Required for the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * operation. Name of the database from which this backup was created. This + * needs to be in the same instance as the backup. Values are of the form + * `projects//instances//databases/`. + * + * Generated from protobuf field string database = 2 [(.google.api.resource_reference) = { + * @return string + */ + public function getDatabase() + { + return $this->database; + } + + /** + * Required for the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * operation. Name of the database from which this backup was created. This + * needs to be in the same instance as the backup. Values are of the form + * `projects//instances//databases/`. + * + * Generated from protobuf field string database = 2 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setDatabase($var) + { + GPBUtil::checkString($var, True); + $this->database = $var; + + return $this; + } + + /** + * The backup will contain an externally consistent copy of the database at + * the timestamp specified by `version_time`. If `version_time` is not + * specified, the system will set `version_time` to the `create_time` of the + * backup. + * + * Generated from protobuf field .google.protobuf.Timestamp version_time = 9; + * @return \Google\Protobuf\Timestamp|null + */ + public function getVersionTime() + { + return $this->version_time; + } + + public function hasVersionTime() + { + return isset($this->version_time); + } + + public function clearVersionTime() + { + unset($this->version_time); + } + + /** + * The backup will contain an externally consistent copy of the database at + * the timestamp specified by `version_time`. If `version_time` is not + * specified, the system will set `version_time` to the `create_time` of the + * backup. + * + * Generated from protobuf field .google.protobuf.Timestamp version_time = 9; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setVersionTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->version_time = $var; + + return $this; + } + + /** + * Required for the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * operation. The expiration time of the backup, with microseconds + * granularity that must be at least 6 hours and at most 366 days + * from the time the CreateBackup request is processed. Once the `expire_time` + * has passed, the backup is eligible to be automatically deleted by Cloud + * Spanner to free the resources used by the backup. + * + * Generated from protobuf field .google.protobuf.Timestamp expire_time = 3; + * @return \Google\Protobuf\Timestamp|null + */ + public function getExpireTime() + { + return $this->expire_time; + } + + public function hasExpireTime() + { + return isset($this->expire_time); + } + + public function clearExpireTime() + { + unset($this->expire_time); + } + + /** + * Required for the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * operation. The expiration time of the backup, with microseconds + * granularity that must be at least 6 hours and at most 366 days + * from the time the CreateBackup request is processed. Once the `expire_time` + * has passed, the backup is eligible to be automatically deleted by Cloud + * Spanner to free the resources used by the backup. + * + * Generated from protobuf field .google.protobuf.Timestamp expire_time = 3; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setExpireTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->expire_time = $var; + + return $this; + } + + /** + * Output only for the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * operation. Required for the + * [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup] + * operation. + * A globally unique identifier for the backup which cannot be + * changed. Values are of the form + * `projects//instances//backups/[a-z][a-z0-9_\-]*[a-z0-9]` + * The final segment of the name must be between 2 and 60 characters + * in length. + * The backup is stored in the location(s) specified in the instance + * configuration of the instance containing the backup, identified + * by the prefix of the backup name of the form + * `projects//instances/`. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Output only for the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * operation. Required for the + * [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup] + * operation. + * A globally unique identifier for the backup which cannot be + * changed. Values are of the form + * `projects//instances//backups/[a-z][a-z0-9_\-]*[a-z0-9]` + * The final segment of the name must be between 2 and 60 characters + * in length. + * The backup is stored in the location(s) specified in the instance + * configuration of the instance containing the backup, identified + * by the prefix of the backup name of the form + * `projects//instances/`. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Output only. The time the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * request is received. If the request does not specify `version_time`, the + * `version_time` of the backup will be equivalent to the `create_time`. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + + /** + * Output only. The time the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * request is received. If the request does not specify `version_time`, the + * `version_time` of the backup will be equivalent to the `create_time`. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Output only. Size of the backup in bytes. + * + * Generated from protobuf field int64 size_bytes = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int|string + */ + public function getSizeBytes() + { + return $this->size_bytes; + } + + /** + * Output only. Size of the backup in bytes. + * + * Generated from protobuf field int64 size_bytes = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int|string $var + * @return $this + */ + public function setSizeBytes($var) + { + GPBUtil::checkInt64($var); + $this->size_bytes = $var; + + return $this; + } + + /** + * Output only. The number of bytes that will be freed by deleting this + * backup. This value will be zero if, for example, this backup is part of an + * incremental backup chain and younger backups in the chain require that we + * keep its data. For backups not in an incremental backup chain, this is + * always the size of the backup. This value may change if backups on the same + * chain get created, deleted or expired. + * + * Generated from protobuf field int64 freeable_size_bytes = 15 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int|string + */ + public function getFreeableSizeBytes() + { + return $this->freeable_size_bytes; + } + + /** + * Output only. The number of bytes that will be freed by deleting this + * backup. This value will be zero if, for example, this backup is part of an + * incremental backup chain and younger backups in the chain require that we + * keep its data. For backups not in an incremental backup chain, this is + * always the size of the backup. This value may change if backups on the same + * chain get created, deleted or expired. + * + * Generated from protobuf field int64 freeable_size_bytes = 15 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int|string $var + * @return $this + */ + public function setFreeableSizeBytes($var) + { + GPBUtil::checkInt64($var); + $this->freeable_size_bytes = $var; + + return $this; + } + + /** + * Output only. For a backup in an incremental backup chain, this is the + * storage space needed to keep the data that has changed since the previous + * backup. For all other backups, this is always the size of the backup. This + * value may change if backups on the same chain get deleted or expired. + * This field can be used to calculate the total storage space used by a set + * of backups. For example, the total space used by all backups of a database + * can be computed by summing up this field. + * + * Generated from protobuf field int64 exclusive_size_bytes = 16 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int|string + */ + public function getExclusiveSizeBytes() + { + return $this->exclusive_size_bytes; + } + + /** + * Output only. For a backup in an incremental backup chain, this is the + * storage space needed to keep the data that has changed since the previous + * backup. For all other backups, this is always the size of the backup. This + * value may change if backups on the same chain get deleted or expired. + * This field can be used to calculate the total storage space used by a set + * of backups. For example, the total space used by all backups of a database + * can be computed by summing up this field. + * + * Generated from protobuf field int64 exclusive_size_bytes = 16 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int|string $var + * @return $this + */ + public function setExclusiveSizeBytes($var) + { + GPBUtil::checkInt64($var); + $this->exclusive_size_bytes = $var; + + return $this; + } + + /** + * Output only. The current state of the backup. + * + * Generated from protobuf field .google.spanner.admin.database.v1.Backup.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getState() + { + return $this->state; + } + + /** + * Output only. The current state of the backup. + * + * Generated from protobuf field .google.spanner.admin.database.v1.Backup.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setState($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Database\V1\Backup\State::class); + $this->state = $var; + + return $this; + } + + /** + * Output only. The names of the restored databases that reference the backup. + * The database names are of + * the form `projects//instances//databases/`. + * Referencing databases may exist in different instances. The existence of + * any referencing database prevents the backup from being deleted. When a + * restored database from the backup enters the `READY` state, the reference + * to the backup is removed. + * + * Generated from protobuf field repeated string referencing_databases = 7 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getReferencingDatabases() + { + return $this->referencing_databases; + } + + /** + * Output only. The names of the restored databases that reference the backup. + * The database names are of + * the form `projects//instances//databases/`. + * Referencing databases may exist in different instances. The existence of + * any referencing database prevents the backup from being deleted. When a + * restored database from the backup enters the `READY` state, the reference + * to the backup is removed. + * + * Generated from protobuf field repeated string referencing_databases = 7 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setReferencingDatabases($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->referencing_databases = $arr; + + return $this; + } + + /** + * Output only. The encryption information for the backup. + * + * Generated from protobuf field .google.spanner.admin.database.v1.EncryptionInfo encryption_info = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Cloud\Spanner\Admin\Database\V1\EncryptionInfo|null + */ + public function getEncryptionInfo() + { + return $this->encryption_info; + } + + public function hasEncryptionInfo() + { + return isset($this->encryption_info); + } + + public function clearEncryptionInfo() + { + unset($this->encryption_info); + } + + /** + * Output only. The encryption information for the backup. + * + * Generated from protobuf field .google.spanner.admin.database.v1.EncryptionInfo encryption_info = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Cloud\Spanner\Admin\Database\V1\EncryptionInfo $var + * @return $this + */ + public function setEncryptionInfo($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\EncryptionInfo::class); + $this->encryption_info = $var; + + return $this; + } + + /** + * Output only. The encryption information for the backup, whether it is + * protected by one or more KMS keys. The information includes all Cloud + * KMS key versions used to encrypt the backup. The `encryption_status' field + * inside of each `EncryptionInfo` is not populated. At least one of the key + * versions must be available for the backup to be restored. If a key version + * is revoked in the middle of a restore, the restore behavior is undefined. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.EncryptionInfo encryption_information = 13 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getEncryptionInformation() + { + return $this->encryption_information; + } + + /** + * Output only. The encryption information for the backup, whether it is + * protected by one or more KMS keys. The information includes all Cloud + * KMS key versions used to encrypt the backup. The `encryption_status' field + * inside of each `EncryptionInfo` is not populated. At least one of the key + * versions must be available for the backup to be restored. If a key version + * is revoked in the middle of a restore, the restore behavior is undefined. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.EncryptionInfo encryption_information = 13 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param array<\Google\Cloud\Spanner\Admin\Database\V1\EncryptionInfo>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setEncryptionInformation($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\Admin\Database\V1\EncryptionInfo::class); + $this->encryption_information = $arr; + + return $this; + } + + /** + * Output only. The database dialect information for the backup. + * + * Generated from protobuf field .google.spanner.admin.database.v1.DatabaseDialect database_dialect = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getDatabaseDialect() + { + return $this->database_dialect; + } + + /** + * Output only. The database dialect information for the backup. + * + * Generated from protobuf field .google.spanner.admin.database.v1.DatabaseDialect database_dialect = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setDatabaseDialect($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Database\V1\DatabaseDialect::class); + $this->database_dialect = $var; + + return $this; + } + + /** + * Output only. The names of the destination backups being created by copying + * this source backup. The backup names are of the form + * `projects//instances//backups/`. + * Referencing backups may exist in different instances. The existence of + * any referencing backup prevents the backup from being deleted. When the + * copy operation is done (either successfully completed or cancelled or the + * destination backup is deleted), the reference to the backup is removed. + * + * Generated from protobuf field repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getReferencingBackups() + { + return $this->referencing_backups; + } + + /** + * Output only. The names of the destination backups being created by copying + * this source backup. The backup names are of the form + * `projects//instances//backups/`. + * Referencing backups may exist in different instances. The existence of + * any referencing backup prevents the backup from being deleted. When the + * copy operation is done (either successfully completed or cancelled or the + * destination backup is deleted), the reference to the backup is removed. + * + * Generated from protobuf field repeated string referencing_backups = 11 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setReferencingBackups($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->referencing_backups = $arr; + + return $this; + } + + /** + * Output only. The max allowed expiration time of the backup, with + * microseconds granularity. A backup's expiration time can be configured in + * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or + * copying an existing backup, the expiration time specified must be + * less than `Backup.max_expire_time`. + * + * Generated from protobuf field .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getMaxExpireTime() + { + return $this->max_expire_time; + } + + public function hasMaxExpireTime() + { + return isset($this->max_expire_time); + } + + public function clearMaxExpireTime() + { + unset($this->max_expire_time); + } + + /** + * Output only. The max allowed expiration time of the backup, with + * microseconds granularity. A backup's expiration time can be configured in + * multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or + * copying an existing backup, the expiration time specified must be + * less than `Backup.max_expire_time`. + * + * Generated from protobuf field .google.protobuf.Timestamp max_expire_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setMaxExpireTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->max_expire_time = $var; + + return $this; + } + + /** + * Output only. List of backup schedule URIs that are associated with + * creating this backup. This is only applicable for scheduled backups, and + * is empty for on-demand backups. + * To optimize for storage, whenever possible, multiple schedules are + * collapsed together to create one backup. In such cases, this field captures + * the list of all backup schedule URIs that are associated with creating + * this backup. If collapsing is not done, then this field captures the + * single backup schedule URI associated with creating this backup. + * + * Generated from protobuf field repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getBackupSchedules() + { + return $this->backup_schedules; + } + + /** + * Output only. List of backup schedule URIs that are associated with + * creating this backup. This is only applicable for scheduled backups, and + * is empty for on-demand backups. + * To optimize for storage, whenever possible, multiple schedules are + * collapsed together to create one backup. In such cases, this field captures + * the list of all backup schedule URIs that are associated with creating + * this backup. If collapsing is not done, then this field captures the + * single backup schedule URI associated with creating this backup. + * + * Generated from protobuf field repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setBackupSchedules($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->backup_schedules = $arr; + + return $this; + } + + /** + * Output only. Populated only for backups in an incremental backup chain. + * Backups share the same chain id if and only if they belong to the same + * incremental backup chain. Use this field to determine which backups are + * part of the same incremental backup chain. The ordering of backups in the + * chain can be determined by ordering the backup `version_time`. + * + * Generated from protobuf field string incremental_backup_chain_id = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getIncrementalBackupChainId() + { + return $this->incremental_backup_chain_id; + } + + /** + * Output only. Populated only for backups in an incremental backup chain. + * Backups share the same chain id if and only if they belong to the same + * incremental backup chain. Use this field to determine which backups are + * part of the same incremental backup chain. The ordering of backups in the + * chain can be determined by ordering the backup `version_time`. + * + * Generated from protobuf field string incremental_backup_chain_id = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setIncrementalBackupChainId($var) + { + GPBUtil::checkString($var, True); + $this->incremental_backup_chain_id = $var; + + return $this; + } + + /** + * Output only. Data deleted at a time older than this is guaranteed not to be + * retained in order to support this backup. For a backup in an incremental + * backup chain, this is the version time of the oldest backup that exists or + * ever existed in the chain. For all other backups, this is the version time + * of the backup. This field can be used to understand what data is being + * retained by the backup system. + * + * Generated from protobuf field .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getOldestVersionTime() + { + return $this->oldest_version_time; + } + + public function hasOldestVersionTime() + { + return isset($this->oldest_version_time); + } + + public function clearOldestVersionTime() + { + unset($this->oldest_version_time); + } + + /** + * Output only. Data deleted at a time older than this is guaranteed not to be + * retained in order to support this backup. For a backup in an incremental + * backup chain, this is the version time of the oldest backup that exists or + * ever existed in the chain. For all other backups, this is the version time + * of the backup. This field can be used to understand what data is being + * retained by the backup system. + * + * Generated from protobuf field .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setOldestVersionTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->oldest_version_time = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/Backup/State.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/Backup/State.php new file mode 100644 index 000000000000..18d79b35ac2d --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/Backup/State.php @@ -0,0 +1,65 @@ +google.spanner.admin.database.v1.Backup.State + */ +class State +{ + /** + * Not specified. + * + * Generated from protobuf enum STATE_UNSPECIFIED = 0; + */ + const STATE_UNSPECIFIED = 0; + /** + * The pending backup is still being created. Operations on the + * backup may fail with `FAILED_PRECONDITION` in this state. + * + * Generated from protobuf enum CREATING = 1; + */ + const CREATING = 1; + /** + * The backup is complete and ready for use. + * + * Generated from protobuf enum READY = 2; + */ + const READY = 2; + + private static $valueToName = [ + self::STATE_UNSPECIFIED => 'STATE_UNSPECIFIED', + self::CREATING => 'CREATING', + self::READY => 'READY', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(State::class, \Google\Cloud\Spanner\Admin\Database\V1\Backup_State::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/BackupInfo.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/BackupInfo.php new file mode 100644 index 000000000000..301cdec6653a --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/BackupInfo.php @@ -0,0 +1,213 @@ +google.spanner.admin.database.v1.BackupInfo + */ +class BackupInfo extends \Google\Protobuf\Internal\Message +{ + /** + * Name of the backup. + * + * Generated from protobuf field string backup = 1 [(.google.api.resource_reference) = { + */ + protected $backup = ''; + /** + * The backup contains an externally consistent copy of `source_database` at + * the timestamp specified by `version_time`. If the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * request did not specify `version_time`, the `version_time` of the backup is + * equivalent to the `create_time`. + * + * Generated from protobuf field .google.protobuf.Timestamp version_time = 4; + */ + protected $version_time = null; + /** + * The time the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 2; + */ + protected $create_time = null; + /** + * Name of the database the backup was created from. + * + * Generated from protobuf field string source_database = 3 [(.google.api.resource_reference) = { + */ + protected $source_database = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $backup + * Name of the backup. + * @type \Google\Protobuf\Timestamp $version_time + * The backup contains an externally consistent copy of `source_database` at + * the timestamp specified by `version_time`. If the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * request did not specify `version_time`, the `version_time` of the backup is + * equivalent to the `create_time`. + * @type \Google\Protobuf\Timestamp $create_time + * The time the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * request was received. + * @type string $source_database + * Name of the database the backup was created from. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Backup::initOnce(); + parent::__construct($data); + } + + /** + * Name of the backup. + * + * Generated from protobuf field string backup = 1 [(.google.api.resource_reference) = { + * @return string + */ + public function getBackup() + { + return $this->backup; + } + + /** + * Name of the backup. + * + * Generated from protobuf field string backup = 1 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setBackup($var) + { + GPBUtil::checkString($var, True); + $this->backup = $var; + + return $this; + } + + /** + * The backup contains an externally consistent copy of `source_database` at + * the timestamp specified by `version_time`. If the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * request did not specify `version_time`, the `version_time` of the backup is + * equivalent to the `create_time`. + * + * Generated from protobuf field .google.protobuf.Timestamp version_time = 4; + * @return \Google\Protobuf\Timestamp|null + */ + public function getVersionTime() + { + return $this->version_time; + } + + public function hasVersionTime() + { + return isset($this->version_time); + } + + public function clearVersionTime() + { + unset($this->version_time); + } + + /** + * The backup contains an externally consistent copy of `source_database` at + * the timestamp specified by `version_time`. If the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * request did not specify `version_time`, the `version_time` of the backup is + * equivalent to the `create_time`. + * + * Generated from protobuf field .google.protobuf.Timestamp version_time = 4; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setVersionTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->version_time = $var; + + return $this; + } + + /** + * The time the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 2; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + + /** + * The time the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 2; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Name of the database the backup was created from. + * + * Generated from protobuf field string source_database = 3 [(.google.api.resource_reference) = { + * @return string + */ + public function getSourceDatabase() + { + return $this->source_database; + } + + /** + * Name of the database the backup was created from. + * + * Generated from protobuf field string source_database = 3 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setSourceDatabase($var) + { + GPBUtil::checkString($var, True); + $this->source_database = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/BackupSchedule.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/BackupSchedule.php new file mode 100644 index 000000000000..4e438c2b75a1 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/BackupSchedule.php @@ -0,0 +1,380 @@ +google.spanner.admin.database.v1.BackupSchedule + */ +class BackupSchedule extends \Google\Protobuf\Internal\Message +{ + /** + * Identifier. Output only for the + * [CreateBackupSchedule][DatabaseAdmin.CreateBackupSchededule] operation. + * Required for the + * [UpdateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule] + * operation. A globally unique identifier for the backup schedule which + * cannot be changed. Values are of the form + * `projects//instances//databases//backupSchedules/[a-z][a-z0-9_\-]*[a-z0-9]` + * The final segment of the name must be between 2 and 60 characters in + * length. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + */ + protected $name = ''; + /** + * Optional. The schedule specification based on which the backup creations + * are triggered. + * + * Generated from protobuf field .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $spec = null; + /** + * Optional. The retention duration of a backup that must be at least 6 hours + * and at most 366 days. The backup is eligible to be automatically deleted + * once the retention period has elapsed. + * + * Generated from protobuf field .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $retention_duration = null; + /** + * Optional. The encryption configuration that will be used to encrypt the + * backup. If this field is not specified, the backup will use the same + * encryption configuration as the database. + * + * Generated from protobuf field .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $encryption_config = null; + /** + * Output only. The timestamp at which the schedule was last updated. + * If the schedule has never been updated, this field contains the timestamp + * when the schedule was first created. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $update_time = null; + protected $backup_type_spec; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Identifier. Output only for the + * [CreateBackupSchedule][DatabaseAdmin.CreateBackupSchededule] operation. + * Required for the + * [UpdateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule] + * operation. A globally unique identifier for the backup schedule which + * cannot be changed. Values are of the form + * `projects//instances//databases//backupSchedules/[a-z][a-z0-9_\-]*[a-z0-9]` + * The final segment of the name must be between 2 and 60 characters in + * length. + * @type \Google\Cloud\Spanner\Admin\Database\V1\BackupScheduleSpec $spec + * Optional. The schedule specification based on which the backup creations + * are triggered. + * @type \Google\Protobuf\Duration $retention_duration + * Optional. The retention duration of a backup that must be at least 6 hours + * and at most 366 days. The backup is eligible to be automatically deleted + * once the retention period has elapsed. + * @type \Google\Cloud\Spanner\Admin\Database\V1\CreateBackupEncryptionConfig $encryption_config + * Optional. The encryption configuration that will be used to encrypt the + * backup. If this field is not specified, the backup will use the same + * encryption configuration as the database. + * @type \Google\Cloud\Spanner\Admin\Database\V1\FullBackupSpec $full_backup_spec + * The schedule creates only full backups. + * @type \Google\Cloud\Spanner\Admin\Database\V1\IncrementalBackupSpec $incremental_backup_spec + * The schedule creates incremental backup chains. + * @type \Google\Protobuf\Timestamp $update_time + * Output only. The timestamp at which the schedule was last updated. + * If the schedule has never been updated, this field contains the timestamp + * when the schedule was first created. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\BackupSchedule::initOnce(); + parent::__construct($data); + } + + /** + * Identifier. Output only for the + * [CreateBackupSchedule][DatabaseAdmin.CreateBackupSchededule] operation. + * Required for the + * [UpdateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule] + * operation. A globally unique identifier for the backup schedule which + * cannot be changed. Values are of the form + * `projects//instances//databases//backupSchedules/[a-z][a-z0-9_\-]*[a-z0-9]` + * The final segment of the name must be between 2 and 60 characters in + * length. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Identifier. Output only for the + * [CreateBackupSchedule][DatabaseAdmin.CreateBackupSchededule] operation. + * Required for the + * [UpdateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule] + * operation. A globally unique identifier for the backup schedule which + * cannot be changed. Values are of the form + * `projects//instances//databases//backupSchedules/[a-z][a-z0-9_\-]*[a-z0-9]` + * The final segment of the name must be between 2 and 60 characters in + * length. + * + * 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. The schedule specification based on which the backup creations + * are triggered. + * + * Generated from protobuf field .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Spanner\Admin\Database\V1\BackupScheduleSpec|null + */ + public function getSpec() + { + return $this->spec; + } + + public function hasSpec() + { + return isset($this->spec); + } + + public function clearSpec() + { + unset($this->spec); + } + + /** + * Optional. The schedule specification based on which the backup creations + * are triggered. + * + * Generated from protobuf field .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Spanner\Admin\Database\V1\BackupScheduleSpec $var + * @return $this + */ + public function setSpec($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\BackupScheduleSpec::class); + $this->spec = $var; + + return $this; + } + + /** + * Optional. The retention duration of a backup that must be at least 6 hours + * and at most 366 days. The backup is eligible to be automatically deleted + * once the retention period has elapsed. + * + * Generated from protobuf field .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Duration|null + */ + public function getRetentionDuration() + { + return $this->retention_duration; + } + + public function hasRetentionDuration() + { + return isset($this->retention_duration); + } + + public function clearRetentionDuration() + { + unset($this->retention_duration); + } + + /** + * Optional. The retention duration of a backup that must be at least 6 hours + * and at most 366 days. The backup is eligible to be automatically deleted + * once the retention period has elapsed. + * + * Generated from protobuf field .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setRetentionDuration($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->retention_duration = $var; + + return $this; + } + + /** + * Optional. The encryption configuration that will be used to encrypt the + * backup. If this field is not specified, the backup will use the same + * encryption configuration as the database. + * + * Generated from protobuf field .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Spanner\Admin\Database\V1\CreateBackupEncryptionConfig|null + */ + public function getEncryptionConfig() + { + return $this->encryption_config; + } + + public function hasEncryptionConfig() + { + return isset($this->encryption_config); + } + + public function clearEncryptionConfig() + { + unset($this->encryption_config); + } + + /** + * Optional. The encryption configuration that will be used to encrypt the + * backup. If this field is not specified, the backup will use the same + * encryption configuration as the database. + * + * Generated from protobuf field .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Spanner\Admin\Database\V1\CreateBackupEncryptionConfig $var + * @return $this + */ + public function setEncryptionConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\CreateBackupEncryptionConfig::class); + $this->encryption_config = $var; + + return $this; + } + + /** + * The schedule creates only full backups. + * + * Generated from protobuf field .google.spanner.admin.database.v1.FullBackupSpec full_backup_spec = 7; + * @return \Google\Cloud\Spanner\Admin\Database\V1\FullBackupSpec|null + */ + public function getFullBackupSpec() + { + return $this->readOneof(7); + } + + public function hasFullBackupSpec() + { + return $this->hasOneof(7); + } + + /** + * The schedule creates only full backups. + * + * Generated from protobuf field .google.spanner.admin.database.v1.FullBackupSpec full_backup_spec = 7; + * @param \Google\Cloud\Spanner\Admin\Database\V1\FullBackupSpec $var + * @return $this + */ + public function setFullBackupSpec($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\FullBackupSpec::class); + $this->writeOneof(7, $var); + + return $this; + } + + /** + * The schedule creates incremental backup chains. + * + * Generated from protobuf field .google.spanner.admin.database.v1.IncrementalBackupSpec incremental_backup_spec = 8; + * @return \Google\Cloud\Spanner\Admin\Database\V1\IncrementalBackupSpec|null + */ + public function getIncrementalBackupSpec() + { + return $this->readOneof(8); + } + + public function hasIncrementalBackupSpec() + { + return $this->hasOneof(8); + } + + /** + * The schedule creates incremental backup chains. + * + * Generated from protobuf field .google.spanner.admin.database.v1.IncrementalBackupSpec incremental_backup_spec = 8; + * @param \Google\Cloud\Spanner\Admin\Database\V1\IncrementalBackupSpec $var + * @return $this + */ + public function setIncrementalBackupSpec($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\IncrementalBackupSpec::class); + $this->writeOneof(8, $var); + + return $this; + } + + /** + * Output only. The timestamp at which the schedule was last updated. + * If the schedule has never been updated, this field contains the timestamp + * when the schedule was first created. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getUpdateTime() + { + return $this->update_time; + } + + public function hasUpdateTime() + { + return isset($this->update_time); + } + + public function clearUpdateTime() + { + unset($this->update_time); + } + + /** + * Output only. The timestamp at which the schedule was last updated. + * If the schedule has never been updated, this field contains the timestamp + * when the schedule was first created. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + + /** + * @return string + */ + public function getBackupTypeSpec() + { + return $this->whichOneof("backup_type_spec"); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/BackupScheduleSpec.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/BackupScheduleSpec.php new file mode 100644 index 000000000000..b78eef7af97d --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/BackupScheduleSpec.php @@ -0,0 +1,75 @@ +google.spanner.admin.database.v1.BackupScheduleSpec + */ +class BackupScheduleSpec extends \Google\Protobuf\Internal\Message +{ + protected $schedule_spec; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Database\V1\CrontabSpec $cron_spec + * Cron style schedule specification. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\BackupSchedule::initOnce(); + parent::__construct($data); + } + + /** + * Cron style schedule specification. + * + * Generated from protobuf field .google.spanner.admin.database.v1.CrontabSpec cron_spec = 1; + * @return \Google\Cloud\Spanner\Admin\Database\V1\CrontabSpec|null + */ + public function getCronSpec() + { + return $this->readOneof(1); + } + + public function hasCronSpec() + { + return $this->hasOneof(1); + } + + /** + * Cron style schedule specification. + * + * Generated from protobuf field .google.spanner.admin.database.v1.CrontabSpec cron_spec = 1; + * @param \Google\Cloud\Spanner\Admin\Database\V1\CrontabSpec $var + * @return $this + */ + public function setCronSpec($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\CrontabSpec::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * @return string + */ + public function getScheduleSpec() + { + return $this->whichOneof("schedule_spec"); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CopyBackupEncryptionConfig.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CopyBackupEncryptionConfig.php new file mode 100644 index 000000000000..07325d77c3d1 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CopyBackupEncryptionConfig.php @@ -0,0 +1,207 @@ +google.spanner.admin.database.v1.CopyBackupEncryptionConfig + */ +class CopyBackupEncryptionConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The encryption type of the backup. + * + * Generated from protobuf field .google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $encryption_type = 0; + /** + * Optional. The Cloud KMS key that will be used to protect the backup. + * This field should be set only when + * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] + * is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * + * Generated from protobuf field string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + protected $kms_key_name = ''; + /** + * Optional. Specifies the KMS configuration for the one or more keys used to + * protect the backup. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * Kms keys specified can be in any order. + * The keys referenced by kms_key_names must fully cover all + * regions of the backup's instance configuration. Some examples: + * * For single region instance configs, specify a single regional + * location KMS key. + * * For multi-regional instance configs of type GOOGLE_MANAGED, + * either specify a multi-regional location KMS key or multiple regional + * location KMS keys that cover all regions in the instance config. + * * For an instance config of type USER_MANAGED, please specify only + * regional location KMS keys to cover each region in the instance config. + * Multi-regional location KMS keys are not supported for USER_MANAGED + * instance configs. + * + * Generated from protobuf field repeated string kms_key_names = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + private $kms_key_names; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $encryption_type + * Required. The encryption type of the backup. + * @type string $kms_key_name + * Optional. The Cloud KMS key that will be used to protect the backup. + * This field should be set only when + * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] + * is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * @type array|\Google\Protobuf\Internal\RepeatedField $kms_key_names + * Optional. Specifies the KMS configuration for the one or more keys used to + * protect the backup. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * Kms keys specified can be in any order. + * The keys referenced by kms_key_names must fully cover all + * regions of the backup's instance configuration. Some examples: + * * For single region instance configs, specify a single regional + * location KMS key. + * * For multi-regional instance configs of type GOOGLE_MANAGED, + * either specify a multi-regional location KMS key or multiple regional + * location KMS keys that cover all regions in the instance config. + * * For an instance config of type USER_MANAGED, please specify only + * regional location KMS keys to cover each region in the instance config. + * Multi-regional location KMS keys are not supported for USER_MANAGED + * instance configs. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Backup::initOnce(); + parent::__construct($data); + } + + /** + * Required. The encryption type of the backup. + * + * Generated from protobuf field .google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return int + */ + public function getEncryptionType() + { + return $this->encryption_type; + } + + /** + * Required. The encryption type of the backup. + * + * Generated from protobuf field .google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param int $var + * @return $this + */ + public function setEncryptionType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Database\V1\CopyBackupEncryptionConfig\EncryptionType::class); + $this->encryption_type = $var; + + return $this; + } + + /** + * Optional. The Cloud KMS key that will be used to protect the backup. + * This field should be set only when + * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] + * is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * + * Generated from protobuf field string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return string + */ + public function getKmsKeyName() + { + return $this->kms_key_name; + } + + /** + * Optional. The Cloud KMS key that will be used to protect the backup. + * This field should be set only when + * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] + * is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * + * Generated from protobuf field string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setKmsKeyName($var) + { + GPBUtil::checkString($var, True); + $this->kms_key_name = $var; + + return $this; + } + + /** + * Optional. Specifies the KMS configuration for the one or more keys used to + * protect the backup. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * Kms keys specified can be in any order. + * The keys referenced by kms_key_names must fully cover all + * regions of the backup's instance configuration. Some examples: + * * For single region instance configs, specify a single regional + * location KMS key. + * * For multi-regional instance configs of type GOOGLE_MANAGED, + * either specify a multi-regional location KMS key or multiple regional + * location KMS keys that cover all regions in the instance config. + * * For an instance config of type USER_MANAGED, please specify only + * regional location KMS keys to cover each region in the instance config. + * Multi-regional location KMS keys are not supported for USER_MANAGED + * instance configs. + * + * Generated from protobuf field repeated string kms_key_names = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getKmsKeyNames() + { + return $this->kms_key_names; + } + + /** + * Optional. Specifies the KMS configuration for the one or more keys used to + * protect the backup. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * Kms keys specified can be in any order. + * The keys referenced by kms_key_names must fully cover all + * regions of the backup's instance configuration. Some examples: + * * For single region instance configs, specify a single regional + * location KMS key. + * * For multi-regional instance configs of type GOOGLE_MANAGED, + * either specify a multi-regional location KMS key or multiple regional + * location KMS keys that cover all regions in the instance config. + * * For an instance config of type USER_MANAGED, please specify only + * regional location KMS keys to cover each region in the instance config. + * Multi-regional location KMS keys are not supported for USER_MANAGED + * instance configs. + * + * Generated from protobuf field repeated string kms_key_names = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setKmsKeyNames($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->kms_key_names = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CopyBackupEncryptionConfig/EncryptionType.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CopyBackupEncryptionConfig/EncryptionType.php new file mode 100644 index 000000000000..56fa3e3beb2b --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CopyBackupEncryptionConfig/EncryptionType.php @@ -0,0 +1,78 @@ +google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType + */ +class EncryptionType +{ + /** + * Unspecified. Do not use. + * + * Generated from protobuf enum ENCRYPTION_TYPE_UNSPECIFIED = 0; + */ + const ENCRYPTION_TYPE_UNSPECIFIED = 0; + /** + * This is the default option for + * [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup] + * when + * [encryption_config][google.spanner.admin.database.v1.CopyBackupEncryptionConfig] + * is not specified. For example, if the source backup is using + * `Customer_Managed_Encryption`, the backup will be using the same Cloud + * KMS key as the source backup. + * + * Generated from protobuf enum USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION = 1; + */ + const USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION = 1; + /** + * Use Google default encryption. + * + * Generated from protobuf enum GOOGLE_DEFAULT_ENCRYPTION = 2; + */ + const GOOGLE_DEFAULT_ENCRYPTION = 2; + /** + * Use customer managed encryption. If specified, either `kms_key_name` or + * `kms_key_names` must contain valid Cloud KMS key(s). + * + * Generated from protobuf enum CUSTOMER_MANAGED_ENCRYPTION = 3; + */ + const CUSTOMER_MANAGED_ENCRYPTION = 3; + + private static $valueToName = [ + self::ENCRYPTION_TYPE_UNSPECIFIED => 'ENCRYPTION_TYPE_UNSPECIFIED', + self::USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION => 'USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION', + self::GOOGLE_DEFAULT_ENCRYPTION => 'GOOGLE_DEFAULT_ENCRYPTION', + self::CUSTOMER_MANAGED_ENCRYPTION => 'CUSTOMER_MANAGED_ENCRYPTION', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(EncryptionType::class, \Google\Cloud\Spanner\Admin\Database\V1\CopyBackupEncryptionConfig_EncryptionType::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CopyBackupMetadata.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CopyBackupMetadata.php new file mode 100644 index 000000000000..833787dae626 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CopyBackupMetadata.php @@ -0,0 +1,258 @@ +google.spanner.admin.database.v1.CopyBackupMetadata + */ +class CopyBackupMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * The name of the backup being created through the copy operation. + * Values are of the form + * `projects//instances//backups/`. + * + * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { + */ + protected $name = ''; + /** + * The name of the source backup that is being copied. + * Values are of the form + * `projects//instances//backups/`. + * + * Generated from protobuf field string source_backup = 2 [(.google.api.resource_reference) = { + */ + protected $source_backup = ''; + /** + * The progress of the + * [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup] + * operation. + * + * Generated from protobuf field .google.spanner.admin.database.v1.OperationProgress progress = 3; + */ + protected $progress = null; + /** + * The time at which cancellation of CopyBackup operation was received. + * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + * starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not guaranteed. + * Clients can use + * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an [Operation.error][google.longrunning.Operation.error] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, + * corresponding to `Code.CANCELLED`. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 4; + */ + protected $cancel_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * The name of the backup being created through the copy operation. + * Values are of the form + * `projects//instances//backups/`. + * @type string $source_backup + * The name of the source backup that is being copied. + * Values are of the form + * `projects//instances//backups/`. + * @type \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress $progress + * The progress of the + * [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup] + * operation. + * @type \Google\Protobuf\Timestamp $cancel_time + * The time at which cancellation of CopyBackup operation was received. + * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + * starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not guaranteed. + * Clients can use + * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an [Operation.error][google.longrunning.Operation.error] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, + * corresponding to `Code.CANCELLED`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Backup::initOnce(); + parent::__construct($data); + } + + /** + * The name of the backup being created through the copy operation. + * Values are of the form + * `projects//instances//backups/`. + * + * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The name of the backup being created through the copy operation. + * Values are of the form + * `projects//instances//backups/`. + * + * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * The name of the source backup that is being copied. + * Values are of the form + * `projects//instances//backups/`. + * + * Generated from protobuf field string source_backup = 2 [(.google.api.resource_reference) = { + * @return string + */ + public function getSourceBackup() + { + return $this->source_backup; + } + + /** + * The name of the source backup that is being copied. + * Values are of the form + * `projects//instances//backups/`. + * + * Generated from protobuf field string source_backup = 2 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setSourceBackup($var) + { + GPBUtil::checkString($var, True); + $this->source_backup = $var; + + return $this; + } + + /** + * The progress of the + * [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup] + * operation. + * + * Generated from protobuf field .google.spanner.admin.database.v1.OperationProgress progress = 3; + * @return \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress|null + */ + public function getProgress() + { + return $this->progress; + } + + public function hasProgress() + { + return isset($this->progress); + } + + public function clearProgress() + { + unset($this->progress); + } + + /** + * The progress of the + * [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup] + * operation. + * + * Generated from protobuf field .google.spanner.admin.database.v1.OperationProgress progress = 3; + * @param \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress $var + * @return $this + */ + public function setProgress($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress::class); + $this->progress = $var; + + return $this; + } + + /** + * The time at which cancellation of CopyBackup operation was received. + * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + * starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not guaranteed. + * Clients can use + * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an [Operation.error][google.longrunning.Operation.error] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, + * corresponding to `Code.CANCELLED`. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 4; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCancelTime() + { + return $this->cancel_time; + } + + public function hasCancelTime() + { + return isset($this->cancel_time); + } + + public function clearCancelTime() + { + unset($this->cancel_time); + } + + /** + * The time at which cancellation of CopyBackup operation was received. + * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + * starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not guaranteed. + * Clients can use + * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an [Operation.error][google.longrunning.Operation.error] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, + * corresponding to `Code.CANCELLED`. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 4; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCancelTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->cancel_time = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CopyBackupRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CopyBackupRequest.php new file mode 100644 index 000000000000..8a80683e54fa --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CopyBackupRequest.php @@ -0,0 +1,321 @@ +google.spanner.admin.database.v1.CopyBackupRequest + */ +class CopyBackupRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the destination instance that will contain the backup + * copy. Values are of the form: `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. The id of the backup copy. + * The `backup_id` appended to `parent` forms the full backup_uri of the form + * `projects//instances//backups/`. + * + * Generated from protobuf field string backup_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $backup_id = ''; + /** + * Required. The source backup to be copied. + * The source backup needs to be in READY state for it to be copied. + * Once CopyBackup is in progress, the source backup cannot be deleted or + * cleaned up on expiration until CopyBackup is finished. + * Values are of the form: + * `projects//instances//backups/`. + * + * Generated from protobuf field string source_backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $source_backup = ''; + /** + * Required. The expiration time of the backup in microsecond granularity. + * The expiration time must be at least 6 hours and at most 366 days + * from the `create_time` of the source backup. Once the `expire_time` has + * passed, the backup is eligible to be automatically deleted by Cloud Spanner + * to free the resources used by the backup. + * + * Generated from protobuf field .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $expire_time = null; + /** + * Optional. The encryption configuration used to encrypt the backup. If this + * field is not specified, the backup will use the same encryption + * configuration as the source backup by default, namely + * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] + * = `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. + * + * Generated from protobuf field .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $encryption_config = null; + + /** + * @param string $parent Required. The name of the destination instance that will contain the backup + * copy. Values are of the form: `projects//instances/`. Please see + * {@see DatabaseAdminClient::instanceName()} for help formatting this field. + * @param string $backupId Required. The id of the backup copy. + * The `backup_id` appended to `parent` forms the full backup_uri of the form + * `projects//instances//backups/`. + * @param string $sourceBackup Required. The source backup to be copied. + * The source backup needs to be in READY state for it to be copied. + * Once CopyBackup is in progress, the source backup cannot be deleted or + * cleaned up on expiration until CopyBackup is finished. + * Values are of the form: + * `projects//instances//backups/`. Please see + * {@see DatabaseAdminClient::backupName()} for help formatting this field. + * @param \Google\Protobuf\Timestamp $expireTime Required. The expiration time of the backup in microsecond granularity. + * The expiration time must be at least 6 hours and at most 366 days + * from the `create_time` of the source backup. Once the `expire_time` has + * passed, the backup is eligible to be automatically deleted by Cloud Spanner + * to free the resources used by the backup. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\CopyBackupRequest + * + * @experimental + */ + public static function build(string $parent, string $backupId, string $sourceBackup, \Google\Protobuf\Timestamp $expireTime): self + { + return (new self()) + ->setParent($parent) + ->setBackupId($backupId) + ->setSourceBackup($sourceBackup) + ->setExpireTime($expireTime); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The name of the destination instance that will contain the backup + * copy. Values are of the form: `projects//instances/`. + * @type string $backup_id + * Required. The id of the backup copy. + * The `backup_id` appended to `parent` forms the full backup_uri of the form + * `projects//instances//backups/`. + * @type string $source_backup + * Required. The source backup to be copied. + * The source backup needs to be in READY state for it to be copied. + * Once CopyBackup is in progress, the source backup cannot be deleted or + * cleaned up on expiration until CopyBackup is finished. + * Values are of the form: + * `projects//instances//backups/`. + * @type \Google\Protobuf\Timestamp $expire_time + * Required. The expiration time of the backup in microsecond granularity. + * The expiration time must be at least 6 hours and at most 366 days + * from the `create_time` of the source backup. Once the `expire_time` has + * passed, the backup is eligible to be automatically deleted by Cloud Spanner + * to free the resources used by the backup. + * @type \Google\Cloud\Spanner\Admin\Database\V1\CopyBackupEncryptionConfig $encryption_config + * Optional. The encryption configuration used to encrypt the backup. If this + * field is not specified, the backup will use the same encryption + * configuration as the source backup by default, namely + * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] + * = `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Backup::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the destination instance that will contain the backup + * copy. Values are of the form: `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The name of the destination instance that will contain the backup + * copy. Values are of the form: `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Required. The id of the backup copy. + * The `backup_id` appended to `parent` forms the full backup_uri of the form + * `projects//instances//backups/`. + * + * Generated from protobuf field string backup_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getBackupId() + { + return $this->backup_id; + } + + /** + * Required. The id of the backup copy. + * The `backup_id` appended to `parent` forms the full backup_uri of the form + * `projects//instances//backups/`. + * + * Generated from protobuf field string backup_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setBackupId($var) + { + GPBUtil::checkString($var, True); + $this->backup_id = $var; + + return $this; + } + + /** + * Required. The source backup to be copied. + * The source backup needs to be in READY state for it to be copied. + * Once CopyBackup is in progress, the source backup cannot be deleted or + * cleaned up on expiration until CopyBackup is finished. + * Values are of the form: + * `projects//instances//backups/`. + * + * Generated from protobuf field string source_backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getSourceBackup() + { + return $this->source_backup; + } + + /** + * Required. The source backup to be copied. + * The source backup needs to be in READY state for it to be copied. + * Once CopyBackup is in progress, the source backup cannot be deleted or + * cleaned up on expiration until CopyBackup is finished. + * Values are of the form: + * `projects//instances//backups/`. + * + * Generated from protobuf field string source_backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setSourceBackup($var) + { + GPBUtil::checkString($var, True); + $this->source_backup = $var; + + return $this; + } + + /** + * Required. The expiration time of the backup in microsecond granularity. + * The expiration time must be at least 6 hours and at most 366 days + * from the `create_time` of the source backup. Once the `expire_time` has + * passed, the backup is eligible to be automatically deleted by Cloud Spanner + * to free the resources used by the backup. + * + * Generated from protobuf field .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getExpireTime() + { + return $this->expire_time; + } + + public function hasExpireTime() + { + return isset($this->expire_time); + } + + public function clearExpireTime() + { + unset($this->expire_time); + } + + /** + * Required. The expiration time of the backup in microsecond granularity. + * The expiration time must be at least 6 hours and at most 366 days + * from the `create_time` of the source backup. Once the `expire_time` has + * passed, the backup is eligible to be automatically deleted by Cloud Spanner + * to free the resources used by the backup. + * + * Generated from protobuf field .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setExpireTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->expire_time = $var; + + return $this; + } + + /** + * Optional. The encryption configuration used to encrypt the backup. If this + * field is not specified, the backup will use the same encryption + * configuration as the source backup by default, namely + * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] + * = `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. + * + * Generated from protobuf field .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Spanner\Admin\Database\V1\CopyBackupEncryptionConfig|null + */ + public function getEncryptionConfig() + { + return $this->encryption_config; + } + + public function hasEncryptionConfig() + { + return isset($this->encryption_config); + } + + public function clearEncryptionConfig() + { + unset($this->encryption_config); + } + + /** + * Optional. The encryption configuration used to encrypt the backup. If this + * field is not specified, the backup will use the same encryption + * configuration as the source backup by default, namely + * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] + * = `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. + * + * Generated from protobuf field .google.spanner.admin.database.v1.CopyBackupEncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Spanner\Admin\Database\V1\CopyBackupEncryptionConfig $var + * @return $this + */ + public function setEncryptionConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\CopyBackupEncryptionConfig::class); + $this->encryption_config = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateBackupEncryptionConfig.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateBackupEncryptionConfig.php new file mode 100644 index 000000000000..40ec928a4b04 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateBackupEncryptionConfig.php @@ -0,0 +1,203 @@ +google.spanner.admin.database.v1.CreateBackupEncryptionConfig + */ +class CreateBackupEncryptionConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The encryption type of the backup. + * + * Generated from protobuf field .google.spanner.admin.database.v1.CreateBackupEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $encryption_type = 0; + /** + * Optional. The Cloud KMS key that will be used to protect the backup. + * This field should be set only when + * [encryption_type][google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type] + * is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * + * Generated from protobuf field string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + protected $kms_key_name = ''; + /** + * Optional. Specifies the KMS configuration for the one or more keys used to + * protect the backup. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * The keys referenced by kms_key_names must fully cover all + * regions of the backup's instance configuration. Some examples: + * * For single region instance configs, specify a single regional + * location KMS key. + * * For multi-regional instance configs of type GOOGLE_MANAGED, + * either specify a multi-regional location KMS key or multiple regional + * location KMS keys that cover all regions in the instance config. + * * For an instance config of type USER_MANAGED, please specify only + * regional location KMS keys to cover each region in the instance config. + * Multi-regional location KMS keys are not supported for USER_MANAGED + * instance configs. + * + * Generated from protobuf field repeated string kms_key_names = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + private $kms_key_names; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $encryption_type + * Required. The encryption type of the backup. + * @type string $kms_key_name + * Optional. The Cloud KMS key that will be used to protect the backup. + * This field should be set only when + * [encryption_type][google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type] + * is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * @type array|\Google\Protobuf\Internal\RepeatedField $kms_key_names + * Optional. Specifies the KMS configuration for the one or more keys used to + * protect the backup. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * The keys referenced by kms_key_names must fully cover all + * regions of the backup's instance configuration. Some examples: + * * For single region instance configs, specify a single regional + * location KMS key. + * * For multi-regional instance configs of type GOOGLE_MANAGED, + * either specify a multi-regional location KMS key or multiple regional + * location KMS keys that cover all regions in the instance config. + * * For an instance config of type USER_MANAGED, please specify only + * regional location KMS keys to cover each region in the instance config. + * Multi-regional location KMS keys are not supported for USER_MANAGED + * instance configs. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Backup::initOnce(); + parent::__construct($data); + } + + /** + * Required. The encryption type of the backup. + * + * Generated from protobuf field .google.spanner.admin.database.v1.CreateBackupEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return int + */ + public function getEncryptionType() + { + return $this->encryption_type; + } + + /** + * Required. The encryption type of the backup. + * + * Generated from protobuf field .google.spanner.admin.database.v1.CreateBackupEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param int $var + * @return $this + */ + public function setEncryptionType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Database\V1\CreateBackupEncryptionConfig\EncryptionType::class); + $this->encryption_type = $var; + + return $this; + } + + /** + * Optional. The Cloud KMS key that will be used to protect the backup. + * This field should be set only when + * [encryption_type][google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type] + * is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * + * Generated from protobuf field string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return string + */ + public function getKmsKeyName() + { + return $this->kms_key_name; + } + + /** + * Optional. The Cloud KMS key that will be used to protect the backup. + * This field should be set only when + * [encryption_type][google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type] + * is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * + * Generated from protobuf field string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setKmsKeyName($var) + { + GPBUtil::checkString($var, True); + $this->kms_key_name = $var; + + return $this; + } + + /** + * Optional. Specifies the KMS configuration for the one or more keys used to + * protect the backup. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * The keys referenced by kms_key_names must fully cover all + * regions of the backup's instance configuration. Some examples: + * * For single region instance configs, specify a single regional + * location KMS key. + * * For multi-regional instance configs of type GOOGLE_MANAGED, + * either specify a multi-regional location KMS key or multiple regional + * location KMS keys that cover all regions in the instance config. + * * For an instance config of type USER_MANAGED, please specify only + * regional location KMS keys to cover each region in the instance config. + * Multi-regional location KMS keys are not supported for USER_MANAGED + * instance configs. + * + * Generated from protobuf field repeated string kms_key_names = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getKmsKeyNames() + { + return $this->kms_key_names; + } + + /** + * Optional. Specifies the KMS configuration for the one or more keys used to + * protect the backup. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * The keys referenced by kms_key_names must fully cover all + * regions of the backup's instance configuration. Some examples: + * * For single region instance configs, specify a single regional + * location KMS key. + * * For multi-regional instance configs of type GOOGLE_MANAGED, + * either specify a multi-regional location KMS key or multiple regional + * location KMS keys that cover all regions in the instance config. + * * For an instance config of type USER_MANAGED, please specify only + * regional location KMS keys to cover each region in the instance config. + * Multi-regional location KMS keys are not supported for USER_MANAGED + * instance configs. + * + * Generated from protobuf field repeated string kms_key_names = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setKmsKeyNames($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->kms_key_names = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateBackupEncryptionConfig/EncryptionType.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateBackupEncryptionConfig/EncryptionType.php new file mode 100644 index 000000000000..be6e5fb5ea47 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateBackupEncryptionConfig/EncryptionType.php @@ -0,0 +1,77 @@ +google.spanner.admin.database.v1.CreateBackupEncryptionConfig.EncryptionType + */ +class EncryptionType +{ + /** + * Unspecified. Do not use. + * + * Generated from protobuf enum ENCRYPTION_TYPE_UNSPECIFIED = 0; + */ + const ENCRYPTION_TYPE_UNSPECIFIED = 0; + /** + * Use the same encryption configuration as the database. This is the + * default option when + * [encryption_config][google.spanner.admin.database.v1.CreateBackupEncryptionConfig] + * is empty. For example, if the database is using + * `Customer_Managed_Encryption`, the backup will be using the same Cloud + * KMS key as the database. + * + * Generated from protobuf enum USE_DATABASE_ENCRYPTION = 1; + */ + const USE_DATABASE_ENCRYPTION = 1; + /** + * Use Google default encryption. + * + * Generated from protobuf enum GOOGLE_DEFAULT_ENCRYPTION = 2; + */ + const GOOGLE_DEFAULT_ENCRYPTION = 2; + /** + * Use customer managed encryption. If specified, `kms_key_name` + * must contain a valid Cloud KMS key. + * + * Generated from protobuf enum CUSTOMER_MANAGED_ENCRYPTION = 3; + */ + const CUSTOMER_MANAGED_ENCRYPTION = 3; + + private static $valueToName = [ + self::ENCRYPTION_TYPE_UNSPECIFIED => 'ENCRYPTION_TYPE_UNSPECIFIED', + self::USE_DATABASE_ENCRYPTION => 'USE_DATABASE_ENCRYPTION', + self::GOOGLE_DEFAULT_ENCRYPTION => 'GOOGLE_DEFAULT_ENCRYPTION', + self::CUSTOMER_MANAGED_ENCRYPTION => 'CUSTOMER_MANAGED_ENCRYPTION', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(EncryptionType::class, \Google\Cloud\Spanner\Admin\Database\V1\CreateBackupEncryptionConfig_EncryptionType::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateBackupMetadata.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateBackupMetadata.php new file mode 100644 index 000000000000..04df2f570b43 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateBackupMetadata.php @@ -0,0 +1,242 @@ +google.spanner.admin.database.v1.CreateBackupMetadata + */ +class CreateBackupMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * The name of the backup being created. + * + * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { + */ + protected $name = ''; + /** + * The name of the database the backup is created from. + * + * Generated from protobuf field string database = 2 [(.google.api.resource_reference) = { + */ + protected $database = ''; + /** + * The progress of the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * operation. + * + * Generated from protobuf field .google.spanner.admin.database.v1.OperationProgress progress = 3; + */ + protected $progress = null; + /** + * The time at which cancellation of this operation was received. + * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + * starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not guaranteed. + * Clients can use + * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an [Operation.error][google.longrunning.Operation.error] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, + * corresponding to `Code.CANCELLED`. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 4; + */ + protected $cancel_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * The name of the backup being created. + * @type string $database + * The name of the database the backup is created from. + * @type \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress $progress + * The progress of the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * operation. + * @type \Google\Protobuf\Timestamp $cancel_time + * The time at which cancellation of this operation was received. + * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + * starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not guaranteed. + * Clients can use + * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an [Operation.error][google.longrunning.Operation.error] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, + * corresponding to `Code.CANCELLED`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Backup::initOnce(); + parent::__construct($data); + } + + /** + * The name of the backup being created. + * + * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The name of the backup being created. + * + * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * The name of the database the backup is created from. + * + * Generated from protobuf field string database = 2 [(.google.api.resource_reference) = { + * @return string + */ + public function getDatabase() + { + return $this->database; + } + + /** + * The name of the database the backup is created from. + * + * Generated from protobuf field string database = 2 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setDatabase($var) + { + GPBUtil::checkString($var, True); + $this->database = $var; + + return $this; + } + + /** + * The progress of the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * operation. + * + * Generated from protobuf field .google.spanner.admin.database.v1.OperationProgress progress = 3; + * @return \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress|null + */ + public function getProgress() + { + return $this->progress; + } + + public function hasProgress() + { + return isset($this->progress); + } + + public function clearProgress() + { + unset($this->progress); + } + + /** + * The progress of the + * [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + * operation. + * + * Generated from protobuf field .google.spanner.admin.database.v1.OperationProgress progress = 3; + * @param \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress $var + * @return $this + */ + public function setProgress($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress::class); + $this->progress = $var; + + return $this; + } + + /** + * The time at which cancellation of this operation was received. + * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + * starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not guaranteed. + * Clients can use + * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an [Operation.error][google.longrunning.Operation.error] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, + * corresponding to `Code.CANCELLED`. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 4; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCancelTime() + { + return $this->cancel_time; + } + + public function hasCancelTime() + { + return isset($this->cancel_time); + } + + public function clearCancelTime() + { + unset($this->cancel_time); + } + + /** + * The time at which cancellation of this operation was received. + * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + * starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not guaranteed. + * Clients can use + * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an [Operation.error][google.longrunning.Operation.error] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, + * corresponding to `Code.CANCELLED`. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 4; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCancelTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->cancel_time = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateBackupRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateBackupRequest.php new file mode 100644 index 000000000000..9c216c980f6f --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateBackupRequest.php @@ -0,0 +1,259 @@ +google.spanner.admin.database.v1.CreateBackupRequest + */ +class CreateBackupRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the instance in which the backup will be + * created. This must be the same instance that contains the database the + * backup will be created from. The backup will be stored in the + * location(s) specified in the instance configuration of this + * instance. Values are of the form + * `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. The id of the backup to be created. The `backup_id` appended to + * `parent` forms the full backup name of the form + * `projects//instances//backups/`. + * + * Generated from protobuf field string backup_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $backup_id = ''; + /** + * Required. The backup to create. + * + * Generated from protobuf field .google.spanner.admin.database.v1.Backup backup = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $backup = null; + /** + * Optional. The encryption configuration used to encrypt the backup. If this + * field is not specified, the backup will use the same encryption + * configuration as the database by default, namely + * [encryption_type][google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type] + * = `USE_DATABASE_ENCRYPTION`. + * + * Generated from protobuf field .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $encryption_config = null; + + /** + * @param string $parent Required. The name of the instance in which the backup will be + * created. This must be the same instance that contains the database the + * backup will be created from. The backup will be stored in the + * location(s) specified in the instance configuration of this + * instance. Values are of the form + * `projects//instances/`. Please see + * {@see DatabaseAdminClient::instanceName()} for help formatting this field. + * @param \Google\Cloud\Spanner\Admin\Database\V1\Backup $backup Required. The backup to create. + * @param string $backupId Required. The id of the backup to be created. The `backup_id` appended to + * `parent` forms the full backup name of the form + * `projects//instances//backups/`. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\CreateBackupRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Spanner\Admin\Database\V1\Backup $backup, string $backupId): self + { + return (new self()) + ->setParent($parent) + ->setBackup($backup) + ->setBackupId($backupId); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The name of the instance in which the backup will be + * created. This must be the same instance that contains the database the + * backup will be created from. The backup will be stored in the + * location(s) specified in the instance configuration of this + * instance. Values are of the form + * `projects//instances/`. + * @type string $backup_id + * Required. The id of the backup to be created. The `backup_id` appended to + * `parent` forms the full backup name of the form + * `projects//instances//backups/`. + * @type \Google\Cloud\Spanner\Admin\Database\V1\Backup $backup + * Required. The backup to create. + * @type \Google\Cloud\Spanner\Admin\Database\V1\CreateBackupEncryptionConfig $encryption_config + * Optional. The encryption configuration used to encrypt the backup. If this + * field is not specified, the backup will use the same encryption + * configuration as the database by default, namely + * [encryption_type][google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type] + * = `USE_DATABASE_ENCRYPTION`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Backup::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the instance in which the backup will be + * created. This must be the same instance that contains the database the + * backup will be created from. The backup will be stored in the + * location(s) specified in the instance configuration of this + * instance. Values are of the form + * `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The name of the instance in which the backup will be + * created. This must be the same instance that contains the database the + * backup will be created from. The backup will be stored in the + * location(s) specified in the instance configuration of this + * instance. Values are of the form + * `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Required. The id of the backup to be created. The `backup_id` appended to + * `parent` forms the full backup name of the form + * `projects//instances//backups/`. + * + * Generated from protobuf field string backup_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getBackupId() + { + return $this->backup_id; + } + + /** + * Required. The id of the backup to be created. The `backup_id` appended to + * `parent` forms the full backup name of the form + * `projects//instances//backups/`. + * + * Generated from protobuf field string backup_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setBackupId($var) + { + GPBUtil::checkString($var, True); + $this->backup_id = $var; + + return $this; + } + + /** + * Required. The backup to create. + * + * Generated from protobuf field .google.spanner.admin.database.v1.Backup backup = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\Admin\Database\V1\Backup|null + */ + public function getBackup() + { + return $this->backup; + } + + public function hasBackup() + { + return isset($this->backup); + } + + public function clearBackup() + { + unset($this->backup); + } + + /** + * Required. The backup to create. + * + * Generated from protobuf field .google.spanner.admin.database.v1.Backup backup = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\Admin\Database\V1\Backup $var + * @return $this + */ + public function setBackup($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\Backup::class); + $this->backup = $var; + + return $this; + } + + /** + * Optional. The encryption configuration used to encrypt the backup. If this + * field is not specified, the backup will use the same encryption + * configuration as the database by default, namely + * [encryption_type][google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type] + * = `USE_DATABASE_ENCRYPTION`. + * + * Generated from protobuf field .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Spanner\Admin\Database\V1\CreateBackupEncryptionConfig|null + */ + public function getEncryptionConfig() + { + return $this->encryption_config; + } + + public function hasEncryptionConfig() + { + return isset($this->encryption_config); + } + + public function clearEncryptionConfig() + { + unset($this->encryption_config); + } + + /** + * Optional. The encryption configuration used to encrypt the backup. If this + * field is not specified, the backup will use the same encryption + * configuration as the database by default, namely + * [encryption_type][google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type] + * = `USE_DATABASE_ENCRYPTION`. + * + * Generated from protobuf field .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Spanner\Admin\Database\V1\CreateBackupEncryptionConfig $var + * @return $this + */ + public function setEncryptionConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\CreateBackupEncryptionConfig::class); + $this->encryption_config = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateBackupScheduleRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateBackupScheduleRequest.php new file mode 100644 index 000000000000..229fd26859de --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateBackupScheduleRequest.php @@ -0,0 +1,174 @@ +google.spanner.admin.database.v1.CreateBackupScheduleRequest + */ +class CreateBackupScheduleRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the database that this backup schedule applies to. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. The Id to use for the backup schedule. The `backup_schedule_id` + * appended to `parent` forms the full backup schedule name of the form + * `projects//instances//databases//backupSchedules/`. + * + * Generated from protobuf field string backup_schedule_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $backup_schedule_id = ''; + /** + * Required. The backup schedule to create. + * + * Generated from protobuf field .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $backup_schedule = null; + + /** + * @param string $parent Required. The name of the database that this backup schedule applies to. Please see + * {@see DatabaseAdminClient::databaseName()} for help formatting this field. + * @param \Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule $backupSchedule Required. The backup schedule to create. + * @param string $backupScheduleId Required. The Id to use for the backup schedule. The `backup_schedule_id` + * appended to `parent` forms the full backup schedule name of the form + * `projects//instances//databases//backupSchedules/`. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\CreateBackupScheduleRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule $backupSchedule, string $backupScheduleId): self + { + return (new self()) + ->setParent($parent) + ->setBackupSchedule($backupSchedule) + ->setBackupScheduleId($backupScheduleId); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The name of the database that this backup schedule applies to. + * @type string $backup_schedule_id + * Required. The Id to use for the backup schedule. The `backup_schedule_id` + * appended to `parent` forms the full backup schedule name of the form + * `projects//instances//databases//backupSchedules/`. + * @type \Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule $backup_schedule + * Required. The backup schedule to create. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\BackupSchedule::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the database that this backup schedule applies to. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The name of the database that this backup schedule applies to. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Required. The Id to use for the backup schedule. The `backup_schedule_id` + * appended to `parent` forms the full backup schedule name of the form + * `projects//instances//databases//backupSchedules/`. + * + * Generated from protobuf field string backup_schedule_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getBackupScheduleId() + { + return $this->backup_schedule_id; + } + + /** + * Required. The Id to use for the backup schedule. The `backup_schedule_id` + * appended to `parent` forms the full backup schedule name of the form + * `projects//instances//databases//backupSchedules/`. + * + * Generated from protobuf field string backup_schedule_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setBackupScheduleId($var) + { + GPBUtil::checkString($var, True); + $this->backup_schedule_id = $var; + + return $this; + } + + /** + * Required. The backup schedule to create. + * + * Generated from protobuf field .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule|null + */ + public function getBackupSchedule() + { + return $this->backup_schedule; + } + + public function hasBackupSchedule() + { + return isset($this->backup_schedule); + } + + public function clearBackupSchedule() + { + unset($this->backup_schedule); + } + + /** + * Required. The backup schedule to create. + * + * Generated from protobuf field .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule $var + * @return $this + */ + public function setBackupSchedule($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule::class); + $this->backup_schedule = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateDatabaseMetadata.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateDatabaseMetadata.php new file mode 100644 index 000000000000..15e141e01574 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateDatabaseMetadata.php @@ -0,0 +1,68 @@ +google.spanner.admin.database.v1.CreateDatabaseMetadata + */ +class CreateDatabaseMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * The database being created. + * + * Generated from protobuf field string database = 1 [(.google.api.resource_reference) = { + */ + protected $database = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $database + * The database being created. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The database being created. + * + * Generated from protobuf field string database = 1 [(.google.api.resource_reference) = { + * @return string + */ + public function getDatabase() + { + return $this->database; + } + + /** + * The database being created. + * + * Generated from protobuf field string database = 1 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setDatabase($var) + { + GPBUtil::checkString($var, True); + $this->database = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateDatabaseRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateDatabaseRequest.php new file mode 100644 index 000000000000..52e40ad3836f --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CreateDatabaseRequest.php @@ -0,0 +1,365 @@ +google.spanner.admin.database.v1.CreateDatabaseRequest + */ +class CreateDatabaseRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the instance that will serve the new database. + * Values are of the form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. A `CREATE DATABASE` statement, which specifies the ID of the + * new database. The database ID must conform to the regular expression + * `[a-z][a-z0-9_\-]*[a-z0-9]` and be between 2 and 30 characters in length. + * If the database ID is a reserved word or if it contains a hyphen, the + * database ID must be enclosed in backticks (`` ` ``). + * + * Generated from protobuf field string create_statement = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $create_statement = ''; + /** + * Optional. A list of DDL statements to run inside the newly created + * database. Statements can create tables, indexes, etc. These + * statements execute atomically with the creation of the database: + * if there is an error in any statement, the database is not created. + * + * Generated from protobuf field repeated string extra_statements = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $extra_statements; + /** + * Optional. The encryption configuration for the database. If this field is + * not specified, Cloud Spanner will encrypt/decrypt all data at rest using + * Google default encryption. + * + * Generated from protobuf field .google.spanner.admin.database.v1.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $encryption_config = null; + /** + * Optional. The dialect of the Cloud Spanner Database. + * + * Generated from protobuf field .google.spanner.admin.database.v1.DatabaseDialect database_dialect = 5 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $database_dialect = 0; + /** + * Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements in + * 'extra_statements' above. + * Contains a protobuf-serialized + * [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto). + * To generate it, [install](https://grpc.io/docs/protoc-installation/) and + * run `protoc` with --include_imports and --descriptor_set_out. For example, + * to generate for moon/shot/app.proto, run + * ``` + * $protoc --proto_path=/app_path --proto_path=/lib_path \ + * --include_imports \ + * --descriptor_set_out=descriptors.data \ + * moon/shot/app.proto + * ``` + * For more details, see protobuffer [self + * description](https://developers.google.com/protocol-buffers/docs/techniques#self-description). + * + * Generated from protobuf field bytes proto_descriptors = 6 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $proto_descriptors = ''; + + /** + * @param string $parent Required. The name of the instance that will serve the new database. + * Values are of the form `projects//instances/`. Please see + * {@see DatabaseAdminClient::instanceName()} for help formatting this field. + * @param string $createStatement Required. A `CREATE DATABASE` statement, which specifies the ID of the + * new database. The database ID must conform to the regular expression + * `[a-z][a-z0-9_\-]*[a-z0-9]` and be between 2 and 30 characters in length. + * If the database ID is a reserved word or if it contains a hyphen, the + * database ID must be enclosed in backticks (`` ` ``). + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\CreateDatabaseRequest + * + * @experimental + */ + public static function build(string $parent, string $createStatement): self + { + return (new self()) + ->setParent($parent) + ->setCreateStatement($createStatement); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The name of the instance that will serve the new database. + * Values are of the form `projects//instances/`. + * @type string $create_statement + * Required. A `CREATE DATABASE` statement, which specifies the ID of the + * new database. The database ID must conform to the regular expression + * `[a-z][a-z0-9_\-]*[a-z0-9]` and be between 2 and 30 characters in length. + * If the database ID is a reserved word or if it contains a hyphen, the + * database ID must be enclosed in backticks (`` ` ``). + * @type array|\Google\Protobuf\Internal\RepeatedField $extra_statements + * Optional. A list of DDL statements to run inside the newly created + * database. Statements can create tables, indexes, etc. These + * statements execute atomically with the creation of the database: + * if there is an error in any statement, the database is not created. + * @type \Google\Cloud\Spanner\Admin\Database\V1\EncryptionConfig $encryption_config + * Optional. The encryption configuration for the database. If this field is + * not specified, Cloud Spanner will encrypt/decrypt all data at rest using + * Google default encryption. + * @type int $database_dialect + * Optional. The dialect of the Cloud Spanner Database. + * @type string $proto_descriptors + * Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements in + * 'extra_statements' above. + * Contains a protobuf-serialized + * [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto). + * To generate it, [install](https://grpc.io/docs/protoc-installation/) and + * run `protoc` with --include_imports and --descriptor_set_out. For example, + * to generate for moon/shot/app.proto, run + * ``` + * $protoc --proto_path=/app_path --proto_path=/lib_path \ + * --include_imports \ + * --descriptor_set_out=descriptors.data \ + * moon/shot/app.proto + * ``` + * For more details, see protobuffer [self + * description](https://developers.google.com/protocol-buffers/docs/techniques#self-description). + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the instance that will serve the new database. + * Values are of the form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The name of the instance that will serve the new database. + * Values are of the form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Required. A `CREATE DATABASE` statement, which specifies the ID of the + * new database. The database ID must conform to the regular expression + * `[a-z][a-z0-9_\-]*[a-z0-9]` and be between 2 and 30 characters in length. + * If the database ID is a reserved word or if it contains a hyphen, the + * database ID must be enclosed in backticks (`` ` ``). + * + * Generated from protobuf field string create_statement = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getCreateStatement() + { + return $this->create_statement; + } + + /** + * Required. A `CREATE DATABASE` statement, which specifies the ID of the + * new database. The database ID must conform to the regular expression + * `[a-z][a-z0-9_\-]*[a-z0-9]` and be between 2 and 30 characters in length. + * If the database ID is a reserved word or if it contains a hyphen, the + * database ID must be enclosed in backticks (`` ` ``). + * + * Generated from protobuf field string create_statement = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setCreateStatement($var) + { + GPBUtil::checkString($var, True); + $this->create_statement = $var; + + return $this; + } + + /** + * Optional. A list of DDL statements to run inside the newly created + * database. Statements can create tables, indexes, etc. These + * statements execute atomically with the creation of the database: + * if there is an error in any statement, the database is not created. + * + * Generated from protobuf field repeated string extra_statements = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getExtraStatements() + { + return $this->extra_statements; + } + + /** + * Optional. A list of DDL statements to run inside the newly created + * database. Statements can create tables, indexes, etc. These + * statements execute atomically with the creation of the database: + * if there is an error in any statement, the database is not created. + * + * Generated from protobuf field repeated string extra_statements = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setExtraStatements($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->extra_statements = $arr; + + return $this; + } + + /** + * Optional. The encryption configuration for the database. If this field is + * not specified, Cloud Spanner will encrypt/decrypt all data at rest using + * Google default encryption. + * + * Generated from protobuf field .google.spanner.admin.database.v1.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Spanner\Admin\Database\V1\EncryptionConfig|null + */ + public function getEncryptionConfig() + { + return $this->encryption_config; + } + + public function hasEncryptionConfig() + { + return isset($this->encryption_config); + } + + public function clearEncryptionConfig() + { + unset($this->encryption_config); + } + + /** + * Optional. The encryption configuration for the database. If this field is + * not specified, Cloud Spanner will encrypt/decrypt all data at rest using + * Google default encryption. + * + * Generated from protobuf field .google.spanner.admin.database.v1.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Spanner\Admin\Database\V1\EncryptionConfig $var + * @return $this + */ + public function setEncryptionConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\EncryptionConfig::class); + $this->encryption_config = $var; + + return $this; + } + + /** + * Optional. The dialect of the Cloud Spanner Database. + * + * Generated from protobuf field .google.spanner.admin.database.v1.DatabaseDialect database_dialect = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getDatabaseDialect() + { + return $this->database_dialect; + } + + /** + * Optional. The dialect of the Cloud Spanner Database. + * + * Generated from protobuf field .google.spanner.admin.database.v1.DatabaseDialect database_dialect = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setDatabaseDialect($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Database\V1\DatabaseDialect::class); + $this->database_dialect = $var; + + return $this; + } + + /** + * Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements in + * 'extra_statements' above. + * Contains a protobuf-serialized + * [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto). + * To generate it, [install](https://grpc.io/docs/protoc-installation/) and + * run `protoc` with --include_imports and --descriptor_set_out. For example, + * to generate for moon/shot/app.proto, run + * ``` + * $protoc --proto_path=/app_path --proto_path=/lib_path \ + * --include_imports \ + * --descriptor_set_out=descriptors.data \ + * moon/shot/app.proto + * ``` + * For more details, see protobuffer [self + * description](https://developers.google.com/protocol-buffers/docs/techniques#self-description). + * + * Generated from protobuf field bytes proto_descriptors = 6 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getProtoDescriptors() + { + return $this->proto_descriptors; + } + + /** + * Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements in + * 'extra_statements' above. + * Contains a protobuf-serialized + * [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto). + * To generate it, [install](https://grpc.io/docs/protoc-installation/) and + * run `protoc` with --include_imports and --descriptor_set_out. For example, + * to generate for moon/shot/app.proto, run + * ``` + * $protoc --proto_path=/app_path --proto_path=/lib_path \ + * --include_imports \ + * --descriptor_set_out=descriptors.data \ + * moon/shot/app.proto + * ``` + * For more details, see protobuffer [self + * description](https://developers.google.com/protocol-buffers/docs/techniques#self-description). + * + * Generated from protobuf field bytes proto_descriptors = 6 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setProtoDescriptors($var) + { + GPBUtil::checkString($var, False); + $this->proto_descriptors = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CrontabSpec.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CrontabSpec.php new file mode 100644 index 000000000000..ba03270160ca --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/CrontabSpec.php @@ -0,0 +1,214 @@ +google.spanner.admin.database.v1.CrontabSpec + */ +class CrontabSpec extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Textual representation of the crontab. User can customize the + * backup frequency and the backup version time using the cron + * expression. The version time must be in UTC timzeone. + * The backup will contain an externally consistent copy of the + * database at the version time. Allowed frequencies are 12 hour, 1 day, + * 1 week and 1 month. Examples of valid cron specifications: + * * `0 2/12 * * * ` : every 12 hours at (2, 14) hours past midnight in UTC. + * * `0 2,14 * * * ` : every 12 hours at (2,14) hours past midnight in UTC. + * * `0 2 * * * ` : once a day at 2 past midnight in UTC. + * * `0 2 * * 0 ` : once a week every Sunday at 2 past midnight in UTC. + * * `0 2 8 * * ` : once a month on 8th day at 2 past midnight in UTC. + * + * Generated from protobuf field string text = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $text = ''; + /** + * Output only. The time zone of the times in `CrontabSpec.text`. Currently + * only UTC is supported. + * + * Generated from protobuf field string time_zone = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $time_zone = ''; + /** + * Output only. Schedule backups will contain an externally consistent copy + * of the database at the version time specified in + * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation + * of the scheduled backups at that version time. Spanner will initiate + * the creation of scheduled backups within the time window bounded by the + * version_time specified in `schedule_spec.cron_spec` and version_time + + * `creation_window`. + * + * Generated from protobuf field .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $creation_window = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $text + * Required. Textual representation of the crontab. User can customize the + * backup frequency and the backup version time using the cron + * expression. The version time must be in UTC timzeone. + * The backup will contain an externally consistent copy of the + * database at the version time. Allowed frequencies are 12 hour, 1 day, + * 1 week and 1 month. Examples of valid cron specifications: + * * `0 2/12 * * * ` : every 12 hours at (2, 14) hours past midnight in UTC. + * * `0 2,14 * * * ` : every 12 hours at (2,14) hours past midnight in UTC. + * * `0 2 * * * ` : once a day at 2 past midnight in UTC. + * * `0 2 * * 0 ` : once a week every Sunday at 2 past midnight in UTC. + * * `0 2 8 * * ` : once a month on 8th day at 2 past midnight in UTC. + * @type string $time_zone + * Output only. The time zone of the times in `CrontabSpec.text`. Currently + * only UTC is supported. + * @type \Google\Protobuf\Duration $creation_window + * Output only. Schedule backups will contain an externally consistent copy + * of the database at the version time specified in + * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation + * of the scheduled backups at that version time. Spanner will initiate + * the creation of scheduled backups within the time window bounded by the + * version_time specified in `schedule_spec.cron_spec` and version_time + + * `creation_window`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\BackupSchedule::initOnce(); + parent::__construct($data); + } + + /** + * Required. Textual representation of the crontab. User can customize the + * backup frequency and the backup version time using the cron + * expression. The version time must be in UTC timzeone. + * The backup will contain an externally consistent copy of the + * database at the version time. Allowed frequencies are 12 hour, 1 day, + * 1 week and 1 month. Examples of valid cron specifications: + * * `0 2/12 * * * ` : every 12 hours at (2, 14) hours past midnight in UTC. + * * `0 2,14 * * * ` : every 12 hours at (2,14) hours past midnight in UTC. + * * `0 2 * * * ` : once a day at 2 past midnight in UTC. + * * `0 2 * * 0 ` : once a week every Sunday at 2 past midnight in UTC. + * * `0 2 8 * * ` : once a month on 8th day at 2 past midnight in UTC. + * + * Generated from protobuf field string text = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * Required. Textual representation of the crontab. User can customize the + * backup frequency and the backup version time using the cron + * expression. The version time must be in UTC timzeone. + * The backup will contain an externally consistent copy of the + * database at the version time. Allowed frequencies are 12 hour, 1 day, + * 1 week and 1 month. Examples of valid cron specifications: + * * `0 2/12 * * * ` : every 12 hours at (2, 14) hours past midnight in UTC. + * * `0 2,14 * * * ` : every 12 hours at (2,14) hours past midnight in UTC. + * * `0 2 * * * ` : once a day at 2 past midnight in UTC. + * * `0 2 * * 0 ` : once a week every Sunday at 2 past midnight in UTC. + * * `0 2 8 * * ` : once a month on 8th day at 2 past midnight in UTC. + * + * Generated from protobuf field string text = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setText($var) + { + GPBUtil::checkString($var, True); + $this->text = $var; + + return $this; + } + + /** + * Output only. The time zone of the times in `CrontabSpec.text`. Currently + * only UTC is supported. + * + * Generated from protobuf field string time_zone = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getTimeZone() + { + return $this->time_zone; + } + + /** + * Output only. The time zone of the times in `CrontabSpec.text`. Currently + * only UTC is supported. + * + * Generated from protobuf field string time_zone = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setTimeZone($var) + { + GPBUtil::checkString($var, True); + $this->time_zone = $var; + + return $this; + } + + /** + * Output only. Schedule backups will contain an externally consistent copy + * of the database at the version time specified in + * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation + * of the scheduled backups at that version time. Spanner will initiate + * the creation of scheduled backups within the time window bounded by the + * version_time specified in `schedule_spec.cron_spec` and version_time + + * `creation_window`. + * + * Generated from protobuf field .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Duration|null + */ + public function getCreationWindow() + { + return $this->creation_window; + } + + public function hasCreationWindow() + { + return isset($this->creation_window); + } + + public function clearCreationWindow() + { + unset($this->creation_window); + } + + /** + * Output only. Schedule backups will contain an externally consistent copy + * of the database at the version time specified in + * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation + * of the scheduled backups at that version time. Spanner will initiate + * the creation of scheduled backups within the time window bounded by the + * version_time specified in `schedule_spec.cron_spec` and version_time + + * `creation_window`. + * + * Generated from protobuf field .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setCreationWindow($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->creation_window = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/Database.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/Database.php new file mode 100644 index 000000000000..7116c55f5d1a --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/Database.php @@ -0,0 +1,605 @@ +google.spanner.admin.database.v1.Database + */ +class Database extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the database. Values are of the form + * `projects//instances//databases/`, + * where `` is as specified in the `CREATE DATABASE` + * statement. This name can be passed to other API methods to + * identify the database. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $name = ''; + /** + * Output only. The current database state. + * + * Generated from protobuf field .google.spanner.admin.database.v1.Database.State state = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $state = 0; + /** + * Output only. If exists, the time at which the database creation started. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $create_time = null; + /** + * Output only. Applicable only for restored databases. Contains information + * about the restore source. + * + * Generated from protobuf field .google.spanner.admin.database.v1.RestoreInfo restore_info = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $restore_info = null; + /** + * Output only. For databases that are using customer managed encryption, this + * field contains the encryption configuration for the database. + * For databases that are using Google default or other types of encryption, + * this field is empty. + * + * Generated from protobuf field .google.spanner.admin.database.v1.EncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $encryption_config = null; + /** + * Output only. For databases that are using customer managed encryption, this + * field contains the encryption information for the database, such as + * all Cloud KMS key versions that are in use. The `encryption_status' field + * inside of each `EncryptionInfo` is not populated. + * For databases that are using Google default or other types of encryption, + * this field is empty. + * This field is propagated lazily from the backend. There might be a delay + * from when a key version is being used and when it appears in this field. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.EncryptionInfo encryption_info = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $encryption_info; + /** + * Output only. The period in which Cloud Spanner retains all versions of data + * for the database. This is the same as the value of version_retention_period + * database option set using + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]. + * Defaults to 1 hour, if not set. + * + * Generated from protobuf field string version_retention_period = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $version_retention_period = ''; + /** + * Output only. Earliest timestamp at which older versions of the data can be + * read. This value is continuously updated by Cloud Spanner and becomes stale + * the moment it is queried. If you are using this value to recover data, make + * sure to account for the time from the moment when the value is queried to + * the moment when you initiate the recovery. + * + * Generated from protobuf field .google.protobuf.Timestamp earliest_version_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $earliest_version_time = null; + /** + * Output only. The read-write region which contains the database's leader + * replicas. + * This is the same as the value of default_leader + * database option set using DatabaseAdmin.CreateDatabase or + * DatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty. + * + * Generated from protobuf field string default_leader = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $default_leader = ''; + /** + * Output only. The dialect of the Cloud Spanner Database. + * + * Generated from protobuf field .google.spanner.admin.database.v1.DatabaseDialect database_dialect = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $database_dialect = 0; + /** + * Whether drop protection is enabled for this database. Defaults to false, + * if not set. For more details, please see how to [prevent accidental + * database + * deletion](https://cloud.google.com/spanner/docs/prevent-database-deletion). + * + * Generated from protobuf field bool enable_drop_protection = 11; + */ + protected $enable_drop_protection = false; + /** + * Output only. If true, the database is being updated. If false, there are no + * ongoing update operations for the database. + * + * Generated from protobuf field bool reconciling = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $reconciling = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the database. Values are of the form + * `projects//instances//databases/`, + * where `` is as specified in the `CREATE DATABASE` + * statement. This name can be passed to other API methods to + * identify the database. + * @type int $state + * Output only. The current database state. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. If exists, the time at which the database creation started. + * @type \Google\Cloud\Spanner\Admin\Database\V1\RestoreInfo $restore_info + * Output only. Applicable only for restored databases. Contains information + * about the restore source. + * @type \Google\Cloud\Spanner\Admin\Database\V1\EncryptionConfig $encryption_config + * Output only. For databases that are using customer managed encryption, this + * field contains the encryption configuration for the database. + * For databases that are using Google default or other types of encryption, + * this field is empty. + * @type array<\Google\Cloud\Spanner\Admin\Database\V1\EncryptionInfo>|\Google\Protobuf\Internal\RepeatedField $encryption_info + * Output only. For databases that are using customer managed encryption, this + * field contains the encryption information for the database, such as + * all Cloud KMS key versions that are in use. The `encryption_status' field + * inside of each `EncryptionInfo` is not populated. + * For databases that are using Google default or other types of encryption, + * this field is empty. + * This field is propagated lazily from the backend. There might be a delay + * from when a key version is being used and when it appears in this field. + * @type string $version_retention_period + * Output only. The period in which Cloud Spanner retains all versions of data + * for the database. This is the same as the value of version_retention_period + * database option set using + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]. + * Defaults to 1 hour, if not set. + * @type \Google\Protobuf\Timestamp $earliest_version_time + * Output only. Earliest timestamp at which older versions of the data can be + * read. This value is continuously updated by Cloud Spanner and becomes stale + * the moment it is queried. If you are using this value to recover data, make + * sure to account for the time from the moment when the value is queried to + * the moment when you initiate the recovery. + * @type string $default_leader + * Output only. The read-write region which contains the database's leader + * replicas. + * This is the same as the value of default_leader + * database option set using DatabaseAdmin.CreateDatabase or + * DatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty. + * @type int $database_dialect + * Output only. The dialect of the Cloud Spanner Database. + * @type bool $enable_drop_protection + * Whether drop protection is enabled for this database. Defaults to false, + * if not set. For more details, please see how to [prevent accidental + * database + * deletion](https://cloud.google.com/spanner/docs/prevent-database-deletion). + * @type bool $reconciling + * Output only. If true, the database is being updated. If false, there are no + * ongoing update operations for the database. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the database. Values are of the form + * `projects//instances//databases/`, + * where `` is as specified in the `CREATE DATABASE` + * statement. This name can be passed to other API methods to + * identify the database. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. The name of the database. Values are of the form + * `projects//instances//databases/`, + * where `` is as specified in the `CREATE DATABASE` + * statement. This name can be passed to other API methods to + * identify the database. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Output only. The current database state. + * + * Generated from protobuf field .google.spanner.admin.database.v1.Database.State state = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getState() + { + return $this->state; + } + + /** + * Output only. The current database state. + * + * Generated from protobuf field .google.spanner.admin.database.v1.Database.State state = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setState($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Database\V1\Database\State::class); + $this->state = $var; + + return $this; + } + + /** + * Output only. If exists, the time at which the database creation started. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + + /** + * Output only. If exists, the time at which the database creation started. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Output only. Applicable only for restored databases. Contains information + * about the restore source. + * + * Generated from protobuf field .google.spanner.admin.database.v1.RestoreInfo restore_info = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Cloud\Spanner\Admin\Database\V1\RestoreInfo|null + */ + public function getRestoreInfo() + { + return $this->restore_info; + } + + public function hasRestoreInfo() + { + return isset($this->restore_info); + } + + public function clearRestoreInfo() + { + unset($this->restore_info); + } + + /** + * Output only. Applicable only for restored databases. Contains information + * about the restore source. + * + * Generated from protobuf field .google.spanner.admin.database.v1.RestoreInfo restore_info = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Cloud\Spanner\Admin\Database\V1\RestoreInfo $var + * @return $this + */ + public function setRestoreInfo($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\RestoreInfo::class); + $this->restore_info = $var; + + return $this; + } + + /** + * Output only. For databases that are using customer managed encryption, this + * field contains the encryption configuration for the database. + * For databases that are using Google default or other types of encryption, + * this field is empty. + * + * Generated from protobuf field .google.spanner.admin.database.v1.EncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Cloud\Spanner\Admin\Database\V1\EncryptionConfig|null + */ + public function getEncryptionConfig() + { + return $this->encryption_config; + } + + public function hasEncryptionConfig() + { + return isset($this->encryption_config); + } + + public function clearEncryptionConfig() + { + unset($this->encryption_config); + } + + /** + * Output only. For databases that are using customer managed encryption, this + * field contains the encryption configuration for the database. + * For databases that are using Google default or other types of encryption, + * this field is empty. + * + * Generated from protobuf field .google.spanner.admin.database.v1.EncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Cloud\Spanner\Admin\Database\V1\EncryptionConfig $var + * @return $this + */ + public function setEncryptionConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\EncryptionConfig::class); + $this->encryption_config = $var; + + return $this; + } + + /** + * Output only. For databases that are using customer managed encryption, this + * field contains the encryption information for the database, such as + * all Cloud KMS key versions that are in use. The `encryption_status' field + * inside of each `EncryptionInfo` is not populated. + * For databases that are using Google default or other types of encryption, + * this field is empty. + * This field is propagated lazily from the backend. There might be a delay + * from when a key version is being used and when it appears in this field. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.EncryptionInfo encryption_info = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getEncryptionInfo() + { + return $this->encryption_info; + } + + /** + * Output only. For databases that are using customer managed encryption, this + * field contains the encryption information for the database, such as + * all Cloud KMS key versions that are in use. The `encryption_status' field + * inside of each `EncryptionInfo` is not populated. + * For databases that are using Google default or other types of encryption, + * this field is empty. + * This field is propagated lazily from the backend. There might be a delay + * from when a key version is being used and when it appears in this field. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.EncryptionInfo encryption_info = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param array<\Google\Cloud\Spanner\Admin\Database\V1\EncryptionInfo>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setEncryptionInfo($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\Admin\Database\V1\EncryptionInfo::class); + $this->encryption_info = $arr; + + return $this; + } + + /** + * Output only. The period in which Cloud Spanner retains all versions of data + * for the database. This is the same as the value of version_retention_period + * database option set using + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]. + * Defaults to 1 hour, if not set. + * + * Generated from protobuf field string version_retention_period = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getVersionRetentionPeriod() + { + return $this->version_retention_period; + } + + /** + * Output only. The period in which Cloud Spanner retains all versions of data + * for the database. This is the same as the value of version_retention_period + * database option set using + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]. + * Defaults to 1 hour, if not set. + * + * Generated from protobuf field string version_retention_period = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setVersionRetentionPeriod($var) + { + GPBUtil::checkString($var, True); + $this->version_retention_period = $var; + + return $this; + } + + /** + * Output only. Earliest timestamp at which older versions of the data can be + * read. This value is continuously updated by Cloud Spanner and becomes stale + * the moment it is queried. If you are using this value to recover data, make + * sure to account for the time from the moment when the value is queried to + * the moment when you initiate the recovery. + * + * Generated from protobuf field .google.protobuf.Timestamp earliest_version_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getEarliestVersionTime() + { + return $this->earliest_version_time; + } + + public function hasEarliestVersionTime() + { + return isset($this->earliest_version_time); + } + + public function clearEarliestVersionTime() + { + unset($this->earliest_version_time); + } + + /** + * Output only. Earliest timestamp at which older versions of the data can be + * read. This value is continuously updated by Cloud Spanner and becomes stale + * the moment it is queried. If you are using this value to recover data, make + * sure to account for the time from the moment when the value is queried to + * the moment when you initiate the recovery. + * + * Generated from protobuf field .google.protobuf.Timestamp earliest_version_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setEarliestVersionTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->earliest_version_time = $var; + + return $this; + } + + /** + * Output only. The read-write region which contains the database's leader + * replicas. + * This is the same as the value of default_leader + * database option set using DatabaseAdmin.CreateDatabase or + * DatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty. + * + * Generated from protobuf field string default_leader = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getDefaultLeader() + { + return $this->default_leader; + } + + /** + * Output only. The read-write region which contains the database's leader + * replicas. + * This is the same as the value of default_leader + * database option set using DatabaseAdmin.CreateDatabase or + * DatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty. + * + * Generated from protobuf field string default_leader = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setDefaultLeader($var) + { + GPBUtil::checkString($var, True); + $this->default_leader = $var; + + return $this; + } + + /** + * Output only. The dialect of the Cloud Spanner Database. + * + * Generated from protobuf field .google.spanner.admin.database.v1.DatabaseDialect database_dialect = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getDatabaseDialect() + { + return $this->database_dialect; + } + + /** + * Output only. The dialect of the Cloud Spanner Database. + * + * Generated from protobuf field .google.spanner.admin.database.v1.DatabaseDialect database_dialect = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setDatabaseDialect($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Database\V1\DatabaseDialect::class); + $this->database_dialect = $var; + + return $this; + } + + /** + * Whether drop protection is enabled for this database. Defaults to false, + * if not set. For more details, please see how to [prevent accidental + * database + * deletion](https://cloud.google.com/spanner/docs/prevent-database-deletion). + * + * Generated from protobuf field bool enable_drop_protection = 11; + * @return bool + */ + public function getEnableDropProtection() + { + return $this->enable_drop_protection; + } + + /** + * Whether drop protection is enabled for this database. Defaults to false, + * if not set. For more details, please see how to [prevent accidental + * database + * deletion](https://cloud.google.com/spanner/docs/prevent-database-deletion). + * + * Generated from protobuf field bool enable_drop_protection = 11; + * @param bool $var + * @return $this + */ + public function setEnableDropProtection($var) + { + GPBUtil::checkBool($var); + $this->enable_drop_protection = $var; + + return $this; + } + + /** + * Output only. If true, the database is being updated. If false, there are no + * ongoing update operations for the database. + * + * Generated from protobuf field bool reconciling = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return bool + */ + public function getReconciling() + { + return $this->reconciling; + } + + /** + * Output only. If true, the database is being updated. If false, there are no + * ongoing update operations for the database. + * + * Generated from protobuf field bool reconciling = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param bool $var + * @return $this + */ + public function setReconciling($var) + { + GPBUtil::checkBool($var); + $this->reconciling = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/Database/State.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/Database/State.php new file mode 100644 index 000000000000..92c56529fbad --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/Database/State.php @@ -0,0 +1,78 @@ +google.spanner.admin.database.v1.Database.State + */ +class State +{ + /** + * Not specified. + * + * Generated from protobuf enum STATE_UNSPECIFIED = 0; + */ + const STATE_UNSPECIFIED = 0; + /** + * The database is still being created. Operations on the database may fail + * with `FAILED_PRECONDITION` in this state. + * + * Generated from protobuf enum CREATING = 1; + */ + const CREATING = 1; + /** + * The database is fully created and ready for use. + * + * Generated from protobuf enum READY = 2; + */ + const READY = 2; + /** + * The database is fully created and ready for use, but is still + * being optimized for performance and cannot handle full load. + * In this state, the database still references the backup + * it was restore from, preventing the backup + * from being deleted. When optimizations are complete, the full performance + * of the database will be restored, and the database will transition to + * `READY` state. + * + * Generated from protobuf enum READY_OPTIMIZING = 3; + */ + const READY_OPTIMIZING = 3; + + private static $valueToName = [ + self::STATE_UNSPECIFIED => 'STATE_UNSPECIFIED', + self::CREATING => 'CREATING', + self::READY => 'READY', + self::READY_OPTIMIZING => 'READY_OPTIMIZING', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(State::class, \Google\Cloud\Spanner\Admin\Database\V1\Database_State::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DatabaseDialect.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DatabaseDialect.php new file mode 100644 index 000000000000..ed173031894b --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DatabaseDialect.php @@ -0,0 +1,62 @@ +google.spanner.admin.database.v1.DatabaseDialect + */ +class DatabaseDialect +{ + /** + * Default value. This value will create a database with the + * GOOGLE_STANDARD_SQL dialect. + * + * Generated from protobuf enum DATABASE_DIALECT_UNSPECIFIED = 0; + */ + const DATABASE_DIALECT_UNSPECIFIED = 0; + /** + * GoogleSQL supported SQL. + * + * Generated from protobuf enum GOOGLE_STANDARD_SQL = 1; + */ + const GOOGLE_STANDARD_SQL = 1; + /** + * PostgreSQL supported SQL. + * + * Generated from protobuf enum POSTGRESQL = 2; + */ + const POSTGRESQL = 2; + + private static $valueToName = [ + self::DATABASE_DIALECT_UNSPECIFIED => 'DATABASE_DIALECT_UNSPECIFIED', + self::GOOGLE_STANDARD_SQL => 'GOOGLE_STANDARD_SQL', + self::POSTGRESQL => 'POSTGRESQL', + ]; + + 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/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DatabaseRole.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DatabaseRole.php new file mode 100644 index 000000000000..f34003461bac --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DatabaseRole.php @@ -0,0 +1,75 @@ +google.spanner.admin.database.v1.DatabaseRole + */ +class DatabaseRole extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the database role. Values are of the form + * `projects//instances//databases//databaseRoles/` + * where `` is as specified in the `CREATE ROLE` DDL statement. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the database role. Values are of the form + * `projects//instances//databases//databaseRoles/` + * where `` is as specified in the `CREATE ROLE` DDL statement. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the database role. Values are of the form + * `projects//instances//databases//databaseRoles/` + * where `` is as specified in the `CREATE ROLE` DDL statement. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. The name of the database role. Values are of the form + * `projects//instances//databases//databaseRoles/` + * where `` is as specified in the `CREATE ROLE` DDL statement. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DdlStatementActionInfo.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DdlStatementActionInfo.php new file mode 100644 index 000000000000..10cae9737db2 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DdlStatementActionInfo.php @@ -0,0 +1,165 @@ +google.spanner.admin.database.v1.DdlStatementActionInfo + */ +class DdlStatementActionInfo extends \Google\Protobuf\Internal\Message +{ + /** + * The action for the DDL statement, e.g. CREATE, ALTER, DROP, GRANT, etc. + * This field is a non-empty string. + * + * Generated from protobuf field string action = 1; + */ + protected $action = ''; + /** + * The entity type for the DDL statement, e.g. TABLE, INDEX, VIEW, etc. + * This field can be empty string for some DDL statement, + * e.g. for statement "ANALYZE", `entity_type` = "". + * + * Generated from protobuf field string entity_type = 2; + */ + protected $entity_type = ''; + /** + * The entity name(s) being operated on the DDL statement. + * E.g. + * 1. For statement "CREATE TABLE t1(...)", `entity_names` = ["t1"]. + * 2. For statement "GRANT ROLE r1, r2 ...", `entity_names` = ["r1", "r2"]. + * 3. For statement "ANALYZE", `entity_names` = []. + * + * Generated from protobuf field repeated string entity_names = 3; + */ + private $entity_names; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $action + * The action for the DDL statement, e.g. CREATE, ALTER, DROP, GRANT, etc. + * This field is a non-empty string. + * @type string $entity_type + * The entity type for the DDL statement, e.g. TABLE, INDEX, VIEW, etc. + * This field can be empty string for some DDL statement, + * e.g. for statement "ANALYZE", `entity_type` = "". + * @type array|\Google\Protobuf\Internal\RepeatedField $entity_names + * The entity name(s) being operated on the DDL statement. + * E.g. + * 1. For statement "CREATE TABLE t1(...)", `entity_names` = ["t1"]. + * 2. For statement "GRANT ROLE r1, r2 ...", `entity_names` = ["r1", "r2"]. + * 3. For statement "ANALYZE", `entity_names` = []. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The action for the DDL statement, e.g. CREATE, ALTER, DROP, GRANT, etc. + * This field is a non-empty string. + * + * Generated from protobuf field string action = 1; + * @return string + */ + public function getAction() + { + return $this->action; + } + + /** + * The action for the DDL statement, e.g. CREATE, ALTER, DROP, GRANT, etc. + * This field is a non-empty string. + * + * Generated from protobuf field string action = 1; + * @param string $var + * @return $this + */ + public function setAction($var) + { + GPBUtil::checkString($var, True); + $this->action = $var; + + return $this; + } + + /** + * The entity type for the DDL statement, e.g. TABLE, INDEX, VIEW, etc. + * This field can be empty string for some DDL statement, + * e.g. for statement "ANALYZE", `entity_type` = "". + * + * Generated from protobuf field string entity_type = 2; + * @return string + */ + public function getEntityType() + { + return $this->entity_type; + } + + /** + * The entity type for the DDL statement, e.g. TABLE, INDEX, VIEW, etc. + * This field can be empty string for some DDL statement, + * e.g. for statement "ANALYZE", `entity_type` = "". + * + * Generated from protobuf field string entity_type = 2; + * @param string $var + * @return $this + */ + public function setEntityType($var) + { + GPBUtil::checkString($var, True); + $this->entity_type = $var; + + return $this; + } + + /** + * The entity name(s) being operated on the DDL statement. + * E.g. + * 1. For statement "CREATE TABLE t1(...)", `entity_names` = ["t1"]. + * 2. For statement "GRANT ROLE r1, r2 ...", `entity_names` = ["r1", "r2"]. + * 3. For statement "ANALYZE", `entity_names` = []. + * + * Generated from protobuf field repeated string entity_names = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getEntityNames() + { + return $this->entity_names; + } + + /** + * The entity name(s) being operated on the DDL statement. + * E.g. + * 1. For statement "CREATE TABLE t1(...)", `entity_names` = ["t1"]. + * 2. For statement "GRANT ROLE r1, r2 ...", `entity_names` = ["r1", "r2"]. + * 3. For statement "ANALYZE", `entity_names` = []. + * + * Generated from protobuf field repeated string entity_names = 3; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setEntityNames($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->entity_names = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DeleteBackupRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DeleteBackupRequest.php new file mode 100644 index 000000000000..a2418220b700 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DeleteBackupRequest.php @@ -0,0 +1,92 @@ +google.spanner.admin.database.v1.DeleteBackupRequest + */ +class DeleteBackupRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Name of the backup to delete. + * Values are of the form + * `projects//instances//backups/`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. Name of the backup to delete. + * Values are of the form + * `projects//instances//backups/`. Please see + * {@see DatabaseAdminClient::backupName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\DeleteBackupRequest + * + * @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. Name of the backup to delete. + * Values are of the form + * `projects//instances//backups/`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Backup::initOnce(); + parent::__construct($data); + } + + /** + * Required. Name of the backup to delete. + * Values are of the form + * `projects//instances//backups/`. + * + * 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. Name of the backup to delete. + * Values are of the form + * `projects//instances//backups/`. + * + * 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/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DeleteBackupScheduleRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DeleteBackupScheduleRequest.php new file mode 100644 index 000000000000..34083030de53 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DeleteBackupScheduleRequest.php @@ -0,0 +1,92 @@ +google.spanner.admin.database.v1.DeleteBackupScheduleRequest + */ +class DeleteBackupScheduleRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the schedule to delete. + * Values are of the form + * `projects//instances//databases//backupSchedules/`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. The name of the schedule to delete. + * Values are of the form + * `projects//instances//databases//backupSchedules/`. Please see + * {@see DatabaseAdminClient::backupScheduleName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\DeleteBackupScheduleRequest + * + * @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. The name of the schedule to delete. + * Values are of the form + * `projects//instances//databases//backupSchedules/`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\BackupSchedule::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the schedule to delete. + * Values are of the form + * `projects//instances//databases//backupSchedules/`. + * + * 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. The name of the schedule to delete. + * Values are of the form + * `projects//instances//databases//backupSchedules/`. + * + * 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/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DropDatabaseRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DropDatabaseRequest.php new file mode 100644 index 000000000000..29d92fc6d153 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/DropDatabaseRequest.php @@ -0,0 +1,82 @@ +google.spanner.admin.database.v1.DropDatabaseRequest + */ +class DropDatabaseRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The database to be dropped. + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $database = ''; + + /** + * @param string $database Required. The database to be dropped. Please see + * {@see DatabaseAdminClient::databaseName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\DropDatabaseRequest + * + * @experimental + */ + public static function build(string $database): self + { + return (new self()) + ->setDatabase($database); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $database + * Required. The database to be dropped. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The database to be dropped. + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getDatabase() + { + return $this->database; + } + + /** + * Required. The database to be dropped. + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setDatabase($var) + { + GPBUtil::checkString($var, True); + $this->database = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/EncryptionConfig.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/EncryptionConfig.php new file mode 100644 index 000000000000..c0bc45190b62 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/EncryptionConfig.php @@ -0,0 +1,161 @@ +google.spanner.admin.database.v1.EncryptionConfig + */ +class EncryptionConfig extends \Google\Protobuf\Internal\Message +{ + /** + * The Cloud KMS key to be used for encrypting and decrypting + * the database. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * + * Generated from protobuf field string kms_key_name = 2 [(.google.api.resource_reference) = { + */ + protected $kms_key_name = ''; + /** + * Specifies the KMS configuration for the one or more keys used to encrypt + * the database. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * The keys referenced by kms_key_names must fully cover all + * regions of the database instance configuration. Some examples: + * * For single region database instance configs, specify a single regional + * location KMS key. + * * For multi-regional database instance configs of type GOOGLE_MANAGED, + * either specify a multi-regional location KMS key or multiple regional + * location KMS keys that cover all regions in the instance config. + * * For a database instance config of type USER_MANAGED, please specify only + * regional location KMS keys to cover each region in the instance config. + * Multi-regional location KMS keys are not supported for USER_MANAGED + * instance configs. + * + * Generated from protobuf field repeated string kms_key_names = 3 [(.google.api.resource_reference) = { + */ + private $kms_key_names; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $kms_key_name + * The Cloud KMS key to be used for encrypting and decrypting + * the database. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * @type array|\Google\Protobuf\Internal\RepeatedField $kms_key_names + * Specifies the KMS configuration for the one or more keys used to encrypt + * the database. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * The keys referenced by kms_key_names must fully cover all + * regions of the database instance configuration. Some examples: + * * For single region database instance configs, specify a single regional + * location KMS key. + * * For multi-regional database instance configs of type GOOGLE_MANAGED, + * either specify a multi-regional location KMS key or multiple regional + * location KMS keys that cover all regions in the instance config. + * * For a database instance config of type USER_MANAGED, please specify only + * regional location KMS keys to cover each region in the instance config. + * Multi-regional location KMS keys are not supported for USER_MANAGED + * instance configs. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Common::initOnce(); + parent::__construct($data); + } + + /** + * The Cloud KMS key to be used for encrypting and decrypting + * the database. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * + * Generated from protobuf field string kms_key_name = 2 [(.google.api.resource_reference) = { + * @return string + */ + public function getKmsKeyName() + { + return $this->kms_key_name; + } + + /** + * The Cloud KMS key to be used for encrypting and decrypting + * the database. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * + * Generated from protobuf field string kms_key_name = 2 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setKmsKeyName($var) + { + GPBUtil::checkString($var, True); + $this->kms_key_name = $var; + + return $this; + } + + /** + * Specifies the KMS configuration for the one or more keys used to encrypt + * the database. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * The keys referenced by kms_key_names must fully cover all + * regions of the database instance configuration. Some examples: + * * For single region database instance configs, specify a single regional + * location KMS key. + * * For multi-regional database instance configs of type GOOGLE_MANAGED, + * either specify a multi-regional location KMS key or multiple regional + * location KMS keys that cover all regions in the instance config. + * * For a database instance config of type USER_MANAGED, please specify only + * regional location KMS keys to cover each region in the instance config. + * Multi-regional location KMS keys are not supported for USER_MANAGED + * instance configs. + * + * Generated from protobuf field repeated string kms_key_names = 3 [(.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getKmsKeyNames() + { + return $this->kms_key_names; + } + + /** + * Specifies the KMS configuration for the one or more keys used to encrypt + * the database. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * The keys referenced by kms_key_names must fully cover all + * regions of the database instance configuration. Some examples: + * * For single region database instance configs, specify a single regional + * location KMS key. + * * For multi-regional database instance configs of type GOOGLE_MANAGED, + * either specify a multi-regional location KMS key or multiple regional + * location KMS keys that cover all regions in the instance config. + * * For a database instance config of type USER_MANAGED, please specify only + * regional location KMS keys to cover each region in the instance config. + * Multi-regional location KMS keys are not supported for USER_MANAGED + * instance configs. + * + * Generated from protobuf field repeated string kms_key_names = 3 [(.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setKmsKeyNames($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->kms_key_names = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/EncryptionInfo.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/EncryptionInfo.php new file mode 100644 index 000000000000..960ada451ae8 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/EncryptionInfo.php @@ -0,0 +1,157 @@ +google.spanner.admin.database.v1.EncryptionInfo + */ +class EncryptionInfo extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. The type of encryption. + * + * Generated from protobuf field .google.spanner.admin.database.v1.EncryptionInfo.Type encryption_type = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $encryption_type = 0; + /** + * Output only. If present, the status of a recent encrypt/decrypt call on + * underlying data for this database or backup. Regardless of status, data is + * always encrypted at rest. + * + * Generated from protobuf field .google.rpc.Status encryption_status = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $encryption_status = null; + /** + * Output only. A Cloud KMS key version that is being used to protect the + * database or backup. + * + * Generated from protobuf field string kms_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + */ + protected $kms_key_version = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $encryption_type + * Output only. The type of encryption. + * @type \Google\Rpc\Status $encryption_status + * Output only. If present, the status of a recent encrypt/decrypt call on + * underlying data for this database or backup. Regardless of status, data is + * always encrypted at rest. + * @type string $kms_key_version + * Output only. A Cloud KMS key version that is being used to protect the + * database or backup. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Common::initOnce(); + parent::__construct($data); + } + + /** + * Output only. The type of encryption. + * + * Generated from protobuf field .google.spanner.admin.database.v1.EncryptionInfo.Type encryption_type = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getEncryptionType() + { + return $this->encryption_type; + } + + /** + * Output only. The type of encryption. + * + * Generated from protobuf field .google.spanner.admin.database.v1.EncryptionInfo.Type encryption_type = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setEncryptionType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Database\V1\EncryptionInfo\Type::class); + $this->encryption_type = $var; + + return $this; + } + + /** + * Output only. If present, the status of a recent encrypt/decrypt call on + * underlying data for this database or backup. Regardless of status, data is + * always encrypted at rest. + * + * Generated from protobuf field .google.rpc.Status encryption_status = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Rpc\Status|null + */ + public function getEncryptionStatus() + { + return $this->encryption_status; + } + + public function hasEncryptionStatus() + { + return isset($this->encryption_status); + } + + public function clearEncryptionStatus() + { + unset($this->encryption_status); + } + + /** + * Output only. If present, the status of a recent encrypt/decrypt call on + * underlying data for this database or backup. Regardless of status, data is + * always encrypted at rest. + * + * Generated from protobuf field .google.rpc.Status encryption_status = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Rpc\Status $var + * @return $this + */ + public function setEncryptionStatus($var) + { + GPBUtil::checkMessage($var, \Google\Rpc\Status::class); + $this->encryption_status = $var; + + return $this; + } + + /** + * Output only. A Cloud KMS key version that is being used to protect the + * database or backup. + * + * Generated from protobuf field string kms_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + * @return string + */ + public function getKmsKeyVersion() + { + return $this->kms_key_version; + } + + /** + * Output only. A Cloud KMS key version that is being used to protect the + * database or backup. + * + * Generated from protobuf field string kms_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setKmsKeyVersion($var) + { + GPBUtil::checkString($var, True); + $this->kms_key_version = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/EncryptionInfo/Type.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/EncryptionInfo/Type.php new file mode 100644 index 000000000000..d54274fba026 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/EncryptionInfo/Type.php @@ -0,0 +1,68 @@ +google.spanner.admin.database.v1.EncryptionInfo.Type + */ +class Type +{ + /** + * Encryption type was not specified, though data at rest remains encrypted. + * + * Generated from protobuf enum TYPE_UNSPECIFIED = 0; + */ + const TYPE_UNSPECIFIED = 0; + /** + * The data is encrypted at rest with a key that is + * fully managed by Google. No key version or status will be populated. + * This is the default state. + * + * Generated from protobuf enum GOOGLE_DEFAULT_ENCRYPTION = 1; + */ + const GOOGLE_DEFAULT_ENCRYPTION = 1; + /** + * The data is encrypted at rest with a key that is + * managed by the customer. The active version of the key. `kms_key_version` + * will be populated, and `encryption_status` may be populated. + * + * Generated from protobuf enum CUSTOMER_MANAGED_ENCRYPTION = 2; + */ + const CUSTOMER_MANAGED_ENCRYPTION = 2; + + private static $valueToName = [ + self::TYPE_UNSPECIFIED => 'TYPE_UNSPECIFIED', + self::GOOGLE_DEFAULT_ENCRYPTION => 'GOOGLE_DEFAULT_ENCRYPTION', + self::CUSTOMER_MANAGED_ENCRYPTION => 'CUSTOMER_MANAGED_ENCRYPTION', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Type::class, \Google\Cloud\Spanner\Admin\Database\V1\EncryptionInfo_Type::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/FullBackupSpec.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/FullBackupSpec.php new file mode 100644 index 000000000000..3edbb8d4fd2b --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/FullBackupSpec.php @@ -0,0 +1,35 @@ +google.spanner.admin.database.v1.FullBackupSpec + */ +class FullBackupSpec extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Backup::initOnce(); + parent::__construct($data); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/GetBackupRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/GetBackupRequest.php new file mode 100644 index 000000000000..442d207b6386 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/GetBackupRequest.php @@ -0,0 +1,92 @@ +google.spanner.admin.database.v1.GetBackupRequest + */ +class GetBackupRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Name of the backup. + * Values are of the form + * `projects//instances//backups/`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. Name of the backup. + * Values are of the form + * `projects//instances//backups/`. Please see + * {@see DatabaseAdminClient::backupName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\GetBackupRequest + * + * @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. Name of the backup. + * Values are of the form + * `projects//instances//backups/`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Backup::initOnce(); + parent::__construct($data); + } + + /** + * Required. Name of the backup. + * Values are of the form + * `projects//instances//backups/`. + * + * 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. Name of the backup. + * Values are of the form + * `projects//instances//backups/`. + * + * 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/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/GetBackupScheduleRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/GetBackupScheduleRequest.php new file mode 100644 index 000000000000..75b5f8400005 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/GetBackupScheduleRequest.php @@ -0,0 +1,92 @@ +google.spanner.admin.database.v1.GetBackupScheduleRequest + */ +class GetBackupScheduleRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the schedule to retrieve. + * Values are of the form + * `projects//instances//databases//backupSchedules/`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. The name of the schedule to retrieve. + * Values are of the form + * `projects//instances//databases//backupSchedules/`. Please see + * {@see DatabaseAdminClient::backupScheduleName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\GetBackupScheduleRequest + * + * @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. The name of the schedule to retrieve. + * Values are of the form + * `projects//instances//databases//backupSchedules/`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\BackupSchedule::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the schedule to retrieve. + * Values are of the form + * `projects//instances//databases//backupSchedules/`. + * + * 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. The name of the schedule to retrieve. + * Values are of the form + * `projects//instances//databases//backupSchedules/`. + * + * 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/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/GetDatabaseDdlRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/GetDatabaseDdlRequest.php new file mode 100644 index 000000000000..6e955af72d1a --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/GetDatabaseDdlRequest.php @@ -0,0 +1,92 @@ +google.spanner.admin.database.v1.GetDatabaseDdlRequest + */ +class GetDatabaseDdlRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The database whose schema we wish to get. + * Values are of the form + * `projects//instances//databases/` + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $database = ''; + + /** + * @param string $database Required. The database whose schema we wish to get. + * Values are of the form + * `projects//instances//databases/` + * Please see {@see DatabaseAdminClient::databaseName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\GetDatabaseDdlRequest + * + * @experimental + */ + public static function build(string $database): self + { + return (new self()) + ->setDatabase($database); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $database + * Required. The database whose schema we wish to get. + * Values are of the form + * `projects//instances//databases/` + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The database whose schema we wish to get. + * Values are of the form + * `projects//instances//databases/` + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getDatabase() + { + return $this->database; + } + + /** + * Required. The database whose schema we wish to get. + * Values are of the form + * `projects//instances//databases/` + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setDatabase($var) + { + GPBUtil::checkString($var, True); + $this->database = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/GetDatabaseDdlResponse.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/GetDatabaseDdlResponse.php new file mode 100644 index 000000000000..a190d7f20b13 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/GetDatabaseDdlResponse.php @@ -0,0 +1,122 @@ +google.spanner.admin.database.v1.GetDatabaseDdlResponse + */ +class GetDatabaseDdlResponse extends \Google\Protobuf\Internal\Message +{ + /** + * A list of formatted DDL statements defining the schema of the database + * specified in the request. + * + * Generated from protobuf field repeated string statements = 1; + */ + private $statements; + /** + * Proto descriptors stored in the database. + * Contains a protobuf-serialized + * [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto). + * For more details, see protobuffer [self + * description](https://developers.google.com/protocol-buffers/docs/techniques#self-description). + * + * Generated from protobuf field bytes proto_descriptors = 2; + */ + protected $proto_descriptors = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array|\Google\Protobuf\Internal\RepeatedField $statements + * A list of formatted DDL statements defining the schema of the database + * specified in the request. + * @type string $proto_descriptors + * Proto descriptors stored in the database. + * Contains a protobuf-serialized + * [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto). + * For more details, see protobuffer [self + * description](https://developers.google.com/protocol-buffers/docs/techniques#self-description). + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * A list of formatted DDL statements defining the schema of the database + * specified in the request. + * + * Generated from protobuf field repeated string statements = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getStatements() + { + return $this->statements; + } + + /** + * A list of formatted DDL statements defining the schema of the database + * specified in the request. + * + * Generated from protobuf field repeated string statements = 1; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setStatements($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->statements = $arr; + + return $this; + } + + /** + * Proto descriptors stored in the database. + * Contains a protobuf-serialized + * [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto). + * For more details, see protobuffer [self + * description](https://developers.google.com/protocol-buffers/docs/techniques#self-description). + * + * Generated from protobuf field bytes proto_descriptors = 2; + * @return string + */ + public function getProtoDescriptors() + { + return $this->proto_descriptors; + } + + /** + * Proto descriptors stored in the database. + * Contains a protobuf-serialized + * [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto). + * For more details, see protobuffer [self + * description](https://developers.google.com/protocol-buffers/docs/techniques#self-description). + * + * Generated from protobuf field bytes proto_descriptors = 2; + * @param string $var + * @return $this + */ + public function setProtoDescriptors($var) + { + GPBUtil::checkString($var, False); + $this->proto_descriptors = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/GetDatabaseRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/GetDatabaseRequest.php new file mode 100644 index 000000000000..bacc542101f3 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/GetDatabaseRequest.php @@ -0,0 +1,87 @@ +google.spanner.admin.database.v1.GetDatabaseRequest + */ +class GetDatabaseRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the requested database. Values are of the form + * `projects//instances//databases/`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. The name of the requested database. Values are of the form + * `projects//instances//databases/`. Please see + * {@see DatabaseAdminClient::databaseName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\GetDatabaseRequest + * + * @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. The name of the requested database. Values are of the form + * `projects//instances//databases/`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the requested database. Values are of the form + * `projects//instances//databases/`. + * + * 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. The name of the requested database. Values are of the form + * `projects//instances//databases/`. + * + * 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/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/IncrementalBackupSpec.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/IncrementalBackupSpec.php new file mode 100644 index 000000000000..8db0cd8de770 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/IncrementalBackupSpec.php @@ -0,0 +1,38 @@ +google.spanner.admin.database.v1.IncrementalBackupSpec + */ +class IncrementalBackupSpec extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Backup::initOnce(); + parent::__construct($data); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupOperationsRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupOperationsRequest.php new file mode 100644 index 000000000000..c12ea71b9f7e --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupOperationsRequest.php @@ -0,0 +1,461 @@ +google.spanner.admin.database.v1.ListBackupOperationsRequest + */ +class ListBackupOperationsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The instance of the backup operations. Values are of + * the form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * An expression that filters the list of returned backup operations. + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the [operation][google.longrunning.Operation] + * are eligible for filtering: + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] + * is + * `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic, but + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `done:true` - The operation is complete. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `metadata.database:prod` - Returns operations where: + * * The operation's metadata type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + * * The source database name of backup contains the string "prod". + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `(metadata.name:howl) AND` \ + * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + * * The backup name contains the string "howl". + * * The operation started before 2018-03-28T14:50:00Z. + * * The operation resulted in an error. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND` \ + * `(metadata.source_backup:test) AND` \ + * `(metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. + * * The source backup name contains the string "test". + * * The operation started before 2022-01-18T14:50:00Z. + * * The operation resulted in an error. + * * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `(metadata.database:test_db)) OR` \ + * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) + * AND` \ + * `(metadata.source_backup:test_bkp)) AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata matches either of criteria: + * * The operation's metadata type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] + * AND the source database name of the backup contains the string + * "test_db" + * * The operation's metadata type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata] + * AND the source backup name contains the string "test_bkp" + * * The operation resulted in an error. + * + * Generated from protobuf field string filter = 2; + */ + protected $filter = ''; + /** + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3; + */ + protected $page_size = 0; + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token] + * from a previous + * [ListBackupOperationsResponse][google.spanner.admin.database.v1.ListBackupOperationsResponse] + * to the same `parent` and with the same `filter`. + * + * Generated from protobuf field string page_token = 4; + */ + protected $page_token = ''; + + /** + * @param string $parent Required. The instance of the backup operations. Values are of + * the form `projects//instances/`. Please see + * {@see DatabaseAdminClient::instanceName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\ListBackupOperationsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The instance of the backup operations. Values are of + * the form `projects//instances/`. + * @type string $filter + * An expression that filters the list of returned backup operations. + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the [operation][google.longrunning.Operation] + * are eligible for filtering: + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] + * is + * `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic, but + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `done:true` - The operation is complete. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `metadata.database:prod` - Returns operations where: + * * The operation's metadata type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + * * The source database name of backup contains the string "prod". + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `(metadata.name:howl) AND` \ + * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + * * The backup name contains the string "howl". + * * The operation started before 2018-03-28T14:50:00Z. + * * The operation resulted in an error. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND` \ + * `(metadata.source_backup:test) AND` \ + * `(metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. + * * The source backup name contains the string "test". + * * The operation started before 2022-01-18T14:50:00Z. + * * The operation resulted in an error. + * * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `(metadata.database:test_db)) OR` \ + * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) + * AND` \ + * `(metadata.source_backup:test_bkp)) AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata matches either of criteria: + * * The operation's metadata type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] + * AND the source database name of the backup contains the string + * "test_db" + * * The operation's metadata type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata] + * AND the source backup name contains the string "test_bkp" + * * The operation resulted in an error. + * @type int $page_size + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @type string $page_token + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token] + * from a previous + * [ListBackupOperationsResponse][google.spanner.admin.database.v1.ListBackupOperationsResponse] + * to the same `parent` and with the same `filter`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Backup::initOnce(); + parent::__construct($data); + } + + /** + * Required. The instance of the backup operations. Values are of + * the form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The instance of the backup operations. Values are of + * the form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * An expression that filters the list of returned backup operations. + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the [operation][google.longrunning.Operation] + * are eligible for filtering: + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] + * is + * `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic, but + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `done:true` - The operation is complete. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `metadata.database:prod` - Returns operations where: + * * The operation's metadata type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + * * The source database name of backup contains the string "prod". + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `(metadata.name:howl) AND` \ + * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + * * The backup name contains the string "howl". + * * The operation started before 2018-03-28T14:50:00Z. + * * The operation resulted in an error. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND` \ + * `(metadata.source_backup:test) AND` \ + * `(metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. + * * The source backup name contains the string "test". + * * The operation started before 2022-01-18T14:50:00Z. + * * The operation resulted in an error. + * * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `(metadata.database:test_db)) OR` \ + * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) + * AND` \ + * `(metadata.source_backup:test_bkp)) AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata matches either of criteria: + * * The operation's metadata type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] + * AND the source database name of the backup contains the string + * "test_db" + * * The operation's metadata type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata] + * AND the source backup name contains the string "test_bkp" + * * The operation resulted in an error. + * + * Generated from protobuf field string filter = 2; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * An expression that filters the list of returned backup operations. + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the [operation][google.longrunning.Operation] + * are eligible for filtering: + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] + * is + * `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic, but + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `done:true` - The operation is complete. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `metadata.database:prod` - Returns operations where: + * * The operation's metadata type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + * * The source database name of backup contains the string "prod". + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `(metadata.name:howl) AND` \ + * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + * * The backup name contains the string "howl". + * * The operation started before 2018-03-28T14:50:00Z. + * * The operation resulted in an error. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND` \ + * `(metadata.source_backup:test) AND` \ + * `(metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. + * * The source backup name contains the string "test". + * * The operation started before 2022-01-18T14:50:00Z. + * * The operation resulted in an error. + * * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `(metadata.database:test_db)) OR` \ + * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) + * AND` \ + * `(metadata.source_backup:test_bkp)) AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata matches either of criteria: + * * The operation's metadata type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] + * AND the source database name of the backup contains the string + * "test_db" + * * The operation's metadata type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata] + * AND the source backup name contains the string "test_bkp" + * * The operation resulted in an error. + * + * Generated from protobuf field string filter = 2; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token] + * from a previous + * [ListBackupOperationsResponse][google.spanner.admin.database.v1.ListBackupOperationsResponse] + * to the same `parent` and with the same `filter`. + * + * Generated from protobuf field string page_token = 4; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token] + * from a previous + * [ListBackupOperationsResponse][google.spanner.admin.database.v1.ListBackupOperationsResponse] + * to the same `parent` and with the same `filter`. + * + * Generated from protobuf field string page_token = 4; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupOperationsResponse.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupOperationsResponse.php new file mode 100644 index 000000000000..145888a176cd --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupOperationsResponse.php @@ -0,0 +1,142 @@ +google.spanner.admin.database.v1.ListBackupOperationsResponse + */ +class ListBackupOperationsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of matching backup [long-running + * operations][google.longrunning.Operation]. Each operation's name will be + * prefixed by the backup's name. The operation's + * [metadata][google.longrunning.Operation.metadata] field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that are pending or have completed/failed/canceled within the + * last 7 days. Operations returned are ordered by + * `operation.metadata.value.progress.start_time` in descending order starting + * from the most recently started operation. + * + * Generated from protobuf field repeated .google.longrunning.Operation operations = 1; + */ + private $operations; + /** + * `next_page_token` can be sent in a subsequent + * [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations] + * call to fetch more of the matching metadata. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\LongRunning\Operation>|\Google\Protobuf\Internal\RepeatedField $operations + * The list of matching backup [long-running + * operations][google.longrunning.Operation]. Each operation's name will be + * prefixed by the backup's name. The operation's + * [metadata][google.longrunning.Operation.metadata] field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that are pending or have completed/failed/canceled within the + * last 7 days. Operations returned are ordered by + * `operation.metadata.value.progress.start_time` in descending order starting + * from the most recently started operation. + * @type string $next_page_token + * `next_page_token` can be sent in a subsequent + * [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations] + * call to fetch more of the matching metadata. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Backup::initOnce(); + parent::__construct($data); + } + + /** + * The list of matching backup [long-running + * operations][google.longrunning.Operation]. Each operation's name will be + * prefixed by the backup's name. The operation's + * [metadata][google.longrunning.Operation.metadata] field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that are pending or have completed/failed/canceled within the + * last 7 days. Operations returned are ordered by + * `operation.metadata.value.progress.start_time` in descending order starting + * from the most recently started operation. + * + * Generated from protobuf field repeated .google.longrunning.Operation operations = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOperations() + { + return $this->operations; + } + + /** + * The list of matching backup [long-running + * operations][google.longrunning.Operation]. Each operation's name will be + * prefixed by the backup's name. The operation's + * [metadata][google.longrunning.Operation.metadata] field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that are pending or have completed/failed/canceled within the + * last 7 days. Operations returned are ordered by + * `operation.metadata.value.progress.start_time` in descending order starting + * from the most recently started operation. + * + * Generated from protobuf field repeated .google.longrunning.Operation operations = 1; + * @param array<\Google\LongRunning\Operation>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOperations($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\LongRunning\Operation::class); + $this->operations = $arr; + + return $this; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations] + * call to fetch more of the matching metadata. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations] + * call to fetch more of the matching metadata. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupSchedulesRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupSchedulesRequest.php new file mode 100644 index 000000000000..01af05ece7c9 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupSchedulesRequest.php @@ -0,0 +1,180 @@ +google.spanner.admin.database.v1.ListBackupSchedulesRequest + */ +class ListBackupSchedulesRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Database is the parent resource whose backup schedules should be + * listed. Values are of the form + * projects//instances//databases/ + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Optional. Number of backup schedules to be returned in the response. If 0 + * or less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $page_size = 0; + /** + * Optional. If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListBackupSchedulesResponse.next_page_token] + * from a previous + * [ListBackupSchedulesResponse][google.spanner.admin.database.v1.ListBackupSchedulesResponse] + * to the same `parent`. + * + * Generated from protobuf field string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $page_token = ''; + + /** + * @param string $parent Required. Database is the parent resource whose backup schedules should be + * listed. Values are of the form + * projects//instances//databases/ + * Please see {@see DatabaseAdminClient::databaseName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\ListBackupSchedulesRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. Database is the parent resource whose backup schedules should be + * listed. Values are of the form + * projects//instances//databases/ + * @type int $page_size + * Optional. Number of backup schedules to be returned in the response. If 0 + * or less, defaults to the server's maximum allowed page size. + * @type string $page_token + * Optional. If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListBackupSchedulesResponse.next_page_token] + * from a previous + * [ListBackupSchedulesResponse][google.spanner.admin.database.v1.ListBackupSchedulesResponse] + * to the same `parent`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\BackupSchedule::initOnce(); + parent::__construct($data); + } + + /** + * Required. Database is the parent resource whose backup schedules should be + * listed. Values are of the form + * projects//instances//databases/ + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. Database is the parent resource whose backup schedules should be + * listed. Values are of the form + * projects//instances//databases/ + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Optional. Number of backup schedules to be returned in the response. If 0 + * or less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Optional. Number of backup schedules to be returned in the response. If 0 + * or less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * Optional. If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListBackupSchedulesResponse.next_page_token] + * from a previous + * [ListBackupSchedulesResponse][google.spanner.admin.database.v1.ListBackupSchedulesResponse] + * to the same `parent`. + * + * Generated from protobuf field string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Optional. If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListBackupSchedulesResponse.next_page_token] + * from a previous + * [ListBackupSchedulesResponse][google.spanner.admin.database.v1.ListBackupSchedulesResponse] + * to the same `parent`. + * + * Generated from protobuf field string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupSchedulesResponse.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupSchedulesResponse.php new file mode 100644 index 000000000000..412a6c3800a9 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupSchedulesResponse.php @@ -0,0 +1,110 @@ +google.spanner.admin.database.v1.ListBackupSchedulesResponse + */ +class ListBackupSchedulesResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of backup schedules for a database. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + private $backup_schedules; + /** + * `next_page_token` can be sent in a subsequent + * [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules] + * call to fetch more of the schedules. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule>|\Google\Protobuf\Internal\RepeatedField $backup_schedules + * The list of backup schedules for a database. + * @type string $next_page_token + * `next_page_token` can be sent in a subsequent + * [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules] + * call to fetch more of the schedules. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\BackupSchedule::initOnce(); + parent::__construct($data); + } + + /** + * The list of backup schedules for a database. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getBackupSchedules() + { + return $this->backup_schedules; + } + + /** + * The list of backup schedules for a database. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + * @param array<\Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setBackupSchedules($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule::class); + $this->backup_schedules = $arr; + + return $this; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules] + * call to fetch more of the schedules. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules] + * call to fetch more of the schedules. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupsRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupsRequest.php new file mode 100644 index 000000000000..cdcfabb13d44 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupsRequest.php @@ -0,0 +1,341 @@ +google.spanner.admin.database.v1.ListBackupsRequest + */ +class ListBackupsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The instance to list backups from. Values are of the + * form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * An expression that filters the list of returned backups. + * A filter expression consists of a field name, a comparison operator, and a + * value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the + * [Backup][google.spanner.admin.database.v1.Backup] are eligible for + * filtering: + * * `name` + * * `database` + * * `state` + * * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `version_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `size_bytes` + * * `backup_schedules` + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic, but + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `name:Howl` - The backup's name contains the string "howl". + * * `database:prod` + * - The database's name contains the string "prod". + * * `state:CREATING` - The backup is pending creation. + * * `state:READY` - The backup is fully created and ready for use. + * * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")` + * - The backup name contains the string "howl" and `create_time` + * of the backup is before 2018-03-28T14:50:00Z. + * * `expire_time < \"2018-03-28T14:50:00Z\"` + * - The backup `expire_time` is before 2018-03-28T14:50:00Z. + * * `size_bytes > 10000000000` - The backup's size is greater than 10GB + * * `backup_schedules:daily` + * - The backup is created from a schedule with "daily" in its name. + * + * Generated from protobuf field string filter = 2; + */ + protected $filter = ''; + /** + * Number of backups to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3; + */ + protected $page_size = 0; + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListBackupsResponse.next_page_token] + * from a previous + * [ListBackupsResponse][google.spanner.admin.database.v1.ListBackupsResponse] + * to the same `parent` and with the same `filter`. + * + * Generated from protobuf field string page_token = 4; + */ + protected $page_token = ''; + + /** + * @param string $parent Required. The instance to list backups from. Values are of the + * form `projects//instances/`. Please see + * {@see DatabaseAdminClient::instanceName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\ListBackupsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The instance to list backups from. Values are of the + * form `projects//instances/`. + * @type string $filter + * An expression that filters the list of returned backups. + * A filter expression consists of a field name, a comparison operator, and a + * value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the + * [Backup][google.spanner.admin.database.v1.Backup] are eligible for + * filtering: + * * `name` + * * `database` + * * `state` + * * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `version_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `size_bytes` + * * `backup_schedules` + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic, but + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `name:Howl` - The backup's name contains the string "howl". + * * `database:prod` + * - The database's name contains the string "prod". + * * `state:CREATING` - The backup is pending creation. + * * `state:READY` - The backup is fully created and ready for use. + * * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")` + * - The backup name contains the string "howl" and `create_time` + * of the backup is before 2018-03-28T14:50:00Z. + * * `expire_time < \"2018-03-28T14:50:00Z\"` + * - The backup `expire_time` is before 2018-03-28T14:50:00Z. + * * `size_bytes > 10000000000` - The backup's size is greater than 10GB + * * `backup_schedules:daily` + * - The backup is created from a schedule with "daily" in its name. + * @type int $page_size + * Number of backups to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @type string $page_token + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListBackupsResponse.next_page_token] + * from a previous + * [ListBackupsResponse][google.spanner.admin.database.v1.ListBackupsResponse] + * to the same `parent` and with the same `filter`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Backup::initOnce(); + parent::__construct($data); + } + + /** + * Required. The instance to list backups from. Values are of the + * form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The instance to list backups from. Values are of the + * form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * An expression that filters the list of returned backups. + * A filter expression consists of a field name, a comparison operator, and a + * value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the + * [Backup][google.spanner.admin.database.v1.Backup] are eligible for + * filtering: + * * `name` + * * `database` + * * `state` + * * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `version_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `size_bytes` + * * `backup_schedules` + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic, but + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `name:Howl` - The backup's name contains the string "howl". + * * `database:prod` + * - The database's name contains the string "prod". + * * `state:CREATING` - The backup is pending creation. + * * `state:READY` - The backup is fully created and ready for use. + * * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")` + * - The backup name contains the string "howl" and `create_time` + * of the backup is before 2018-03-28T14:50:00Z. + * * `expire_time < \"2018-03-28T14:50:00Z\"` + * - The backup `expire_time` is before 2018-03-28T14:50:00Z. + * * `size_bytes > 10000000000` - The backup's size is greater than 10GB + * * `backup_schedules:daily` + * - The backup is created from a schedule with "daily" in its name. + * + * Generated from protobuf field string filter = 2; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * An expression that filters the list of returned backups. + * A filter expression consists of a field name, a comparison operator, and a + * value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the + * [Backup][google.spanner.admin.database.v1.Backup] are eligible for + * filtering: + * * `name` + * * `database` + * * `state` + * * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `version_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `size_bytes` + * * `backup_schedules` + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic, but + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `name:Howl` - The backup's name contains the string "howl". + * * `database:prod` + * - The database's name contains the string "prod". + * * `state:CREATING` - The backup is pending creation. + * * `state:READY` - The backup is fully created and ready for use. + * * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")` + * - The backup name contains the string "howl" and `create_time` + * of the backup is before 2018-03-28T14:50:00Z. + * * `expire_time < \"2018-03-28T14:50:00Z\"` + * - The backup `expire_time` is before 2018-03-28T14:50:00Z. + * * `size_bytes > 10000000000` - The backup's size is greater than 10GB + * * `backup_schedules:daily` + * - The backup is created from a schedule with "daily" in its name. + * + * Generated from protobuf field string filter = 2; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * Number of backups to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Number of backups to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListBackupsResponse.next_page_token] + * from a previous + * [ListBackupsResponse][google.spanner.admin.database.v1.ListBackupsResponse] + * to the same `parent` and with the same `filter`. + * + * Generated from protobuf field string page_token = 4; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListBackupsResponse.next_page_token] + * from a previous + * [ListBackupsResponse][google.spanner.admin.database.v1.ListBackupsResponse] + * to the same `parent` and with the same `filter`. + * + * Generated from protobuf field string page_token = 4; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupsResponse.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupsResponse.php new file mode 100644 index 000000000000..97493b3614f1 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListBackupsResponse.php @@ -0,0 +1,114 @@ +google.spanner.admin.database.v1.ListBackupsResponse + */ +class ListBackupsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of matching backups. Backups returned are ordered by `create_time` + * in descending order, starting from the most recent `create_time`. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.Backup backups = 1; + */ + private $backups; + /** + * `next_page_token` can be sent in a subsequent + * [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups] + * call to fetch more of the matching backups. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Spanner\Admin\Database\V1\Backup>|\Google\Protobuf\Internal\RepeatedField $backups + * The list of matching backups. Backups returned are ordered by `create_time` + * in descending order, starting from the most recent `create_time`. + * @type string $next_page_token + * `next_page_token` can be sent in a subsequent + * [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups] + * call to fetch more of the matching backups. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Backup::initOnce(); + parent::__construct($data); + } + + /** + * The list of matching backups. Backups returned are ordered by `create_time` + * in descending order, starting from the most recent `create_time`. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.Backup backups = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getBackups() + { + return $this->backups; + } + + /** + * The list of matching backups. Backups returned are ordered by `create_time` + * in descending order, starting from the most recent `create_time`. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.Backup backups = 1; + * @param array<\Google\Cloud\Spanner\Admin\Database\V1\Backup>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setBackups($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\Admin\Database\V1\Backup::class); + $this->backups = $arr; + + return $this; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups] + * call to fetch more of the matching backups. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups] + * call to fetch more of the matching backups. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabaseOperationsRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabaseOperationsRequest.php new file mode 100644 index 000000000000..b080b3ec6f4c --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabaseOperationsRequest.php @@ -0,0 +1,361 @@ +google.spanner.admin.database.v1.ListDatabaseOperationsRequest + */ +class ListDatabaseOperationsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The instance of the database operations. + * Values are of the form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * An expression that filters the list of returned operations. + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the [Operation][google.longrunning.Operation] + * are eligible for filtering: + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata] + * is + * `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `done:true` - The operation is complete. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` \ + * `(metadata.source_type:BACKUP) AND` \ + * `(metadata.backup_info.backup:backup_howl) AND` \ + * `(metadata.name:restored_howl) AND` \ + * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. + * * The database is restored from a backup. + * * The backup name contains "backup_howl". + * * The restored database's name contains "restored_howl". + * * The operation started before 2018-03-28T14:50:00Z. + * * The operation resulted in an error. + * + * Generated from protobuf field string filter = 2; + */ + protected $filter = ''; + /** + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3; + */ + protected $page_size = 0; + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token] + * from a previous + * [ListDatabaseOperationsResponse][google.spanner.admin.database.v1.ListDatabaseOperationsResponse] + * to the same `parent` and with the same `filter`. + * + * Generated from protobuf field string page_token = 4; + */ + protected $page_token = ''; + + /** + * @param string $parent Required. The instance of the database operations. + * Values are of the form `projects//instances/`. Please see + * {@see DatabaseAdminClient::instanceName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\ListDatabaseOperationsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The instance of the database operations. + * Values are of the form `projects//instances/`. + * @type string $filter + * An expression that filters the list of returned operations. + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the [Operation][google.longrunning.Operation] + * are eligible for filtering: + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata] + * is + * `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `done:true` - The operation is complete. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` \ + * `(metadata.source_type:BACKUP) AND` \ + * `(metadata.backup_info.backup:backup_howl) AND` \ + * `(metadata.name:restored_howl) AND` \ + * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. + * * The database is restored from a backup. + * * The backup name contains "backup_howl". + * * The restored database's name contains "restored_howl". + * * The operation started before 2018-03-28T14:50:00Z. + * * The operation resulted in an error. + * @type int $page_size + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @type string $page_token + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token] + * from a previous + * [ListDatabaseOperationsResponse][google.spanner.admin.database.v1.ListDatabaseOperationsResponse] + * to the same `parent` and with the same `filter`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The instance of the database operations. + * Values are of the form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The instance of the database operations. + * Values are of the form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * An expression that filters the list of returned operations. + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the [Operation][google.longrunning.Operation] + * are eligible for filtering: + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata] + * is + * `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `done:true` - The operation is complete. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` \ + * `(metadata.source_type:BACKUP) AND` \ + * `(metadata.backup_info.backup:backup_howl) AND` \ + * `(metadata.name:restored_howl) AND` \ + * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. + * * The database is restored from a backup. + * * The backup name contains "backup_howl". + * * The restored database's name contains "restored_howl". + * * The operation started before 2018-03-28T14:50:00Z. + * * The operation resulted in an error. + * + * Generated from protobuf field string filter = 2; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * An expression that filters the list of returned operations. + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the [Operation][google.longrunning.Operation] + * are eligible for filtering: + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata] + * is + * `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `done:true` - The operation is complete. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` \ + * `(metadata.source_type:BACKUP) AND` \ + * `(metadata.backup_info.backup:backup_howl) AND` \ + * `(metadata.name:restored_howl) AND` \ + * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. + * * The database is restored from a backup. + * * The backup name contains "backup_howl". + * * The restored database's name contains "restored_howl". + * * The operation started before 2018-03-28T14:50:00Z. + * * The operation resulted in an error. + * + * Generated from protobuf field string filter = 2; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token] + * from a previous + * [ListDatabaseOperationsResponse][google.spanner.admin.database.v1.ListDatabaseOperationsResponse] + * to the same `parent` and with the same `filter`. + * + * Generated from protobuf field string page_token = 4; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token] + * from a previous + * [ListDatabaseOperationsResponse][google.spanner.admin.database.v1.ListDatabaseOperationsResponse] + * to the same `parent` and with the same `filter`. + * + * Generated from protobuf field string page_token = 4; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabaseOperationsResponse.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabaseOperationsResponse.php new file mode 100644 index 000000000000..5e6f45741b25 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabaseOperationsResponse.php @@ -0,0 +1,126 @@ +google.spanner.admin.database.v1.ListDatabaseOperationsResponse + */ +class ListDatabaseOperationsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of matching database [long-running + * operations][google.longrunning.Operation]. Each operation's name will be + * prefixed by the database's name. The operation's + * [metadata][google.longrunning.Operation.metadata] field type + * `metadata.type_url` describes the type of the metadata. + * + * Generated from protobuf field repeated .google.longrunning.Operation operations = 1; + */ + private $operations; + /** + * `next_page_token` can be sent in a subsequent + * [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations] + * call to fetch more of the matching metadata. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\LongRunning\Operation>|\Google\Protobuf\Internal\RepeatedField $operations + * The list of matching database [long-running + * operations][google.longrunning.Operation]. Each operation's name will be + * prefixed by the database's name. The operation's + * [metadata][google.longrunning.Operation.metadata] field type + * `metadata.type_url` describes the type of the metadata. + * @type string $next_page_token + * `next_page_token` can be sent in a subsequent + * [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations] + * call to fetch more of the matching metadata. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The list of matching database [long-running + * operations][google.longrunning.Operation]. Each operation's name will be + * prefixed by the database's name. The operation's + * [metadata][google.longrunning.Operation.metadata] field type + * `metadata.type_url` describes the type of the metadata. + * + * Generated from protobuf field repeated .google.longrunning.Operation operations = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOperations() + { + return $this->operations; + } + + /** + * The list of matching database [long-running + * operations][google.longrunning.Operation]. Each operation's name will be + * prefixed by the database's name. The operation's + * [metadata][google.longrunning.Operation.metadata] field type + * `metadata.type_url` describes the type of the metadata. + * + * Generated from protobuf field repeated .google.longrunning.Operation operations = 1; + * @param array<\Google\LongRunning\Operation>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOperations($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\LongRunning\Operation::class); + $this->operations = $arr; + + return $this; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations] + * call to fetch more of the matching metadata. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations] + * call to fetch more of the matching metadata. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabaseRolesRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabaseRolesRequest.php new file mode 100644 index 000000000000..789226a8d1cd --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabaseRolesRequest.php @@ -0,0 +1,176 @@ +google.spanner.admin.database.v1.ListDatabaseRolesRequest + */ +class ListDatabaseRolesRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The database whose roles should be listed. + * Values are of the form + * `projects//instances//databases/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Number of database roles to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2; + */ + protected $page_size = 0; + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListDatabaseRolesResponse.next_page_token] + * from a previous + * [ListDatabaseRolesResponse][google.spanner.admin.database.v1.ListDatabaseRolesResponse]. + * + * Generated from protobuf field string page_token = 3; + */ + protected $page_token = ''; + + /** + * @param string $parent Required. The database whose roles should be listed. + * Values are of the form + * `projects//instances//databases/`. Please see + * {@see DatabaseAdminClient::databaseName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\ListDatabaseRolesRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The database whose roles should be listed. + * Values are of the form + * `projects//instances//databases/`. + * @type int $page_size + * Number of database roles to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * @type string $page_token + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListDatabaseRolesResponse.next_page_token] + * from a previous + * [ListDatabaseRolesResponse][google.spanner.admin.database.v1.ListDatabaseRolesResponse]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The database whose roles should be listed. + * Values are of the form + * `projects//instances//databases/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The database whose roles should be listed. + * Values are of the form + * `projects//instances//databases/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Number of database roles to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Number of database roles to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListDatabaseRolesResponse.next_page_token] + * from a previous + * [ListDatabaseRolesResponse][google.spanner.admin.database.v1.ListDatabaseRolesResponse]. + * + * Generated from protobuf field string page_token = 3; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListDatabaseRolesResponse.next_page_token] + * from a previous + * [ListDatabaseRolesResponse][google.spanner.admin.database.v1.ListDatabaseRolesResponse]. + * + * Generated from protobuf field string page_token = 3; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabaseRolesResponse.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabaseRolesResponse.php new file mode 100644 index 000000000000..e2f2c68f908e --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabaseRolesResponse.php @@ -0,0 +1,110 @@ +google.spanner.admin.database.v1.ListDatabaseRolesResponse + */ +class ListDatabaseRolesResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Database roles that matched the request. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.DatabaseRole database_roles = 1; + */ + private $database_roles; + /** + * `next_page_token` can be sent in a subsequent + * [ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles] + * call to fetch more of the matching roles. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Spanner\Admin\Database\V1\DatabaseRole>|\Google\Protobuf\Internal\RepeatedField $database_roles + * Database roles that matched the request. + * @type string $next_page_token + * `next_page_token` can be sent in a subsequent + * [ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles] + * call to fetch more of the matching roles. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Database roles that matched the request. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.DatabaseRole database_roles = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDatabaseRoles() + { + return $this->database_roles; + } + + /** + * Database roles that matched the request. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.DatabaseRole database_roles = 1; + * @param array<\Google\Cloud\Spanner\Admin\Database\V1\DatabaseRole>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDatabaseRoles($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\Admin\Database\V1\DatabaseRole::class); + $this->database_roles = $arr; + + return $this; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles] + * call to fetch more of the matching roles. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles] + * call to fetch more of the matching roles. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabasesRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabasesRequest.php new file mode 100644 index 000000000000..647992bff82d --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabasesRequest.php @@ -0,0 +1,171 @@ +google.spanner.admin.database.v1.ListDatabasesRequest + */ +class ListDatabasesRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The instance whose databases should be listed. + * Values are of the form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Number of databases to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3; + */ + protected $page_size = 0; + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token] + * from a previous + * [ListDatabasesResponse][google.spanner.admin.database.v1.ListDatabasesResponse]. + * + * Generated from protobuf field string page_token = 4; + */ + protected $page_token = ''; + + /** + * @param string $parent Required. The instance whose databases should be listed. + * Values are of the form `projects//instances/`. Please see + * {@see DatabaseAdminClient::instanceName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\ListDatabasesRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The instance whose databases should be listed. + * Values are of the form `projects//instances/`. + * @type int $page_size + * Number of databases to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * @type string $page_token + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token] + * from a previous + * [ListDatabasesResponse][google.spanner.admin.database.v1.ListDatabasesResponse]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The instance whose databases should be listed. + * Values are of the form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The instance whose databases should be listed. + * Values are of the form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Number of databases to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Number of databases to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token] + * from a previous + * [ListDatabasesResponse][google.spanner.admin.database.v1.ListDatabasesResponse]. + * + * Generated from protobuf field string page_token = 4; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token] + * from a previous + * [ListDatabasesResponse][google.spanner.admin.database.v1.ListDatabasesResponse]. + * + * Generated from protobuf field string page_token = 4; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabasesResponse.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabasesResponse.php new file mode 100644 index 000000000000..91e10c3ba675 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/ListDatabasesResponse.php @@ -0,0 +1,110 @@ +google.spanner.admin.database.v1.ListDatabasesResponse + */ +class ListDatabasesResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Databases that matched the request. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.Database databases = 1; + */ + private $databases; + /** + * `next_page_token` can be sent in a subsequent + * [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases] + * call to fetch more of the matching databases. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Spanner\Admin\Database\V1\Database>|\Google\Protobuf\Internal\RepeatedField $databases + * Databases that matched the request. + * @type string $next_page_token + * `next_page_token` can be sent in a subsequent + * [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases] + * call to fetch more of the matching databases. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Databases that matched the request. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.Database databases = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDatabases() + { + return $this->databases; + } + + /** + * Databases that matched the request. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.Database databases = 1; + * @param array<\Google\Cloud\Spanner\Admin\Database\V1\Database>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDatabases($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\Admin\Database\V1\Database::class); + $this->databases = $arr; + + return $this; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases] + * call to fetch more of the matching databases. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases] + * call to fetch more of the matching databases. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/OperationProgress.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/OperationProgress.php new file mode 100644 index 000000000000..457e0f5b87d2 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/OperationProgress.php @@ -0,0 +1,164 @@ +google.spanner.admin.database.v1.OperationProgress + */ +class OperationProgress extends \Google\Protobuf\Internal\Message +{ + /** + * Percent completion of the operation. + * Values are between 0 and 100 inclusive. + * + * Generated from protobuf field int32 progress_percent = 1; + */ + protected $progress_percent = 0; + /** + * Time the request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + */ + protected $start_time = null; + /** + * If set, the time at which this operation failed or was completed + * successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 3; + */ + protected $end_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $progress_percent + * Percent completion of the operation. + * Values are between 0 and 100 inclusive. + * @type \Google\Protobuf\Timestamp $start_time + * Time the request was received. + * @type \Google\Protobuf\Timestamp $end_time + * If set, the time at which this operation failed or was completed + * successfully. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Common::initOnce(); + parent::__construct($data); + } + + /** + * Percent completion of the operation. + * Values are between 0 and 100 inclusive. + * + * Generated from protobuf field int32 progress_percent = 1; + * @return int + */ + public function getProgressPercent() + { + return $this->progress_percent; + } + + /** + * Percent completion of the operation. + * Values are between 0 and 100 inclusive. + * + * Generated from protobuf field int32 progress_percent = 1; + * @param int $var + * @return $this + */ + public function setProgressPercent($var) + { + GPBUtil::checkInt32($var); + $this->progress_percent = $var; + + return $this; + } + + /** + * Time the request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + * @return \Google\Protobuf\Timestamp|null + */ + public function getStartTime() + { + return $this->start_time; + } + + public function hasStartTime() + { + return isset($this->start_time); + } + + public function clearStartTime() + { + unset($this->start_time); + } + + /** + * Time the request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setStartTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->start_time = $var; + + return $this; + } + + /** + * If set, the time at which this operation failed or was completed + * successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 3; + * @return \Google\Protobuf\Timestamp|null + */ + public function getEndTime() + { + return $this->end_time; + } + + public function hasEndTime() + { + return isset($this->end_time); + } + + public function clearEndTime() + { + unset($this->end_time); + } + + /** + * If set, the time at which this operation failed or was completed + * successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 3; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setEndTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->end_time = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/OptimizeRestoredDatabaseMetadata.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/OptimizeRestoredDatabaseMetadata.php new file mode 100644 index 000000000000..6030a18943a5 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/OptimizeRestoredDatabaseMetadata.php @@ -0,0 +1,114 @@ +google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata + */ +class OptimizeRestoredDatabaseMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * Name of the restored database being optimized. + * + * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { + */ + protected $name = ''; + /** + * The progress of the post-restore optimizations. + * + * Generated from protobuf field .google.spanner.admin.database.v1.OperationProgress progress = 2; + */ + protected $progress = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Name of the restored database being optimized. + * @type \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress $progress + * The progress of the post-restore optimizations. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Name of the restored database being optimized. + * + * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Name of the restored database being optimized. + * + * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * The progress of the post-restore optimizations. + * + * Generated from protobuf field .google.spanner.admin.database.v1.OperationProgress progress = 2; + * @return \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress|null + */ + public function getProgress() + { + return $this->progress; + } + + public function hasProgress() + { + return isset($this->progress); + } + + public function clearProgress() + { + unset($this->progress); + } + + /** + * The progress of the post-restore optimizations. + * + * Generated from protobuf field .google.spanner.admin.database.v1.OperationProgress progress = 2; + * @param \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress $var + * @return $this + */ + public function setProgress($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress::class); + $this->progress = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreDatabaseEncryptionConfig.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreDatabaseEncryptionConfig.php new file mode 100644 index 000000000000..7826049bac09 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreDatabaseEncryptionConfig.php @@ -0,0 +1,203 @@ +google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig + */ +class RestoreDatabaseEncryptionConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The encryption type of the restored database. + * + * Generated from protobuf field .google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $encryption_type = 0; + /** + * Optional. The Cloud KMS key that will be used to encrypt/decrypt the + * restored database. This field should be set only when + * [encryption_type][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type] + * is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * + * Generated from protobuf field string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + protected $kms_key_name = ''; + /** + * Optional. Specifies the KMS configuration for the one or more keys used to + * encrypt the database. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * The keys referenced by kms_key_names must fully cover all + * regions of the database instance configuration. Some examples: + * * For single region database instance configs, specify a single regional + * location KMS key. + * * For multi-regional database instance configs of type GOOGLE_MANAGED, + * either specify a multi-regional location KMS key or multiple regional + * location KMS keys that cover all regions in the instance config. + * * For a database instance config of type USER_MANAGED, please specify only + * regional location KMS keys to cover each region in the instance config. + * Multi-regional location KMS keys are not supported for USER_MANAGED + * instance configs. + * + * Generated from protobuf field repeated string kms_key_names = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + private $kms_key_names; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $encryption_type + * Required. The encryption type of the restored database. + * @type string $kms_key_name + * Optional. The Cloud KMS key that will be used to encrypt/decrypt the + * restored database. This field should be set only when + * [encryption_type][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type] + * is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * @type array|\Google\Protobuf\Internal\RepeatedField $kms_key_names + * Optional. Specifies the KMS configuration for the one or more keys used to + * encrypt the database. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * The keys referenced by kms_key_names must fully cover all + * regions of the database instance configuration. Some examples: + * * For single region database instance configs, specify a single regional + * location KMS key. + * * For multi-regional database instance configs of type GOOGLE_MANAGED, + * either specify a multi-regional location KMS key or multiple regional + * location KMS keys that cover all regions in the instance config. + * * For a database instance config of type USER_MANAGED, please specify only + * regional location KMS keys to cover each region in the instance config. + * Multi-regional location KMS keys are not supported for USER_MANAGED + * instance configs. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The encryption type of the restored database. + * + * Generated from protobuf field .google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return int + */ + public function getEncryptionType() + { + return $this->encryption_type; + } + + /** + * Required. The encryption type of the restored database. + * + * Generated from protobuf field .google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.EncryptionType encryption_type = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param int $var + * @return $this + */ + public function setEncryptionType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Database\V1\RestoreDatabaseEncryptionConfig\EncryptionType::class); + $this->encryption_type = $var; + + return $this; + } + + /** + * Optional. The Cloud KMS key that will be used to encrypt/decrypt the + * restored database. This field should be set only when + * [encryption_type][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type] + * is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * + * Generated from protobuf field string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return string + */ + public function getKmsKeyName() + { + return $this->kms_key_name; + } + + /** + * Optional. The Cloud KMS key that will be used to encrypt/decrypt the + * restored database. This field should be set only when + * [encryption_type][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type] + * is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * + * Generated from protobuf field string kms_key_name = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setKmsKeyName($var) + { + GPBUtil::checkString($var, True); + $this->kms_key_name = $var; + + return $this; + } + + /** + * Optional. Specifies the KMS configuration for the one or more keys used to + * encrypt the database. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * The keys referenced by kms_key_names must fully cover all + * regions of the database instance configuration. Some examples: + * * For single region database instance configs, specify a single regional + * location KMS key. + * * For multi-regional database instance configs of type GOOGLE_MANAGED, + * either specify a multi-regional location KMS key or multiple regional + * location KMS keys that cover all regions in the instance config. + * * For a database instance config of type USER_MANAGED, please specify only + * regional location KMS keys to cover each region in the instance config. + * Multi-regional location KMS keys are not supported for USER_MANAGED + * instance configs. + * + * Generated from protobuf field repeated string kms_key_names = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getKmsKeyNames() + { + return $this->kms_key_names; + } + + /** + * Optional. Specifies the KMS configuration for the one or more keys used to + * encrypt the database. Values are of the form + * `projects//locations//keyRings//cryptoKeys/`. + * The keys referenced by kms_key_names must fully cover all + * regions of the database instance configuration. Some examples: + * * For single region database instance configs, specify a single regional + * location KMS key. + * * For multi-regional database instance configs of type GOOGLE_MANAGED, + * either specify a multi-regional location KMS key or multiple regional + * location KMS keys that cover all regions in the instance config. + * * For a database instance config of type USER_MANAGED, please specify only + * regional location KMS keys to cover each region in the instance config. + * Multi-regional location KMS keys are not supported for USER_MANAGED + * instance configs. + * + * Generated from protobuf field repeated string kms_key_names = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setKmsKeyNames($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->kms_key_names = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreDatabaseEncryptionConfig/EncryptionType.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreDatabaseEncryptionConfig/EncryptionType.php new file mode 100644 index 000000000000..6650757c3714 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreDatabaseEncryptionConfig/EncryptionType.php @@ -0,0 +1,74 @@ +google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.EncryptionType + */ +class EncryptionType +{ + /** + * Unspecified. Do not use. + * + * Generated from protobuf enum ENCRYPTION_TYPE_UNSPECIFIED = 0; + */ + const ENCRYPTION_TYPE_UNSPECIFIED = 0; + /** + * This is the default option when + * [encryption_config][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig] + * is not specified. + * + * Generated from protobuf enum USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION = 1; + */ + const USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION = 1; + /** + * Use Google default encryption. + * + * Generated from protobuf enum GOOGLE_DEFAULT_ENCRYPTION = 2; + */ + const GOOGLE_DEFAULT_ENCRYPTION = 2; + /** + * Use customer managed encryption. If specified, `kms_key_name` must + * must contain a valid Cloud KMS key. + * + * Generated from protobuf enum CUSTOMER_MANAGED_ENCRYPTION = 3; + */ + const CUSTOMER_MANAGED_ENCRYPTION = 3; + + private static $valueToName = [ + self::ENCRYPTION_TYPE_UNSPECIFIED => 'ENCRYPTION_TYPE_UNSPECIFIED', + self::USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION => 'USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION', + self::GOOGLE_DEFAULT_ENCRYPTION => 'GOOGLE_DEFAULT_ENCRYPTION', + self::CUSTOMER_MANAGED_ENCRYPTION => 'CUSTOMER_MANAGED_ENCRYPTION', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(EncryptionType::class, \Google\Cloud\Spanner\Admin\Database\V1\RestoreDatabaseEncryptionConfig_EncryptionType::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreDatabaseMetadata.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreDatabaseMetadata.php new file mode 100644 index 000000000000..176d1a1ee7ad --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreDatabaseMetadata.php @@ -0,0 +1,358 @@ +google.spanner.admin.database.v1.RestoreDatabaseMetadata + */ +class RestoreDatabaseMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * Name of the database being created and restored to. + * + * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { + */ + protected $name = ''; + /** + * The type of the restore source. + * + * Generated from protobuf field .google.spanner.admin.database.v1.RestoreSourceType source_type = 2; + */ + protected $source_type = 0; + /** + * The progress of the + * [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase] + * operation. + * + * Generated from protobuf field .google.spanner.admin.database.v1.OperationProgress progress = 4; + */ + protected $progress = null; + /** + * The time at which cancellation of this operation was received. + * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + * starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not guaranteed. + * Clients can use + * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an [Operation.error][google.longrunning.Operation.error] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 5; + */ + protected $cancel_time = null; + /** + * If exists, the name of the long-running operation that will be used to + * track the post-restore optimization process to optimize the performance of + * the restored database, and remove the dependency on the restore source. + * The name is of the form + * `projects//instances//databases//operations/` + * where the is the name of database being created and restored to. + * The metadata type of the long-running operation is + * [OptimizeRestoredDatabaseMetadata][google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata]. + * This long-running operation will be automatically created by the system + * after the RestoreDatabase long-running operation completes successfully. + * This operation will not be created if the restore was not successful. + * + * Generated from protobuf field string optimize_database_operation_name = 6; + */ + protected $optimize_database_operation_name = ''; + protected $source_info; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Name of the database being created and restored to. + * @type int $source_type + * The type of the restore source. + * @type \Google\Cloud\Spanner\Admin\Database\V1\BackupInfo $backup_info + * Information about the backup used to restore the database. + * @type \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress $progress + * The progress of the + * [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase] + * operation. + * @type \Google\Protobuf\Timestamp $cancel_time + * The time at which cancellation of this operation was received. + * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + * starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not guaranteed. + * Clients can use + * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an [Operation.error][google.longrunning.Operation.error] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`. + * @type string $optimize_database_operation_name + * If exists, the name of the long-running operation that will be used to + * track the post-restore optimization process to optimize the performance of + * the restored database, and remove the dependency on the restore source. + * The name is of the form + * `projects//instances//databases//operations/` + * where the is the name of database being created and restored to. + * The metadata type of the long-running operation is + * [OptimizeRestoredDatabaseMetadata][google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata]. + * This long-running operation will be automatically created by the system + * after the RestoreDatabase long-running operation completes successfully. + * This operation will not be created if the restore was not successful. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Name of the database being created and restored to. + * + * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Name of the database being created and restored to. + * + * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * The type of the restore source. + * + * Generated from protobuf field .google.spanner.admin.database.v1.RestoreSourceType source_type = 2; + * @return int + */ + public function getSourceType() + { + return $this->source_type; + } + + /** + * The type of the restore source. + * + * Generated from protobuf field .google.spanner.admin.database.v1.RestoreSourceType source_type = 2; + * @param int $var + * @return $this + */ + public function setSourceType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Database\V1\RestoreSourceType::class); + $this->source_type = $var; + + return $this; + } + + /** + * Information about the backup used to restore the database. + * + * Generated from protobuf field .google.spanner.admin.database.v1.BackupInfo backup_info = 3; + * @return \Google\Cloud\Spanner\Admin\Database\V1\BackupInfo|null + */ + public function getBackupInfo() + { + return $this->readOneof(3); + } + + public function hasBackupInfo() + { + return $this->hasOneof(3); + } + + /** + * Information about the backup used to restore the database. + * + * Generated from protobuf field .google.spanner.admin.database.v1.BackupInfo backup_info = 3; + * @param \Google\Cloud\Spanner\Admin\Database\V1\BackupInfo $var + * @return $this + */ + public function setBackupInfo($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\BackupInfo::class); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * The progress of the + * [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase] + * operation. + * + * Generated from protobuf field .google.spanner.admin.database.v1.OperationProgress progress = 4; + * @return \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress|null + */ + public function getProgress() + { + return $this->progress; + } + + public function hasProgress() + { + return isset($this->progress); + } + + public function clearProgress() + { + unset($this->progress); + } + + /** + * The progress of the + * [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase] + * operation. + * + * Generated from protobuf field .google.spanner.admin.database.v1.OperationProgress progress = 4; + * @param \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress $var + * @return $this + */ + public function setProgress($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress::class); + $this->progress = $var; + + return $this; + } + + /** + * The time at which cancellation of this operation was received. + * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + * starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not guaranteed. + * Clients can use + * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an [Operation.error][google.longrunning.Operation.error] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 5; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCancelTime() + { + return $this->cancel_time; + } + + public function hasCancelTime() + { + return isset($this->cancel_time); + } + + public function clearCancelTime() + { + unset($this->cancel_time); + } + + /** + * The time at which cancellation of this operation was received. + * [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + * starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not guaranteed. + * Clients can use + * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an [Operation.error][google.longrunning.Operation.error] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 5; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCancelTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->cancel_time = $var; + + return $this; + } + + /** + * If exists, the name of the long-running operation that will be used to + * track the post-restore optimization process to optimize the performance of + * the restored database, and remove the dependency on the restore source. + * The name is of the form + * `projects//instances//databases//operations/` + * where the is the name of database being created and restored to. + * The metadata type of the long-running operation is + * [OptimizeRestoredDatabaseMetadata][google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata]. + * This long-running operation will be automatically created by the system + * after the RestoreDatabase long-running operation completes successfully. + * This operation will not be created if the restore was not successful. + * + * Generated from protobuf field string optimize_database_operation_name = 6; + * @return string + */ + public function getOptimizeDatabaseOperationName() + { + return $this->optimize_database_operation_name; + } + + /** + * If exists, the name of the long-running operation that will be used to + * track the post-restore optimization process to optimize the performance of + * the restored database, and remove the dependency on the restore source. + * The name is of the form + * `projects//instances//databases//operations/` + * where the is the name of database being created and restored to. + * The metadata type of the long-running operation is + * [OptimizeRestoredDatabaseMetadata][google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata]. + * This long-running operation will be automatically created by the system + * after the RestoreDatabase long-running operation completes successfully. + * This operation will not be created if the restore was not successful. + * + * Generated from protobuf field string optimize_database_operation_name = 6; + * @param string $var + * @return $this + */ + public function setOptimizeDatabaseOperationName($var) + { + GPBUtil::checkString($var, True); + $this->optimize_database_operation_name = $var; + + return $this; + } + + /** + * @return string + */ + public function getSourceInfo() + { + return $this->whichOneof("source_info"); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreDatabaseRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreDatabaseRequest.php new file mode 100644 index 000000000000..7e9f39516096 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreDatabaseRequest.php @@ -0,0 +1,265 @@ +google.spanner.admin.database.v1.RestoreDatabaseRequest + */ +class RestoreDatabaseRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the instance in which to create the + * restored database. This instance must be in the same project and + * have the same instance configuration as the instance containing + * the source backup. Values are of the form + * `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. The id of the database to create and restore to. This + * database must not already exist. The `database_id` appended to + * `parent` forms the full database name of the form + * `projects//instances//databases/`. + * + * Generated from protobuf field string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $database_id = ''; + /** + * Optional. An encryption configuration describing the encryption type and + * key resources in Cloud KMS used to encrypt/decrypt the database to restore + * to. If this field is not specified, the restored database will use the same + * encryption configuration as the backup by default, namely + * [encryption_type][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type] + * = `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. + * + * Generated from protobuf field .google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $encryption_config = null; + protected $source; + + /** + * @param string $parent Required. The name of the instance in which to create the + * restored database. This instance must be in the same project and + * have the same instance configuration as the instance containing + * the source backup. Values are of the form + * `projects//instances/`. Please see + * {@see DatabaseAdminClient::instanceName()} for help formatting this field. + * @param string $databaseId Required. The id of the database to create and restore to. This + * database must not already exist. The `database_id` appended to + * `parent` forms the full database name of the form + * `projects//instances//databases/`. + * @param string $backup Name of the backup from which to restore. Values are of the form + * `projects//instances//backups/`. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\RestoreDatabaseRequest + * + * @experimental + */ + public static function build(string $parent, string $databaseId, string $backup): self + { + return (new self()) + ->setParent($parent) + ->setDatabaseId($databaseId) + ->setBackup($backup); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The name of the instance in which to create the + * restored database. This instance must be in the same project and + * have the same instance configuration as the instance containing + * the source backup. Values are of the form + * `projects//instances/`. + * @type string $database_id + * Required. The id of the database to create and restore to. This + * database must not already exist. The `database_id` appended to + * `parent` forms the full database name of the form + * `projects//instances//databases/`. + * @type string $backup + * Name of the backup from which to restore. Values are of the form + * `projects//instances//backups/`. + * @type \Google\Cloud\Spanner\Admin\Database\V1\RestoreDatabaseEncryptionConfig $encryption_config + * Optional. An encryption configuration describing the encryption type and + * key resources in Cloud KMS used to encrypt/decrypt the database to restore + * to. If this field is not specified, the restored database will use the same + * encryption configuration as the backup by default, namely + * [encryption_type][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type] + * = `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the instance in which to create the + * restored database. This instance must be in the same project and + * have the same instance configuration as the instance containing + * the source backup. Values are of the form + * `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The name of the instance in which to create the + * restored database. This instance must be in the same project and + * have the same instance configuration as the instance containing + * the source backup. Values are of the form + * `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Required. The id of the database to create and restore to. This + * database must not already exist. The `database_id` appended to + * `parent` forms the full database name of the form + * `projects//instances//databases/`. + * + * Generated from protobuf field string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getDatabaseId() + { + return $this->database_id; + } + + /** + * Required. The id of the database to create and restore to. This + * database must not already exist. The `database_id` appended to + * `parent` forms the full database name of the form + * `projects//instances//databases/`. + * + * Generated from protobuf field string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setDatabaseId($var) + { + GPBUtil::checkString($var, True); + $this->database_id = $var; + + return $this; + } + + /** + * Name of the backup from which to restore. Values are of the form + * `projects//instances//backups/`. + * + * Generated from protobuf field string backup = 3 [(.google.api.resource_reference) = { + * @return string + */ + public function getBackup() + { + return $this->readOneof(3); + } + + public function hasBackup() + { + return $this->hasOneof(3); + } + + /** + * Name of the backup from which to restore. Values are of the form + * `projects//instances//backups/`. + * + * Generated from protobuf field string backup = 3 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setBackup($var) + { + GPBUtil::checkString($var, True); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * Optional. An encryption configuration describing the encryption type and + * key resources in Cloud KMS used to encrypt/decrypt the database to restore + * to. If this field is not specified, the restored database will use the same + * encryption configuration as the backup by default, namely + * [encryption_type][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type] + * = `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. + * + * Generated from protobuf field .google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Spanner\Admin\Database\V1\RestoreDatabaseEncryptionConfig|null + */ + public function getEncryptionConfig() + { + return $this->encryption_config; + } + + public function hasEncryptionConfig() + { + return isset($this->encryption_config); + } + + public function clearEncryptionConfig() + { + unset($this->encryption_config); + } + + /** + * Optional. An encryption configuration describing the encryption type and + * key resources in Cloud KMS used to encrypt/decrypt the database to restore + * to. If this field is not specified, the restored database will use the same + * encryption configuration as the backup by default, namely + * [encryption_type][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type] + * = `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. + * + * Generated from protobuf field .google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Spanner\Admin\Database\V1\RestoreDatabaseEncryptionConfig $var + * @return $this + */ + public function setEncryptionConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\RestoreDatabaseEncryptionConfig::class); + $this->encryption_config = $var; + + return $this; + } + + /** + * @return string + */ + public function getSource() + { + return $this->whichOneof("source"); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreInfo.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreInfo.php new file mode 100644 index 000000000000..2bcfe27d1868 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreInfo.php @@ -0,0 +1,112 @@ +google.spanner.admin.database.v1.RestoreInfo + */ +class RestoreInfo extends \Google\Protobuf\Internal\Message +{ + /** + * The type of the restore source. + * + * Generated from protobuf field .google.spanner.admin.database.v1.RestoreSourceType source_type = 1; + */ + protected $source_type = 0; + protected $source_info; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $source_type + * The type of the restore source. + * @type \Google\Cloud\Spanner\Admin\Database\V1\BackupInfo $backup_info + * Information about the backup used to restore the database. The backup + * may no longer exist. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The type of the restore source. + * + * Generated from protobuf field .google.spanner.admin.database.v1.RestoreSourceType source_type = 1; + * @return int + */ + public function getSourceType() + { + return $this->source_type; + } + + /** + * The type of the restore source. + * + * Generated from protobuf field .google.spanner.admin.database.v1.RestoreSourceType source_type = 1; + * @param int $var + * @return $this + */ + public function setSourceType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Database\V1\RestoreSourceType::class); + $this->source_type = $var; + + return $this; + } + + /** + * Information about the backup used to restore the database. The backup + * may no longer exist. + * + * Generated from protobuf field .google.spanner.admin.database.v1.BackupInfo backup_info = 2; + * @return \Google\Cloud\Spanner\Admin\Database\V1\BackupInfo|null + */ + public function getBackupInfo() + { + return $this->readOneof(2); + } + + public function hasBackupInfo() + { + return $this->hasOneof(2); + } + + /** + * Information about the backup used to restore the database. The backup + * may no longer exist. + * + * Generated from protobuf field .google.spanner.admin.database.v1.BackupInfo backup_info = 2; + * @param \Google\Cloud\Spanner\Admin\Database\V1\BackupInfo $var + * @return $this + */ + public function setBackupInfo($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\BackupInfo::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * @return string + */ + public function getSourceInfo() + { + return $this->whichOneof("source_info"); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreSourceType.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreSourceType.php new file mode 100644 index 000000000000..9d51c00e2be6 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/RestoreSourceType.php @@ -0,0 +1,54 @@ +google.spanner.admin.database.v1.RestoreSourceType + */ +class RestoreSourceType +{ + /** + * No restore associated. + * + * Generated from protobuf enum TYPE_UNSPECIFIED = 0; + */ + const TYPE_UNSPECIFIED = 0; + /** + * A backup was used as the source of the restore. + * + * Generated from protobuf enum BACKUP = 1; + */ + const BACKUP = 1; + + private static $valueToName = [ + self::TYPE_UNSPECIFIED => 'TYPE_UNSPECIFIED', + self::BACKUP => 'BACKUP', + ]; + + 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/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateBackupRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateBackupRequest.php new file mode 100644 index 000000000000..0c76d8690c85 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateBackupRequest.php @@ -0,0 +1,172 @@ +google.spanner.admin.database.v1.UpdateBackupRequest + */ +class UpdateBackupRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The backup to update. `backup.name`, and the fields to be updated + * as specified by `update_mask` are required. Other fields are ignored. + * Update is only supported for the following fields: + * * `backup.expire_time`. + * + * Generated from protobuf field .google.spanner.admin.database.v1.Backup backup = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $backup = null; + /** + * Required. A mask specifying which fields (e.g. `expire_time`) in the + * Backup resource should be updated. This mask is relative to the Backup + * resource, not to the request message. The field mask must always be + * specified; this prevents any future fields from being erased accidentally + * by clients that do not know about them. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $update_mask = null; + + /** + * @param \Google\Cloud\Spanner\Admin\Database\V1\Backup $backup Required. The backup to update. `backup.name`, and the fields to be updated + * as specified by `update_mask` are required. Other fields are ignored. + * Update is only supported for the following fields: + * * `backup.expire_time`. + * @param \Google\Protobuf\FieldMask $updateMask Required. A mask specifying which fields (e.g. `expire_time`) in the + * Backup resource should be updated. This mask is relative to the Backup + * resource, not to the request message. The field mask must always be + * specified; this prevents any future fields from being erased accidentally + * by clients that do not know about them. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\UpdateBackupRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Spanner\Admin\Database\V1\Backup $backup, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setBackup($backup) + ->setUpdateMask($updateMask); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Database\V1\Backup $backup + * Required. The backup to update. `backup.name`, and the fields to be updated + * as specified by `update_mask` are required. Other fields are ignored. + * Update is only supported for the following fields: + * * `backup.expire_time`. + * @type \Google\Protobuf\FieldMask $update_mask + * Required. A mask specifying which fields (e.g. `expire_time`) in the + * Backup resource should be updated. This mask is relative to the Backup + * resource, not to the request message. The field mask must always be + * specified; this prevents any future fields from being erased accidentally + * by clients that do not know about them. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\Backup::initOnce(); + parent::__construct($data); + } + + /** + * Required. The backup to update. `backup.name`, and the fields to be updated + * as specified by `update_mask` are required. Other fields are ignored. + * Update is only supported for the following fields: + * * `backup.expire_time`. + * + * Generated from protobuf field .google.spanner.admin.database.v1.Backup backup = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\Admin\Database\V1\Backup|null + */ + public function getBackup() + { + return $this->backup; + } + + public function hasBackup() + { + return isset($this->backup); + } + + public function clearBackup() + { + unset($this->backup); + } + + /** + * Required. The backup to update. `backup.name`, and the fields to be updated + * as specified by `update_mask` are required. Other fields are ignored. + * Update is only supported for the following fields: + * * `backup.expire_time`. + * + * Generated from protobuf field .google.spanner.admin.database.v1.Backup backup = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\Admin\Database\V1\Backup $var + * @return $this + */ + public function setBackup($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\Backup::class); + $this->backup = $var; + + return $this; + } + + /** + * Required. A mask specifying which fields (e.g. `expire_time`) in the + * Backup resource should be updated. This mask is relative to the Backup + * resource, not to the request message. The field mask must always be + * specified; this prevents any future fields from being erased accidentally + * by clients that do not know about them. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\FieldMask|null + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + + /** + * Required. A mask specifying which fields (e.g. `expire_time`) in the + * Backup resource should be updated. This mask is relative to the Backup + * resource, not to the request message. The field mask must always be + * specified; this prevents any future fields from being erased accidentally + * by clients that do not know about them. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateBackupScheduleRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateBackupScheduleRequest.php new file mode 100644 index 000000000000..9d0e58d7f5b8 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateBackupScheduleRequest.php @@ -0,0 +1,167 @@ +google.spanner.admin.database.v1.UpdateBackupScheduleRequest + */ +class UpdateBackupScheduleRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The backup schedule to update. `backup_schedule.name`, and the + * fields to be updated as specified by `update_mask` are required. Other + * fields are ignored. + * + * Generated from protobuf field .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $backup_schedule = null; + /** + * Required. A mask specifying which fields in the BackupSchedule resource + * should be updated. This mask is relative to the BackupSchedule resource, + * not to the request message. The field mask must always be + * specified; this prevents any future fields from being erased + * accidentally. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $update_mask = null; + + /** + * @param \Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule $backupSchedule Required. The backup schedule to update. `backup_schedule.name`, and the + * fields to be updated as specified by `update_mask` are required. Other + * fields are ignored. + * @param \Google\Protobuf\FieldMask $updateMask Required. A mask specifying which fields in the BackupSchedule resource + * should be updated. This mask is relative to the BackupSchedule resource, + * not to the request message. The field mask must always be + * specified; this prevents any future fields from being erased + * accidentally. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\UpdateBackupScheduleRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule $backupSchedule, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setBackupSchedule($backupSchedule) + ->setUpdateMask($updateMask); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule $backup_schedule + * Required. The backup schedule to update. `backup_schedule.name`, and the + * fields to be updated as specified by `update_mask` are required. Other + * fields are ignored. + * @type \Google\Protobuf\FieldMask $update_mask + * Required. A mask specifying which fields in the BackupSchedule resource + * should be updated. This mask is relative to the BackupSchedule resource, + * not to the request message. The field mask must always be + * specified; this prevents any future fields from being erased + * accidentally. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\BackupSchedule::initOnce(); + parent::__construct($data); + } + + /** + * Required. The backup schedule to update. `backup_schedule.name`, and the + * fields to be updated as specified by `update_mask` are required. Other + * fields are ignored. + * + * Generated from protobuf field .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule|null + */ + public function getBackupSchedule() + { + return $this->backup_schedule; + } + + public function hasBackupSchedule() + { + return isset($this->backup_schedule); + } + + public function clearBackupSchedule() + { + unset($this->backup_schedule); + } + + /** + * Required. The backup schedule to update. `backup_schedule.name`, and the + * fields to be updated as specified by `update_mask` are required. Other + * fields are ignored. + * + * Generated from protobuf field .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule $var + * @return $this + */ + public function setBackupSchedule($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule::class); + $this->backup_schedule = $var; + + return $this; + } + + /** + * Required. A mask specifying which fields in the BackupSchedule resource + * should be updated. This mask is relative to the BackupSchedule resource, + * not to the request message. The field mask must always be + * specified; this prevents any future fields from being erased + * accidentally. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\FieldMask|null + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + + /** + * Required. A mask specifying which fields in the BackupSchedule resource + * should be updated. This mask is relative to the BackupSchedule resource, + * not to the request message. The field mask must always be + * specified; this prevents any future fields from being erased + * accidentally. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateDatabaseDdlMetadata.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateDatabaseDdlMetadata.php new file mode 100644 index 000000000000..767766fad333 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateDatabaseDdlMetadata.php @@ -0,0 +1,286 @@ +google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata + */ +class UpdateDatabaseDdlMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * The database being modified. + * + * Generated from protobuf field string database = 1 [(.google.api.resource_reference) = { + */ + protected $database = ''; + /** + * For an update this list contains all the statements. For an + * individual statement, this list contains only that statement. + * + * Generated from protobuf field repeated string statements = 2; + */ + private $statements; + /** + * Reports the commit timestamps of all statements that have + * succeeded so far, where `commit_timestamps[i]` is the commit + * timestamp for the statement `statements[i]`. + * + * Generated from protobuf field repeated .google.protobuf.Timestamp commit_timestamps = 3; + */ + private $commit_timestamps; + /** + * Output only. When true, indicates that the operation is throttled e.g. + * due to resource constraints. When resources become available the operation + * will resume and this field will be false again. + * + * Generated from protobuf field bool throttled = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $throttled = false; + /** + * The progress of the + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] + * operations. All DDL statements will have continuously updating progress, + * and `progress[i]` is the operation progress for `statements[i]`. Also, + * `progress[i]` will have start time and end time populated with commit + * timestamp of operation, as well as a progress of 100% once the operation + * has completed. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.OperationProgress progress = 5; + */ + private $progress; + /** + * The brief action info for the DDL statements. + * `actions[i]` is the brief info for `statements[i]`. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.DdlStatementActionInfo actions = 6; + */ + private $actions; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $database + * The database being modified. + * @type array|\Google\Protobuf\Internal\RepeatedField $statements + * For an update this list contains all the statements. For an + * individual statement, this list contains only that statement. + * @type array<\Google\Protobuf\Timestamp>|\Google\Protobuf\Internal\RepeatedField $commit_timestamps + * Reports the commit timestamps of all statements that have + * succeeded so far, where `commit_timestamps[i]` is the commit + * timestamp for the statement `statements[i]`. + * @type bool $throttled + * Output only. When true, indicates that the operation is throttled e.g. + * due to resource constraints. When resources become available the operation + * will resume and this field will be false again. + * @type array<\Google\Cloud\Spanner\Admin\Database\V1\OperationProgress>|\Google\Protobuf\Internal\RepeatedField $progress + * The progress of the + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] + * operations. All DDL statements will have continuously updating progress, + * and `progress[i]` is the operation progress for `statements[i]`. Also, + * `progress[i]` will have start time and end time populated with commit + * timestamp of operation, as well as a progress of 100% once the operation + * has completed. + * @type array<\Google\Cloud\Spanner\Admin\Database\V1\DdlStatementActionInfo>|\Google\Protobuf\Internal\RepeatedField $actions + * The brief action info for the DDL statements. + * `actions[i]` is the brief info for `statements[i]`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The database being modified. + * + * Generated from protobuf field string database = 1 [(.google.api.resource_reference) = { + * @return string + */ + public function getDatabase() + { + return $this->database; + } + + /** + * The database being modified. + * + * Generated from protobuf field string database = 1 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setDatabase($var) + { + GPBUtil::checkString($var, True); + $this->database = $var; + + return $this; + } + + /** + * For an update this list contains all the statements. For an + * individual statement, this list contains only that statement. + * + * Generated from protobuf field repeated string statements = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getStatements() + { + return $this->statements; + } + + /** + * For an update this list contains all the statements. For an + * individual statement, this list contains only that statement. + * + * Generated from protobuf field repeated string statements = 2; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setStatements($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->statements = $arr; + + return $this; + } + + /** + * Reports the commit timestamps of all statements that have + * succeeded so far, where `commit_timestamps[i]` is the commit + * timestamp for the statement `statements[i]`. + * + * Generated from protobuf field repeated .google.protobuf.Timestamp commit_timestamps = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getCommitTimestamps() + { + return $this->commit_timestamps; + } + + /** + * Reports the commit timestamps of all statements that have + * succeeded so far, where `commit_timestamps[i]` is the commit + * timestamp for the statement `statements[i]`. + * + * Generated from protobuf field repeated .google.protobuf.Timestamp commit_timestamps = 3; + * @param array<\Google\Protobuf\Timestamp>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setCommitTimestamps($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Timestamp::class); + $this->commit_timestamps = $arr; + + return $this; + } + + /** + * Output only. When true, indicates that the operation is throttled e.g. + * due to resource constraints. When resources become available the operation + * will resume and this field will be false again. + * + * Generated from protobuf field bool throttled = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return bool + */ + public function getThrottled() + { + return $this->throttled; + } + + /** + * Output only. When true, indicates that the operation is throttled e.g. + * due to resource constraints. When resources become available the operation + * will resume and this field will be false again. + * + * Generated from protobuf field bool throttled = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param bool $var + * @return $this + */ + public function setThrottled($var) + { + GPBUtil::checkBool($var); + $this->throttled = $var; + + return $this; + } + + /** + * The progress of the + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] + * operations. All DDL statements will have continuously updating progress, + * and `progress[i]` is the operation progress for `statements[i]`. Also, + * `progress[i]` will have start time and end time populated with commit + * timestamp of operation, as well as a progress of 100% once the operation + * has completed. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.OperationProgress progress = 5; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getProgress() + { + return $this->progress; + } + + /** + * The progress of the + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] + * operations. All DDL statements will have continuously updating progress, + * and `progress[i]` is the operation progress for `statements[i]`. Also, + * `progress[i]` will have start time and end time populated with commit + * timestamp of operation, as well as a progress of 100% once the operation + * has completed. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.OperationProgress progress = 5; + * @param array<\Google\Cloud\Spanner\Admin\Database\V1\OperationProgress>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setProgress($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress::class); + $this->progress = $arr; + + return $this; + } + + /** + * The brief action info for the DDL statements. + * `actions[i]` is the brief info for `statements[i]`. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.DdlStatementActionInfo actions = 6; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getActions() + { + return $this->actions; + } + + /** + * The brief action info for the DDL statements. + * `actions[i]` is the brief info for `statements[i]`. + * + * Generated from protobuf field repeated .google.spanner.admin.database.v1.DdlStatementActionInfo actions = 6; + * @param array<\Google\Cloud\Spanner\Admin\Database\V1\DdlStatementActionInfo>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setActions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\Admin\Database\V1\DdlStatementActionInfo::class); + $this->actions = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateDatabaseDdlRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateDatabaseDdlRequest.php new file mode 100644 index 000000000000..d520012a1ad1 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateDatabaseDdlRequest.php @@ -0,0 +1,323 @@ +google.spanner.admin.database.v1.UpdateDatabaseDdlRequest + */ +class UpdateDatabaseDdlRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The database to update. + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $database = ''; + /** + * Required. DDL statements to be applied to the database. + * + * Generated from protobuf field repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $statements; + /** + * If empty, the new update request is assigned an + * automatically-generated operation ID. Otherwise, `operation_id` + * is used to construct the name of the resulting + * [Operation][google.longrunning.Operation]. + * Specifying an explicit operation ID simplifies determining + * whether the statements were executed in the event that the + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] + * call is replayed, or the return value is otherwise lost: the + * [database][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.database] + * and `operation_id` fields can be combined to form the + * [name][google.longrunning.Operation.name] of the resulting + * [longrunning.Operation][google.longrunning.Operation]: + * `/operations/`. + * `operation_id` should be unique within the database, and must be + * a valid identifier: `[a-z][a-z0-9_]*`. Note that + * automatically-generated operation IDs always begin with an + * underscore. If the named operation already exists, + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] + * returns `ALREADY_EXISTS`. + * + * Generated from protobuf field string operation_id = 3; + */ + protected $operation_id = ''; + /** + * Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements. + * Contains a protobuf-serialized + * [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto). + * To generate it, [install](https://grpc.io/docs/protoc-installation/) and + * run `protoc` with --include_imports and --descriptor_set_out. For example, + * to generate for moon/shot/app.proto, run + * ``` + * $protoc --proto_path=/app_path --proto_path=/lib_path \ + * --include_imports \ + * --descriptor_set_out=descriptors.data \ + * moon/shot/app.proto + * ``` + * For more details, see protobuffer [self + * description](https://developers.google.com/protocol-buffers/docs/techniques#self-description). + * + * Generated from protobuf field bytes proto_descriptors = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $proto_descriptors = ''; + + /** + * @param string $database Required. The database to update. Please see + * {@see DatabaseAdminClient::databaseName()} for help formatting this field. + * @param string[] $statements Required. DDL statements to be applied to the database. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseDdlRequest + * + * @experimental + */ + public static function build(string $database, array $statements): self + { + return (new self()) + ->setDatabase($database) + ->setStatements($statements); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $database + * Required. The database to update. + * @type array|\Google\Protobuf\Internal\RepeatedField $statements + * Required. DDL statements to be applied to the database. + * @type string $operation_id + * If empty, the new update request is assigned an + * automatically-generated operation ID. Otherwise, `operation_id` + * is used to construct the name of the resulting + * [Operation][google.longrunning.Operation]. + * Specifying an explicit operation ID simplifies determining + * whether the statements were executed in the event that the + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] + * call is replayed, or the return value is otherwise lost: the + * [database][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.database] + * and `operation_id` fields can be combined to form the + * [name][google.longrunning.Operation.name] of the resulting + * [longrunning.Operation][google.longrunning.Operation]: + * `/operations/`. + * `operation_id` should be unique within the database, and must be + * a valid identifier: `[a-z][a-z0-9_]*`. Note that + * automatically-generated operation IDs always begin with an + * underscore. If the named operation already exists, + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] + * returns `ALREADY_EXISTS`. + * @type string $proto_descriptors + * Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements. + * Contains a protobuf-serialized + * [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto). + * To generate it, [install](https://grpc.io/docs/protoc-installation/) and + * run `protoc` with --include_imports and --descriptor_set_out. For example, + * to generate for moon/shot/app.proto, run + * ``` + * $protoc --proto_path=/app_path --proto_path=/lib_path \ + * --include_imports \ + * --descriptor_set_out=descriptors.data \ + * moon/shot/app.proto + * ``` + * For more details, see protobuffer [self + * description](https://developers.google.com/protocol-buffers/docs/techniques#self-description). + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The database to update. + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getDatabase() + { + return $this->database; + } + + /** + * Required. The database to update. + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setDatabase($var) + { + GPBUtil::checkString($var, True); + $this->database = $var; + + return $this; + } + + /** + * Required. DDL statements to be applied to the database. + * + * Generated from protobuf field repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getStatements() + { + return $this->statements; + } + + /** + * Required. DDL statements to be applied to the database. + * + * Generated from protobuf field repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setStatements($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->statements = $arr; + + return $this; + } + + /** + * If empty, the new update request is assigned an + * automatically-generated operation ID. Otherwise, `operation_id` + * is used to construct the name of the resulting + * [Operation][google.longrunning.Operation]. + * Specifying an explicit operation ID simplifies determining + * whether the statements were executed in the event that the + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] + * call is replayed, or the return value is otherwise lost: the + * [database][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.database] + * and `operation_id` fields can be combined to form the + * [name][google.longrunning.Operation.name] of the resulting + * [longrunning.Operation][google.longrunning.Operation]: + * `/operations/`. + * `operation_id` should be unique within the database, and must be + * a valid identifier: `[a-z][a-z0-9_]*`. Note that + * automatically-generated operation IDs always begin with an + * underscore. If the named operation already exists, + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] + * returns `ALREADY_EXISTS`. + * + * Generated from protobuf field string operation_id = 3; + * @return string + */ + public function getOperationId() + { + return $this->operation_id; + } + + /** + * If empty, the new update request is assigned an + * automatically-generated operation ID. Otherwise, `operation_id` + * is used to construct the name of the resulting + * [Operation][google.longrunning.Operation]. + * Specifying an explicit operation ID simplifies determining + * whether the statements were executed in the event that the + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] + * call is replayed, or the return value is otherwise lost: the + * [database][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.database] + * and `operation_id` fields can be combined to form the + * [name][google.longrunning.Operation.name] of the resulting + * [longrunning.Operation][google.longrunning.Operation]: + * `/operations/`. + * `operation_id` should be unique within the database, and must be + * a valid identifier: `[a-z][a-z0-9_]*`. Note that + * automatically-generated operation IDs always begin with an + * underscore. If the named operation already exists, + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] + * returns `ALREADY_EXISTS`. + * + * Generated from protobuf field string operation_id = 3; + * @param string $var + * @return $this + */ + public function setOperationId($var) + { + GPBUtil::checkString($var, True); + $this->operation_id = $var; + + return $this; + } + + /** + * Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements. + * Contains a protobuf-serialized + * [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto). + * To generate it, [install](https://grpc.io/docs/protoc-installation/) and + * run `protoc` with --include_imports and --descriptor_set_out. For example, + * to generate for moon/shot/app.proto, run + * ``` + * $protoc --proto_path=/app_path --proto_path=/lib_path \ + * --include_imports \ + * --descriptor_set_out=descriptors.data \ + * moon/shot/app.proto + * ``` + * For more details, see protobuffer [self + * description](https://developers.google.com/protocol-buffers/docs/techniques#self-description). + * + * Generated from protobuf field bytes proto_descriptors = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getProtoDescriptors() + { + return $this->proto_descriptors; + } + + /** + * Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements. + * Contains a protobuf-serialized + * [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto). + * To generate it, [install](https://grpc.io/docs/protoc-installation/) and + * run `protoc` with --include_imports and --descriptor_set_out. For example, + * to generate for moon/shot/app.proto, run + * ``` + * $protoc --proto_path=/app_path --proto_path=/lib_path \ + * --include_imports \ + * --descriptor_set_out=descriptors.data \ + * moon/shot/app.proto + * ``` + * For more details, see protobuffer [self + * description](https://developers.google.com/protocol-buffers/docs/techniques#self-description). + * + * Generated from protobuf field bytes proto_descriptors = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setProtoDescriptors($var) + { + GPBUtil::checkString($var, False); + $this->proto_descriptors = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateDatabaseMetadata.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateDatabaseMetadata.php new file mode 100644 index 000000000000..19c926a4aa5e --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateDatabaseMetadata.php @@ -0,0 +1,182 @@ +google.spanner.admin.database.v1.UpdateDatabaseMetadata + */ +class UpdateDatabaseMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * The request for + * [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase]. + * + * Generated from protobuf field .google.spanner.admin.database.v1.UpdateDatabaseRequest request = 1; + */ + protected $request = null; + /** + * The progress of the + * [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase] + * operation. + * + * Generated from protobuf field .google.spanner.admin.database.v1.OperationProgress progress = 2; + */ + protected $progress = null; + /** + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is best-effort). + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + */ + protected $cancel_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseRequest $request + * The request for + * [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase]. + * @type \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress $progress + * The progress of the + * [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase] + * operation. + * @type \Google\Protobuf\Timestamp $cancel_time + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is best-effort). + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The request for + * [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase]. + * + * Generated from protobuf field .google.spanner.admin.database.v1.UpdateDatabaseRequest request = 1; + * @return \Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseRequest|null + */ + public function getRequest() + { + return $this->request; + } + + public function hasRequest() + { + return isset($this->request); + } + + public function clearRequest() + { + unset($this->request); + } + + /** + * The request for + * [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase]. + * + * Generated from protobuf field .google.spanner.admin.database.v1.UpdateDatabaseRequest request = 1; + * @param \Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseRequest $var + * @return $this + */ + public function setRequest($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseRequest::class); + $this->request = $var; + + return $this; + } + + /** + * The progress of the + * [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase] + * operation. + * + * Generated from protobuf field .google.spanner.admin.database.v1.OperationProgress progress = 2; + * @return \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress|null + */ + public function getProgress() + { + return $this->progress; + } + + public function hasProgress() + { + return isset($this->progress); + } + + public function clearProgress() + { + unset($this->progress); + } + + /** + * The progress of the + * [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase] + * operation. + * + * Generated from protobuf field .google.spanner.admin.database.v1.OperationProgress progress = 2; + * @param \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress $var + * @return $this + */ + public function setProgress($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\OperationProgress::class); + $this->progress = $var; + + return $this; + } + + /** + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is best-effort). + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCancelTime() + { + return $this->cancel_time; + } + + public function hasCancelTime() + { + return isset($this->cancel_time); + } + + public function clearCancelTime() + { + unset($this->cancel_time); + } + + /** + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is best-effort). + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCancelTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->cancel_time = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateDatabaseRequest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateDatabaseRequest.php new file mode 100644 index 000000000000..7fecddf2dd12 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/proto/src/Google/Cloud/Spanner/Admin/Database/V1/UpdateDatabaseRequest.php @@ -0,0 +1,152 @@ +google.spanner.admin.database.v1.UpdateDatabaseRequest + */ +class UpdateDatabaseRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The database to update. + * The `name` field of the database is of the form + * `projects//instances//databases/`. + * + * Generated from protobuf field .google.spanner.admin.database.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $database = null; + /** + * Required. The list of fields to update. Currently, only + * `enable_drop_protection` field can be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $update_mask = null; + + /** + * @param \Google\Cloud\Spanner\Admin\Database\V1\Database $database Required. The database to update. + * The `name` field of the database is of the form + * `projects//instances//databases/`. + * @param \Google\Protobuf\FieldMask $updateMask Required. The list of fields to update. Currently, only + * `enable_drop_protection` field can be updated. + * + * @return \Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Spanner\Admin\Database\V1\Database $database, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setDatabase($database) + ->setUpdateMask($updateMask); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Database\V1\Database $database + * Required. The database to update. + * The `name` field of the database is of the form + * `projects//instances//databases/`. + * @type \Google\Protobuf\FieldMask $update_mask + * Required. The list of fields to update. Currently, only + * `enable_drop_protection` field can be updated. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Database\V1\SpannerDatabaseAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The database to update. + * The `name` field of the database is of the form + * `projects//instances//databases/`. + * + * Generated from protobuf field .google.spanner.admin.database.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\Admin\Database\V1\Database|null + */ + public function getDatabase() + { + return $this->database; + } + + public function hasDatabase() + { + return isset($this->database); + } + + public function clearDatabase() + { + unset($this->database); + } + + /** + * Required. The database to update. + * The `name` field of the database is of the form + * `projects//instances//databases/`. + * + * Generated from protobuf field .google.spanner.admin.database.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\Admin\Database\V1\Database $var + * @return $this + */ + public function setDatabase($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Database\V1\Database::class); + $this->database = $var; + + return $this; + } + + /** + * Required. The list of fields to update. Currently, only + * `enable_drop_protection` field can be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\FieldMask|null + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + + /** + * Required. The list of fields to update. Currently, only + * `enable_drop_protection` field can be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/copy_backup.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/copy_backup.php new file mode 100644 index 000000000000..bf4780852402 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/copy_backup.php @@ -0,0 +1,116 @@ +/instances//backups//operations/` + * and can be used to track copying of the backup. The operation is associated + * with the destination backup. + * The [metadata][google.longrunning.Operation.metadata] field type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [Backup][google.spanner.admin.database.v1.Backup], if successful. + * Cancelling the returned operation will stop the copying and delete the + * destination backup. Concurrent CopyBackup requests can run on the same + * source backup. + * + * @param string $formattedParent The name of the destination instance that will contain the backup + * copy. Values are of the form: `projects//instances/`. Please see + * {@see DatabaseAdminClient::instanceName()} for help formatting this field. + * @param string $backupId The id of the backup copy. + * The `backup_id` appended to `parent` forms the full backup_uri of the form + * `projects//instances//backups/`. + * @param string $formattedSourceBackup The source backup to be copied. + * The source backup needs to be in READY state for it to be copied. + * Once CopyBackup is in progress, the source backup cannot be deleted or + * cleaned up on expiration until CopyBackup is finished. + * Values are of the form: + * `projects//instances//backups/`. Please see + * {@see DatabaseAdminClient::backupName()} for help formatting this field. + */ +function copy_backup_sample( + string $formattedParent, + string $backupId, + string $formattedSourceBackup +): void { + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $expireTime = new Timestamp(); + $request = (new CopyBackupRequest()) + ->setParent($formattedParent) + ->setBackupId($backupId) + ->setSourceBackup($formattedSourceBackup) + ->setExpireTime($expireTime); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $databaseAdminClient->copyBackup($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Backup $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * 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 = DatabaseAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + $backupId = '[BACKUP_ID]'; + $formattedSourceBackup = DatabaseAdminClient::backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + + copy_backup_sample($formattedParent, $backupId, $formattedSourceBackup); +} +// [END spanner_v1_generated_DatabaseAdmin_CopyBackup_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/create_backup.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/create_backup.php new file mode 100644 index 000000000000..f37b442933b9 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/create_backup.php @@ -0,0 +1,106 @@ +/instances//backups//operations/` + * and can be used to track creation of the backup. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [Backup][google.spanner.admin.database.v1.Backup], if successful. + * Cancelling the returned operation will stop the creation and delete the + * backup. There can be only one pending backup creation per database. Backup + * creation of different databases can run concurrently. + * + * @param string $formattedParent The name of the instance in which the backup will be + * created. This must be the same instance that contains the database the + * backup will be created from. The backup will be stored in the + * location(s) specified in the instance configuration of this + * instance. Values are of the form + * `projects//instances/`. Please see + * {@see DatabaseAdminClient::instanceName()} for help formatting this field. + * @param string $backupId The id of the backup to be created. The `backup_id` appended to + * `parent` forms the full backup name of the form + * `projects//instances//backups/`. + */ +function create_backup_sample(string $formattedParent, string $backupId): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $backup = new Backup(); + $request = (new CreateBackupRequest()) + ->setParent($formattedParent) + ->setBackupId($backupId) + ->setBackup($backup); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $databaseAdminClient->createBackup($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Backup $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * 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 = DatabaseAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + $backupId = '[BACKUP_ID]'; + + create_backup_sample($formattedParent, $backupId); +} +// [END spanner_v1_generated_DatabaseAdmin_CreateBackup_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/create_backup_schedule.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/create_backup_schedule.php new file mode 100644 index 000000000000..ba14928345f0 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/create_backup_schedule.php @@ -0,0 +1,78 @@ +/instances//databases//backupSchedules/`. + */ +function create_backup_schedule_sample(string $formattedParent, string $backupScheduleId): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $backupSchedule = new BackupSchedule(); + $request = (new CreateBackupScheduleRequest()) + ->setParent($formattedParent) + ->setBackupScheduleId($backupScheduleId) + ->setBackupSchedule($backupSchedule); + + // Call the API and handle any network failures. + try { + /** @var BackupSchedule $response */ + $response = $databaseAdminClient->createBackupSchedule($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 = DatabaseAdminClient::databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $backupScheduleId = '[BACKUP_SCHEDULE_ID]'; + + create_backup_schedule_sample($formattedParent, $backupScheduleId); +} +// [END spanner_v1_generated_DatabaseAdmin_CreateBackupSchedule_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/create_database.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/create_database.php new file mode 100644 index 000000000000..308c9926dcd8 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/create_database.php @@ -0,0 +1,98 @@ +/operations/` and + * can be used to track preparation of the database. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [Database][google.spanner.admin.database.v1.Database], if successful. + * + * @param string $formattedParent The name of the instance that will serve the new database. + * Values are of the form `projects//instances/`. Please see + * {@see DatabaseAdminClient::instanceName()} for help formatting this field. + * @param string $createStatement A `CREATE DATABASE` statement, which specifies the ID of the + * new database. The database ID must conform to the regular expression + * `[a-z][a-z0-9_\-]*[a-z0-9]` and be between 2 and 30 characters in length. + * If the database ID is a reserved word or if it contains a hyphen, the + * database ID must be enclosed in backticks (`` ` ``). + */ +function create_database_sample(string $formattedParent, string $createStatement): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $request = (new CreateDatabaseRequest()) + ->setParent($formattedParent) + ->setCreateStatement($createStatement); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $databaseAdminClient->createDatabase($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Database $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * 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 = DatabaseAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + $createStatement = '[CREATE_STATEMENT]'; + + create_database_sample($formattedParent, $createStatement); +} +// [END spanner_v1_generated_DatabaseAdmin_CreateDatabase_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/delete_backup.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/delete_backup.php new file mode 100644 index 000000000000..46ba2aa004e1 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/delete_backup.php @@ -0,0 +1,72 @@ +/instances//backups/`. Please see + * {@see DatabaseAdminClient::backupName()} for help formatting this field. + */ +function delete_backup_sample(string $formattedName): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $request = (new DeleteBackupRequest()) + ->setName($formattedName); + + // Call the API and handle any network failures. + try { + $databaseAdminClient->deleteBackup($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 = DatabaseAdminClient::backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + + delete_backup_sample($formattedName); +} +// [END spanner_v1_generated_DatabaseAdmin_DeleteBackup_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/delete_backup_schedule.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/delete_backup_schedule.php new file mode 100644 index 000000000000..ed7fab2b6c98 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/delete_backup_schedule.php @@ -0,0 +1,76 @@ +/instances//databases//backupSchedules/`. Please see + * {@see DatabaseAdminClient::backupScheduleName()} for help formatting this field. + */ +function delete_backup_schedule_sample(string $formattedName): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $request = (new DeleteBackupScheduleRequest()) + ->setName($formattedName); + + // Call the API and handle any network failures. + try { + $databaseAdminClient->deleteBackupSchedule($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 = DatabaseAdminClient::backupScheduleName( + '[PROJECT]', + '[INSTANCE]', + '[DATABASE]', + '[SCHEDULE]' + ); + + delete_backup_schedule_sample($formattedName); +} +// [END spanner_v1_generated_DatabaseAdmin_DeleteBackupSchedule_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/drop_database.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/drop_database.php new file mode 100644 index 000000000000..691a64182331 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/drop_database.php @@ -0,0 +1,73 @@ +setDatabase($formattedDatabase); + + // Call the API and handle any network failures. + try { + $databaseAdminClient->dropDatabase($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 +{ + $formattedDatabase = DatabaseAdminClient::databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + + drop_database_sample($formattedDatabase); +} +// [END spanner_v1_generated_DatabaseAdmin_DropDatabase_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/get_backup.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/get_backup.php new file mode 100644 index 000000000000..dd0c37e50d96 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/get_backup.php @@ -0,0 +1,74 @@ +/instances//backups/`. Please see + * {@see DatabaseAdminClient::backupName()} for help formatting this field. + */ +function get_backup_sample(string $formattedName): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $request = (new GetBackupRequest()) + ->setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var Backup $response */ + $response = $databaseAdminClient->getBackup($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 = DatabaseAdminClient::backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + + get_backup_sample($formattedName); +} +// [END spanner_v1_generated_DatabaseAdmin_GetBackup_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/get_backup_schedule.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/get_backup_schedule.php new file mode 100644 index 000000000000..d6b4b6d9996b --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/get_backup_schedule.php @@ -0,0 +1,78 @@ +/instances//databases//backupSchedules/`. Please see + * {@see DatabaseAdminClient::backupScheduleName()} for help formatting this field. + */ +function get_backup_schedule_sample(string $formattedName): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $request = (new GetBackupScheduleRequest()) + ->setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var BackupSchedule $response */ + $response = $databaseAdminClient->getBackupSchedule($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 = DatabaseAdminClient::backupScheduleName( + '[PROJECT]', + '[INSTANCE]', + '[DATABASE]', + '[SCHEDULE]' + ); + + get_backup_schedule_sample($formattedName); +} +// [END spanner_v1_generated_DatabaseAdmin_GetBackupSchedule_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/get_database.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/get_database.php new file mode 100644 index 000000000000..2d3f26df97fe --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/get_database.php @@ -0,0 +1,72 @@ +/instances//databases/`. Please see + * {@see DatabaseAdminClient::databaseName()} for help formatting this field. + */ +function get_database_sample(string $formattedName): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $request = (new GetDatabaseRequest()) + ->setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var Database $response */ + $response = $databaseAdminClient->getDatabase($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 = DatabaseAdminClient::databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + + get_database_sample($formattedName); +} +// [END spanner_v1_generated_DatabaseAdmin_GetDatabase_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/get_database_ddl.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/get_database_ddl.php new file mode 100644 index 000000000000..011dd8892cfb --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/get_database_ddl.php @@ -0,0 +1,75 @@ +/instances//databases/` + * Please see {@see DatabaseAdminClient::databaseName()} for help formatting this field. + */ +function get_database_ddl_sample(string $formattedDatabase): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $request = (new GetDatabaseDdlRequest()) + ->setDatabase($formattedDatabase); + + // Call the API and handle any network failures. + try { + /** @var GetDatabaseDdlResponse $response */ + $response = $databaseAdminClient->getDatabaseDdl($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 +{ + $formattedDatabase = DatabaseAdminClient::databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + + get_database_ddl_sample($formattedDatabase); +} +// [END spanner_v1_generated_DatabaseAdmin_GetDatabaseDdl_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/get_iam_policy.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/get_iam_policy.php new file mode 100644 index 000000000000..4bbbe40d0e1f --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/get_iam_policy.php @@ -0,0 +1,78 @@ +setResource($resource); + + // Call the API and handle any network failures. + try { + /** @var Policy $response */ + $response = $databaseAdminClient->getIamPolicy($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 +{ + $resource = '[RESOURCE]'; + + get_iam_policy_sample($resource); +} +// [END spanner_v1_generated_DatabaseAdmin_GetIamPolicy_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_backup_operations.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_backup_operations.php new file mode 100644 index 000000000000..2298fb55c22a --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_backup_operations.php @@ -0,0 +1,86 @@ +/instances//backups//operations/`. + * The long-running operation + * [metadata][google.longrunning.Operation.metadata] field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. Operations returned are ordered by + * `operation.metadata.value.progress.start_time` in descending order starting + * from the most recently started operation. + * + * @param string $formattedParent The instance of the backup operations. Values are of + * the form `projects//instances/`. Please see + * {@see DatabaseAdminClient::instanceName()} for help formatting this field. + */ +function list_backup_operations_sample(string $formattedParent): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $request = (new ListBackupOperationsRequest()) + ->setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $databaseAdminClient->listBackupOperations($request); + + /** @var Operation $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()); + } +} + +/** + * 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 = DatabaseAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + + list_backup_operations_sample($formattedParent); +} +// [END spanner_v1_generated_DatabaseAdmin_ListBackupOperations_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_backup_schedules.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_backup_schedules.php new file mode 100644 index 000000000000..82cd57070834 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_backup_schedules.php @@ -0,0 +1,78 @@ +/instances//databases/ + * Please see {@see DatabaseAdminClient::databaseName()} for help formatting this field. + */ +function list_backup_schedules_sample(string $formattedParent): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $request = (new ListBackupSchedulesRequest()) + ->setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $databaseAdminClient->listBackupSchedules($request); + + /** @var BackupSchedule $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()); + } +} + +/** + * 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 = DatabaseAdminClient::databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + + list_backup_schedules_sample($formattedParent); +} +// [END spanner_v1_generated_DatabaseAdmin_ListBackupSchedules_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_backups.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_backups.php new file mode 100644 index 000000000000..d687264c7a41 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_backups.php @@ -0,0 +1,79 @@ +/instances/`. Please see + * {@see DatabaseAdminClient::instanceName()} for help formatting this field. + */ +function list_backups_sample(string $formattedParent): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $request = (new ListBackupsRequest()) + ->setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $databaseAdminClient->listBackups($request); + + /** @var Backup $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()); + } +} + +/** + * 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 = DatabaseAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + + list_backups_sample($formattedParent); +} +// [END spanner_v1_generated_DatabaseAdmin_ListBackups_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_database_operations.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_database_operations.php new file mode 100644 index 000000000000..b5fdc2e72e1f --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_database_operations.php @@ -0,0 +1,84 @@ +/instances//databases//operations/`. + * The long-running operation + * [metadata][google.longrunning.Operation.metadata] field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. + * + * @param string $formattedParent The instance of the database operations. + * Values are of the form `projects//instances/`. Please see + * {@see DatabaseAdminClient::instanceName()} for help formatting this field. + */ +function list_database_operations_sample(string $formattedParent): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $request = (new ListDatabaseOperationsRequest()) + ->setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $databaseAdminClient->listDatabaseOperations($request); + + /** @var Operation $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()); + } +} + +/** + * 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 = DatabaseAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + + list_database_operations_sample($formattedParent); +} +// [END spanner_v1_generated_DatabaseAdmin_ListDatabaseOperations_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_database_roles.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_database_roles.php new file mode 100644 index 000000000000..adad9a597fe4 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_database_roles.php @@ -0,0 +1,78 @@ +/instances//databases/`. Please see + * {@see DatabaseAdminClient::databaseName()} for help formatting this field. + */ +function list_database_roles_sample(string $formattedParent): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $request = (new ListDatabaseRolesRequest()) + ->setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $databaseAdminClient->listDatabaseRoles($request); + + /** @var DatabaseRole $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()); + } +} + +/** + * 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 = DatabaseAdminClient::databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + + list_database_roles_sample($formattedParent); +} +// [END spanner_v1_generated_DatabaseAdmin_ListDatabaseRoles_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_databases.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_databases.php new file mode 100644 index 000000000000..34951db4e1cf --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/list_databases.php @@ -0,0 +1,77 @@ +/instances/`. Please see + * {@see DatabaseAdminClient::instanceName()} for help formatting this field. + */ +function list_databases_sample(string $formattedParent): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $request = (new ListDatabasesRequest()) + ->setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $databaseAdminClient->listDatabases($request); + + /** @var Database $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()); + } +} + +/** + * 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 = DatabaseAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + + list_databases_sample($formattedParent); +} +// [END spanner_v1_generated_DatabaseAdmin_ListDatabases_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/restore_database.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/restore_database.php new file mode 100644 index 000000000000..bc4a42a8b5e1 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/restore_database.php @@ -0,0 +1,109 @@ +/instances//databases//operations/`, + * and can be used to track the progress of the operation, and to cancel it. + * The [metadata][google.longrunning.Operation.metadata] field type is + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. + * The [response][google.longrunning.Operation.response] type + * is [Database][google.spanner.admin.database.v1.Database], if + * successful. Cancelling the returned operation will stop the restore and + * delete the database. + * There can be only one database being restored into an instance at a time. + * Once the restore operation completes, a new restore operation can be + * initiated, without waiting for the optimize operation associated with the + * first restore to complete. + * + * @param string $formattedParent The name of the instance in which to create the + * restored database. This instance must be in the same project and + * have the same instance configuration as the instance containing + * the source backup. Values are of the form + * `projects//instances/`. Please see + * {@see DatabaseAdminClient::instanceName()} for help formatting this field. + * @param string $databaseId The id of the database to create and restore to. This + * database must not already exist. The `database_id` appended to + * `parent` forms the full database name of the form + * `projects//instances//databases/`. + */ +function restore_database_sample(string $formattedParent, string $databaseId): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $request = (new RestoreDatabaseRequest()) + ->setParent($formattedParent) + ->setDatabaseId($databaseId); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $databaseAdminClient->restoreDatabase($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Database $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * 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 = DatabaseAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + $databaseId = '[DATABASE_ID]'; + + restore_database_sample($formattedParent, $databaseId); +} +// [END spanner_v1_generated_DatabaseAdmin_RestoreDatabase_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/set_iam_policy.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/set_iam_policy.php new file mode 100644 index 000000000000..3b13570033d8 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/set_iam_policy.php @@ -0,0 +1,79 @@ +setResource($resource) + ->setPolicy($policy); + + // Call the API and handle any network failures. + try { + /** @var Policy $response */ + $response = $databaseAdminClient->setIamPolicy($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 +{ + $resource = '[RESOURCE]'; + + set_iam_policy_sample($resource); +} +// [END spanner_v1_generated_DatabaseAdmin_SetIamPolicy_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/test_iam_permissions.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/test_iam_permissions.php new file mode 100644 index 000000000000..5dabcf6475f4 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/test_iam_permissions.php @@ -0,0 +1,87 @@ +setResource($resource) + ->setPermissions($permissions); + + // Call the API and handle any network failures. + try { + /** @var TestIamPermissionsResponse $response */ + $response = $databaseAdminClient->testIamPermissions($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 +{ + $resource = '[RESOURCE]'; + $permissionsElement = '[PERMISSIONS]'; + + test_iam_permissions_sample($resource, $permissionsElement); +} +// [END spanner_v1_generated_DatabaseAdmin_TestIamPermissions_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/update_backup.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/update_backup.php new file mode 100644 index 000000000000..af4bc1f93d3f --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/update_backup.php @@ -0,0 +1,63 @@ +setBackup($backup) + ->setUpdateMask($updateMask); + + // Call the API and handle any network failures. + try { + /** @var Backup $response */ + $response = $databaseAdminClient->updateBackup($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END spanner_v1_generated_DatabaseAdmin_UpdateBackup_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/update_backup_schedule.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/update_backup_schedule.php new file mode 100644 index 000000000000..b00ed6cc827e --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/update_backup_schedule.php @@ -0,0 +1,62 @@ +setBackupSchedule($backupSchedule) + ->setUpdateMask($updateMask); + + // Call the API and handle any network failures. + try { + /** @var BackupSchedule $response */ + $response = $databaseAdminClient->updateBackupSchedule($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END spanner_v1_generated_DatabaseAdmin_UpdateBackupSchedule_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/update_database.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/update_database.php new file mode 100644 index 000000000000..2897445d8857 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/update_database.php @@ -0,0 +1,126 @@ +/instances//databases//operations/` + * and can be used to track the database modification. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [UpdateDatabaseMetadata][google.spanner.admin.database.v1.UpdateDatabaseMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [Database][google.spanner.admin.database.v1.Database], if successful. + * + * @param string $databaseName The name of the database. Values are of the form + * `projects//instances//databases/`, + * where `` is as specified in the `CREATE DATABASE` + * statement. This name can be passed to other API methods to + * identify the database. + */ +function update_database_sample(string $databaseName): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $database = (new Database()) + ->setName($databaseName); + $updateMask = new FieldMask(); + $request = (new UpdateDatabaseRequest()) + ->setDatabase($database) + ->setUpdateMask($updateMask); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $databaseAdminClient->updateDatabase($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Database $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * 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 +{ + $databaseName = '[NAME]'; + + update_database_sample($databaseName); +} +// [END spanner_v1_generated_DatabaseAdmin_UpdateDatabase_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/update_database_ddl.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/update_database_ddl.php new file mode 100644 index 000000000000..9597e1cda6ef --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/samples/V1/DatabaseAdminClient/update_database_ddl.php @@ -0,0 +1,91 @@ +/operations/` and can be used to + * track execution of the schema change(s). The + * [metadata][google.longrunning.Operation.metadata] field type is + * [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. + * The operation has no response. + * + * @param string $formattedDatabase The database to update. Please see + * {@see DatabaseAdminClient::databaseName()} for help formatting this field. + * @param string $statementsElement DDL statements to be applied to the database. + */ +function update_database_ddl_sample(string $formattedDatabase, string $statementsElement): void +{ + // Create a client. + $databaseAdminClient = new DatabaseAdminClient(); + + // Prepare the request message. + $statements = [$statementsElement,]; + $request = (new UpdateDatabaseDdlRequest()) + ->setDatabase($formattedDatabase) + ->setStatements($statements); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $databaseAdminClient->updateDatabaseDdl($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + printf('Operation completed successfully.' . PHP_EOL); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * 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 +{ + $formattedDatabase = DatabaseAdminClient::databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $statementsElement = '[STATEMENTS]'; + + update_database_ddl_sample($formattedDatabase, $statementsElement); +} +// [END spanner_v1_generated_DatabaseAdmin_UpdateDatabaseDdl_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/Client/DatabaseAdminClient.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/Client/DatabaseAdminClient.php new file mode 100644 index 000000000000..6b925d2de9e4 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/Client/DatabaseAdminClient.php @@ -0,0 +1,1232 @@ + copyBackupAsync(CopyBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface createBackupAsync(CreateBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface createBackupScheduleAsync(CreateBackupScheduleRequest $request, array $optionalArgs = []) + * @method PromiseInterface createDatabaseAsync(CreateDatabaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteBackupAsync(DeleteBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteBackupScheduleAsync(DeleteBackupScheduleRequest $request, array $optionalArgs = []) + * @method PromiseInterface dropDatabaseAsync(DropDatabaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBackupAsync(GetBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBackupScheduleAsync(GetBackupScheduleRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDatabaseAsync(GetDatabaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDatabaseDdlAsync(GetDatabaseDdlRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBackupOperationsAsync(ListBackupOperationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBackupSchedulesAsync(ListBackupSchedulesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBackupsAsync(ListBackupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDatabaseOperationsAsync(ListDatabaseOperationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDatabaseRolesAsync(ListDatabaseRolesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDatabasesAsync(ListDatabasesRequest $request, array $optionalArgs = []) + * @method PromiseInterface restoreDatabaseAsync(RestoreDatabaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateBackupAsync(UpdateBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateBackupScheduleAsync(UpdateBackupScheduleRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDatabaseAsync(UpdateDatabaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDatabaseDdlAsync(UpdateDatabaseDdlRequest $request, array $optionalArgs = []) + */ +final class DatabaseAdminClient +{ + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.spanner.admin.database.v1.DatabaseAdmin'; + + /** + * The default address of the service. + * + * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. + */ + private const SERVICE_ADDRESS = 'spanner.googleapis.com'; + + /** The address template of the service. */ + private const SERVICE_ADDRESS_TEMPLATE = 'spanner.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', + 'https://www.googleapis.com/auth/spanner.admin', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/database_admin_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/database_admin_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/database_admin_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/database_admin_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a backup + * resource. + * + * @param string $project + * @param string $instance + * @param string $backup + * + * @return string The formatted backup resource. + */ + public static function backupName(string $project, string $instance, string $backup): string + { + return self::getPathTemplate('backup')->render([ + 'project' => $project, + 'instance' => $instance, + 'backup' => $backup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * backup_schedule resource. + * + * @param string $project + * @param string $instance + * @param string $database + * @param string $schedule + * + * @return string The formatted backup_schedule resource. + */ + public static function backupScheduleName(string $project, string $instance, string $database, string $schedule): string + { + return self::getPathTemplate('backupSchedule')->render([ + 'project' => $project, + 'instance' => $instance, + 'database' => $database, + 'schedule' => $schedule, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a crypto_key + * resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * + * @return string The formatted crypto_key resource. + */ + public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string + { + return self::getPathTemplate('cryptoKey')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * crypto_key_version resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * @param string $cryptoKeyVersion + * + * @return string The formatted crypto_key_version resource. + */ + public static function cryptoKeyVersionName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string + { + return self::getPathTemplate('cryptoKeyVersion')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + 'crypto_key_version' => $cryptoKeyVersion, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a database + * resource. + * + * @param string $project + * @param string $instance + * @param string $database + * + * @return string The formatted database resource. + */ + public static function databaseName(string $project, string $instance, string $database): string + { + return self::getPathTemplate('database')->render([ + 'project' => $project, + 'instance' => $instance, + 'database' => $database, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'instance' => $instance, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - backup: projects/{project}/instances/{instance}/backups/{backup} + * - backupSchedule: projects/{project}/instances/{instance}/databases/{database}/backupSchedules/{schedule} + * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} + * - cryptoKeyVersion: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version} + * - database: projects/{project}/instances/{instance}/databases/{database} + * - instance: projects/{project}/instances/{instance} + * + * 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. + * + * Setting the "SPANNER_EMULATOR_HOST" environment variable will automatically set + * the API Endpoint to the value specified in the variable, as well as ensure that + * empty credentials are used in the transport layer. + * + * @param array $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 'spanner.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * 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 + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @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 + * } + * + * @throws ValidationException + */ + public function __construct(array $options = []) + { + $options = $this->setDefaultEmulatorConfig($options); + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($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); + } + + /** + * Starts copying a Cloud Spanner Backup. + * The returned backup [long-running operation][google.longrunning.Operation] + * will have a name of the format + * `projects//instances//backups//operations/` + * and can be used to track copying of the backup. The operation is associated + * with the destination backup. + * The [metadata][google.longrunning.Operation.metadata] field type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [Backup][google.spanner.admin.database.v1.Backup], if successful. + * Cancelling the returned operation will stop the copying and delete the + * destination backup. Concurrent CopyBackup requests can run on the same + * source backup. + * + * The async variant is {@see DatabaseAdminClient::copyBackupAsync()} . + * + * @example samples/V1/DatabaseAdminClient/copy_backup.php + * + * @param CopyBackupRequest $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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function copyBackup(CopyBackupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CopyBackup', $request, $callOptions)->wait(); + } + + /** + * Starts creating a new Cloud Spanner Backup. + * The returned backup [long-running operation][google.longrunning.Operation] + * will have a name of the format + * `projects//instances//backups//operations/` + * and can be used to track creation of the backup. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [Backup][google.spanner.admin.database.v1.Backup], if successful. + * Cancelling the returned operation will stop the creation and delete the + * backup. There can be only one pending backup creation per database. Backup + * creation of different databases can run concurrently. + * + * The async variant is {@see DatabaseAdminClient::createBackupAsync()} . + * + * @example samples/V1/DatabaseAdminClient/create_backup.php + * + * @param CreateBackupRequest $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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBackup(CreateBackupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateBackup', $request, $callOptions)->wait(); + } + + /** + * Creates a new backup schedule. + * + * The async variant is {@see DatabaseAdminClient::createBackupScheduleAsync()} . + * + * @example samples/V1/DatabaseAdminClient/create_backup_schedule.php + * + * @param CreateBackupScheduleRequest $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 BackupSchedule + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBackupSchedule(CreateBackupScheduleRequest $request, array $callOptions = []): BackupSchedule + { + return $this->startApiCall('CreateBackupSchedule', $request, $callOptions)->wait(); + } + + /** + * Creates a new Cloud Spanner database and starts to prepare it for serving. + * The returned [long-running operation][google.longrunning.Operation] will + * have a name of the format `/operations/` and + * can be used to track preparation of the database. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [Database][google.spanner.admin.database.v1.Database], if successful. + * + * The async variant is {@see DatabaseAdminClient::createDatabaseAsync()} . + * + * @example samples/V1/DatabaseAdminClient/create_database.php + * + * @param CreateDatabaseRequest $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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDatabase(CreateDatabaseRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateDatabase', $request, $callOptions)->wait(); + } + + /** + * Deletes a pending or completed + * [Backup][google.spanner.admin.database.v1.Backup]. + * + * The async variant is {@see DatabaseAdminClient::deleteBackupAsync()} . + * + * @example samples/V1/DatabaseAdminClient/delete_backup.php + * + * @param DeleteBackupRequest $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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteBackup(DeleteBackupRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteBackup', $request, $callOptions)->wait(); + } + + /** + * Deletes a backup schedule. + * + * The async variant is {@see DatabaseAdminClient::deleteBackupScheduleAsync()} . + * + * @example samples/V1/DatabaseAdminClient/delete_backup_schedule.php + * + * @param DeleteBackupScheduleRequest $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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteBackupSchedule(DeleteBackupScheduleRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteBackupSchedule', $request, $callOptions)->wait(); + } + + /** + * Drops (aka deletes) a Cloud Spanner database. + * Completed backups for the database will be retained according to their + * `expire_time`. + * Note: Cloud Spanner might continue to accept requests for a few seconds + * after the database has been deleted. + * + * The async variant is {@see DatabaseAdminClient::dropDatabaseAsync()} . + * + * @example samples/V1/DatabaseAdminClient/drop_database.php + * + * @param DropDatabaseRequest $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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function dropDatabase(DropDatabaseRequest $request, array $callOptions = []): void + { + $this->startApiCall('DropDatabase', $request, $callOptions)->wait(); + } + + /** + * Gets metadata on a pending or completed + * [Backup][google.spanner.admin.database.v1.Backup]. + * + * The async variant is {@see DatabaseAdminClient::getBackupAsync()} . + * + * @example samples/V1/DatabaseAdminClient/get_backup.php + * + * @param GetBackupRequest $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 Backup + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBackup(GetBackupRequest $request, array $callOptions = []): Backup + { + return $this->startApiCall('GetBackup', $request, $callOptions)->wait(); + } + + /** + * Gets backup schedule for the input schedule name. + * + * The async variant is {@see DatabaseAdminClient::getBackupScheduleAsync()} . + * + * @example samples/V1/DatabaseAdminClient/get_backup_schedule.php + * + * @param GetBackupScheduleRequest $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 BackupSchedule + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBackupSchedule(GetBackupScheduleRequest $request, array $callOptions = []): BackupSchedule + { + return $this->startApiCall('GetBackupSchedule', $request, $callOptions)->wait(); + } + + /** + * Gets the state of a Cloud Spanner database. + * + * The async variant is {@see DatabaseAdminClient::getDatabaseAsync()} . + * + * @example samples/V1/DatabaseAdminClient/get_database.php + * + * @param GetDatabaseRequest $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 Database + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDatabase(GetDatabaseRequest $request, array $callOptions = []): Database + { + return $this->startApiCall('GetDatabase', $request, $callOptions)->wait(); + } + + /** + * Returns the schema of a Cloud Spanner database as a list of formatted + * DDL statements. This method does not show pending schema updates, those may + * be queried using the [Operations][google.longrunning.Operations] API. + * + * The async variant is {@see DatabaseAdminClient::getDatabaseDdlAsync()} . + * + * @example samples/V1/DatabaseAdminClient/get_database_ddl.php + * + * @param GetDatabaseDdlRequest $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 GetDatabaseDdlResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDatabaseDdl(GetDatabaseDdlRequest $request, array $callOptions = []): GetDatabaseDdlResponse + { + return $this->startApiCall('GetDatabaseDdl', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a database or backup resource. + * Returns an empty policy if a database or backup exists but does not have a + * policy set. + * + * Authorization requires `spanner.databases.getIamPolicy` permission on + * [resource][google.iam.v1.GetIamPolicyRequest.resource]. + * For backups, authorization requires `spanner.backups.getIamPolicy` + * permission on [resource][google.iam.v1.GetIamPolicyRequest.resource]. + * + * The async variant is {@see DatabaseAdminClient::getIamPolicyAsync()} . + * + * @example samples/V1/DatabaseAdminClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Lists the backup [long-running operations][google.longrunning.Operation] in + * the given instance. A backup operation has a name of the form + * `projects//instances//backups//operations/`. + * The long-running operation + * [metadata][google.longrunning.Operation.metadata] field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. Operations returned are ordered by + * `operation.metadata.value.progress.start_time` in descending order starting + * from the most recently started operation. + * + * The async variant is {@see DatabaseAdminClient::listBackupOperationsAsync()} . + * + * @example samples/V1/DatabaseAdminClient/list_backup_operations.php + * + * @param ListBackupOperationsRequest $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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBackupOperations(ListBackupOperationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBackupOperations', $request, $callOptions); + } + + /** + * Lists all the backup schedules for the database. + * + * The async variant is {@see DatabaseAdminClient::listBackupSchedulesAsync()} . + * + * @example samples/V1/DatabaseAdminClient/list_backup_schedules.php + * + * @param ListBackupSchedulesRequest $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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBackupSchedules(ListBackupSchedulesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBackupSchedules', $request, $callOptions); + } + + /** + * Lists completed and pending backups. + * Backups returned are ordered by `create_time` in descending order, + * starting from the most recent `create_time`. + * + * The async variant is {@see DatabaseAdminClient::listBackupsAsync()} . + * + * @example samples/V1/DatabaseAdminClient/list_backups.php + * + * @param ListBackupsRequest $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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBackups(ListBackupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBackups', $request, $callOptions); + } + + /** + * Lists database [longrunning-operations][google.longrunning.Operation]. + * A database operation has a name of the form + * `projects//instances//databases//operations/`. + * The long-running operation + * [metadata][google.longrunning.Operation.metadata] field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. + * + * The async variant is {@see DatabaseAdminClient::listDatabaseOperationsAsync()} . + * + * @example samples/V1/DatabaseAdminClient/list_database_operations.php + * + * @param ListDatabaseOperationsRequest $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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDatabaseOperations(ListDatabaseOperationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDatabaseOperations', $request, $callOptions); + } + + /** + * Lists Cloud Spanner database roles. + * + * The async variant is {@see DatabaseAdminClient::listDatabaseRolesAsync()} . + * + * @example samples/V1/DatabaseAdminClient/list_database_roles.php + * + * @param ListDatabaseRolesRequest $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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDatabaseRoles(ListDatabaseRolesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDatabaseRoles', $request, $callOptions); + } + + /** + * Lists Cloud Spanner databases. + * + * The async variant is {@see DatabaseAdminClient::listDatabasesAsync()} . + * + * @example samples/V1/DatabaseAdminClient/list_databases.php + * + * @param ListDatabasesRequest $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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDatabases(ListDatabasesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDatabases', $request, $callOptions); + } + + /** + * Create a new database by restoring from a completed backup. The new + * database must be in the same project and in an instance with the same + * instance configuration as the instance containing + * the backup. The returned database [long-running + * operation][google.longrunning.Operation] has a name of the format + * `projects//instances//databases//operations/`, + * and can be used to track the progress of the operation, and to cancel it. + * The [metadata][google.longrunning.Operation.metadata] field type is + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. + * The [response][google.longrunning.Operation.response] type + * is [Database][google.spanner.admin.database.v1.Database], if + * successful. Cancelling the returned operation will stop the restore and + * delete the database. + * There can be only one database being restored into an instance at a time. + * Once the restore operation completes, a new restore operation can be + * initiated, without waiting for the optimize operation associated with the + * first restore to complete. + * + * The async variant is {@see DatabaseAdminClient::restoreDatabaseAsync()} . + * + * @example samples/V1/DatabaseAdminClient/restore_database.php + * + * @param RestoreDatabaseRequest $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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function restoreDatabase(RestoreDatabaseRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RestoreDatabase', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on a database or backup resource. + * Replaces any existing policy. + * + * Authorization requires `spanner.databases.setIamPolicy` + * permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. + * For backups, authorization requires `spanner.backups.setIamPolicy` + * permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. + * + * The async variant is {@see DatabaseAdminClient::setIamPolicyAsync()} . + * + * @example samples/V1/DatabaseAdminClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that the caller has on the specified database or backup + * resource. + * + * Attempting this RPC on a non-existent Cloud Spanner database will + * result in a NOT_FOUND error if the user has + * `spanner.databases.list` permission on the containing Cloud + * Spanner instance. Otherwise returns an empty set of permissions. + * Calling this method on a backup that does not exist will + * result in a NOT_FOUND error if the user has + * `spanner.backups.list` permission on the containing instance. + * + * The async variant is {@see DatabaseAdminClient::testIamPermissionsAsync()} . + * + * @example samples/V1/DatabaseAdminClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates a pending or completed + * [Backup][google.spanner.admin.database.v1.Backup]. + * + * The async variant is {@see DatabaseAdminClient::updateBackupAsync()} . + * + * @example samples/V1/DatabaseAdminClient/update_backup.php + * + * @param UpdateBackupRequest $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 Backup + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateBackup(UpdateBackupRequest $request, array $callOptions = []): Backup + { + return $this->startApiCall('UpdateBackup', $request, $callOptions)->wait(); + } + + /** + * Updates a backup schedule. + * + * The async variant is {@see DatabaseAdminClient::updateBackupScheduleAsync()} . + * + * @example samples/V1/DatabaseAdminClient/update_backup_schedule.php + * + * @param UpdateBackupScheduleRequest $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 BackupSchedule + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateBackupSchedule(UpdateBackupScheduleRequest $request, array $callOptions = []): BackupSchedule + { + return $this->startApiCall('UpdateBackupSchedule', $request, $callOptions)->wait(); + } + + /** + * Updates a Cloud Spanner database. The returned + * [long-running operation][google.longrunning.Operation] can be used to track + * the progress of updating the database. If the named database does not + * exist, returns `NOT_FOUND`. + * + * While the operation is pending: + * + * * The database's + * [reconciling][google.spanner.admin.database.v1.Database.reconciling] + * field is set to true. + * * Cancelling the operation is best-effort. If the cancellation succeeds, + * the operation metadata's + * [cancel_time][google.spanner.admin.database.v1.UpdateDatabaseMetadata.cancel_time] + * is set, the updates are reverted, and the operation terminates with a + * `CANCELLED` status. + * * New UpdateDatabase requests will return a `FAILED_PRECONDITION` error + * until the pending operation is done (returns successfully or with + * error). + * * Reading the database via the API continues to give the pre-request + * values. + * + * Upon completion of the returned operation: + * + * * The new values are in effect and readable via the API. + * * The database's + * [reconciling][google.spanner.admin.database.v1.Database.reconciling] + * field becomes false. + * + * The returned [long-running operation][google.longrunning.Operation] will + * have a name of the format + * `projects//instances//databases//operations/` + * and can be used to track the database modification. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [UpdateDatabaseMetadata][google.spanner.admin.database.v1.UpdateDatabaseMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [Database][google.spanner.admin.database.v1.Database], if successful. + * + * The async variant is {@see DatabaseAdminClient::updateDatabaseAsync()} . + * + * @example samples/V1/DatabaseAdminClient/update_database.php + * + * @param UpdateDatabaseRequest $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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDatabase(UpdateDatabaseRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateDatabase', $request, $callOptions)->wait(); + } + + /** + * Updates the schema of a Cloud Spanner database by + * creating/altering/dropping tables, columns, indexes, etc. The returned + * [long-running operation][google.longrunning.Operation] will have a name of + * the format `/operations/` and can be used to + * track execution of the schema change(s). The + * [metadata][google.longrunning.Operation.metadata] field type is + * [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. + * The operation has no response. + * + * The async variant is {@see DatabaseAdminClient::updateDatabaseDdlAsync()} . + * + * @example samples/V1/DatabaseAdminClient/update_database_ddl.php + * + * @param UpdateDatabaseDdlRequest $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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDatabaseDdl(UpdateDatabaseDdlRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateDatabaseDdl', $request, $callOptions)->wait(); + } + + /** Configure the gapic configuration to use a service emulator. */ + private function setDefaultEmulatorConfig(array $options): array + { + $emulatorHost = getenv('SPANNER_EMULATOR_HOST'); + if (empty($emulatorHost)) { + return $options; + } + + if ($scheme = parse_url($emulatorHost, PHP_URL_SCHEME)) { + $search = $scheme . '://'; + $emulatorHost = str_replace($search, '', $emulatorHost); + } + + $options['apiEndpoint'] ??= $emulatorHost; + $options['transportConfig']['grpc']['stubOpts']['credentials'] ??= ChannelCredentials::createInsecure(); + $options['credentials'] ??= new InsecureCredentialsWrapper(); + return $options; + } +} diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/DatabaseAdminClient.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/DatabaseAdminClient.php new file mode 100644 index 000000000000..b3ac00fb0866 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/DatabaseAdminClient.php @@ -0,0 +1,34 @@ +instanceName('[PROJECT]', '[INSTANCE]'); + * $backupId = 'backup_id'; + * $formattedSourceBackup = $databaseAdminClient->backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + * $expireTime = new Timestamp(); + * $operationResponse = $databaseAdminClient->copyBackup($formattedParent, $backupId, $formattedSourceBackup, $expireTime); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $databaseAdminClient->copyBackup($formattedParent, $backupId, $formattedSourceBackup, $expireTime); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $databaseAdminClient->resumeOperation($operationName, 'copyBackup'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * 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. + * + * @deprecated Please use the new service client {@see \Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient}. + */ +class DatabaseAdminGapicClient +{ + use GapicClientTrait; + + /** The name of the service. */ + const SERVICE_NAME = 'google.spanner.admin.database.v1.DatabaseAdmin'; + + /** + * The default address of the service. + * + * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. + */ + const SERVICE_ADDRESS = 'spanner.googleapis.com'; + + /** The address template of the service. */ + private const SERVICE_ADDRESS_TEMPLATE = 'spanner.UNIVERSE_DOMAIN'; + + /** The default port of the service. */ + const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/spanner.admin', + ]; + + private static $backupNameTemplate; + + private static $backupScheduleNameTemplate; + + private static $cryptoKeyNameTemplate; + + private static $cryptoKeyVersionNameTemplate; + + private static $databaseNameTemplate; + + private static $instanceNameTemplate; + + private static $pathTemplateMap; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/database_admin_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/database_admin_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/database_admin_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/database_admin_rest_client_config.php', + ], + ], + ]; + } + + private static function getBackupNameTemplate() + { + if (self::$backupNameTemplate == null) { + self::$backupNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/backups/{backup}'); + } + + return self::$backupNameTemplate; + } + + private static function getBackupScheduleNameTemplate() + { + if (self::$backupScheduleNameTemplate == null) { + self::$backupScheduleNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/databases/{database}/backupSchedules/{schedule}'); + } + + return self::$backupScheduleNameTemplate; + } + + private static function getCryptoKeyNameTemplate() + { + if (self::$cryptoKeyNameTemplate == null) { + self::$cryptoKeyNameTemplate = new PathTemplate('projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}'); + } + + return self::$cryptoKeyNameTemplate; + } + + private static function getCryptoKeyVersionNameTemplate() + { + if (self::$cryptoKeyVersionNameTemplate == null) { + self::$cryptoKeyVersionNameTemplate = new PathTemplate('projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}'); + } + + return self::$cryptoKeyVersionNameTemplate; + } + + private static function getDatabaseNameTemplate() + { + if (self::$databaseNameTemplate == null) { + self::$databaseNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/databases/{database}'); + } + + return self::$databaseNameTemplate; + } + + private static function getInstanceNameTemplate() + { + if (self::$instanceNameTemplate == null) { + self::$instanceNameTemplate = new PathTemplate('projects/{project}/instances/{instance}'); + } + + return self::$instanceNameTemplate; + } + + private static function getPathTemplateMap() + { + if (self::$pathTemplateMap == null) { + self::$pathTemplateMap = [ + 'backup' => self::getBackupNameTemplate(), + 'backupSchedule' => self::getBackupScheduleNameTemplate(), + 'cryptoKey' => self::getCryptoKeyNameTemplate(), + 'cryptoKeyVersion' => self::getCryptoKeyVersionNameTemplate(), + 'database' => self::getDatabaseNameTemplate(), + 'instance' => self::getInstanceNameTemplate(), + ]; + } + + return self::$pathTemplateMap; + } + + /** + * Formats a string containing the fully-qualified path to represent a backup + * resource. + * + * @param string $project + * @param string $instance + * @param string $backup + * + * @return string The formatted backup resource. + */ + public static function backupName($project, $instance, $backup) + { + return self::getBackupNameTemplate()->render([ + 'project' => $project, + 'instance' => $instance, + 'backup' => $backup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * backup_schedule resource. + * + * @param string $project + * @param string $instance + * @param string $database + * @param string $schedule + * + * @return string The formatted backup_schedule resource. + */ + public static function backupScheduleName($project, $instance, $database, $schedule) + { + return self::getBackupScheduleNameTemplate()->render([ + 'project' => $project, + 'instance' => $instance, + 'database' => $database, + 'schedule' => $schedule, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a crypto_key + * resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * + * @return string The formatted crypto_key resource. + */ + public static function cryptoKeyName($project, $location, $keyRing, $cryptoKey) + { + return self::getCryptoKeyNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * crypto_key_version resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * @param string $cryptoKeyVersion + * + * @return string The formatted crypto_key_version resource. + */ + public static function cryptoKeyVersionName($project, $location, $keyRing, $cryptoKey, $cryptoKeyVersion) + { + return self::getCryptoKeyVersionNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + 'crypto_key_version' => $cryptoKeyVersion, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a database + * resource. + * + * @param string $project + * @param string $instance + * @param string $database + * + * @return string The formatted database resource. + */ + public static function databaseName($project, $instance, $database) + { + return self::getDatabaseNameTemplate()->render([ + 'project' => $project, + 'instance' => $instance, + 'database' => $database, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName($project, $instance) + { + return self::getInstanceNameTemplate()->render([ + 'project' => $project, + 'instance' => $instance, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - backup: projects/{project}/instances/{instance}/backups/{backup} + * - backupSchedule: projects/{project}/instances/{instance}/databases/{database}/backupSchedules/{schedule} + * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} + * - cryptoKeyVersion: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version} + * - database: projects/{project}/instances/{instance}/databases/{database} + * - instance: projects/{project}/instances/{instance} + * + * 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($formattedName, $template = null) + { + $templateMap = self::getPathTemplateMap(); + if ($template) { + if (!isset($templateMap[$template])) { + throw new ValidationException("Template name $template does not exist"); + } + + return $templateMap[$template]->match($formattedName); + } + + foreach ($templateMap as $templateName => $pathTemplate) { + try { + return $pathTemplate->match($formattedName); + } catch (ValidationException $ex) { + // Swallow the exception to continue trying other path templates + } + } + + throw new ValidationException("Input did not match any known format. Input: $formattedName"); + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Constructor. + * + * @param array $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 'spanner.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * 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 + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @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. + * } + * + * @throws ValidationException + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** + * Starts copying a Cloud Spanner Backup. + * The returned backup [long-running operation][google.longrunning.Operation] + * will have a name of the format + * `projects//instances//backups//operations/` + * and can be used to track copying of the backup. The operation is associated + * with the destination backup. + * The [metadata][google.longrunning.Operation.metadata] field type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [Backup][google.spanner.admin.database.v1.Backup], if successful. + * Cancelling the returned operation will stop the copying and delete the + * destination backup. Concurrent CopyBackup requests can run on the same + * source backup. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedParent = $databaseAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * $backupId = 'backup_id'; + * $formattedSourceBackup = $databaseAdminClient->backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + * $expireTime = new Timestamp(); + * $operationResponse = $databaseAdminClient->copyBackup($formattedParent, $backupId, $formattedSourceBackup, $expireTime); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $databaseAdminClient->copyBackup($formattedParent, $backupId, $formattedSourceBackup, $expireTime); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $databaseAdminClient->resumeOperation($operationName, 'copyBackup'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The name of the destination instance that will contain the backup + * copy. Values are of the form: `projects//instances/`. + * @param string $backupId Required. The id of the backup copy. + * The `backup_id` appended to `parent` forms the full backup_uri of the form + * `projects//instances//backups/`. + * @param string $sourceBackup Required. The source backup to be copied. + * The source backup needs to be in READY state for it to be copied. + * Once CopyBackup is in progress, the source backup cannot be deleted or + * cleaned up on expiration until CopyBackup is finished. + * Values are of the form: + * `projects//instances//backups/`. + * @param Timestamp $expireTime Required. The expiration time of the backup in microsecond granularity. + * The expiration time must be at least 6 hours and at most 366 days + * from the `create_time` of the source backup. Once the `expire_time` has + * passed, the backup is eligible to be automatically deleted by Cloud Spanner + * to free the resources used by the backup. + * @param array $optionalArgs { + * Optional. + * + * @type CopyBackupEncryptionConfig $encryptionConfig + * Optional. The encryption configuration used to encrypt the backup. If this + * field is not specified, the backup will use the same encryption + * configuration as the source backup by default, namely + * [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] + * = `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. + * @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 \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function copyBackup($parent, $backupId, $sourceBackup, $expireTime, array $optionalArgs = []) + { + $request = new CopyBackupRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setBackupId($backupId); + $request->setSourceBackup($sourceBackup); + $request->setExpireTime($expireTime); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['encryptionConfig'])) { + $request->setEncryptionConfig($optionalArgs['encryptionConfig']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('CopyBackup', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } + + /** + * Starts creating a new Cloud Spanner Backup. + * The returned backup [long-running operation][google.longrunning.Operation] + * will have a name of the format + * `projects//instances//backups//operations/` + * and can be used to track creation of the backup. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [Backup][google.spanner.admin.database.v1.Backup], if successful. + * Cancelling the returned operation will stop the creation and delete the + * backup. There can be only one pending backup creation per database. Backup + * creation of different databases can run concurrently. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedParent = $databaseAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * $backupId = 'backup_id'; + * $backup = new Backup(); + * $operationResponse = $databaseAdminClient->createBackup($formattedParent, $backupId, $backup); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $databaseAdminClient->createBackup($formattedParent, $backupId, $backup); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $databaseAdminClient->resumeOperation($operationName, 'createBackup'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The name of the instance in which the backup will be + * created. This must be the same instance that contains the database the + * backup will be created from. The backup will be stored in the + * location(s) specified in the instance configuration of this + * instance. Values are of the form + * `projects//instances/`. + * @param string $backupId Required. The id of the backup to be created. The `backup_id` appended to + * `parent` forms the full backup name of the form + * `projects//instances//backups/`. + * @param Backup $backup Required. The backup to create. + * @param array $optionalArgs { + * Optional. + * + * @type CreateBackupEncryptionConfig $encryptionConfig + * Optional. The encryption configuration used to encrypt the backup. If this + * field is not specified, the backup will use the same encryption + * configuration as the database by default, namely + * [encryption_type][google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type] + * = `USE_DATABASE_ENCRYPTION`. + * @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 \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function createBackup($parent, $backupId, $backup, array $optionalArgs = []) + { + $request = new CreateBackupRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setBackupId($backupId); + $request->setBackup($backup); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['encryptionConfig'])) { + $request->setEncryptionConfig($optionalArgs['encryptionConfig']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('CreateBackup', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } + + /** + * Creates a new backup schedule. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedParent = $databaseAdminClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + * $backupScheduleId = 'backup_schedule_id'; + * $backupSchedule = new BackupSchedule(); + * $response = $databaseAdminClient->createBackupSchedule($formattedParent, $backupScheduleId, $backupSchedule); + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The name of the database that this backup schedule applies to. + * @param string $backupScheduleId Required. The Id to use for the backup schedule. The `backup_schedule_id` + * appended to `parent` forms the full backup schedule name of the form + * `projects//instances//databases//backupSchedules/`. + * @param BackupSchedule $backupSchedule Required. The backup schedule to create. + * @param array $optionalArgs { + * 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 \Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule + * + * @throws ApiException if the remote call fails + */ + public function createBackupSchedule($parent, $backupScheduleId, $backupSchedule, array $optionalArgs = []) + { + $request = new CreateBackupScheduleRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setBackupScheduleId($backupScheduleId); + $request->setBackupSchedule($backupSchedule); + $requestParamHeaders['parent'] = $parent; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateBackupSchedule', BackupSchedule::class, $optionalArgs, $request)->wait(); + } + + /** + * Creates a new Cloud Spanner database and starts to prepare it for serving. + * The returned [long-running operation][google.longrunning.Operation] will + * have a name of the format `/operations/` and + * can be used to track preparation of the database. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [Database][google.spanner.admin.database.v1.Database], if successful. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedParent = $databaseAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * $createStatement = 'create_statement'; + * $operationResponse = $databaseAdminClient->createDatabase($formattedParent, $createStatement); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $databaseAdminClient->createDatabase($formattedParent, $createStatement); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $databaseAdminClient->resumeOperation($operationName, 'createDatabase'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The name of the instance that will serve the new database. + * Values are of the form `projects//instances/`. + * @param string $createStatement Required. A `CREATE DATABASE` statement, which specifies the ID of the + * new database. The database ID must conform to the regular expression + * `[a-z][a-z0-9_\-]*[a-z0-9]` and be between 2 and 30 characters in length. + * If the database ID is a reserved word or if it contains a hyphen, the + * database ID must be enclosed in backticks (`` ` ``). + * @param array $optionalArgs { + * Optional. + * + * @type string[] $extraStatements + * Optional. A list of DDL statements to run inside the newly created + * database. Statements can create tables, indexes, etc. These + * statements execute atomically with the creation of the database: + * if there is an error in any statement, the database is not created. + * @type EncryptionConfig $encryptionConfig + * Optional. The encryption configuration for the database. If this field is + * not specified, Cloud Spanner will encrypt/decrypt all data at rest using + * Google default encryption. + * @type int $databaseDialect + * Optional. The dialect of the Cloud Spanner Database. + * For allowed values, use constants defined on {@see \Google\Cloud\Spanner\Admin\Database\V1\DatabaseDialect} + * @type string $protoDescriptors + * Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements in + * 'extra_statements' above. + * Contains a protobuf-serialized + * [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto). + * To generate it, [install](https://grpc.io/docs/protoc-installation/) and + * run `protoc` with --include_imports and --descriptor_set_out. For example, + * to generate for moon/shot/app.proto, run + * ``` + * $protoc --proto_path=/app_path --proto_path=/lib_path \ + * --include_imports \ + * --descriptor_set_out=descriptors.data \ + * moon/shot/app.proto + * ``` + * For more details, see protobuffer [self + * description](https://developers.google.com/protocol-buffers/docs/techniques#self-description). + * @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 \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function createDatabase($parent, $createStatement, array $optionalArgs = []) + { + $request = new CreateDatabaseRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setCreateStatement($createStatement); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['extraStatements'])) { + $request->setExtraStatements($optionalArgs['extraStatements']); + } + + if (isset($optionalArgs['encryptionConfig'])) { + $request->setEncryptionConfig($optionalArgs['encryptionConfig']); + } + + if (isset($optionalArgs['databaseDialect'])) { + $request->setDatabaseDialect($optionalArgs['databaseDialect']); + } + + if (isset($optionalArgs['protoDescriptors'])) { + $request->setProtoDescriptors($optionalArgs['protoDescriptors']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('CreateDatabase', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } + + /** + * Deletes a pending or completed + * [Backup][google.spanner.admin.database.v1.Backup]. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedName = $databaseAdminClient->backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + * $databaseAdminClient->deleteBackup($formattedName); + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $name Required. Name of the backup to delete. + * Values are of the form + * `projects//instances//backups/`. + * @param array $optionalArgs { + * 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. + * } + * + * @throws ApiException if the remote call fails + */ + public function deleteBackup($name, array $optionalArgs = []) + { + $request = new DeleteBackupRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteBackup', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Deletes a backup schedule. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedName = $databaseAdminClient->backupScheduleName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SCHEDULE]'); + * $databaseAdminClient->deleteBackupSchedule($formattedName); + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the schedule to delete. + * Values are of the form + * `projects//instances//databases//backupSchedules/`. + * @param array $optionalArgs { + * 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. + * } + * + * @throws ApiException if the remote call fails + */ + public function deleteBackupSchedule($name, array $optionalArgs = []) + { + $request = new DeleteBackupScheduleRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteBackupSchedule', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Drops (aka deletes) a Cloud Spanner database. + * Completed backups for the database will be retained according to their + * `expire_time`. + * Note: Cloud Spanner might continue to accept requests for a few seconds + * after the database has been deleted. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedDatabase = $databaseAdminClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + * $databaseAdminClient->dropDatabase($formattedDatabase); + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $database Required. The database to be dropped. + * @param array $optionalArgs { + * 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. + * } + * + * @throws ApiException if the remote call fails + */ + public function dropDatabase($database, array $optionalArgs = []) + { + $request = new DropDatabaseRequest(); + $requestParamHeaders = []; + $request->setDatabase($database); + $requestParamHeaders['database'] = $database; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DropDatabase', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Gets metadata on a pending or completed + * [Backup][google.spanner.admin.database.v1.Backup]. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedName = $databaseAdminClient->backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + * $response = $databaseAdminClient->getBackup($formattedName); + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $name Required. Name of the backup. + * Values are of the form + * `projects//instances//backups/`. + * @param array $optionalArgs { + * 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 \Google\Cloud\Spanner\Admin\Database\V1\Backup + * + * @throws ApiException if the remote call fails + */ + public function getBackup($name, array $optionalArgs = []) + { + $request = new GetBackupRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetBackup', Backup::class, $optionalArgs, $request)->wait(); + } + + /** + * Gets backup schedule for the input schedule name. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedName = $databaseAdminClient->backupScheduleName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SCHEDULE]'); + * $response = $databaseAdminClient->getBackupSchedule($formattedName); + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the schedule to retrieve. + * Values are of the form + * `projects//instances//databases//backupSchedules/`. + * @param array $optionalArgs { + * 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 \Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule + * + * @throws ApiException if the remote call fails + */ + public function getBackupSchedule($name, array $optionalArgs = []) + { + $request = new GetBackupScheduleRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetBackupSchedule', BackupSchedule::class, $optionalArgs, $request)->wait(); + } + + /** + * Gets the state of a Cloud Spanner database. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedName = $databaseAdminClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + * $response = $databaseAdminClient->getDatabase($formattedName); + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the requested database. Values are of the form + * `projects//instances//databases/`. + * @param array $optionalArgs { + * 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 \Google\Cloud\Spanner\Admin\Database\V1\Database + * + * @throws ApiException if the remote call fails + */ + public function getDatabase($name, array $optionalArgs = []) + { + $request = new GetDatabaseRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetDatabase', Database::class, $optionalArgs, $request)->wait(); + } + + /** + * Returns the schema of a Cloud Spanner database as a list of formatted + * DDL statements. This method does not show pending schema updates, those may + * be queried using the [Operations][google.longrunning.Operations] API. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedDatabase = $databaseAdminClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + * $response = $databaseAdminClient->getDatabaseDdl($formattedDatabase); + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $database Required. The database whose schema we wish to get. + * Values are of the form + * `projects//instances//databases/` + * @param array $optionalArgs { + * 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 \Google\Cloud\Spanner\Admin\Database\V1\GetDatabaseDdlResponse + * + * @throws ApiException if the remote call fails + */ + public function getDatabaseDdl($database, array $optionalArgs = []) + { + $request = new GetDatabaseDdlRequest(); + $requestParamHeaders = []; + $request->setDatabase($database); + $requestParamHeaders['database'] = $database; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetDatabaseDdl', GetDatabaseDdlResponse::class, $optionalArgs, $request)->wait(); + } + + /** + * Gets the access control policy for a database or backup resource. + * Returns an empty policy if a database or backup exists but does not have a + * policy set. + * + * Authorization requires `spanner.databases.getIamPolicy` permission on + * [resource][google.iam.v1.GetIamPolicyRequest.resource]. + * For backups, authorization requires `spanner.backups.getIamPolicy` + * permission on [resource][google.iam.v1.GetIamPolicyRequest.resource]. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $resource = 'resource'; + * $response = $databaseAdminClient->getIamPolicy($resource); + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $resource REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param array $optionalArgs { + * Optional. + * + * @type GetPolicyOptions $options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @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 \Google\Cloud\Iam\V1\Policy + * + * @throws ApiException if the remote call fails + */ + public function getIamPolicy($resource, array $optionalArgs = []) + { + $request = new GetIamPolicyRequest(); + $requestParamHeaders = []; + $request->setResource($resource); + $requestParamHeaders['resource'] = $resource; + if (isset($optionalArgs['options'])) { + $request->setOptions($optionalArgs['options']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetIamPolicy', Policy::class, $optionalArgs, $request)->wait(); + } + + /** + * Lists the backup [long-running operations][google.longrunning.Operation] in + * the given instance. A backup operation has a name of the form + * `projects//instances//backups//operations/`. + * The long-running operation + * [metadata][google.longrunning.Operation.metadata] field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. Operations returned are ordered by + * `operation.metadata.value.progress.start_time` in descending order starting + * from the most recently started operation. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedParent = $databaseAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * // Iterate over pages of elements + * $pagedResponse = $databaseAdminClient->listBackupOperations($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $databaseAdminClient->listBackupOperations($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The instance of the backup operations. Values are of + * the form `projects//instances/`. + * @param array $optionalArgs { + * Optional. + * + * @type string $filter + * An expression that filters the list of returned backup operations. + * + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the [operation][google.longrunning.Operation] + * are eligible for filtering: + * + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] + * is + * `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic, but + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `done:true` - The operation is complete. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `metadata.database:prod` - Returns operations where: + * * The operation's metadata type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + * * The source database name of backup contains the string "prod". + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `(metadata.name:howl) AND` \ + * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + * * The backup name contains the string "howl". + * * The operation started before 2018-03-28T14:50:00Z. + * * The operation resulted in an error. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND` \ + * `(metadata.source_backup:test) AND` \ + * `(metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. + * * The source backup name contains the string "test". + * * The operation started before 2022-01-18T14:50:00Z. + * * The operation resulted in an error. + * * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `(metadata.database:test_db)) OR` \ + * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) + * AND` \ + * `(metadata.source_backup:test_bkp)) AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata matches either of criteria: + * * The operation's metadata type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] + * AND the source database name of the backup contains the string + * "test_db" + * * The operation's metadata type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata] + * AND the source backup name contains the string "test_bkp" + * * The operation resulted in an error. + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @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 \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listBackupOperations($parent, array $optionalArgs = []) + { + $request = new ListBackupOperationsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } + + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListBackupOperations', $optionalArgs, ListBackupOperationsResponse::class, $request); + } + + /** + * Lists all the backup schedules for the database. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedParent = $databaseAdminClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + * // Iterate over pages of elements + * $pagedResponse = $databaseAdminClient->listBackupSchedules($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $databaseAdminClient->listBackupSchedules($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. Database is the parent resource whose backup schedules should be + * listed. Values are of the form + * projects//instances//databases/ + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @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 \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listBackupSchedules($parent, array $optionalArgs = []) + { + $request = new ListBackupSchedulesRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListBackupSchedules', $optionalArgs, ListBackupSchedulesResponse::class, $request); + } + + /** + * Lists completed and pending backups. + * Backups returned are ordered by `create_time` in descending order, + * starting from the most recent `create_time`. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedParent = $databaseAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * // Iterate over pages of elements + * $pagedResponse = $databaseAdminClient->listBackups($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $databaseAdminClient->listBackups($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The instance to list backups from. Values are of the + * form `projects//instances/`. + * @param array $optionalArgs { + * Optional. + * + * @type string $filter + * An expression that filters the list of returned backups. + * + * A filter expression consists of a field name, a comparison operator, and a + * value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the + * [Backup][google.spanner.admin.database.v1.Backup] are eligible for + * filtering: + * + * * `name` + * * `database` + * * `state` + * * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `version_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `size_bytes` + * * `backup_schedules` + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic, but + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `name:Howl` - The backup's name contains the string "howl". + * * `database:prod` + * - The database's name contains the string "prod". + * * `state:CREATING` - The backup is pending creation. + * * `state:READY` - The backup is fully created and ready for use. + * * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")` + * - The backup name contains the string "howl" and `create_time` + * of the backup is before 2018-03-28T14:50:00Z. + * * `expire_time < \"2018-03-28T14:50:00Z\"` + * - The backup `expire_time` is before 2018-03-28T14:50:00Z. + * * `size_bytes > 10000000000` - The backup's size is greater than 10GB + * * `backup_schedules:daily` + * - The backup is created from a schedule with "daily" in its name. + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @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 \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listBackups($parent, array $optionalArgs = []) + { + $request = new ListBackupsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } + + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListBackups', $optionalArgs, ListBackupsResponse::class, $request); + } + + /** + * Lists database [longrunning-operations][google.longrunning.Operation]. + * A database operation has a name of the form + * `projects//instances//databases//operations/`. + * The long-running operation + * [metadata][google.longrunning.Operation.metadata] field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedParent = $databaseAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * // Iterate over pages of elements + * $pagedResponse = $databaseAdminClient->listDatabaseOperations($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $databaseAdminClient->listDatabaseOperations($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The instance of the database operations. + * Values are of the form `projects//instances/`. + * @param array $optionalArgs { + * Optional. + * + * @type string $filter + * An expression that filters the list of returned operations. + * + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the [Operation][google.longrunning.Operation] + * are eligible for filtering: + * + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata] + * is + * `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `done:true` - The operation is complete. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` \ + * `(metadata.source_type:BACKUP) AND` \ + * `(metadata.backup_info.backup:backup_howl) AND` \ + * `(metadata.name:restored_howl) AND` \ + * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. + * * The database is restored from a backup. + * * The backup name contains "backup_howl". + * * The restored database's name contains "restored_howl". + * * The operation started before 2018-03-28T14:50:00Z. + * * The operation resulted in an error. + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @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 \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listDatabaseOperations($parent, array $optionalArgs = []) + { + $request = new ListDatabaseOperationsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } + + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListDatabaseOperations', $optionalArgs, ListDatabaseOperationsResponse::class, $request); + } + + /** + * Lists Cloud Spanner database roles. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedParent = $databaseAdminClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + * // Iterate over pages of elements + * $pagedResponse = $databaseAdminClient->listDatabaseRoles($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $databaseAdminClient->listDatabaseRoles($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The database whose roles should be listed. + * Values are of the form + * `projects//instances//databases/`. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @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 \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listDatabaseRoles($parent, array $optionalArgs = []) + { + $request = new ListDatabaseRolesRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListDatabaseRoles', $optionalArgs, ListDatabaseRolesResponse::class, $request); + } + + /** + * Lists Cloud Spanner databases. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedParent = $databaseAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * // Iterate over pages of elements + * $pagedResponse = $databaseAdminClient->listDatabases($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $databaseAdminClient->listDatabases($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The instance whose databases should be listed. + * Values are of the form `projects//instances/`. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @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 \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listDatabases($parent, array $optionalArgs = []) + { + $request = new ListDatabasesRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListDatabases', $optionalArgs, ListDatabasesResponse::class, $request); + } + + /** + * Create a new database by restoring from a completed backup. The new + * database must be in the same project and in an instance with the same + * instance configuration as the instance containing + * the backup. The returned database [long-running + * operation][google.longrunning.Operation] has a name of the format + * `projects//instances//databases//operations/`, + * and can be used to track the progress of the operation, and to cancel it. + * The [metadata][google.longrunning.Operation.metadata] field type is + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. + * The [response][google.longrunning.Operation.response] type + * is [Database][google.spanner.admin.database.v1.Database], if + * successful. Cancelling the returned operation will stop the restore and + * delete the database. + * There can be only one database being restored into an instance at a time. + * Once the restore operation completes, a new restore operation can be + * initiated, without waiting for the optimize operation associated with the + * first restore to complete. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedParent = $databaseAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * $databaseId = 'database_id'; + * $operationResponse = $databaseAdminClient->restoreDatabase($formattedParent, $databaseId); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $databaseAdminClient->restoreDatabase($formattedParent, $databaseId); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $databaseAdminClient->resumeOperation($operationName, 'restoreDatabase'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The name of the instance in which to create the + * restored database. This instance must be in the same project and + * have the same instance configuration as the instance containing + * the source backup. Values are of the form + * `projects//instances/`. + * @param string $databaseId Required. The id of the database to create and restore to. This + * database must not already exist. The `database_id` appended to + * `parent` forms the full database name of the form + * `projects//instances//databases/`. + * @param array $optionalArgs { + * Optional. + * + * @type string $backup + * Name of the backup from which to restore. Values are of the form + * `projects//instances//backups/`. + * @type RestoreDatabaseEncryptionConfig $encryptionConfig + * Optional. An encryption configuration describing the encryption type and + * key resources in Cloud KMS used to encrypt/decrypt the database to restore + * to. If this field is not specified, the restored database will use the same + * encryption configuration as the backup by default, namely + * [encryption_type][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type] + * = `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. + * @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 \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function restoreDatabase($parent, $databaseId, array $optionalArgs = []) + { + $request = new RestoreDatabaseRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setDatabaseId($databaseId); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['backup'])) { + $request->setBackup($optionalArgs['backup']); + } + + if (isset($optionalArgs['encryptionConfig'])) { + $request->setEncryptionConfig($optionalArgs['encryptionConfig']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('RestoreDatabase', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } + + /** + * Sets the access control policy on a database or backup resource. + * Replaces any existing policy. + * + * Authorization requires `spanner.databases.setIamPolicy` + * permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. + * For backups, authorization requires `spanner.backups.setIamPolicy` + * permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $resource = 'resource'; + * $policy = new Policy(); + * $response = $databaseAdminClient->setIamPolicy($resource, $policy); + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $resource REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param Policy $policy REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param array $optionalArgs { + * Optional. + * + * @type FieldMask $updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @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 \Google\Cloud\Iam\V1\Policy + * + * @throws ApiException if the remote call fails + */ + public function setIamPolicy($resource, $policy, array $optionalArgs = []) + { + $request = new SetIamPolicyRequest(); + $requestParamHeaders = []; + $request->setResource($resource); + $request->setPolicy($policy); + $requestParamHeaders['resource'] = $resource; + if (isset($optionalArgs['updateMask'])) { + $request->setUpdateMask($optionalArgs['updateMask']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('SetIamPolicy', Policy::class, $optionalArgs, $request)->wait(); + } + + /** + * Returns permissions that the caller has on the specified database or backup + * resource. + * + * Attempting this RPC on a non-existent Cloud Spanner database will + * result in a NOT_FOUND error if the user has + * `spanner.databases.list` permission on the containing Cloud + * Spanner instance. Otherwise returns an empty set of permissions. + * Calling this method on a backup that does not exist will + * result in a NOT_FOUND error if the user has + * `spanner.backups.list` permission on the containing instance. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $resource = 'resource'; + * $permissions = []; + * $response = $databaseAdminClient->testIamPermissions($resource, $permissions); + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $resource REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param string[] $permissions The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param array $optionalArgs { + * 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 \Google\Cloud\Iam\V1\TestIamPermissionsResponse + * + * @throws ApiException if the remote call fails + */ + public function testIamPermissions($resource, $permissions, array $optionalArgs = []) + { + $request = new TestIamPermissionsRequest(); + $requestParamHeaders = []; + $request->setResource($resource); + $request->setPermissions($permissions); + $requestParamHeaders['resource'] = $resource; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('TestIamPermissions', TestIamPermissionsResponse::class, $optionalArgs, $request)->wait(); + } + + /** + * Updates a pending or completed + * [Backup][google.spanner.admin.database.v1.Backup]. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $backup = new Backup(); + * $updateMask = new FieldMask(); + * $response = $databaseAdminClient->updateBackup($backup, $updateMask); + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param Backup $backup Required. The backup to update. `backup.name`, and the fields to be updated + * as specified by `update_mask` are required. Other fields are ignored. + * Update is only supported for the following fields: + * * `backup.expire_time`. + * @param FieldMask $updateMask Required. A mask specifying which fields (e.g. `expire_time`) in the + * Backup resource should be updated. This mask is relative to the Backup + * resource, not to the request message. The field mask must always be + * specified; this prevents any future fields from being erased accidentally + * by clients that do not know about them. + * @param array $optionalArgs { + * 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 \Google\Cloud\Spanner\Admin\Database\V1\Backup + * + * @throws ApiException if the remote call fails + */ + public function updateBackup($backup, $updateMask, array $optionalArgs = []) + { + $request = new UpdateBackupRequest(); + $requestParamHeaders = []; + $request->setBackup($backup); + $request->setUpdateMask($updateMask); + $requestParamHeaders['backup.name'] = $backup->getName(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('UpdateBackup', Backup::class, $optionalArgs, $request)->wait(); + } + + /** + * Updates a backup schedule. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $backupSchedule = new BackupSchedule(); + * $updateMask = new FieldMask(); + * $response = $databaseAdminClient->updateBackupSchedule($backupSchedule, $updateMask); + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param BackupSchedule $backupSchedule Required. The backup schedule to update. `backup_schedule.name`, and the + * fields to be updated as specified by `update_mask` are required. Other + * fields are ignored. + * @param FieldMask $updateMask Required. A mask specifying which fields in the BackupSchedule resource + * should be updated. This mask is relative to the BackupSchedule resource, + * not to the request message. The field mask must always be + * specified; this prevents any future fields from being erased + * accidentally. + * @param array $optionalArgs { + * 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 \Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule + * + * @throws ApiException if the remote call fails + */ + public function updateBackupSchedule($backupSchedule, $updateMask, array $optionalArgs = []) + { + $request = new UpdateBackupScheduleRequest(); + $requestParamHeaders = []; + $request->setBackupSchedule($backupSchedule); + $request->setUpdateMask($updateMask); + $requestParamHeaders['backup_schedule.name'] = $backupSchedule->getName(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('UpdateBackupSchedule', BackupSchedule::class, $optionalArgs, $request)->wait(); + } + + /** + * Updates a Cloud Spanner database. The returned + * [long-running operation][google.longrunning.Operation] can be used to track + * the progress of updating the database. If the named database does not + * exist, returns `NOT_FOUND`. + * + * While the operation is pending: + * + * * The database's + * [reconciling][google.spanner.admin.database.v1.Database.reconciling] + * field is set to true. + * * Cancelling the operation is best-effort. If the cancellation succeeds, + * the operation metadata's + * [cancel_time][google.spanner.admin.database.v1.UpdateDatabaseMetadata.cancel_time] + * is set, the updates are reverted, and the operation terminates with a + * `CANCELLED` status. + * * New UpdateDatabase requests will return a `FAILED_PRECONDITION` error + * until the pending operation is done (returns successfully or with + * error). + * * Reading the database via the API continues to give the pre-request + * values. + * + * Upon completion of the returned operation: + * + * * The new values are in effect and readable via the API. + * * The database's + * [reconciling][google.spanner.admin.database.v1.Database.reconciling] + * field becomes false. + * + * The returned [long-running operation][google.longrunning.Operation] will + * have a name of the format + * `projects//instances//databases//operations/` + * and can be used to track the database modification. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [UpdateDatabaseMetadata][google.spanner.admin.database.v1.UpdateDatabaseMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [Database][google.spanner.admin.database.v1.Database], if successful. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $database = new Database(); + * $updateMask = new FieldMask(); + * $operationResponse = $databaseAdminClient->updateDatabase($database, $updateMask); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $databaseAdminClient->updateDatabase($database, $updateMask); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $databaseAdminClient->resumeOperation($operationName, 'updateDatabase'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param Database $database Required. The database to update. + * The `name` field of the database is of the form + * `projects//instances//databases/`. + * @param FieldMask $updateMask Required. The list of fields to update. Currently, only + * `enable_drop_protection` field can be updated. + * @param array $optionalArgs { + * 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 \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function updateDatabase($database, $updateMask, array $optionalArgs = []) + { + $request = new UpdateDatabaseRequest(); + $requestParamHeaders = []; + $request->setDatabase($database); + $request->setUpdateMask($updateMask); + $requestParamHeaders['database.name'] = $database->getName(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('UpdateDatabase', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } + + /** + * Updates the schema of a Cloud Spanner database by + * creating/altering/dropping tables, columns, indexes, etc. The returned + * [long-running operation][google.longrunning.Operation] will have a name of + * the format `/operations/` and can be used to + * track execution of the schema change(s). The + * [metadata][google.longrunning.Operation.metadata] field type is + * [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. + * The operation has no response. + * + * Sample code: + * ``` + * $databaseAdminClient = new DatabaseAdminClient(); + * try { + * $formattedDatabase = $databaseAdminClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + * $statements = []; + * $operationResponse = $databaseAdminClient->updateDatabaseDdl($formattedDatabase, $statements); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $databaseAdminClient->updateDatabaseDdl($formattedDatabase, $statements); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $databaseAdminClient->resumeOperation($operationName, 'updateDatabaseDdl'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $databaseAdminClient->close(); + * } + * ``` + * + * @param string $database Required. The database to update. + * @param string[] $statements Required. DDL statements to be applied to the database. + * @param array $optionalArgs { + * Optional. + * + * @type string $operationId + * If empty, the new update request is assigned an + * automatically-generated operation ID. Otherwise, `operation_id` + * is used to construct the name of the resulting + * [Operation][google.longrunning.Operation]. + * + * Specifying an explicit operation ID simplifies determining + * whether the statements were executed in the event that the + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] + * call is replayed, or the return value is otherwise lost: the + * [database][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.database] + * and `operation_id` fields can be combined to form the + * [name][google.longrunning.Operation.name] of the resulting + * [longrunning.Operation][google.longrunning.Operation]: + * `/operations/`. + * + * `operation_id` should be unique within the database, and must be + * a valid identifier: `[a-z][a-z0-9_]*`. Note that + * automatically-generated operation IDs always begin with an + * underscore. If the named operation already exists, + * [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] + * returns `ALREADY_EXISTS`. + * @type string $protoDescriptors + * Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements. + * Contains a protobuf-serialized + * [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto). + * To generate it, [install](https://grpc.io/docs/protoc-installation/) and + * run `protoc` with --include_imports and --descriptor_set_out. For example, + * to generate for moon/shot/app.proto, run + * ``` + * $protoc --proto_path=/app_path --proto_path=/lib_path \ + * --include_imports \ + * --descriptor_set_out=descriptors.data \ + * moon/shot/app.proto + * ``` + * For more details, see protobuffer [self + * description](https://developers.google.com/protocol-buffers/docs/techniques#self-description). + * @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 \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function updateDatabaseDdl($database, $statements, array $optionalArgs = []) + { + $request = new UpdateDatabaseDdlRequest(); + $requestParamHeaders = []; + $request->setDatabase($database); + $request->setStatements($statements); + $requestParamHeaders['database'] = $database; + if (isset($optionalArgs['operationId'])) { + $request->setOperationId($optionalArgs['operationId']); + } + + if (isset($optionalArgs['protoDescriptors'])) { + $request->setProtoDescriptors($optionalArgs['protoDescriptors']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('UpdateDatabaseDdl', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } +} diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/gapic_metadata.json b/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/gapic_metadata.json new file mode 100644 index 000000000000..42f9576de062 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/gapic_metadata.json @@ -0,0 +1,143 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services\/RPCs to the corresponding library clients\/methods", + "language": "php", + "protoPackage": "google.spanner.admin.database.v1", + "libraryPackage": "Google\\Cloud\\Spanner\\Admin\\Database\\V1", + "services": { + "DatabaseAdmin": { + "clients": { + "grpc": { + "libraryClient": "DatabaseAdminGapicClient", + "rpcs": { + "CopyBackup": { + "methods": [ + "copyBackup" + ] + }, + "CreateBackup": { + "methods": [ + "createBackup" + ] + }, + "CreateBackupSchedule": { + "methods": [ + "createBackupSchedule" + ] + }, + "CreateDatabase": { + "methods": [ + "createDatabase" + ] + }, + "DeleteBackup": { + "methods": [ + "deleteBackup" + ] + }, + "DeleteBackupSchedule": { + "methods": [ + "deleteBackupSchedule" + ] + }, + "DropDatabase": { + "methods": [ + "dropDatabase" + ] + }, + "GetBackup": { + "methods": [ + "getBackup" + ] + }, + "GetBackupSchedule": { + "methods": [ + "getBackupSchedule" + ] + }, + "GetDatabase": { + "methods": [ + "getDatabase" + ] + }, + "GetDatabaseDdl": { + "methods": [ + "getDatabaseDdl" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "ListBackupOperations": { + "methods": [ + "listBackupOperations" + ] + }, + "ListBackupSchedules": { + "methods": [ + "listBackupSchedules" + ] + }, + "ListBackups": { + "methods": [ + "listBackups" + ] + }, + "ListDatabaseOperations": { + "methods": [ + "listDatabaseOperations" + ] + }, + "ListDatabaseRoles": { + "methods": [ + "listDatabaseRoles" + ] + }, + "ListDatabases": { + "methods": [ + "listDatabases" + ] + }, + "RestoreDatabase": { + "methods": [ + "restoreDatabase" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "UpdateBackup": { + "methods": [ + "updateBackup" + ] + }, + "UpdateBackupSchedule": { + "methods": [ + "updateBackupSchedule" + ] + }, + "UpdateDatabase": { + "methods": [ + "updateDatabase" + ] + }, + "UpdateDatabaseDdl": { + "methods": [ + "updateDatabaseDdl" + ] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/resources/database_admin_client_config.json b/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/resources/database_admin_client_config.json new file mode 100644 index 000000000000..c39bb9e64ee2 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/resources/database_admin_client_config.json @@ -0,0 +1,193 @@ +{ + "interfaces": { + "google.spanner.admin.database.v1.DatabaseAdmin": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_1_codes": [ + "UNAVAILABLE", + "DEADLINE_EXCEEDED" + ], + "retry_policy_2_codes": [ + "UNAVAILABLE", + "DEADLINE_EXCEEDED" + ], + "no_retry_1_codes": [], + "no_retry_2_codes": [] + }, + "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": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 32000, + "initial_rpc_timeout_millis": 3600000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 3600000, + "total_timeout_millis": 3600000 + }, + "retry_policy_2_params": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 32000, + "initial_rpc_timeout_millis": 30000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 30000, + "total_timeout_millis": 30000 + }, + "no_retry_1_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 3600000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 3600000, + "total_timeout_millis": 3600000 + }, + "no_retry_2_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 30000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 30000, + "total_timeout_millis": 30000 + } + }, + "methods": { + "CopyBackup": { + "timeout_millis": 3600000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "CreateBackup": { + "timeout_millis": 3600000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "CreateBackupSchedule": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "CreateDatabase": { + "timeout_millis": 3600000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "DeleteBackup": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "DeleteBackupSchedule": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "DropDatabase": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "GetBackup": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "GetBackupSchedule": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "GetDatabase": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "GetDatabaseDdl": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "GetIamPolicy": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_2_codes", + "retry_params_name": "retry_policy_2_params" + }, + "ListBackupOperations": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListBackupSchedules": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListBackups": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListDatabaseOperations": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListDatabaseRoles": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListDatabases": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "RestoreDatabase": { + "timeout_millis": 3600000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "SetIamPolicy": { + "timeout_millis": 30000, + "retry_codes_name": "no_retry_2_codes", + "retry_params_name": "no_retry_2_params" + }, + "TestIamPermissions": { + "timeout_millis": 30000, + "retry_codes_name": "no_retry_2_codes", + "retry_params_name": "no_retry_2_params" + }, + "UpdateBackup": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "UpdateBackupSchedule": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "UpdateDatabase": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "UpdateDatabaseDdl": { + "timeout_millis": 3600000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + } + } + } + } +} diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/resources/database_admin_descriptor_config.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/resources/database_admin_descriptor_config.php new file mode 100644 index 000000000000..8c838a9fed43 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/resources/database_admin_descriptor_config.php @@ -0,0 +1,429 @@ + [ + 'google.spanner.admin.database.v1.DatabaseAdmin' => [ + 'CopyBackup' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\Backup', + 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\CopyBackupMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'CreateBackup' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\Backup', + 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\CreateBackupMetadata', + 'initialPollDelayMillis' => '20000', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '45000', + 'totalPollTimeoutMillis' => '172800000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'CreateDatabase' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\Database', + 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\CreateDatabaseMetadata', + 'initialPollDelayMillis' => '20000', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '45000', + 'totalPollTimeoutMillis' => '86400000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'RestoreDatabase' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\Database', + 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\RestoreDatabaseMetadata', + 'initialPollDelayMillis' => '20000', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '45000', + 'totalPollTimeoutMillis' => '86400000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateDatabase' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\Database', + 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'database.name', + 'fieldAccessors' => [ + 'getDatabase', + 'getName', + ], + ], + ], + ], + 'UpdateDatabaseDdl' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Protobuf\GPBEmpty', + 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseDdlMetadata', + 'initialPollDelayMillis' => '20000', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '45000', + 'totalPollTimeoutMillis' => '86400000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'database', + 'fieldAccessors' => [ + 'getDatabase', + ], + ], + ], + ], + 'CreateBackupSchedule' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteBackup' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'DeleteBackupSchedule' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'DropDatabase' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'database', + 'fieldAccessors' => [ + 'getDatabase', + ], + ], + ], + ], + 'GetBackup' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Database\V1\Backup', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetBackupSchedule' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetDatabase' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Database\V1\Database', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetDatabaseDdl' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Database\V1\GetDatabaseDdlResponse', + 'headerParams' => [ + [ + 'keyName' => 'database', + 'fieldAccessors' => [ + 'getDatabase', + ], + ], + ], + ], + 'GetIamPolicy' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Iam\V1\Policy', + 'headerParams' => [ + [ + 'keyName' => 'resource', + 'fieldAccessors' => [ + 'getResource', + ], + ], + ], + ], + 'ListBackupOperations' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getOperations', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Database\V1\ListBackupOperationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'ListBackupSchedules' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getBackupSchedules', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Database\V1\ListBackupSchedulesResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'ListBackups' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getBackups', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Database\V1\ListBackupsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'ListDatabaseOperations' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getOperations', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Database\V1\ListDatabaseOperationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'ListDatabaseRoles' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getDatabaseRoles', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Database\V1\ListDatabaseRolesResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'ListDatabases' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getDatabases', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Database\V1\ListDatabasesResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'SetIamPolicy' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Iam\V1\Policy', + 'headerParams' => [ + [ + 'keyName' => 'resource', + 'fieldAccessors' => [ + 'getResource', + ], + ], + ], + ], + 'TestIamPermissions' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Iam\V1\TestIamPermissionsResponse', + 'headerParams' => [ + [ + 'keyName' => 'resource', + 'fieldAccessors' => [ + 'getResource', + ], + ], + ], + ], + 'UpdateBackup' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Database\V1\Backup', + 'headerParams' => [ + [ + 'keyName' => 'backup.name', + 'fieldAccessors' => [ + 'getBackup', + 'getName', + ], + ], + ], + ], + 'UpdateBackupSchedule' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Database\V1\BackupSchedule', + 'headerParams' => [ + [ + 'keyName' => 'backup_schedule.name', + 'fieldAccessors' => [ + 'getBackupSchedule', + 'getName', + ], + ], + ], + ], + 'templateMap' => [ + 'backup' => 'projects/{project}/instances/{instance}/backups/{backup}', + 'backupSchedule' => 'projects/{project}/instances/{instance}/databases/{database}/backupSchedules/{schedule}', + 'cryptoKey' => 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}', + 'cryptoKeyVersion' => 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}', + 'database' => 'projects/{project}/instances/{instance}/databases/{database}', + 'instance' => 'projects/{project}/instances/{instance}', + ], + ], + ], +]; diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/resources/database_admin_rest_client_config.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/resources/database_admin_rest_client_config.php new file mode 100644 index 000000000000..1bf0d796614f --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/src/V1/resources/database_admin_rest_client_config.php @@ -0,0 +1,477 @@ + [ + 'google.longrunning.Operations' => [ + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}:cancel', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}:cancel', + ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/backups/*/operations/*}:cancel', + ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/instanceConfigs/*/operations/*}:cancel', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}', + ], + [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/backups/*/operations/*}', + ], + [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instanceConfigs/*/operations/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/backups/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instanceConfigs/*/operations/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/backups/*/operations}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instanceConfigs/*/operations}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + 'google.spanner.admin.database.v1.DatabaseAdmin' => [ + 'CopyBackup' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*/instances/*}/backups:copy', + 'body' => '*', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'CreateBackup' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*/instances/*}/backups', + 'body' => 'backup', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + 'queryParams' => [ + 'backup_id', + ], + ], + 'CreateBackupSchedule' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*/instances/*/databases/*}/backupSchedules', + 'body' => 'backup_schedule', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + 'queryParams' => [ + 'backup_schedule_id', + ], + ], + 'CreateDatabase' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*/instances/*}/databases', + 'body' => '*', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteBackup' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/backups/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteBackupSchedule' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/backupSchedules/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DropDatabase' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{database=projects/*/instances/*/databases/*}', + 'placeholders' => [ + 'database' => [ + 'getters' => [ + 'getDatabase', + ], + ], + ], + ], + 'GetBackup' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/backups/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetBackupSchedule' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/backupSchedules/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetDatabase' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetDatabaseDdl' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{database=projects/*/instances/*/databases/*}/ddl', + 'placeholders' => [ + 'database' => [ + 'getters' => [ + 'getDatabase', + ], + ], + ], + ], + 'GetIamPolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy', + 'body' => '*', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*/backups/*}:getIamPolicy', + 'body' => '*', + ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*/databases/*/backupSchedules/*}:getIamPolicy', + 'body' => '*', + ], + ], + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'ListBackupOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/instances/*}/backupOperations', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'ListBackupSchedules' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/instances/*/databases/*}/backupSchedules', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'ListBackups' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/instances/*}/backups', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'ListDatabaseOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/instances/*}/databaseOperations', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'ListDatabaseRoles' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/instances/*/databases/*}/databaseRoles', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'ListDatabases' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/instances/*}/databases', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'RestoreDatabase' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*/instances/*}/databases:restore', + 'body' => '*', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'SetIamPolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy', + 'body' => '*', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*/backups/*}:setIamPolicy', + 'body' => '*', + ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*/databases/*/backupSchedules/*}:setIamPolicy', + 'body' => '*', + ], + ], + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'TestIamPermissions' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*/databases/*}:testIamPermissions', + 'body' => '*', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*/backups/*}:testIamPermissions', + 'body' => '*', + ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*/databases/*/backupSchedules/*}:testIamPermissions', + 'body' => '*', + ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*/databases/*/databaseRoles/*}:testIamPermissions', + 'body' => '*', + ], + ], + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'UpdateBackup' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{backup.name=projects/*/instances/*/backups/*}', + 'body' => 'backup', + 'placeholders' => [ + 'backup.name' => [ + 'getters' => [ + 'getBackup', + 'getName', + ], + ], + ], + 'queryParams' => [ + 'update_mask', + ], + ], + 'UpdateBackupSchedule' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{backup_schedule.name=projects/*/instances/*/databases/*/backupSchedules/*}', + 'body' => 'backup_schedule', + 'placeholders' => [ + 'backup_schedule.name' => [ + 'getters' => [ + 'getBackupSchedule', + 'getName', + ], + ], + ], + 'queryParams' => [ + 'update_mask', + ], + ], + 'UpdateDatabase' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{database.name=projects/*/instances/*/databases/*}', + 'body' => 'database', + 'placeholders' => [ + 'database.name' => [ + 'getters' => [ + 'getDatabase', + 'getName', + ], + ], + ], + 'queryParams' => [ + 'update_mask', + ], + ], + 'UpdateDatabaseDdl' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{database=projects/*/instances/*/databases/*}/ddl', + 'body' => '*', + 'placeholders' => [ + 'database' => [ + 'getters' => [ + 'getDatabase', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/tests/Unit/V1/Client/DatabaseAdminClientTest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/tests/Unit/V1/Client/DatabaseAdminClientTest.php new file mode 100644 index 000000000000..9f3811b985fd --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/tests/Unit/V1/Client/DatabaseAdminClientTest.php @@ -0,0 +1,2352 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return DatabaseAdminClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new DatabaseAdminClient($options); + } + + /** @test */ + public function copyBackupTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/copyBackupTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $database = 'database1789464955'; + $name = 'name3373707'; + $sizeBytes = 1796325715; + $freeableSizeBytes = 1302251206; + $exclusiveSizeBytes = 1085921554; + $incrementalBackupChainId = 'incrementalBackupChainId-792099119'; + $expectedResponse = new Backup(); + $expectedResponse->setDatabase($database); + $expectedResponse->setName($name); + $expectedResponse->setSizeBytes($sizeBytes); + $expectedResponse->setFreeableSizeBytes($freeableSizeBytes); + $expectedResponse->setExclusiveSizeBytes($exclusiveSizeBytes); + $expectedResponse->setIncrementalBackupChainId($incrementalBackupChainId); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/copyBackupTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $backupId = 'backupId1355353272'; + $formattedSourceBackup = $gapicClient->backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + $expireTime = new Timestamp(); + $request = (new CopyBackupRequest()) + ->setParent($formattedParent) + ->setBackupId($backupId) + ->setSourceBackup($formattedSourceBackup) + ->setExpireTime($expireTime); + $response = $gapicClient->copyBackup($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/CopyBackup', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getBackupId(); + $this->assertProtobufEquals($backupId, $actualValue); + $actualValue = $actualApiRequestObject->getSourceBackup(); + $this->assertProtobufEquals($formattedSourceBackup, $actualValue); + $actualValue = $actualApiRequestObject->getExpireTime(); + $this->assertProtobufEquals($expireTime, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/copyBackupTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function copyBackupExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/copyBackupTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $backupId = 'backupId1355353272'; + $formattedSourceBackup = $gapicClient->backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + $expireTime = new Timestamp(); + $request = (new CopyBackupRequest()) + ->setParent($formattedParent) + ->setBackupId($backupId) + ->setSourceBackup($formattedSourceBackup) + ->setExpireTime($expireTime); + $response = $gapicClient->copyBackup($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/copyBackupTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createBackupTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createBackupTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $database = 'database1789464955'; + $name = 'name3373707'; + $sizeBytes = 1796325715; + $freeableSizeBytes = 1302251206; + $exclusiveSizeBytes = 1085921554; + $incrementalBackupChainId = 'incrementalBackupChainId-792099119'; + $expectedResponse = new Backup(); + $expectedResponse->setDatabase($database); + $expectedResponse->setName($name); + $expectedResponse->setSizeBytes($sizeBytes); + $expectedResponse->setFreeableSizeBytes($freeableSizeBytes); + $expectedResponse->setExclusiveSizeBytes($exclusiveSizeBytes); + $expectedResponse->setIncrementalBackupChainId($incrementalBackupChainId); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createBackupTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $backupId = 'backupId1355353272'; + $backup = new Backup(); + $request = (new CreateBackupRequest()) + ->setParent($formattedParent) + ->setBackupId($backupId) + ->setBackup($backup); + $response = $gapicClient->createBackup($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/CreateBackup', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getBackupId(); + $this->assertProtobufEquals($backupId, $actualValue); + $actualValue = $actualApiRequestObject->getBackup(); + $this->assertProtobufEquals($backup, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createBackupTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createBackupExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createBackupTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $backupId = 'backupId1355353272'; + $backup = new Backup(); + $request = (new CreateBackupRequest()) + ->setParent($formattedParent) + ->setBackupId($backupId) + ->setBackup($backup); + $response = $gapicClient->createBackup($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createBackupTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createBackupScheduleTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $expectedResponse = new BackupSchedule(); + $expectedResponse->setName($name); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $backupScheduleId = 'backupScheduleId326010054'; + $backupSchedule = new BackupSchedule(); + $request = (new CreateBackupScheduleRequest()) + ->setParent($formattedParent) + ->setBackupScheduleId($backupScheduleId) + ->setBackupSchedule($backupSchedule); + $response = $gapicClient->createBackupSchedule($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/CreateBackupSchedule', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getBackupScheduleId(); + $this->assertProtobufEquals($backupScheduleId, $actualValue); + $actualValue = $actualRequestObject->getBackupSchedule(); + $this->assertProtobufEquals($backupSchedule, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createBackupScheduleExceptionTest() + { + $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 + $formattedParent = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $backupScheduleId = 'backupScheduleId326010054'; + $backupSchedule = new BackupSchedule(); + $request = (new CreateBackupScheduleRequest()) + ->setParent($formattedParent) + ->setBackupScheduleId($backupScheduleId) + ->setBackupSchedule($backupSchedule); + try { + $gapicClient->createBackupSchedule($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 createDatabaseTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createDatabaseTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $versionRetentionPeriod = 'versionRetentionPeriod907249289'; + $defaultLeader = 'defaultLeader1941180615'; + $enableDropProtection = false; + $reconciling = false; + $expectedResponse = new Database(); + $expectedResponse->setName($name); + $expectedResponse->setVersionRetentionPeriod($versionRetentionPeriod); + $expectedResponse->setDefaultLeader($defaultLeader); + $expectedResponse->setEnableDropProtection($enableDropProtection); + $expectedResponse->setReconciling($reconciling); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createDatabaseTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $createStatement = 'createStatement552974828'; + $request = (new CreateDatabaseRequest()) + ->setParent($formattedParent) + ->setCreateStatement($createStatement); + $response = $gapicClient->createDatabase($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/CreateDatabase', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getCreateStatement(); + $this->assertProtobufEquals($createStatement, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createDatabaseTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createDatabaseExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createDatabaseTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $createStatement = 'createStatement552974828'; + $request = (new CreateDatabaseRequest()) + ->setParent($formattedParent) + ->setCreateStatement($createStatement); + $response = $gapicClient->createDatabase($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createDatabaseTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function deleteBackupTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + $request = (new DeleteBackupRequest()) + ->setName($formattedName); + $gapicClient->deleteBackup($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/DeleteBackup', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteBackupExceptionTest() + { + $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->backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + $request = (new DeleteBackupRequest()) + ->setName($formattedName); + try { + $gapicClient->deleteBackup($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 deleteBackupScheduleTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->backupScheduleName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SCHEDULE]'); + $request = (new DeleteBackupScheduleRequest()) + ->setName($formattedName); + $gapicClient->deleteBackupSchedule($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/DeleteBackupSchedule', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteBackupScheduleExceptionTest() + { + $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->backupScheduleName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SCHEDULE]'); + $request = (new DeleteBackupScheduleRequest()) + ->setName($formattedName); + try { + $gapicClient->deleteBackupSchedule($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 dropDatabaseTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $request = (new DropDatabaseRequest()) + ->setDatabase($formattedDatabase); + $gapicClient->dropDatabase($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/DropDatabase', $actualFuncCall); + $actualValue = $actualRequestObject->getDatabase(); + $this->assertProtobufEquals($formattedDatabase, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function dropDatabaseExceptionTest() + { + $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 + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $request = (new DropDatabaseRequest()) + ->setDatabase($formattedDatabase); + try { + $gapicClient->dropDatabase($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 getBackupTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $database = 'database1789464955'; + $name2 = 'name2-1052831874'; + $sizeBytes = 1796325715; + $freeableSizeBytes = 1302251206; + $exclusiveSizeBytes = 1085921554; + $incrementalBackupChainId = 'incrementalBackupChainId-792099119'; + $expectedResponse = new Backup(); + $expectedResponse->setDatabase($database); + $expectedResponse->setName($name2); + $expectedResponse->setSizeBytes($sizeBytes); + $expectedResponse->setFreeableSizeBytes($freeableSizeBytes); + $expectedResponse->setExclusiveSizeBytes($exclusiveSizeBytes); + $expectedResponse->setIncrementalBackupChainId($incrementalBackupChainId); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + $request = (new GetBackupRequest()) + ->setName($formattedName); + $response = $gapicClient->getBackup($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/GetBackup', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getBackupExceptionTest() + { + $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->backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + $request = (new GetBackupRequest()) + ->setName($formattedName); + try { + $gapicClient->getBackup($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 getBackupScheduleTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $expectedResponse = new BackupSchedule(); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->backupScheduleName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SCHEDULE]'); + $request = (new GetBackupScheduleRequest()) + ->setName($formattedName); + $response = $gapicClient->getBackupSchedule($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/GetBackupSchedule', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getBackupScheduleExceptionTest() + { + $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->backupScheduleName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SCHEDULE]'); + $request = (new GetBackupScheduleRequest()) + ->setName($formattedName); + try { + $gapicClient->getBackupSchedule($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 getDatabaseTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $versionRetentionPeriod = 'versionRetentionPeriod907249289'; + $defaultLeader = 'defaultLeader1941180615'; + $enableDropProtection = false; + $reconciling = false; + $expectedResponse = new Database(); + $expectedResponse->setName($name2); + $expectedResponse->setVersionRetentionPeriod($versionRetentionPeriod); + $expectedResponse->setDefaultLeader($defaultLeader); + $expectedResponse->setEnableDropProtection($enableDropProtection); + $expectedResponse->setReconciling($reconciling); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $request = (new GetDatabaseRequest()) + ->setName($formattedName); + $response = $gapicClient->getDatabase($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/GetDatabase', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getDatabaseExceptionTest() + { + $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->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $request = (new GetDatabaseRequest()) + ->setName($formattedName); + try { + $gapicClient->getDatabase($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 getDatabaseDdlTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $protoDescriptors = '13'; + $expectedResponse = new GetDatabaseDdlResponse(); + $expectedResponse->setProtoDescriptors($protoDescriptors); + $transport->addResponse($expectedResponse); + // Mock request + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $request = (new GetDatabaseDdlRequest()) + ->setDatabase($formattedDatabase); + $response = $gapicClient->getDatabaseDdl($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/GetDatabaseDdl', $actualFuncCall); + $actualValue = $actualRequestObject->getDatabase(); + $this->assertProtobufEquals($formattedDatabase, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getDatabaseDdlExceptionTest() + { + $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 + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $request = (new GetDatabaseDdlRequest()) + ->setDatabase($formattedDatabase); + try { + $gapicClient->getDatabaseDdl($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 getIamPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $version = 351608024; + $etag = '21'; + $expectedResponse = new Policy(); + $expectedResponse->setVersion($version); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $request = (new GetIamPolicyRequest()) + ->setResource($resource); + $response = $gapicClient->getIamPolicy($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/GetIamPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getIamPolicyExceptionTest() + { + $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 + $resource = 'resource-341064690'; + $request = (new GetIamPolicyRequest()) + ->setResource($resource); + try { + $gapicClient->getIamPolicy($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 listBackupOperationsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $operationsElement = new Operation(); + $operations = [ + $operationsElement, + ]; + $expectedResponse = new ListBackupOperationsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setOperations($operations); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $request = (new ListBackupOperationsRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listBackupOperations($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getOperations()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/ListBackupOperations', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listBackupOperationsExceptionTest() + { + $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 + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $request = (new ListBackupOperationsRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listBackupOperations($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 listBackupSchedulesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $backupSchedulesElement = new BackupSchedule(); + $backupSchedules = [ + $backupSchedulesElement, + ]; + $expectedResponse = new ListBackupSchedulesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setBackupSchedules($backupSchedules); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $request = (new ListBackupSchedulesRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listBackupSchedules($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getBackupSchedules()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/ListBackupSchedules', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listBackupSchedulesExceptionTest() + { + $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 + $formattedParent = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $request = (new ListBackupSchedulesRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listBackupSchedules($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 listBackupsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $backupsElement = new Backup(); + $backups = [ + $backupsElement, + ]; + $expectedResponse = new ListBackupsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setBackups($backups); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $request = (new ListBackupsRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listBackups($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getBackups()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/ListBackups', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listBackupsExceptionTest() + { + $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 + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $request = (new ListBackupsRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listBackups($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 listDatabaseOperationsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $operationsElement = new Operation(); + $operations = [ + $operationsElement, + ]; + $expectedResponse = new ListDatabaseOperationsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setOperations($operations); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $request = (new ListDatabaseOperationsRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listDatabaseOperations($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getOperations()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/ListDatabaseOperations', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listDatabaseOperationsExceptionTest() + { + $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 + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $request = (new ListDatabaseOperationsRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listDatabaseOperations($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 listDatabaseRolesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $databaseRolesElement = new DatabaseRole(); + $databaseRoles = [ + $databaseRolesElement, + ]; + $expectedResponse = new ListDatabaseRolesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setDatabaseRoles($databaseRoles); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $request = (new ListDatabaseRolesRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listDatabaseRoles($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getDatabaseRoles()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/ListDatabaseRoles', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listDatabaseRolesExceptionTest() + { + $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 + $formattedParent = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $request = (new ListDatabaseRolesRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listDatabaseRoles($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 listDatabasesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $databasesElement = new Database(); + $databases = [ + $databasesElement, + ]; + $expectedResponse = new ListDatabasesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setDatabases($databases); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $request = (new ListDatabasesRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listDatabases($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getDatabases()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/ListDatabases', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listDatabasesExceptionTest() + { + $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 + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $request = (new ListDatabasesRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listDatabases($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 restoreDatabaseTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/restoreDatabaseTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $versionRetentionPeriod = 'versionRetentionPeriod907249289'; + $defaultLeader = 'defaultLeader1941180615'; + $enableDropProtection = false; + $reconciling = false; + $expectedResponse = new Database(); + $expectedResponse->setName($name); + $expectedResponse->setVersionRetentionPeriod($versionRetentionPeriod); + $expectedResponse->setDefaultLeader($defaultLeader); + $expectedResponse->setEnableDropProtection($enableDropProtection); + $expectedResponse->setReconciling($reconciling); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/restoreDatabaseTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $databaseId = 'databaseId816491103'; + $request = (new RestoreDatabaseRequest()) + ->setParent($formattedParent) + ->setDatabaseId($databaseId); + $response = $gapicClient->restoreDatabase($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/RestoreDatabase', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getDatabaseId(); + $this->assertProtobufEquals($databaseId, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/restoreDatabaseTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function restoreDatabaseExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/restoreDatabaseTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $databaseId = 'databaseId816491103'; + $request = (new RestoreDatabaseRequest()) + ->setParent($formattedParent) + ->setDatabaseId($databaseId); + $response = $gapicClient->restoreDatabase($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/restoreDatabaseTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function setIamPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $version = 351608024; + $etag = '21'; + $expectedResponse = new Policy(); + $expectedResponse->setVersion($version); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $policy = new Policy(); + $request = (new SetIamPolicyRequest()) + ->setResource($resource) + ->setPolicy($policy); + $response = $gapicClient->setIamPolicy($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/SetIamPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $actualValue = $actualRequestObject->getPolicy(); + $this->assertProtobufEquals($policy, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function setIamPolicyExceptionTest() + { + $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 + $resource = 'resource-341064690'; + $policy = new Policy(); + $request = (new SetIamPolicyRequest()) + ->setResource($resource) + ->setPolicy($policy); + try { + $gapicClient->setIamPolicy($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 testIamPermissionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new TestIamPermissionsResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $permissions = []; + $request = (new TestIamPermissionsRequest()) + ->setResource($resource) + ->setPermissions($permissions); + $response = $gapicClient->testIamPermissions($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/TestIamPermissions', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $actualValue = $actualRequestObject->getPermissions(); + $this->assertProtobufEquals($permissions, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function testIamPermissionsExceptionTest() + { + $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 + $resource = 'resource-341064690'; + $permissions = []; + $request = (new TestIamPermissionsRequest()) + ->setResource($resource) + ->setPermissions($permissions); + try { + $gapicClient->testIamPermissions($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 updateBackupTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $database = 'database1789464955'; + $name = 'name3373707'; + $sizeBytes = 1796325715; + $freeableSizeBytes = 1302251206; + $exclusiveSizeBytes = 1085921554; + $incrementalBackupChainId = 'incrementalBackupChainId-792099119'; + $expectedResponse = new Backup(); + $expectedResponse->setDatabase($database); + $expectedResponse->setName($name); + $expectedResponse->setSizeBytes($sizeBytes); + $expectedResponse->setFreeableSizeBytes($freeableSizeBytes); + $expectedResponse->setExclusiveSizeBytes($exclusiveSizeBytes); + $expectedResponse->setIncrementalBackupChainId($incrementalBackupChainId); + $transport->addResponse($expectedResponse); + // Mock request + $backup = new Backup(); + $updateMask = new FieldMask(); + $request = (new UpdateBackupRequest()) + ->setBackup($backup) + ->setUpdateMask($updateMask); + $response = $gapicClient->updateBackup($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/UpdateBackup', $actualFuncCall); + $actualValue = $actualRequestObject->getBackup(); + $this->assertProtobufEquals($backup, $actualValue); + $actualValue = $actualRequestObject->getUpdateMask(); + $this->assertProtobufEquals($updateMask, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateBackupExceptionTest() + { + $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 + $backup = new Backup(); + $updateMask = new FieldMask(); + $request = (new UpdateBackupRequest()) + ->setBackup($backup) + ->setUpdateMask($updateMask); + try { + $gapicClient->updateBackup($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 updateBackupScheduleTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $expectedResponse = new BackupSchedule(); + $expectedResponse->setName($name); + $transport->addResponse($expectedResponse); + // Mock request + $backupSchedule = new BackupSchedule(); + $updateMask = new FieldMask(); + $request = (new UpdateBackupScheduleRequest()) + ->setBackupSchedule($backupSchedule) + ->setUpdateMask($updateMask); + $response = $gapicClient->updateBackupSchedule($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/UpdateBackupSchedule', $actualFuncCall); + $actualValue = $actualRequestObject->getBackupSchedule(); + $this->assertProtobufEquals($backupSchedule, $actualValue); + $actualValue = $actualRequestObject->getUpdateMask(); + $this->assertProtobufEquals($updateMask, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateBackupScheduleExceptionTest() + { + $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 + $backupSchedule = new BackupSchedule(); + $updateMask = new FieldMask(); + $request = (new UpdateBackupScheduleRequest()) + ->setBackupSchedule($backupSchedule) + ->setUpdateMask($updateMask); + try { + $gapicClient->updateBackupSchedule($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 updateDatabaseTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateDatabaseTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $versionRetentionPeriod = 'versionRetentionPeriod907249289'; + $defaultLeader = 'defaultLeader1941180615'; + $enableDropProtection = false; + $reconciling = false; + $expectedResponse = new Database(); + $expectedResponse->setName($name); + $expectedResponse->setVersionRetentionPeriod($versionRetentionPeriod); + $expectedResponse->setDefaultLeader($defaultLeader); + $expectedResponse->setEnableDropProtection($enableDropProtection); + $expectedResponse->setReconciling($reconciling); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/updateDatabaseTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $database = new Database(); + $databaseName = 'databaseName-459093338'; + $database->setName($databaseName); + $updateMask = new FieldMask(); + $request = (new UpdateDatabaseRequest()) + ->setDatabase($database) + ->setUpdateMask($updateMask); + $response = $gapicClient->updateDatabase($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/UpdateDatabase', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getDatabase(); + $this->assertProtobufEquals($database, $actualValue); + $actualValue = $actualApiRequestObject->getUpdateMask(); + $this->assertProtobufEquals($updateMask, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateDatabaseTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateDatabaseExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateDatabaseTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $database = new Database(); + $databaseName = 'databaseName-459093338'; + $database->setName($databaseName); + $updateMask = new FieldMask(); + $request = (new UpdateDatabaseRequest()) + ->setDatabase($database) + ->setUpdateMask($updateMask); + $response = $gapicClient->updateDatabase($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateDatabaseTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateDatabaseDdlTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateDatabaseDdlTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new GPBEmpty(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/updateDatabaseDdlTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $statements = []; + $request = (new UpdateDatabaseDdlRequest()) + ->setDatabase($formattedDatabase) + ->setStatements($statements); + $response = $gapicClient->updateDatabaseDdl($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/UpdateDatabaseDdl', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getDatabase(); + $this->assertProtobufEquals($formattedDatabase, $actualValue); + $actualValue = $actualApiRequestObject->getStatements(); + $this->assertProtobufEquals($statements, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateDatabaseDdlTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateDatabaseDdlExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateDatabaseDdlTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $statements = []; + $request = (new UpdateDatabaseDdlRequest()) + ->setDatabase($formattedDatabase) + ->setStatements($statements); + $response = $gapicClient->updateDatabaseDdl($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateDatabaseDdlTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function copyBackupAsyncTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/copyBackupTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $database = 'database1789464955'; + $name = 'name3373707'; + $sizeBytes = 1796325715; + $freeableSizeBytes = 1302251206; + $exclusiveSizeBytes = 1085921554; + $incrementalBackupChainId = 'incrementalBackupChainId-792099119'; + $expectedResponse = new Backup(); + $expectedResponse->setDatabase($database); + $expectedResponse->setName($name); + $expectedResponse->setSizeBytes($sizeBytes); + $expectedResponse->setFreeableSizeBytes($freeableSizeBytes); + $expectedResponse->setExclusiveSizeBytes($exclusiveSizeBytes); + $expectedResponse->setIncrementalBackupChainId($incrementalBackupChainId); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/copyBackupTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $backupId = 'backupId1355353272'; + $formattedSourceBackup = $gapicClient->backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + $expireTime = new Timestamp(); + $request = (new CopyBackupRequest()) + ->setParent($formattedParent) + ->setBackupId($backupId) + ->setSourceBackup($formattedSourceBackup) + ->setExpireTime($expireTime); + $response = $gapicClient->copyBackupAsync($request)->wait(); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/CopyBackup', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getBackupId(); + $this->assertProtobufEquals($backupId, $actualValue); + $actualValue = $actualApiRequestObject->getSourceBackup(); + $this->assertProtobufEquals($formattedSourceBackup, $actualValue); + $actualValue = $actualApiRequestObject->getExpireTime(); + $this->assertProtobufEquals($expireTime, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/copyBackupTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } +} diff --git a/owl-bot-staging/Spanner/v1/Admin/Database/v1/tests/Unit/V1/DatabaseAdminClientTest.php b/owl-bot-staging/Spanner/v1/Admin/Database/v1/tests/Unit/V1/DatabaseAdminClientTest.php new file mode 100644 index 000000000000..2371125aab73 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Database/v1/tests/Unit/V1/DatabaseAdminClientTest.php @@ -0,0 +1,2109 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return DatabaseAdminClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new DatabaseAdminClient($options); + } + + /** @test */ + public function copyBackupTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/copyBackupTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $database = 'database1789464955'; + $name = 'name3373707'; + $sizeBytes = 1796325715; + $freeableSizeBytes = 1302251206; + $exclusiveSizeBytes = 1085921554; + $incrementalBackupChainId = 'incrementalBackupChainId-792099119'; + $expectedResponse = new Backup(); + $expectedResponse->setDatabase($database); + $expectedResponse->setName($name); + $expectedResponse->setSizeBytes($sizeBytes); + $expectedResponse->setFreeableSizeBytes($freeableSizeBytes); + $expectedResponse->setExclusiveSizeBytes($exclusiveSizeBytes); + $expectedResponse->setIncrementalBackupChainId($incrementalBackupChainId); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/copyBackupTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $backupId = 'backupId1355353272'; + $formattedSourceBackup = $gapicClient->backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + $expireTime = new Timestamp(); + $response = $gapicClient->copyBackup($formattedParent, $backupId, $formattedSourceBackup, $expireTime); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/CopyBackup', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getBackupId(); + $this->assertProtobufEquals($backupId, $actualValue); + $actualValue = $actualApiRequestObject->getSourceBackup(); + $this->assertProtobufEquals($formattedSourceBackup, $actualValue); + $actualValue = $actualApiRequestObject->getExpireTime(); + $this->assertProtobufEquals($expireTime, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/copyBackupTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function copyBackupExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/copyBackupTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $backupId = 'backupId1355353272'; + $formattedSourceBackup = $gapicClient->backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + $expireTime = new Timestamp(); + $response = $gapicClient->copyBackup($formattedParent, $backupId, $formattedSourceBackup, $expireTime); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/copyBackupTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createBackupTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createBackupTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $database = 'database1789464955'; + $name = 'name3373707'; + $sizeBytes = 1796325715; + $freeableSizeBytes = 1302251206; + $exclusiveSizeBytes = 1085921554; + $incrementalBackupChainId = 'incrementalBackupChainId-792099119'; + $expectedResponse = new Backup(); + $expectedResponse->setDatabase($database); + $expectedResponse->setName($name); + $expectedResponse->setSizeBytes($sizeBytes); + $expectedResponse->setFreeableSizeBytes($freeableSizeBytes); + $expectedResponse->setExclusiveSizeBytes($exclusiveSizeBytes); + $expectedResponse->setIncrementalBackupChainId($incrementalBackupChainId); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createBackupTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $backupId = 'backupId1355353272'; + $backup = new Backup(); + $response = $gapicClient->createBackup($formattedParent, $backupId, $backup); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/CreateBackup', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getBackupId(); + $this->assertProtobufEquals($backupId, $actualValue); + $actualValue = $actualApiRequestObject->getBackup(); + $this->assertProtobufEquals($backup, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createBackupTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createBackupExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createBackupTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $backupId = 'backupId1355353272'; + $backup = new Backup(); + $response = $gapicClient->createBackup($formattedParent, $backupId, $backup); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createBackupTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createBackupScheduleTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $expectedResponse = new BackupSchedule(); + $expectedResponse->setName($name); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $backupScheduleId = 'backupScheduleId326010054'; + $backupSchedule = new BackupSchedule(); + $response = $gapicClient->createBackupSchedule($formattedParent, $backupScheduleId, $backupSchedule); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/CreateBackupSchedule', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getBackupScheduleId(); + $this->assertProtobufEquals($backupScheduleId, $actualValue); + $actualValue = $actualRequestObject->getBackupSchedule(); + $this->assertProtobufEquals($backupSchedule, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createBackupScheduleExceptionTest() + { + $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 + $formattedParent = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $backupScheduleId = 'backupScheduleId326010054'; + $backupSchedule = new BackupSchedule(); + try { + $gapicClient->createBackupSchedule($formattedParent, $backupScheduleId, $backupSchedule); + // 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 createDatabaseTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createDatabaseTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $versionRetentionPeriod = 'versionRetentionPeriod907249289'; + $defaultLeader = 'defaultLeader1941180615'; + $enableDropProtection = false; + $reconciling = false; + $expectedResponse = new Database(); + $expectedResponse->setName($name); + $expectedResponse->setVersionRetentionPeriod($versionRetentionPeriod); + $expectedResponse->setDefaultLeader($defaultLeader); + $expectedResponse->setEnableDropProtection($enableDropProtection); + $expectedResponse->setReconciling($reconciling); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createDatabaseTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $createStatement = 'createStatement552974828'; + $response = $gapicClient->createDatabase($formattedParent, $createStatement); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/CreateDatabase', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getCreateStatement(); + $this->assertProtobufEquals($createStatement, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createDatabaseTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createDatabaseExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createDatabaseTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $createStatement = 'createStatement552974828'; + $response = $gapicClient->createDatabase($formattedParent, $createStatement); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createDatabaseTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function deleteBackupTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + $gapicClient->deleteBackup($formattedName); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/DeleteBackup', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteBackupExceptionTest() + { + $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->backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + try { + $gapicClient->deleteBackup($formattedName); + // 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 deleteBackupScheduleTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->backupScheduleName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SCHEDULE]'); + $gapicClient->deleteBackupSchedule($formattedName); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/DeleteBackupSchedule', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteBackupScheduleExceptionTest() + { + $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->backupScheduleName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SCHEDULE]'); + try { + $gapicClient->deleteBackupSchedule($formattedName); + // 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 dropDatabaseTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $gapicClient->dropDatabase($formattedDatabase); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/DropDatabase', $actualFuncCall); + $actualValue = $actualRequestObject->getDatabase(); + $this->assertProtobufEquals($formattedDatabase, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function dropDatabaseExceptionTest() + { + $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 + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + try { + $gapicClient->dropDatabase($formattedDatabase); + // 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 getBackupTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $database = 'database1789464955'; + $name2 = 'name2-1052831874'; + $sizeBytes = 1796325715; + $freeableSizeBytes = 1302251206; + $exclusiveSizeBytes = 1085921554; + $incrementalBackupChainId = 'incrementalBackupChainId-792099119'; + $expectedResponse = new Backup(); + $expectedResponse->setDatabase($database); + $expectedResponse->setName($name2); + $expectedResponse->setSizeBytes($sizeBytes); + $expectedResponse->setFreeableSizeBytes($freeableSizeBytes); + $expectedResponse->setExclusiveSizeBytes($exclusiveSizeBytes); + $expectedResponse->setIncrementalBackupChainId($incrementalBackupChainId); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + $response = $gapicClient->getBackup($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/GetBackup', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getBackupExceptionTest() + { + $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->backupName('[PROJECT]', '[INSTANCE]', '[BACKUP]'); + try { + $gapicClient->getBackup($formattedName); + // 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 getBackupScheduleTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $expectedResponse = new BackupSchedule(); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->backupScheduleName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SCHEDULE]'); + $response = $gapicClient->getBackupSchedule($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/GetBackupSchedule', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getBackupScheduleExceptionTest() + { + $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->backupScheduleName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SCHEDULE]'); + try { + $gapicClient->getBackupSchedule($formattedName); + // 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 getDatabaseTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $versionRetentionPeriod = 'versionRetentionPeriod907249289'; + $defaultLeader = 'defaultLeader1941180615'; + $enableDropProtection = false; + $reconciling = false; + $expectedResponse = new Database(); + $expectedResponse->setName($name2); + $expectedResponse->setVersionRetentionPeriod($versionRetentionPeriod); + $expectedResponse->setDefaultLeader($defaultLeader); + $expectedResponse->setEnableDropProtection($enableDropProtection); + $expectedResponse->setReconciling($reconciling); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $response = $gapicClient->getDatabase($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/GetDatabase', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getDatabaseExceptionTest() + { + $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->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + try { + $gapicClient->getDatabase($formattedName); + // 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 getDatabaseDdlTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $protoDescriptors = '13'; + $expectedResponse = new GetDatabaseDdlResponse(); + $expectedResponse->setProtoDescriptors($protoDescriptors); + $transport->addResponse($expectedResponse); + // Mock request + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $response = $gapicClient->getDatabaseDdl($formattedDatabase); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/GetDatabaseDdl', $actualFuncCall); + $actualValue = $actualRequestObject->getDatabase(); + $this->assertProtobufEquals($formattedDatabase, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getDatabaseDdlExceptionTest() + { + $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 + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + try { + $gapicClient->getDatabaseDdl($formattedDatabase); + // 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 getIamPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $version = 351608024; + $etag = '21'; + $expectedResponse = new Policy(); + $expectedResponse->setVersion($version); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $response = $gapicClient->getIamPolicy($resource); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/GetIamPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getIamPolicyExceptionTest() + { + $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 + $resource = 'resource-341064690'; + try { + $gapicClient->getIamPolicy($resource); + // 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 listBackupOperationsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $operationsElement = new Operation(); + $operations = [ + $operationsElement, + ]; + $expectedResponse = new ListBackupOperationsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setOperations($operations); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $response = $gapicClient->listBackupOperations($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getOperations()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/ListBackupOperations', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listBackupOperationsExceptionTest() + { + $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 + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + try { + $gapicClient->listBackupOperations($formattedParent); + // 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 listBackupSchedulesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $backupSchedulesElement = new BackupSchedule(); + $backupSchedules = [ + $backupSchedulesElement, + ]; + $expectedResponse = new ListBackupSchedulesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setBackupSchedules($backupSchedules); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $response = $gapicClient->listBackupSchedules($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getBackupSchedules()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/ListBackupSchedules', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listBackupSchedulesExceptionTest() + { + $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 + $formattedParent = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + try { + $gapicClient->listBackupSchedules($formattedParent); + // 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 listBackupsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $backupsElement = new Backup(); + $backups = [ + $backupsElement, + ]; + $expectedResponse = new ListBackupsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setBackups($backups); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $response = $gapicClient->listBackups($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getBackups()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/ListBackups', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listBackupsExceptionTest() + { + $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 + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + try { + $gapicClient->listBackups($formattedParent); + // 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 listDatabaseOperationsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $operationsElement = new Operation(); + $operations = [ + $operationsElement, + ]; + $expectedResponse = new ListDatabaseOperationsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setOperations($operations); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $response = $gapicClient->listDatabaseOperations($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getOperations()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/ListDatabaseOperations', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listDatabaseOperationsExceptionTest() + { + $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 + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + try { + $gapicClient->listDatabaseOperations($formattedParent); + // 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 listDatabaseRolesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $databaseRolesElement = new DatabaseRole(); + $databaseRoles = [ + $databaseRolesElement, + ]; + $expectedResponse = new ListDatabaseRolesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setDatabaseRoles($databaseRoles); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $response = $gapicClient->listDatabaseRoles($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getDatabaseRoles()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/ListDatabaseRoles', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listDatabaseRolesExceptionTest() + { + $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 + $formattedParent = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + try { + $gapicClient->listDatabaseRoles($formattedParent); + // 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 listDatabasesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $databasesElement = new Database(); + $databases = [ + $databasesElement, + ]; + $expectedResponse = new ListDatabasesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setDatabases($databases); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $response = $gapicClient->listDatabases($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getDatabases()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/ListDatabases', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listDatabasesExceptionTest() + { + $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 + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + try { + $gapicClient->listDatabases($formattedParent); + // 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 restoreDatabaseTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/restoreDatabaseTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $versionRetentionPeriod = 'versionRetentionPeriod907249289'; + $defaultLeader = 'defaultLeader1941180615'; + $enableDropProtection = false; + $reconciling = false; + $expectedResponse = new Database(); + $expectedResponse->setName($name); + $expectedResponse->setVersionRetentionPeriod($versionRetentionPeriod); + $expectedResponse->setDefaultLeader($defaultLeader); + $expectedResponse->setEnableDropProtection($enableDropProtection); + $expectedResponse->setReconciling($reconciling); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/restoreDatabaseTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $databaseId = 'databaseId816491103'; + $response = $gapicClient->restoreDatabase($formattedParent, $databaseId); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/RestoreDatabase', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getDatabaseId(); + $this->assertProtobufEquals($databaseId, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/restoreDatabaseTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function restoreDatabaseExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/restoreDatabaseTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $databaseId = 'databaseId816491103'; + $response = $gapicClient->restoreDatabase($formattedParent, $databaseId); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/restoreDatabaseTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function setIamPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $version = 351608024; + $etag = '21'; + $expectedResponse = new Policy(); + $expectedResponse->setVersion($version); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $policy = new Policy(); + $response = $gapicClient->setIamPolicy($resource, $policy); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/SetIamPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $actualValue = $actualRequestObject->getPolicy(); + $this->assertProtobufEquals($policy, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function setIamPolicyExceptionTest() + { + $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 + $resource = 'resource-341064690'; + $policy = new Policy(); + try { + $gapicClient->setIamPolicy($resource, $policy); + // 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 testIamPermissionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new TestIamPermissionsResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $permissions = []; + $response = $gapicClient->testIamPermissions($resource, $permissions); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/TestIamPermissions', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $actualValue = $actualRequestObject->getPermissions(); + $this->assertProtobufEquals($permissions, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function testIamPermissionsExceptionTest() + { + $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 + $resource = 'resource-341064690'; + $permissions = []; + try { + $gapicClient->testIamPermissions($resource, $permissions); + // 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 updateBackupTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $database = 'database1789464955'; + $name = 'name3373707'; + $sizeBytes = 1796325715; + $freeableSizeBytes = 1302251206; + $exclusiveSizeBytes = 1085921554; + $incrementalBackupChainId = 'incrementalBackupChainId-792099119'; + $expectedResponse = new Backup(); + $expectedResponse->setDatabase($database); + $expectedResponse->setName($name); + $expectedResponse->setSizeBytes($sizeBytes); + $expectedResponse->setFreeableSizeBytes($freeableSizeBytes); + $expectedResponse->setExclusiveSizeBytes($exclusiveSizeBytes); + $expectedResponse->setIncrementalBackupChainId($incrementalBackupChainId); + $transport->addResponse($expectedResponse); + // Mock request + $backup = new Backup(); + $updateMask = new FieldMask(); + $response = $gapicClient->updateBackup($backup, $updateMask); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/UpdateBackup', $actualFuncCall); + $actualValue = $actualRequestObject->getBackup(); + $this->assertProtobufEquals($backup, $actualValue); + $actualValue = $actualRequestObject->getUpdateMask(); + $this->assertProtobufEquals($updateMask, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateBackupExceptionTest() + { + $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 + $backup = new Backup(); + $updateMask = new FieldMask(); + try { + $gapicClient->updateBackup($backup, $updateMask); + // 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 updateBackupScheduleTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $expectedResponse = new BackupSchedule(); + $expectedResponse->setName($name); + $transport->addResponse($expectedResponse); + // Mock request + $backupSchedule = new BackupSchedule(); + $updateMask = new FieldMask(); + $response = $gapicClient->updateBackupSchedule($backupSchedule, $updateMask); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/UpdateBackupSchedule', $actualFuncCall); + $actualValue = $actualRequestObject->getBackupSchedule(); + $this->assertProtobufEquals($backupSchedule, $actualValue); + $actualValue = $actualRequestObject->getUpdateMask(); + $this->assertProtobufEquals($updateMask, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateBackupScheduleExceptionTest() + { + $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 + $backupSchedule = new BackupSchedule(); + $updateMask = new FieldMask(); + try { + $gapicClient->updateBackupSchedule($backupSchedule, $updateMask); + // 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 updateDatabaseTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateDatabaseTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $versionRetentionPeriod = 'versionRetentionPeriod907249289'; + $defaultLeader = 'defaultLeader1941180615'; + $enableDropProtection = false; + $reconciling = false; + $expectedResponse = new Database(); + $expectedResponse->setName($name); + $expectedResponse->setVersionRetentionPeriod($versionRetentionPeriod); + $expectedResponse->setDefaultLeader($defaultLeader); + $expectedResponse->setEnableDropProtection($enableDropProtection); + $expectedResponse->setReconciling($reconciling); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/updateDatabaseTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $database = new Database(); + $databaseName = 'databaseName-459093338'; + $database->setName($databaseName); + $updateMask = new FieldMask(); + $response = $gapicClient->updateDatabase($database, $updateMask); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/UpdateDatabase', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getDatabase(); + $this->assertProtobufEquals($database, $actualValue); + $actualValue = $actualApiRequestObject->getUpdateMask(); + $this->assertProtobufEquals($updateMask, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateDatabaseTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateDatabaseExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateDatabaseTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $database = new Database(); + $databaseName = 'databaseName-459093338'; + $database->setName($databaseName); + $updateMask = new FieldMask(); + $response = $gapicClient->updateDatabase($database, $updateMask); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateDatabaseTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateDatabaseDdlTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateDatabaseDdlTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new GPBEmpty(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/updateDatabaseDdlTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $statements = []; + $response = $gapicClient->updateDatabaseDdl($formattedDatabase, $statements); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.database.v1.DatabaseAdmin/UpdateDatabaseDdl', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getDatabase(); + $this->assertProtobufEquals($formattedDatabase, $actualValue); + $actualValue = $actualApiRequestObject->getStatements(); + $this->assertProtobufEquals($statements, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateDatabaseDdlTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateDatabaseDdlExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateDatabaseDdlTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $statements = []; + $response = $gapicClient->updateDatabaseDdl($formattedDatabase, $statements); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateDatabaseDdlTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } +} diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Instance/V1/Common.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Instance/V1/Common.php new file mode 100644 index 000000000000..ce280a9688c2 Binary files /dev/null and b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Instance/V1/Common.php differ diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Instance/V1/SpannerInstanceAdmin.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Instance/V1/SpannerInstanceAdmin.php new file mode 100644 index 000000000000..3bca763a961b Binary files /dev/null and b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/GPBMetadata/Google/Spanner/Admin/Instance/V1/SpannerInstanceAdmin.php differ diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/AutoscalingConfig.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/AutoscalingConfig.php new file mode 100644 index 000000000000..2dd5cea37d14 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/AutoscalingConfig.php @@ -0,0 +1,183 @@ +google.spanner.admin.instance.v1.AutoscalingConfig + */ +class AutoscalingConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Autoscaling limits for an instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingLimits autoscaling_limits = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $autoscaling_limits = null; + /** + * Required. The autoscaling targets for an instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingTargets autoscaling_targets = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $autoscaling_targets = null; + /** + * Optional. Optional asymmetric autoscaling options. + * Replicas matching the replica selection criteria will be autoscaled + * independently from other replicas. The autoscaler will scale the replicas + * based on the utilization of replicas identified by the replica selection. + * Replica selections should not overlap with each other. + * Other replicas (those do not match any replica selection) will be + * autoscaled together and will have the same compute capacity allocated to + * them. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.AutoscalingConfig.AsymmetricAutoscalingOption asymmetric_autoscaling_options = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $asymmetric_autoscaling_options; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingLimits $autoscaling_limits + * Required. Autoscaling limits for an instance. + * @type \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingTargets $autoscaling_targets + * Required. The autoscaling targets for an instance. + * @type array<\Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AsymmetricAutoscalingOption>|\Google\Protobuf\Internal\RepeatedField $asymmetric_autoscaling_options + * Optional. Optional asymmetric autoscaling options. + * Replicas matching the replica selection criteria will be autoscaled + * independently from other replicas. The autoscaler will scale the replicas + * based on the utilization of replicas identified by the replica selection. + * Replica selections should not overlap with each other. + * Other replicas (those do not match any replica selection) will be + * autoscaled together and will have the same compute capacity allocated to + * them. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. Autoscaling limits for an instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingLimits autoscaling_limits = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingLimits|null + */ + public function getAutoscalingLimits() + { + return $this->autoscaling_limits; + } + + public function hasAutoscalingLimits() + { + return isset($this->autoscaling_limits); + } + + public function clearAutoscalingLimits() + { + unset($this->autoscaling_limits); + } + + /** + * Required. Autoscaling limits for an instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingLimits autoscaling_limits = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingLimits $var + * @return $this + */ + public function setAutoscalingLimits($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingLimits::class); + $this->autoscaling_limits = $var; + + return $this; + } + + /** + * Required. The autoscaling targets for an instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingTargets autoscaling_targets = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingTargets|null + */ + public function getAutoscalingTargets() + { + return $this->autoscaling_targets; + } + + public function hasAutoscalingTargets() + { + return isset($this->autoscaling_targets); + } + + public function clearAutoscalingTargets() + { + unset($this->autoscaling_targets); + } + + /** + * Required. The autoscaling targets for an instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingTargets autoscaling_targets = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingTargets $var + * @return $this + */ + public function setAutoscalingTargets($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingTargets::class); + $this->autoscaling_targets = $var; + + return $this; + } + + /** + * Optional. Optional asymmetric autoscaling options. + * Replicas matching the replica selection criteria will be autoscaled + * independently from other replicas. The autoscaler will scale the replicas + * based on the utilization of replicas identified by the replica selection. + * Replica selections should not overlap with each other. + * Other replicas (those do not match any replica selection) will be + * autoscaled together and will have the same compute capacity allocated to + * them. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.AutoscalingConfig.AsymmetricAutoscalingOption asymmetric_autoscaling_options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getAsymmetricAutoscalingOptions() + { + return $this->asymmetric_autoscaling_options; + } + + /** + * Optional. Optional asymmetric autoscaling options. + * Replicas matching the replica selection criteria will be autoscaled + * independently from other replicas. The autoscaler will scale the replicas + * based on the utilization of replicas identified by the replica selection. + * Replica selections should not overlap with each other. + * Other replicas (those do not match any replica selection) will be + * autoscaled together and will have the same compute capacity allocated to + * them. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.AutoscalingConfig.AsymmetricAutoscalingOption asymmetric_autoscaling_options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param array<\Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AsymmetricAutoscalingOption>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setAsymmetricAutoscalingOptions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AsymmetricAutoscalingOption::class); + $this->asymmetric_autoscaling_options = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/AutoscalingConfig/AsymmetricAutoscalingOption.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/AutoscalingConfig/AsymmetricAutoscalingOption.php new file mode 100644 index 000000000000..f2f31e0b6c2c --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/AutoscalingConfig/AsymmetricAutoscalingOption.php @@ -0,0 +1,133 @@ +google.spanner.admin.instance.v1.AutoscalingConfig.AsymmetricAutoscalingOption + */ +class AsymmetricAutoscalingOption extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Selects the replicas to which this AsymmetricAutoscalingOption + * applies. Only read-only replicas are supported. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.ReplicaSelection replica_selection = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $replica_selection = null; + /** + * Optional. Overrides applied to the top-level autoscaling configuration + * for the selected replicas. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AsymmetricAutoscalingOption.AutoscalingConfigOverrides overrides = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $overrides = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Instance\V1\ReplicaSelection $replica_selection + * Required. Selects the replicas to which this AsymmetricAutoscalingOption + * applies. Only read-only replicas are supported. + * @type \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AsymmetricAutoscalingOption\AutoscalingConfigOverrides $overrides + * Optional. Overrides applied to the top-level autoscaling configuration + * for the selected replicas. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. Selects the replicas to which this AsymmetricAutoscalingOption + * applies. Only read-only replicas are supported. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.ReplicaSelection replica_selection = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\ReplicaSelection|null + */ + public function getReplicaSelection() + { + return $this->replica_selection; + } + + public function hasReplicaSelection() + { + return isset($this->replica_selection); + } + + public function clearReplicaSelection() + { + unset($this->replica_selection); + } + + /** + * Required. Selects the replicas to which this AsymmetricAutoscalingOption + * applies. Only read-only replicas are supported. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.ReplicaSelection replica_selection = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\ReplicaSelection $var + * @return $this + */ + public function setReplicaSelection($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\ReplicaSelection::class); + $this->replica_selection = $var; + + return $this; + } + + /** + * Optional. Overrides applied to the top-level autoscaling configuration + * for the selected replicas. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AsymmetricAutoscalingOption.AutoscalingConfigOverrides overrides = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AsymmetricAutoscalingOption\AutoscalingConfigOverrides|null + */ + public function getOverrides() + { + return $this->overrides; + } + + public function hasOverrides() + { + return isset($this->overrides); + } + + public function clearOverrides() + { + unset($this->overrides); + } + + /** + * Optional. Overrides applied to the top-level autoscaling configuration + * for the selected replicas. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AsymmetricAutoscalingOption.AutoscalingConfigOverrides overrides = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AsymmetricAutoscalingOption\AutoscalingConfigOverrides $var + * @return $this + */ + public function setOverrides($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AsymmetricAutoscalingOption\AutoscalingConfigOverrides::class); + $this->overrides = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(AsymmetricAutoscalingOption::class, \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig_AsymmetricAutoscalingOption::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/AutoscalingConfig/AsymmetricAutoscalingOption/AutoscalingConfigOverrides.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/AutoscalingConfig/AsymmetricAutoscalingOption/AutoscalingConfigOverrides.php new file mode 100644 index 000000000000..e6c06e4f4013 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/AutoscalingConfig/AsymmetricAutoscalingOption/AutoscalingConfigOverrides.php @@ -0,0 +1,129 @@ +google.spanner.admin.instance.v1.AutoscalingConfig.AsymmetricAutoscalingOption.AutoscalingConfigOverrides + */ +class AutoscalingConfigOverrides extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. If specified, overrides the min/max limit in the top-level + * autoscaling configuration for the selected replicas. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingLimits autoscaling_limits = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $autoscaling_limits = null; + /** + * Optional. If specified, overrides the autoscaling target + * high_priority_cpu_utilization_percent in the top-level autoscaling + * configuration for the selected replicas. + * + * Generated from protobuf field int32 autoscaling_target_high_priority_cpu_utilization_percent = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $autoscaling_target_high_priority_cpu_utilization_percent = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingLimits $autoscaling_limits + * Optional. If specified, overrides the min/max limit in the top-level + * autoscaling configuration for the selected replicas. + * @type int $autoscaling_target_high_priority_cpu_utilization_percent + * Optional. If specified, overrides the autoscaling target + * high_priority_cpu_utilization_percent in the top-level autoscaling + * configuration for the selected replicas. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Optional. If specified, overrides the min/max limit in the top-level + * autoscaling configuration for the selected replicas. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingLimits autoscaling_limits = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingLimits|null + */ + public function getAutoscalingLimits() + { + return $this->autoscaling_limits; + } + + public function hasAutoscalingLimits() + { + return isset($this->autoscaling_limits); + } + + public function clearAutoscalingLimits() + { + unset($this->autoscaling_limits); + } + + /** + * Optional. If specified, overrides the min/max limit in the top-level + * autoscaling configuration for the selected replicas. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingLimits autoscaling_limits = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingLimits $var + * @return $this + */ + public function setAutoscalingLimits($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingLimits::class); + $this->autoscaling_limits = $var; + + return $this; + } + + /** + * Optional. If specified, overrides the autoscaling target + * high_priority_cpu_utilization_percent in the top-level autoscaling + * configuration for the selected replicas. + * + * Generated from protobuf field int32 autoscaling_target_high_priority_cpu_utilization_percent = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getAutoscalingTargetHighPriorityCpuUtilizationPercent() + { + return $this->autoscaling_target_high_priority_cpu_utilization_percent; + } + + /** + * Optional. If specified, overrides the autoscaling target + * high_priority_cpu_utilization_percent in the top-level autoscaling + * configuration for the selected replicas. + * + * Generated from protobuf field int32 autoscaling_target_high_priority_cpu_utilization_percent = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setAutoscalingTargetHighPriorityCpuUtilizationPercent($var) + { + GPBUtil::checkInt32($var); + $this->autoscaling_target_high_priority_cpu_utilization_percent = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(AutoscalingConfigOverrides::class, \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig_AsymmetricAutoscalingOption_AutoscalingConfigOverrides::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/AutoscalingConfig/AutoscalingLimits.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/AutoscalingConfig/AutoscalingLimits.php new file mode 100644 index 000000000000..48ac73c059f5 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/AutoscalingConfig/AutoscalingLimits.php @@ -0,0 +1,205 @@ +google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingLimits + */ +class AutoscalingLimits extends \Google\Protobuf\Internal\Message +{ + protected $min_limit; + protected $max_limit; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $min_nodes + * Minimum number of nodes allocated to the instance. If set, this number + * should be greater than or equal to 1. + * @type int $min_processing_units + * Minimum number of processing units allocated to the instance. If set, + * this number should be multiples of 1000. + * @type int $max_nodes + * Maximum number of nodes allocated to the instance. If set, this number + * should be greater than or equal to min_nodes. + * @type int $max_processing_units + * Maximum number of processing units allocated to the instance. If set, + * this number should be multiples of 1000 and be greater than or equal to + * min_processing_units. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Minimum number of nodes allocated to the instance. If set, this number + * should be greater than or equal to 1. + * + * Generated from protobuf field int32 min_nodes = 1; + * @return int + */ + public function getMinNodes() + { + return $this->readOneof(1); + } + + public function hasMinNodes() + { + return $this->hasOneof(1); + } + + /** + * Minimum number of nodes allocated to the instance. If set, this number + * should be greater than or equal to 1. + * + * Generated from protobuf field int32 min_nodes = 1; + * @param int $var + * @return $this + */ + public function setMinNodes($var) + { + GPBUtil::checkInt32($var); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * Minimum number of processing units allocated to the instance. If set, + * this number should be multiples of 1000. + * + * Generated from protobuf field int32 min_processing_units = 2; + * @return int + */ + public function getMinProcessingUnits() + { + return $this->readOneof(2); + } + + public function hasMinProcessingUnits() + { + return $this->hasOneof(2); + } + + /** + * Minimum number of processing units allocated to the instance. If set, + * this number should be multiples of 1000. + * + * Generated from protobuf field int32 min_processing_units = 2; + * @param int $var + * @return $this + */ + public function setMinProcessingUnits($var) + { + GPBUtil::checkInt32($var); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * Maximum number of nodes allocated to the instance. If set, this number + * should be greater than or equal to min_nodes. + * + * Generated from protobuf field int32 max_nodes = 3; + * @return int + */ + public function getMaxNodes() + { + return $this->readOneof(3); + } + + public function hasMaxNodes() + { + return $this->hasOneof(3); + } + + /** + * Maximum number of nodes allocated to the instance. If set, this number + * should be greater than or equal to min_nodes. + * + * Generated from protobuf field int32 max_nodes = 3; + * @param int $var + * @return $this + */ + public function setMaxNodes($var) + { + GPBUtil::checkInt32($var); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * Maximum number of processing units allocated to the instance. If set, + * this number should be multiples of 1000 and be greater than or equal to + * min_processing_units. + * + * Generated from protobuf field int32 max_processing_units = 4; + * @return int + */ + public function getMaxProcessingUnits() + { + return $this->readOneof(4); + } + + public function hasMaxProcessingUnits() + { + return $this->hasOneof(4); + } + + /** + * Maximum number of processing units allocated to the instance. If set, + * this number should be multiples of 1000 and be greater than or equal to + * min_processing_units. + * + * Generated from protobuf field int32 max_processing_units = 4; + * @param int $var + * @return $this + */ + public function setMaxProcessingUnits($var) + { + GPBUtil::checkInt32($var); + $this->writeOneof(4, $var); + + return $this; + } + + /** + * @return string + */ + public function getMinLimit() + { + return $this->whichOneof("min_limit"); + } + + /** + * @return string + */ + public function getMaxLimit() + { + return $this->whichOneof("max_limit"); + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(AutoscalingLimits::class, \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig_AutoscalingLimits::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/AutoscalingConfig/AutoscalingTargets.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/AutoscalingConfig/AutoscalingTargets.php new file mode 100644 index 000000000000..a1b2d41cc75b --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/AutoscalingConfig/AutoscalingTargets.php @@ -0,0 +1,128 @@ +google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingTargets + */ +class AutoscalingTargets extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The target high priority cpu utilization percentage that the + * autoscaler should be trying to achieve for the instance. This number is + * on a scale from 0 (no utilization) to 100 (full utilization). The valid + * range is [10, 90] inclusive. + * + * Generated from protobuf field int32 high_priority_cpu_utilization_percent = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $high_priority_cpu_utilization_percent = 0; + /** + * Required. The target storage utilization percentage that the autoscaler + * should be trying to achieve for the instance. This number is on a scale + * from 0 (no utilization) to 100 (full utilization). The valid range is + * [10, 99] inclusive. + * + * Generated from protobuf field int32 storage_utilization_percent = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $storage_utilization_percent = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $high_priority_cpu_utilization_percent + * Required. The target high priority cpu utilization percentage that the + * autoscaler should be trying to achieve for the instance. This number is + * on a scale from 0 (no utilization) to 100 (full utilization). The valid + * range is [10, 90] inclusive. + * @type int $storage_utilization_percent + * Required. The target storage utilization percentage that the autoscaler + * should be trying to achieve for the instance. This number is on a scale + * from 0 (no utilization) to 100 (full utilization). The valid range is + * [10, 99] inclusive. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The target high priority cpu utilization percentage that the + * autoscaler should be trying to achieve for the instance. This number is + * on a scale from 0 (no utilization) to 100 (full utilization). The valid + * range is [10, 90] inclusive. + * + * Generated from protobuf field int32 high_priority_cpu_utilization_percent = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return int + */ + public function getHighPriorityCpuUtilizationPercent() + { + return $this->high_priority_cpu_utilization_percent; + } + + /** + * Required. The target high priority cpu utilization percentage that the + * autoscaler should be trying to achieve for the instance. This number is + * on a scale from 0 (no utilization) to 100 (full utilization). The valid + * range is [10, 90] inclusive. + * + * Generated from protobuf field int32 high_priority_cpu_utilization_percent = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param int $var + * @return $this + */ + public function setHighPriorityCpuUtilizationPercent($var) + { + GPBUtil::checkInt32($var); + $this->high_priority_cpu_utilization_percent = $var; + + return $this; + } + + /** + * Required. The target storage utilization percentage that the autoscaler + * should be trying to achieve for the instance. This number is on a scale + * from 0 (no utilization) to 100 (full utilization). The valid range is + * [10, 99] inclusive. + * + * Generated from protobuf field int32 storage_utilization_percent = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return int + */ + public function getStorageUtilizationPercent() + { + return $this->storage_utilization_percent; + } + + /** + * Required. The target storage utilization percentage that the autoscaler + * should be trying to achieve for the instance. This number is on a scale + * from 0 (no utilization) to 100 (full utilization). The valid range is + * [10, 99] inclusive. + * + * Generated from protobuf field int32 storage_utilization_percent = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param int $var + * @return $this + */ + public function setStorageUtilizationPercent($var) + { + GPBUtil::checkInt32($var); + $this->storage_utilization_percent = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(AutoscalingTargets::class, \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig_AutoscalingTargets::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstanceConfigMetadata.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstanceConfigMetadata.php new file mode 100644 index 000000000000..ef9454d09d96 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstanceConfigMetadata.php @@ -0,0 +1,174 @@ +google.spanner.admin.instance.v1.CreateInstanceConfigMetadata + */ +class CreateInstanceConfigMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * The target instance configuration end state. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig instance_config = 1; + */ + protected $instance_config = null; + /** + * The progress of the + * [CreateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstanceConfig] + * operation. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.OperationProgress progress = 2; + */ + protected $progress = null; + /** + * The time at which this operation was cancelled. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + */ + protected $cancel_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig $instance_config + * The target instance configuration end state. + * @type \Google\Cloud\Spanner\Admin\Instance\V1\OperationProgress $progress + * The progress of the + * [CreateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstanceConfig] + * operation. + * @type \Google\Protobuf\Timestamp $cancel_time + * The time at which this operation was cancelled. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The target instance configuration end state. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig instance_config = 1; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig|null + */ + public function getInstanceConfig() + { + return $this->instance_config; + } + + public function hasInstanceConfig() + { + return isset($this->instance_config); + } + + public function clearInstanceConfig() + { + unset($this->instance_config); + } + + /** + * The target instance configuration end state. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig instance_config = 1; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig $var + * @return $this + */ + public function setInstanceConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig::class); + $this->instance_config = $var; + + return $this; + } + + /** + * The progress of the + * [CreateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstanceConfig] + * operation. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.OperationProgress progress = 2; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\OperationProgress|null + */ + public function getProgress() + { + return $this->progress; + } + + public function hasProgress() + { + return isset($this->progress); + } + + public function clearProgress() + { + unset($this->progress); + } + + /** + * The progress of the + * [CreateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstanceConfig] + * operation. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.OperationProgress progress = 2; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\OperationProgress $var + * @return $this + */ + public function setProgress($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\OperationProgress::class); + $this->progress = $var; + + return $this; + } + + /** + * The time at which this operation was cancelled. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCancelTime() + { + return $this->cancel_time; + } + + public function hasCancelTime() + { + return isset($this->cancel_time); + } + + public function clearCancelTime() + { + unset($this->cancel_time); + } + + /** + * The time at which this operation was cancelled. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCancelTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->cancel_time = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstanceConfigRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstanceConfigRequest.php new file mode 100644 index 000000000000..c714bc17563b --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstanceConfigRequest.php @@ -0,0 +1,242 @@ +google.spanner.admin.instance.v1.CreateInstanceConfigRequest + */ +class CreateInstanceConfigRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the project in which to create the instance + * configuration. Values are of the form `projects/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. The ID of the instance configuration to create. Valid identifiers + * are of the form `custom-[-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + * characters in length. The `custom-` prefix is required to avoid name + * conflicts with Google-managed configurations. + * + * Generated from protobuf field string instance_config_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $instance_config_id = ''; + /** + * Required. The `InstanceConfig` proto of the configuration to create. + * `instance_config.name` must be + * `/instanceConfigs/`. + * `instance_config.base_config` must be a Google-managed configuration name, + * e.g. /instanceConfigs/us-east1, /instanceConfigs/nam3. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig instance_config = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $instance_config = null; + /** + * An option to validate, but not actually execute, a request, + * and provide the same response. + * + * Generated from protobuf field bool validate_only = 4; + */ + protected $validate_only = false; + + /** + * @param string $parent Required. The name of the project in which to create the instance + * configuration. Values are of the form `projects/`. Please see + * {@see InstanceAdminClient::projectName()} for help formatting this field. + * @param \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig $instanceConfig Required. The `InstanceConfig` proto of the configuration to create. + * `instance_config.name` must be + * `/instanceConfigs/`. + * `instance_config.base_config` must be a Google-managed configuration name, + * e.g. /instanceConfigs/us-east1, /instanceConfigs/nam3. + * @param string $instanceConfigId Required. The ID of the instance configuration to create. Valid identifiers + * are of the form `custom-[-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + * characters in length. The `custom-` prefix is required to avoid name + * conflicts with Google-managed configurations. + * + * @return \Google\Cloud\Spanner\Admin\Instance\V1\CreateInstanceConfigRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig $instanceConfig, string $instanceConfigId): self + { + return (new self()) + ->setParent($parent) + ->setInstanceConfig($instanceConfig) + ->setInstanceConfigId($instanceConfigId); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The name of the project in which to create the instance + * configuration. Values are of the form `projects/`. + * @type string $instance_config_id + * Required. The ID of the instance configuration to create. Valid identifiers + * are of the form `custom-[-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + * characters in length. The `custom-` prefix is required to avoid name + * conflicts with Google-managed configurations. + * @type \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig $instance_config + * Required. The `InstanceConfig` proto of the configuration to create. + * `instance_config.name` must be + * `/instanceConfigs/`. + * `instance_config.base_config` must be a Google-managed configuration name, + * e.g. /instanceConfigs/us-east1, /instanceConfigs/nam3. + * @type bool $validate_only + * An option to validate, but not actually execute, a request, + * and provide the same response. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the project in which to create the instance + * configuration. Values are of the form `projects/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The name of the project in which to create the instance + * configuration. Values are of the form `projects/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Required. The ID of the instance configuration to create. Valid identifiers + * are of the form `custom-[-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + * characters in length. The `custom-` prefix is required to avoid name + * conflicts with Google-managed configurations. + * + * Generated from protobuf field string instance_config_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getInstanceConfigId() + { + return $this->instance_config_id; + } + + /** + * Required. The ID of the instance configuration to create. Valid identifiers + * are of the form `custom-[-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + * characters in length. The `custom-` prefix is required to avoid name + * conflicts with Google-managed configurations. + * + * Generated from protobuf field string instance_config_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setInstanceConfigId($var) + { + GPBUtil::checkString($var, True); + $this->instance_config_id = $var; + + return $this; + } + + /** + * Required. The `InstanceConfig` proto of the configuration to create. + * `instance_config.name` must be + * `/instanceConfigs/`. + * `instance_config.base_config` must be a Google-managed configuration name, + * e.g. /instanceConfigs/us-east1, /instanceConfigs/nam3. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig instance_config = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig|null + */ + public function getInstanceConfig() + { + return $this->instance_config; + } + + public function hasInstanceConfig() + { + return isset($this->instance_config); + } + + public function clearInstanceConfig() + { + unset($this->instance_config); + } + + /** + * Required. The `InstanceConfig` proto of the configuration to create. + * `instance_config.name` must be + * `/instanceConfigs/`. + * `instance_config.base_config` must be a Google-managed configuration name, + * e.g. /instanceConfigs/us-east1, /instanceConfigs/nam3. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig instance_config = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig $var + * @return $this + */ + public function setInstanceConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig::class); + $this->instance_config = $var; + + return $this; + } + + /** + * An option to validate, but not actually execute, a request, + * and provide the same response. + * + * Generated from protobuf field bool validate_only = 4; + * @return bool + */ + public function getValidateOnly() + { + return $this->validate_only; + } + + /** + * An option to validate, but not actually execute, a request, + * and provide the same response. + * + * Generated from protobuf field bool validate_only = 4; + * @param bool $var + * @return $this + */ + public function setValidateOnly($var) + { + GPBUtil::checkBool($var); + $this->validate_only = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstanceMetadata.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstanceMetadata.php new file mode 100644 index 000000000000..0b08f1253a6f --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstanceMetadata.php @@ -0,0 +1,260 @@ +google.spanner.admin.instance.v1.CreateInstanceMetadata + */ +class CreateInstanceMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * The instance being created. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance instance = 1; + */ + protected $instance = null; + /** + * The time at which the + * [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance] + * request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + */ + protected $start_time = null; + /** + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is guaranteed to succeed) and + * cannot be cancelled again. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + */ + protected $cancel_time = null; + /** + * The time at which this operation failed or was completed successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 4; + */ + protected $end_time = null; + /** + * The expected fulfillment period of this create operation. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.FulfillmentPeriod expected_fulfillment_period = 5; + */ + protected $expected_fulfillment_period = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Instance\V1\Instance $instance + * The instance being created. + * @type \Google\Protobuf\Timestamp $start_time + * The time at which the + * [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance] + * request was received. + * @type \Google\Protobuf\Timestamp $cancel_time + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is guaranteed to succeed) and + * cannot be cancelled again. + * @type \Google\Protobuf\Timestamp $end_time + * The time at which this operation failed or was completed successfully. + * @type int $expected_fulfillment_period + * The expected fulfillment period of this create operation. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The instance being created. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance instance = 1; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\Instance|null + */ + public function getInstance() + { + return $this->instance; + } + + public function hasInstance() + { + return isset($this->instance); + } + + public function clearInstance() + { + unset($this->instance); + } + + /** + * The instance being created. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance instance = 1; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\Instance $var + * @return $this + */ + public function setInstance($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\Instance::class); + $this->instance = $var; + + return $this; + } + + /** + * The time at which the + * [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance] + * request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + * @return \Google\Protobuf\Timestamp|null + */ + public function getStartTime() + { + return $this->start_time; + } + + public function hasStartTime() + { + return isset($this->start_time); + } + + public function clearStartTime() + { + unset($this->start_time); + } + + /** + * The time at which the + * [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance] + * request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setStartTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->start_time = $var; + + return $this; + } + + /** + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is guaranteed to succeed) and + * cannot be cancelled again. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCancelTime() + { + return $this->cancel_time; + } + + public function hasCancelTime() + { + return isset($this->cancel_time); + } + + public function clearCancelTime() + { + unset($this->cancel_time); + } + + /** + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is guaranteed to succeed) and + * cannot be cancelled again. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCancelTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->cancel_time = $var; + + return $this; + } + + /** + * The time at which this operation failed or was completed successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 4; + * @return \Google\Protobuf\Timestamp|null + */ + public function getEndTime() + { + return $this->end_time; + } + + public function hasEndTime() + { + return isset($this->end_time); + } + + public function clearEndTime() + { + unset($this->end_time); + } + + /** + * The time at which this operation failed or was completed successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 4; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setEndTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->end_time = $var; + + return $this; + } + + /** + * The expected fulfillment period of this create operation. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.FulfillmentPeriod expected_fulfillment_period = 5; + * @return int + */ + public function getExpectedFulfillmentPeriod() + { + return $this->expected_fulfillment_period; + } + + /** + * The expected fulfillment period of this create operation. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.FulfillmentPeriod expected_fulfillment_period = 5; + * @param int $var + * @return $this + */ + public function setExpectedFulfillmentPeriod($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Instance\V1\FulfillmentPeriod::class); + $this->expected_fulfillment_period = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstancePartitionMetadata.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstancePartitionMetadata.php new file mode 100644 index 000000000000..3494bbcea33a --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstancePartitionMetadata.php @@ -0,0 +1,226 @@ +google.spanner.admin.instance.v1.CreateInstancePartitionMetadata + */ +class CreateInstancePartitionMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * The instance partition being created. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstancePartition instance_partition = 1; + */ + protected $instance_partition = null; + /** + * The time at which the + * [CreateInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstancePartition] + * request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + */ + protected $start_time = null; + /** + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is guaranteed to succeed) and + * cannot be cancelled again. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + */ + protected $cancel_time = null; + /** + * The time at which this operation failed or was completed successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 4; + */ + protected $end_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition $instance_partition + * The instance partition being created. + * @type \Google\Protobuf\Timestamp $start_time + * The time at which the + * [CreateInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstancePartition] + * request was received. + * @type \Google\Protobuf\Timestamp $cancel_time + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is guaranteed to succeed) and + * cannot be cancelled again. + * @type \Google\Protobuf\Timestamp $end_time + * The time at which this operation failed or was completed successfully. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The instance partition being created. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstancePartition instance_partition = 1; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition|null + */ + public function getInstancePartition() + { + return $this->instance_partition; + } + + public function hasInstancePartition() + { + return isset($this->instance_partition); + } + + public function clearInstancePartition() + { + unset($this->instance_partition); + } + + /** + * The instance partition being created. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstancePartition instance_partition = 1; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition $var + * @return $this + */ + public function setInstancePartition($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition::class); + $this->instance_partition = $var; + + return $this; + } + + /** + * The time at which the + * [CreateInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstancePartition] + * request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + * @return \Google\Protobuf\Timestamp|null + */ + public function getStartTime() + { + return $this->start_time; + } + + public function hasStartTime() + { + return isset($this->start_time); + } + + public function clearStartTime() + { + unset($this->start_time); + } + + /** + * The time at which the + * [CreateInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstancePartition] + * request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setStartTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->start_time = $var; + + return $this; + } + + /** + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is guaranteed to succeed) and + * cannot be cancelled again. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCancelTime() + { + return $this->cancel_time; + } + + public function hasCancelTime() + { + return isset($this->cancel_time); + } + + public function clearCancelTime() + { + unset($this->cancel_time); + } + + /** + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is guaranteed to succeed) and + * cannot be cancelled again. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCancelTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->cancel_time = $var; + + return $this; + } + + /** + * The time at which this operation failed or was completed successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 4; + * @return \Google\Protobuf\Timestamp|null + */ + public function getEndTime() + { + return $this->end_time; + } + + public function hasEndTime() + { + return isset($this->end_time); + } + + public function clearEndTime() + { + unset($this->end_time); + } + + /** + * The time at which this operation failed or was completed successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 4; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setEndTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->end_time = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstancePartitionRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstancePartitionRequest.php new file mode 100644 index 000000000000..d12f2223ea98 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstancePartitionRequest.php @@ -0,0 +1,194 @@ +google.spanner.admin.instance.v1.CreateInstancePartitionRequest + */ +class CreateInstancePartitionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the instance in which to create the instance + * partition. Values are of the form + * `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. The ID of the instance partition to create. Valid identifiers are + * of the form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + * characters in length. + * + * Generated from protobuf field string instance_partition_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $instance_partition_id = ''; + /** + * Required. The instance partition to create. The instance_partition.name may + * be omitted, but if specified must be + * `/instancePartitions/`. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstancePartition instance_partition = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $instance_partition = null; + + /** + * @param string $parent Required. The name of the instance in which to create the instance + * partition. Values are of the form + * `projects//instances/`. Please see + * {@see InstanceAdminClient::instanceName()} for help formatting this field. + * @param \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition $instancePartition Required. The instance partition to create. The instance_partition.name may + * be omitted, but if specified must be + * `/instancePartitions/`. + * @param string $instancePartitionId Required. The ID of the instance partition to create. Valid identifiers are + * of the form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + * characters in length. + * + * @return \Google\Cloud\Spanner\Admin\Instance\V1\CreateInstancePartitionRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition $instancePartition, string $instancePartitionId): self + { + return (new self()) + ->setParent($parent) + ->setInstancePartition($instancePartition) + ->setInstancePartitionId($instancePartitionId); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The name of the instance in which to create the instance + * partition. Values are of the form + * `projects//instances/`. + * @type string $instance_partition_id + * Required. The ID of the instance partition to create. Valid identifiers are + * of the form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + * characters in length. + * @type \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition $instance_partition + * Required. The instance partition to create. The instance_partition.name may + * be omitted, but if specified must be + * `/instancePartitions/`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the instance in which to create the instance + * partition. Values are of the form + * `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The name of the instance in which to create the instance + * partition. Values are of the form + * `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Required. The ID of the instance partition to create. Valid identifiers are + * of the form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + * characters in length. + * + * Generated from protobuf field string instance_partition_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getInstancePartitionId() + { + return $this->instance_partition_id; + } + + /** + * Required. The ID of the instance partition to create. Valid identifiers are + * of the form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + * characters in length. + * + * Generated from protobuf field string instance_partition_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setInstancePartitionId($var) + { + GPBUtil::checkString($var, True); + $this->instance_partition_id = $var; + + return $this; + } + + /** + * Required. The instance partition to create. The instance_partition.name may + * be omitted, but if specified must be + * `/instancePartitions/`. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstancePartition instance_partition = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition|null + */ + public function getInstancePartition() + { + return $this->instance_partition; + } + + public function hasInstancePartition() + { + return isset($this->instance_partition); + } + + public function clearInstancePartition() + { + unset($this->instance_partition); + } + + /** + * Required. The instance partition to create. The instance_partition.name may + * be omitted, but if specified must be + * `/instancePartitions/`. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstancePartition instance_partition = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition $var + * @return $this + */ + public function setInstancePartition($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition::class); + $this->instance_partition = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstanceRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstanceRequest.php new file mode 100644 index 000000000000..1954b4933248 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/CreateInstanceRequest.php @@ -0,0 +1,184 @@ +google.spanner.admin.instance.v1.CreateInstanceRequest + */ +class CreateInstanceRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the project in which to create the instance. Values + * are of the form `projects/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. The ID of the instance to create. Valid identifiers are of the + * form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 characters in + * length. + * + * Generated from protobuf field string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $instance_id = ''; + /** + * Required. The instance to create. The name may be omitted, but if + * specified must be `/instances/`. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance instance = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $instance = null; + + /** + * @param string $parent Required. The name of the project in which to create the instance. Values + * are of the form `projects/`. Please see + * {@see InstanceAdminClient::projectName()} for help formatting this field. + * @param string $instanceId Required. The ID of the instance to create. Valid identifiers are of the + * form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 characters in + * length. + * @param \Google\Cloud\Spanner\Admin\Instance\V1\Instance $instance Required. The instance to create. The name may be omitted, but if + * specified must be `/instances/`. + * + * @return \Google\Cloud\Spanner\Admin\Instance\V1\CreateInstanceRequest + * + * @experimental + */ + public static function build(string $parent, string $instanceId, \Google\Cloud\Spanner\Admin\Instance\V1\Instance $instance): self + { + return (new self()) + ->setParent($parent) + ->setInstanceId($instanceId) + ->setInstance($instance); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The name of the project in which to create the instance. Values + * are of the form `projects/`. + * @type string $instance_id + * Required. The ID of the instance to create. Valid identifiers are of the + * form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 characters in + * length. + * @type \Google\Cloud\Spanner\Admin\Instance\V1\Instance $instance + * Required. The instance to create. The name may be omitted, but if + * specified must be `/instances/`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the project in which to create the instance. Values + * are of the form `projects/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The name of the project in which to create the instance. Values + * are of the form `projects/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Required. The ID of the instance to create. Valid identifiers are of the + * form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 characters in + * length. + * + * Generated from protobuf field string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getInstanceId() + { + return $this->instance_id; + } + + /** + * Required. The ID of the instance to create. Valid identifiers are of the + * form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 characters in + * length. + * + * Generated from protobuf field string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setInstanceId($var) + { + GPBUtil::checkString($var, True); + $this->instance_id = $var; + + return $this; + } + + /** + * Required. The instance to create. The name may be omitted, but if + * specified must be `/instances/`. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance instance = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\Instance|null + */ + public function getInstance() + { + return $this->instance; + } + + public function hasInstance() + { + return isset($this->instance); + } + + public function clearInstance() + { + unset($this->instance); + } + + /** + * Required. The instance to create. The name may be omitted, but if + * specified must be `/instances/`. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance instance = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\Instance $var + * @return $this + */ + public function setInstance($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\Instance::class); + $this->instance = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/DeleteInstanceConfigRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/DeleteInstanceConfigRequest.php new file mode 100644 index 000000000000..8b9edba36c3f --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/DeleteInstanceConfigRequest.php @@ -0,0 +1,188 @@ +google.spanner.admin.instance.v1.DeleteInstanceConfigRequest + */ +class DeleteInstanceConfigRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the instance configuration to be deleted. + * Values are of the form + * `projects//instanceConfigs/` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + /** + * Used for optimistic concurrency control as a way to help prevent + * simultaneous deletes of an instance configuration from overwriting each + * other. If not empty, the API + * only deletes the instance configuration when the etag provided matches the + * current status of the requested instance configuration. Otherwise, deletes + * the instance configuration without checking the current status of the + * requested instance configuration. + * + * Generated from protobuf field string etag = 2; + */ + protected $etag = ''; + /** + * An option to validate, but not actually execute, a request, + * and provide the same response. + * + * Generated from protobuf field bool validate_only = 3; + */ + protected $validate_only = false; + + /** + * @param string $name Required. The name of the instance configuration to be deleted. + * Values are of the form + * `projects//instanceConfigs/` + * Please see {@see InstanceAdminClient::instanceConfigName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Instance\V1\DeleteInstanceConfigRequest + * + * @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. The name of the instance configuration to be deleted. + * Values are of the form + * `projects//instanceConfigs/` + * @type string $etag + * Used for optimistic concurrency control as a way to help prevent + * simultaneous deletes of an instance configuration from overwriting each + * other. If not empty, the API + * only deletes the instance configuration when the etag provided matches the + * current status of the requested instance configuration. Otherwise, deletes + * the instance configuration without checking the current status of the + * requested instance configuration. + * @type bool $validate_only + * An option to validate, but not actually execute, a request, + * and provide the same response. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the instance configuration to be deleted. + * Values are of the form + * `projects//instanceConfigs/` + * + * 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. The name of the instance configuration to be deleted. + * Values are of the form + * `projects//instanceConfigs/` + * + * 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; + } + + /** + * Used for optimistic concurrency control as a way to help prevent + * simultaneous deletes of an instance configuration from overwriting each + * other. If not empty, the API + * only deletes the instance configuration when the etag provided matches the + * current status of the requested instance configuration. Otherwise, deletes + * the instance configuration without checking the current status of the + * requested instance configuration. + * + * Generated from protobuf field string etag = 2; + * @return string + */ + public function getEtag() + { + return $this->etag; + } + + /** + * Used for optimistic concurrency control as a way to help prevent + * simultaneous deletes of an instance configuration from overwriting each + * other. If not empty, the API + * only deletes the instance configuration when the etag provided matches the + * current status of the requested instance configuration. Otherwise, deletes + * the instance configuration without checking the current status of the + * requested instance configuration. + * + * Generated from protobuf field string etag = 2; + * @param string $var + * @return $this + */ + public function setEtag($var) + { + GPBUtil::checkString($var, True); + $this->etag = $var; + + return $this; + } + + /** + * An option to validate, but not actually execute, a request, + * and provide the same response. + * + * Generated from protobuf field bool validate_only = 3; + * @return bool + */ + public function getValidateOnly() + { + return $this->validate_only; + } + + /** + * An option to validate, but not actually execute, a request, + * and provide the same response. + * + * Generated from protobuf field bool validate_only = 3; + * @param bool $var + * @return $this + */ + public function setValidateOnly($var) + { + GPBUtil::checkBool($var); + $this->validate_only = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/DeleteInstancePartitionRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/DeleteInstancePartitionRequest.php new file mode 100644 index 000000000000..430f00f61956 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/DeleteInstancePartitionRequest.php @@ -0,0 +1,138 @@ +google.spanner.admin.instance.v1.DeleteInstancePartitionRequest + */ +class DeleteInstancePartitionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the instance partition to be deleted. + * Values are of the form + * `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + /** + * Optional. If not empty, the API only deletes the instance partition when + * the etag provided matches the current status of the requested instance + * partition. Otherwise, deletes the instance partition without checking the + * current status of the requested instance partition. + * + * Generated from protobuf field string etag = 2; + */ + protected $etag = ''; + + /** + * @param string $name Required. The name of the instance partition to be deleted. + * Values are of the form + * `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}` + * Please see {@see InstanceAdminClient::instancePartitionName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Instance\V1\DeleteInstancePartitionRequest + * + * @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. The name of the instance partition to be deleted. + * Values are of the form + * `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}` + * @type string $etag + * Optional. If not empty, the API only deletes the instance partition when + * the etag provided matches the current status of the requested instance + * partition. Otherwise, deletes the instance partition without checking the + * current status of the requested instance partition. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the instance partition to be deleted. + * Values are of the form + * `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}` + * + * 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. The name of the instance partition to be deleted. + * Values are of the form + * `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}` + * + * 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; + } + + /** + * Optional. If not empty, the API only deletes the instance partition when + * the etag provided matches the current status of the requested instance + * partition. Otherwise, deletes the instance partition without checking the + * current status of the requested instance partition. + * + * Generated from protobuf field string etag = 2; + * @return string + */ + public function getEtag() + { + return $this->etag; + } + + /** + * Optional. If not empty, the API only deletes the instance partition when + * the etag provided matches the current status of the requested instance + * partition. Otherwise, deletes the instance partition without checking the + * current status of the requested instance partition. + * + * Generated from protobuf field string etag = 2; + * @param string $var + * @return $this + */ + public function setEtag($var) + { + GPBUtil::checkString($var, True); + $this->etag = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/DeleteInstanceRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/DeleteInstanceRequest.php new file mode 100644 index 000000000000..f8633ecef64d --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/DeleteInstanceRequest.php @@ -0,0 +1,87 @@ +google.spanner.admin.instance.v1.DeleteInstanceRequest + */ +class DeleteInstanceRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the instance to be deleted. Values are of the form + * `projects//instances/` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. The name of the instance to be deleted. Values are of the form + * `projects//instances/` + * Please see {@see InstanceAdminClient::instanceName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Instance\V1\DeleteInstanceRequest + * + * @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. The name of the instance to be deleted. Values are of the form + * `projects//instances/` + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the instance to be deleted. Values are of the form + * `projects//instances/` + * + * 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. The name of the instance to be deleted. Values are of the form + * `projects//instances/` + * + * 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/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/FreeInstanceMetadata.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/FreeInstanceMetadata.php new file mode 100644 index 000000000000..49b3e7084a27 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/FreeInstanceMetadata.php @@ -0,0 +1,180 @@ +google.spanner.admin.instance.v1.FreeInstanceMetadata + */ +class FreeInstanceMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. Timestamp after which the instance will either be upgraded or + * scheduled for deletion after a grace period. ExpireBehavior is used to + * choose between upgrading or scheduling the free instance for deletion. This + * timestamp is set during the creation of a free instance. + * + * Generated from protobuf field .google.protobuf.Timestamp expire_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $expire_time = null; + /** + * Output only. If present, the timestamp at which the free instance was + * upgraded to a provisioned instance. + * + * Generated from protobuf field .google.protobuf.Timestamp upgrade_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $upgrade_time = null; + /** + * Specifies the expiration behavior of a free instance. The default of + * ExpireBehavior is `REMOVE_AFTER_GRACE_PERIOD`. This can be modified during + * or after creation, and before expiration. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.FreeInstanceMetadata.ExpireBehavior expire_behavior = 3; + */ + protected $expire_behavior = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\Timestamp $expire_time + * Output only. Timestamp after which the instance will either be upgraded or + * scheduled for deletion after a grace period. ExpireBehavior is used to + * choose between upgrading or scheduling the free instance for deletion. This + * timestamp is set during the creation of a free instance. + * @type \Google\Protobuf\Timestamp $upgrade_time + * Output only. If present, the timestamp at which the free instance was + * upgraded to a provisioned instance. + * @type int $expire_behavior + * Specifies the expiration behavior of a free instance. The default of + * ExpireBehavior is `REMOVE_AFTER_GRACE_PERIOD`. This can be modified during + * or after creation, and before expiration. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Output only. Timestamp after which the instance will either be upgraded or + * scheduled for deletion after a grace period. ExpireBehavior is used to + * choose between upgrading or scheduling the free instance for deletion. This + * timestamp is set during the creation of a free instance. + * + * Generated from protobuf field .google.protobuf.Timestamp expire_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getExpireTime() + { + return $this->expire_time; + } + + public function hasExpireTime() + { + return isset($this->expire_time); + } + + public function clearExpireTime() + { + unset($this->expire_time); + } + + /** + * Output only. Timestamp after which the instance will either be upgraded or + * scheduled for deletion after a grace period. ExpireBehavior is used to + * choose between upgrading or scheduling the free instance for deletion. This + * timestamp is set during the creation of a free instance. + * + * Generated from protobuf field .google.protobuf.Timestamp expire_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setExpireTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->expire_time = $var; + + return $this; + } + + /** + * Output only. If present, the timestamp at which the free instance was + * upgraded to a provisioned instance. + * + * Generated from protobuf field .google.protobuf.Timestamp upgrade_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getUpgradeTime() + { + return $this->upgrade_time; + } + + public function hasUpgradeTime() + { + return isset($this->upgrade_time); + } + + public function clearUpgradeTime() + { + unset($this->upgrade_time); + } + + /** + * Output only. If present, the timestamp at which the free instance was + * upgraded to a provisioned instance. + * + * Generated from protobuf field .google.protobuf.Timestamp upgrade_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpgradeTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->upgrade_time = $var; + + return $this; + } + + /** + * Specifies the expiration behavior of a free instance. The default of + * ExpireBehavior is `REMOVE_AFTER_GRACE_PERIOD`. This can be modified during + * or after creation, and before expiration. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.FreeInstanceMetadata.ExpireBehavior expire_behavior = 3; + * @return int + */ + public function getExpireBehavior() + { + return $this->expire_behavior; + } + + /** + * Specifies the expiration behavior of a free instance. The default of + * ExpireBehavior is `REMOVE_AFTER_GRACE_PERIOD`. This can be modified during + * or after creation, and before expiration. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.FreeInstanceMetadata.ExpireBehavior expire_behavior = 3; + * @param int $var + * @return $this + */ + public function setExpireBehavior($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Instance\V1\FreeInstanceMetadata\ExpireBehavior::class); + $this->expire_behavior = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/FreeInstanceMetadata/ExpireBehavior.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/FreeInstanceMetadata/ExpireBehavior.php new file mode 100644 index 000000000000..84f5ec48409f --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/FreeInstanceMetadata/ExpireBehavior.php @@ -0,0 +1,66 @@ +google.spanner.admin.instance.v1.FreeInstanceMetadata.ExpireBehavior + */ +class ExpireBehavior +{ + /** + * Not specified. + * + * Generated from protobuf enum EXPIRE_BEHAVIOR_UNSPECIFIED = 0; + */ + const EXPIRE_BEHAVIOR_UNSPECIFIED = 0; + /** + * When the free instance expires, upgrade the instance to a provisioned + * instance. + * + * Generated from protobuf enum FREE_TO_PROVISIONED = 1; + */ + const FREE_TO_PROVISIONED = 1; + /** + * When the free instance expires, disable the instance, and delete it + * after the grace period passes if it has not been upgraded. + * + * Generated from protobuf enum REMOVE_AFTER_GRACE_PERIOD = 2; + */ + const REMOVE_AFTER_GRACE_PERIOD = 2; + + private static $valueToName = [ + self::EXPIRE_BEHAVIOR_UNSPECIFIED => 'EXPIRE_BEHAVIOR_UNSPECIFIED', + self::FREE_TO_PROVISIONED => 'FREE_TO_PROVISIONED', + self::REMOVE_AFTER_GRACE_PERIOD => 'REMOVE_AFTER_GRACE_PERIOD', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(ExpireBehavior::class, \Google\Cloud\Spanner\Admin\Instance\V1\FreeInstanceMetadata_ExpireBehavior::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/FulfillmentPeriod.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/FulfillmentPeriod.php new file mode 100644 index 000000000000..3fa91d6d998b --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/FulfillmentPeriod.php @@ -0,0 +1,63 @@ +google.spanner.admin.instance.v1.FulfillmentPeriod + */ +class FulfillmentPeriod +{ + /** + * Not specified. + * + * Generated from protobuf enum FULFILLMENT_PERIOD_UNSPECIFIED = 0; + */ + const FULFILLMENT_PERIOD_UNSPECIFIED = 0; + /** + * Normal fulfillment period. The operation is expected to complete within + * minutes. + * + * Generated from protobuf enum FULFILLMENT_PERIOD_NORMAL = 1; + */ + const FULFILLMENT_PERIOD_NORMAL = 1; + /** + * Extended fulfillment period. It can take up to an hour for the operation + * to complete. + * + * Generated from protobuf enum FULFILLMENT_PERIOD_EXTENDED = 2; + */ + const FULFILLMENT_PERIOD_EXTENDED = 2; + + private static $valueToName = [ + self::FULFILLMENT_PERIOD_UNSPECIFIED => 'FULFILLMENT_PERIOD_UNSPECIFIED', + self::FULFILLMENT_PERIOD_NORMAL => 'FULFILLMENT_PERIOD_NORMAL', + self::FULFILLMENT_PERIOD_EXTENDED => 'FULFILLMENT_PERIOD_EXTENDED', + ]; + + 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/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/GetInstanceConfigRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/GetInstanceConfigRequest.php new file mode 100644 index 000000000000..c0d299ac0b80 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/GetInstanceConfigRequest.php @@ -0,0 +1,87 @@ +google.spanner.admin.instance.v1.GetInstanceConfigRequest + */ +class GetInstanceConfigRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the requested instance configuration. Values are of + * the form `projects//instanceConfigs/`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. The name of the requested instance configuration. Values are of + * the form `projects//instanceConfigs/`. Please see + * {@see InstanceAdminClient::instanceConfigName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Instance\V1\GetInstanceConfigRequest + * + * @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. The name of the requested instance configuration. Values are of + * the form `projects//instanceConfigs/`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the requested instance configuration. Values are of + * the form `projects//instanceConfigs/`. + * + * 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. The name of the requested instance configuration. Values are of + * the form `projects//instanceConfigs/`. + * + * 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/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/GetInstancePartitionRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/GetInstancePartitionRequest.php new file mode 100644 index 000000000000..e703503feb23 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/GetInstancePartitionRequest.php @@ -0,0 +1,92 @@ +google.spanner.admin.instance.v1.GetInstancePartitionRequest + */ +class GetInstancePartitionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the requested instance partition. Values are of + * the form + * `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. The name of the requested instance partition. Values are of + * the form + * `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}`. Please see + * {@see InstanceAdminClient::instancePartitionName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Instance\V1\GetInstancePartitionRequest + * + * @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. The name of the requested instance partition. Values are of + * the form + * `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the requested instance partition. Values are of + * the form + * `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}`. + * + * 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. The name of the requested instance partition. Values are of + * the form + * `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}`. + * + * 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/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/GetInstanceRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/GetInstanceRequest.php new file mode 100644 index 000000000000..6f054759ba44 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/GetInstanceRequest.php @@ -0,0 +1,143 @@ +google.spanner.admin.instance.v1.GetInstanceRequest + */ +class GetInstanceRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the requested instance. Values are of the form + * `projects//instances/`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + /** + * If field_mask is present, specifies the subset of + * [Instance][google.spanner.admin.instance.v1.Instance] fields that should be + * returned. If absent, all + * [Instance][google.spanner.admin.instance.v1.Instance] fields are returned. + * + * Generated from protobuf field .google.protobuf.FieldMask field_mask = 2; + */ + protected $field_mask = null; + + /** + * @param string $name Required. The name of the requested instance. Values are of the form + * `projects//instances/`. Please see + * {@see InstanceAdminClient::instanceName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Instance\V1\GetInstanceRequest + * + * @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. The name of the requested instance. Values are of the form + * `projects//instances/`. + * @type \Google\Protobuf\FieldMask $field_mask + * If field_mask is present, specifies the subset of + * [Instance][google.spanner.admin.instance.v1.Instance] fields that should be + * returned. If absent, all + * [Instance][google.spanner.admin.instance.v1.Instance] fields are returned. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the requested instance. Values are of the form + * `projects//instances/`. + * + * 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. The name of the requested instance. Values are of the form + * `projects//instances/`. + * + * 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; + } + + /** + * If field_mask is present, specifies the subset of + * [Instance][google.spanner.admin.instance.v1.Instance] fields that should be + * returned. If absent, all + * [Instance][google.spanner.admin.instance.v1.Instance] fields are returned. + * + * Generated from protobuf field .google.protobuf.FieldMask field_mask = 2; + * @return \Google\Protobuf\FieldMask|null + */ + public function getFieldMask() + { + return $this->field_mask; + } + + public function hasFieldMask() + { + return isset($this->field_mask); + } + + public function clearFieldMask() + { + unset($this->field_mask); + } + + /** + * If field_mask is present, specifies the subset of + * [Instance][google.spanner.admin.instance.v1.Instance] fields that should be + * returned. If absent, all + * [Instance][google.spanner.admin.instance.v1.Instance] fields are returned. + * + * Generated from protobuf field .google.protobuf.FieldMask field_mask = 2; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setFieldMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->field_mask = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/Instance.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/Instance.php new file mode 100644 index 000000000000..1bfe83d9e4fb --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/Instance.php @@ -0,0 +1,861 @@ +google.spanner.admin.instance.v1.Instance + */ +class Instance extends \Google\Protobuf\Internal\Message +{ + /** + * Required. A unique identifier for the instance, which cannot be changed + * after the instance is created. Values are of the form + * `projects//instances/[a-z][-a-z0-9]*[a-z0-9]`. The final + * segment of the name must be between 2 and 64 characters in length. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $name = ''; + /** + * Required. The name of the instance's configuration. Values are of the form + * `projects//instanceConfigs/`. See + * also [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] and + * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. + * + * Generated from protobuf field string config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $config = ''; + /** + * Required. The descriptive name for this instance as it appears in UIs. + * Must be unique per project and between 4 and 30 characters in length. + * + * Generated from protobuf field string display_name = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $display_name = ''; + /** + * The number of nodes allocated to this instance. At most, one of either + * `node_count` or `processing_units` should be present in the message. + * Users can set the `node_count` field to specify the target number of nodes + * allocated to the instance. + * If autoscaling is enabled, `node_count` is treated as an `OUTPUT_ONLY` + * field and reflects the current number of nodes allocated to the instance. + * This might be zero in API responses for instances that are not yet in the + * `READY` state. + * For more information, see + * [Compute capacity, nodes, and processing + * units](https://cloud.google.com/spanner/docs/compute-capacity). + * + * Generated from protobuf field int32 node_count = 5; + */ + protected $node_count = 0; + /** + * The number of processing units allocated to this instance. At most, one of + * either `processing_units` or `node_count` should be present in the message. + * Users can set the `processing_units` field to specify the target number of + * processing units allocated to the instance. + * If autoscaling is enabled, `processing_units` is treated as an + * `OUTPUT_ONLY` field and reflects the current number of processing units + * allocated to the instance. + * This might be zero in API responses for instances that are not yet in the + * `READY` state. + * For more information, see + * [Compute capacity, nodes and processing + * units](https://cloud.google.com/spanner/docs/compute-capacity). + * + * Generated from protobuf field int32 processing_units = 9; + */ + protected $processing_units = 0; + /** + * Output only. Lists the compute capacity per ReplicaSelection. A replica + * selection identifies a set of replicas with common properties. Replicas + * identified by a ReplicaSelection are scaled with the same compute capacity. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.ReplicaComputeCapacity replica_compute_capacity = 19 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $replica_compute_capacity; + /** + * Optional. The autoscaling configuration. Autoscaling is enabled if this + * field is set. When autoscaling is enabled, node_count and processing_units + * are treated as OUTPUT_ONLY fields and reflect the current compute capacity + * allocated to the instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig autoscaling_config = 17 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $autoscaling_config = null; + /** + * Output only. The current instance state. For + * [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance], + * the state must be either omitted or set to `CREATING`. For + * [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance], + * the state must be either omitted or set to `READY`. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $state = 0; + /** + * Cloud Labels are a flexible and lightweight mechanism for organizing cloud + * resources into groups that reflect a customer's organizational needs and + * deployment strategies. Cloud Labels can be used to filter collections of + * resources. They can be used to control how resource metrics are aggregated. + * And they can be used as arguments to policy management rules (e.g. route, + * firewall, load balancing, etc.). + * * Label keys must be between 1 and 63 characters long and must conform to + * the following regular expression: `[a-z][a-z0-9_-]{0,62}`. + * * Label values must be between 0 and 63 characters long and must conform + * to the regular expression `[a-z0-9_-]{0,63}`. + * * No more than 64 labels can be associated with a given resource. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * If you plan to use labels in your own code, please note that additional + * characters may be allowed in the future. And so you are advised to use an + * internal label representation, such as JSON, which doesn't rely upon + * specific characters being disallowed. For example, representing labels + * as the string: name + "_" + value would prove problematic if we were to + * allow "_" in a future release. + * + * Generated from protobuf field map labels = 7; + */ + private $labels; + /** + * The `InstanceType` of the current instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance.InstanceType instance_type = 10; + */ + protected $instance_type = 0; + /** + * Deprecated. This field is not populated. + * + * Generated from protobuf field repeated string endpoint_uris = 8; + */ + private $endpoint_uris; + /** + * Output only. The time at which the instance was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $create_time = null; + /** + * Output only. The time at which the instance was most recently updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $update_time = null; + /** + * Free instance metadata. Only populated for free instances. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.FreeInstanceMetadata free_instance_metadata = 13; + */ + protected $free_instance_metadata = null; + /** + * Optional. The `Edition` of the current instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance.Edition edition = 20 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $edition = 0; + /** + * Optional. Controls the default backup schedule behavior for new databases + * within the instance. By default, a backup schedule is created automatically + * when a new database is created in a new instance. + * Note that the `AUTOMATIC` value isn't permitted for free instances, + * as backups and backup schedules aren't supported for free instances. + * In the `GetInstance` or `ListInstances` response, if the value of + * `default_backup_schedule_type` isn't set, or set to `NONE`, Spanner doesn't + * create a default backup schedule for new databases in the instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance.DefaultBackupScheduleType default_backup_schedule_type = 23 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $default_backup_schedule_type = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. A unique identifier for the instance, which cannot be changed + * after the instance is created. Values are of the form + * `projects//instances/[a-z][-a-z0-9]*[a-z0-9]`. The final + * segment of the name must be between 2 and 64 characters in length. + * @type string $config + * Required. The name of the instance's configuration. Values are of the form + * `projects//instanceConfigs/`. See + * also [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] and + * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. + * @type string $display_name + * Required. The descriptive name for this instance as it appears in UIs. + * Must be unique per project and between 4 and 30 characters in length. + * @type int $node_count + * The number of nodes allocated to this instance. At most, one of either + * `node_count` or `processing_units` should be present in the message. + * Users can set the `node_count` field to specify the target number of nodes + * allocated to the instance. + * If autoscaling is enabled, `node_count` is treated as an `OUTPUT_ONLY` + * field and reflects the current number of nodes allocated to the instance. + * This might be zero in API responses for instances that are not yet in the + * `READY` state. + * For more information, see + * [Compute capacity, nodes, and processing + * units](https://cloud.google.com/spanner/docs/compute-capacity). + * @type int $processing_units + * The number of processing units allocated to this instance. At most, one of + * either `processing_units` or `node_count` should be present in the message. + * Users can set the `processing_units` field to specify the target number of + * processing units allocated to the instance. + * If autoscaling is enabled, `processing_units` is treated as an + * `OUTPUT_ONLY` field and reflects the current number of processing units + * allocated to the instance. + * This might be zero in API responses for instances that are not yet in the + * `READY` state. + * For more information, see + * [Compute capacity, nodes and processing + * units](https://cloud.google.com/spanner/docs/compute-capacity). + * @type array<\Google\Cloud\Spanner\Admin\Instance\V1\ReplicaComputeCapacity>|\Google\Protobuf\Internal\RepeatedField $replica_compute_capacity + * Output only. Lists the compute capacity per ReplicaSelection. A replica + * selection identifies a set of replicas with common properties. Replicas + * identified by a ReplicaSelection are scaled with the same compute capacity. + * @type \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig $autoscaling_config + * Optional. The autoscaling configuration. Autoscaling is enabled if this + * field is set. When autoscaling is enabled, node_count and processing_units + * are treated as OUTPUT_ONLY fields and reflect the current compute capacity + * allocated to the instance. + * @type int $state + * Output only. The current instance state. For + * [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance], + * the state must be either omitted or set to `CREATING`. For + * [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance], + * the state must be either omitted or set to `READY`. + * @type array|\Google\Protobuf\Internal\MapField $labels + * Cloud Labels are a flexible and lightweight mechanism for organizing cloud + * resources into groups that reflect a customer's organizational needs and + * deployment strategies. Cloud Labels can be used to filter collections of + * resources. They can be used to control how resource metrics are aggregated. + * And they can be used as arguments to policy management rules (e.g. route, + * firewall, load balancing, etc.). + * * Label keys must be between 1 and 63 characters long and must conform to + * the following regular expression: `[a-z][a-z0-9_-]{0,62}`. + * * Label values must be between 0 and 63 characters long and must conform + * to the regular expression `[a-z0-9_-]{0,63}`. + * * No more than 64 labels can be associated with a given resource. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * If you plan to use labels in your own code, please note that additional + * characters may be allowed in the future. And so you are advised to use an + * internal label representation, such as JSON, which doesn't rely upon + * specific characters being disallowed. For example, representing labels + * as the string: name + "_" + value would prove problematic if we were to + * allow "_" in a future release. + * @type int $instance_type + * The `InstanceType` of the current instance. + * @type array|\Google\Protobuf\Internal\RepeatedField $endpoint_uris + * Deprecated. This field is not populated. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. The time at which the instance was created. + * @type \Google\Protobuf\Timestamp $update_time + * Output only. The time at which the instance was most recently updated. + * @type \Google\Cloud\Spanner\Admin\Instance\V1\FreeInstanceMetadata $free_instance_metadata + * Free instance metadata. Only populated for free instances. + * @type int $edition + * Optional. The `Edition` of the current instance. + * @type int $default_backup_schedule_type + * Optional. Controls the default backup schedule behavior for new databases + * within the instance. By default, a backup schedule is created automatically + * when a new database is created in a new instance. + * Note that the `AUTOMATIC` value isn't permitted for free instances, + * as backups and backup schedules aren't supported for free instances. + * In the `GetInstance` or `ListInstances` response, if the value of + * `default_backup_schedule_type` isn't set, or set to `NONE`, Spanner doesn't + * create a default backup schedule for new databases in the instance. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. A unique identifier for the instance, which cannot be changed + * after the instance is created. Values are of the form + * `projects//instances/[a-z][-a-z0-9]*[a-z0-9]`. The final + * segment of the name must be between 2 and 64 characters in length. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. A unique identifier for the instance, which cannot be changed + * after the instance is created. Values are of the form + * `projects//instances/[a-z][-a-z0-9]*[a-z0-9]`. The final + * segment of the name must be between 2 and 64 characters in length. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Required. The name of the instance's configuration. Values are of the form + * `projects//instanceConfigs/`. See + * also [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] and + * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. + * + * Generated from protobuf field string config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getConfig() + { + return $this->config; + } + + /** + * Required. The name of the instance's configuration. Values are of the form + * `projects//instanceConfigs/`. See + * also [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] and + * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. + * + * Generated from protobuf field string config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setConfig($var) + { + GPBUtil::checkString($var, True); + $this->config = $var; + + return $this; + } + + /** + * Required. The descriptive name for this instance as it appears in UIs. + * Must be unique per project and between 4 and 30 characters in length. + * + * Generated from protobuf field string display_name = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getDisplayName() + { + return $this->display_name; + } + + /** + * Required. The descriptive name for this instance as it appears in UIs. + * Must be unique per project and between 4 and 30 characters in length. + * + * Generated from protobuf field string display_name = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setDisplayName($var) + { + GPBUtil::checkString($var, True); + $this->display_name = $var; + + return $this; + } + + /** + * The number of nodes allocated to this instance. At most, one of either + * `node_count` or `processing_units` should be present in the message. + * Users can set the `node_count` field to specify the target number of nodes + * allocated to the instance. + * If autoscaling is enabled, `node_count` is treated as an `OUTPUT_ONLY` + * field and reflects the current number of nodes allocated to the instance. + * This might be zero in API responses for instances that are not yet in the + * `READY` state. + * For more information, see + * [Compute capacity, nodes, and processing + * units](https://cloud.google.com/spanner/docs/compute-capacity). + * + * Generated from protobuf field int32 node_count = 5; + * @return int + */ + public function getNodeCount() + { + return $this->node_count; + } + + /** + * The number of nodes allocated to this instance. At most, one of either + * `node_count` or `processing_units` should be present in the message. + * Users can set the `node_count` field to specify the target number of nodes + * allocated to the instance. + * If autoscaling is enabled, `node_count` is treated as an `OUTPUT_ONLY` + * field and reflects the current number of nodes allocated to the instance. + * This might be zero in API responses for instances that are not yet in the + * `READY` state. + * For more information, see + * [Compute capacity, nodes, and processing + * units](https://cloud.google.com/spanner/docs/compute-capacity). + * + * Generated from protobuf field int32 node_count = 5; + * @param int $var + * @return $this + */ + public function setNodeCount($var) + { + GPBUtil::checkInt32($var); + $this->node_count = $var; + + return $this; + } + + /** + * The number of processing units allocated to this instance. At most, one of + * either `processing_units` or `node_count` should be present in the message. + * Users can set the `processing_units` field to specify the target number of + * processing units allocated to the instance. + * If autoscaling is enabled, `processing_units` is treated as an + * `OUTPUT_ONLY` field and reflects the current number of processing units + * allocated to the instance. + * This might be zero in API responses for instances that are not yet in the + * `READY` state. + * For more information, see + * [Compute capacity, nodes and processing + * units](https://cloud.google.com/spanner/docs/compute-capacity). + * + * Generated from protobuf field int32 processing_units = 9; + * @return int + */ + public function getProcessingUnits() + { + return $this->processing_units; + } + + /** + * The number of processing units allocated to this instance. At most, one of + * either `processing_units` or `node_count` should be present in the message. + * Users can set the `processing_units` field to specify the target number of + * processing units allocated to the instance. + * If autoscaling is enabled, `processing_units` is treated as an + * `OUTPUT_ONLY` field and reflects the current number of processing units + * allocated to the instance. + * This might be zero in API responses for instances that are not yet in the + * `READY` state. + * For more information, see + * [Compute capacity, nodes and processing + * units](https://cloud.google.com/spanner/docs/compute-capacity). + * + * Generated from protobuf field int32 processing_units = 9; + * @param int $var + * @return $this + */ + public function setProcessingUnits($var) + { + GPBUtil::checkInt32($var); + $this->processing_units = $var; + + return $this; + } + + /** + * Output only. Lists the compute capacity per ReplicaSelection. A replica + * selection identifies a set of replicas with common properties. Replicas + * identified by a ReplicaSelection are scaled with the same compute capacity. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.ReplicaComputeCapacity replica_compute_capacity = 19 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getReplicaComputeCapacity() + { + return $this->replica_compute_capacity; + } + + /** + * Output only. Lists the compute capacity per ReplicaSelection. A replica + * selection identifies a set of replicas with common properties. Replicas + * identified by a ReplicaSelection are scaled with the same compute capacity. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.ReplicaComputeCapacity replica_compute_capacity = 19 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param array<\Google\Cloud\Spanner\Admin\Instance\V1\ReplicaComputeCapacity>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setReplicaComputeCapacity($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\Admin\Instance\V1\ReplicaComputeCapacity::class); + $this->replica_compute_capacity = $arr; + + return $this; + } + + /** + * Optional. The autoscaling configuration. Autoscaling is enabled if this + * field is set. When autoscaling is enabled, node_count and processing_units + * are treated as OUTPUT_ONLY fields and reflect the current compute capacity + * allocated to the instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig autoscaling_config = 17 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig|null + */ + public function getAutoscalingConfig() + { + return $this->autoscaling_config; + } + + public function hasAutoscalingConfig() + { + return isset($this->autoscaling_config); + } + + public function clearAutoscalingConfig() + { + unset($this->autoscaling_config); + } + + /** + * Optional. The autoscaling configuration. Autoscaling is enabled if this + * field is set. When autoscaling is enabled, node_count and processing_units + * are treated as OUTPUT_ONLY fields and reflect the current compute capacity + * allocated to the instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig autoscaling_config = 17 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig $var + * @return $this + */ + public function setAutoscalingConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig::class); + $this->autoscaling_config = $var; + + return $this; + } + + /** + * Output only. The current instance state. For + * [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance], + * the state must be either omitted or set to `CREATING`. For + * [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance], + * the state must be either omitted or set to `READY`. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getState() + { + return $this->state; + } + + /** + * Output only. The current instance state. For + * [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance], + * the state must be either omitted or set to `CREATING`. For + * [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance], + * the state must be either omitted or set to `READY`. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setState($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Instance\V1\Instance\State::class); + $this->state = $var; + + return $this; + } + + /** + * Cloud Labels are a flexible and lightweight mechanism for organizing cloud + * resources into groups that reflect a customer's organizational needs and + * deployment strategies. Cloud Labels can be used to filter collections of + * resources. They can be used to control how resource metrics are aggregated. + * And they can be used as arguments to policy management rules (e.g. route, + * firewall, load balancing, etc.). + * * Label keys must be between 1 and 63 characters long and must conform to + * the following regular expression: `[a-z][a-z0-9_-]{0,62}`. + * * Label values must be between 0 and 63 characters long and must conform + * to the regular expression `[a-z0-9_-]{0,63}`. + * * No more than 64 labels can be associated with a given resource. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * If you plan to use labels in your own code, please note that additional + * characters may be allowed in the future. And so you are advised to use an + * internal label representation, such as JSON, which doesn't rely upon + * specific characters being disallowed. For example, representing labels + * as the string: name + "_" + value would prove problematic if we were to + * allow "_" in a future release. + * + * Generated from protobuf field map labels = 7; + * @return \Google\Protobuf\Internal\MapField + */ + public function getLabels() + { + return $this->labels; + } + + /** + * Cloud Labels are a flexible and lightweight mechanism for organizing cloud + * resources into groups that reflect a customer's organizational needs and + * deployment strategies. Cloud Labels can be used to filter collections of + * resources. They can be used to control how resource metrics are aggregated. + * And they can be used as arguments to policy management rules (e.g. route, + * firewall, load balancing, etc.). + * * Label keys must be between 1 and 63 characters long and must conform to + * the following regular expression: `[a-z][a-z0-9_-]{0,62}`. + * * Label values must be between 0 and 63 characters long and must conform + * to the regular expression `[a-z0-9_-]{0,63}`. + * * No more than 64 labels can be associated with a given resource. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * If you plan to use labels in your own code, please note that additional + * characters may be allowed in the future. And so you are advised to use an + * internal label representation, such as JSON, which doesn't rely upon + * specific characters being disallowed. For example, representing labels + * as the string: name + "_" + value would prove problematic if we were to + * allow "_" in a future release. + * + * Generated from protobuf field map labels = 7; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setLabels($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->labels = $arr; + + return $this; + } + + /** + * The `InstanceType` of the current instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance.InstanceType instance_type = 10; + * @return int + */ + public function getInstanceType() + { + return $this->instance_type; + } + + /** + * The `InstanceType` of the current instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance.InstanceType instance_type = 10; + * @param int $var + * @return $this + */ + public function setInstanceType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Instance\V1\Instance\InstanceType::class); + $this->instance_type = $var; + + return $this; + } + + /** + * Deprecated. This field is not populated. + * + * Generated from protobuf field repeated string endpoint_uris = 8; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getEndpointUris() + { + return $this->endpoint_uris; + } + + /** + * Deprecated. This field is not populated. + * + * Generated from protobuf field repeated string endpoint_uris = 8; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setEndpointUris($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->endpoint_uris = $arr; + + return $this; + } + + /** + * Output only. The time at which the instance was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + + /** + * Output only. The time at which the instance was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Output only. The time at which the instance was most recently updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getUpdateTime() + { + return $this->update_time; + } + + public function hasUpdateTime() + { + return isset($this->update_time); + } + + public function clearUpdateTime() + { + unset($this->update_time); + } + + /** + * Output only. The time at which the instance was most recently updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + + /** + * Free instance metadata. Only populated for free instances. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.FreeInstanceMetadata free_instance_metadata = 13; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\FreeInstanceMetadata|null + */ + public function getFreeInstanceMetadata() + { + return $this->free_instance_metadata; + } + + public function hasFreeInstanceMetadata() + { + return isset($this->free_instance_metadata); + } + + public function clearFreeInstanceMetadata() + { + unset($this->free_instance_metadata); + } + + /** + * Free instance metadata. Only populated for free instances. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.FreeInstanceMetadata free_instance_metadata = 13; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\FreeInstanceMetadata $var + * @return $this + */ + public function setFreeInstanceMetadata($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\FreeInstanceMetadata::class); + $this->free_instance_metadata = $var; + + return $this; + } + + /** + * Optional. The `Edition` of the current instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance.Edition edition = 20 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getEdition() + { + return $this->edition; + } + + /** + * Optional. The `Edition` of the current instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance.Edition edition = 20 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setEdition($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Instance\V1\Instance\Edition::class); + $this->edition = $var; + + return $this; + } + + /** + * Optional. Controls the default backup schedule behavior for new databases + * within the instance. By default, a backup schedule is created automatically + * when a new database is created in a new instance. + * Note that the `AUTOMATIC` value isn't permitted for free instances, + * as backups and backup schedules aren't supported for free instances. + * In the `GetInstance` or `ListInstances` response, if the value of + * `default_backup_schedule_type` isn't set, or set to `NONE`, Spanner doesn't + * create a default backup schedule for new databases in the instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance.DefaultBackupScheduleType default_backup_schedule_type = 23 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getDefaultBackupScheduleType() + { + return $this->default_backup_schedule_type; + } + + /** + * Optional. Controls the default backup schedule behavior for new databases + * within the instance. By default, a backup schedule is created automatically + * when a new database is created in a new instance. + * Note that the `AUTOMATIC` value isn't permitted for free instances, + * as backups and backup schedules aren't supported for free instances. + * In the `GetInstance` or `ListInstances` response, if the value of + * `default_backup_schedule_type` isn't set, or set to `NONE`, Spanner doesn't + * create a default backup schedule for new databases in the instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance.DefaultBackupScheduleType default_backup_schedule_type = 23 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setDefaultBackupScheduleType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Instance\V1\Instance\DefaultBackupScheduleType::class); + $this->default_backup_schedule_type = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/Instance/DefaultBackupScheduleType.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/Instance/DefaultBackupScheduleType.php new file mode 100644 index 000000000000..ca0a5ec8fd95 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/Instance/DefaultBackupScheduleType.php @@ -0,0 +1,71 @@ +google.spanner.admin.instance.v1.Instance.DefaultBackupScheduleType + */ +class DefaultBackupScheduleType +{ + /** + * Not specified. + * + * Generated from protobuf enum DEFAULT_BACKUP_SCHEDULE_TYPE_UNSPECIFIED = 0; + */ + const DEFAULT_BACKUP_SCHEDULE_TYPE_UNSPECIFIED = 0; + /** + * A default backup schedule isn't created automatically when a new database + * is created in the instance. + * + * Generated from protobuf enum NONE = 1; + */ + const NONE = 1; + /** + * A default backup schedule is created automatically when a new database + * is created in the instance. The default backup schedule creates a full + * backup every 24 hours. These full backups are retained for 7 days. + * You can edit or delete the default backup schedule once it's created. + * + * Generated from protobuf enum AUTOMATIC = 2; + */ + const AUTOMATIC = 2; + + private static $valueToName = [ + self::DEFAULT_BACKUP_SCHEDULE_TYPE_UNSPECIFIED => 'DEFAULT_BACKUP_SCHEDULE_TYPE_UNSPECIFIED', + self::NONE => 'NONE', + self::AUTOMATIC => 'AUTOMATIC', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(DefaultBackupScheduleType::class, \Google\Cloud\Spanner\Admin\Instance\V1\Instance_DefaultBackupScheduleType::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/Instance/Edition.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/Instance/Edition.php new file mode 100644 index 000000000000..f05fa2f3b48d --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/Instance/Edition.php @@ -0,0 +1,72 @@ +google.spanner.admin.instance.v1.Instance.Edition + */ +class Edition +{ + /** + * Edition not specified. + * + * Generated from protobuf enum EDITION_UNSPECIFIED = 0; + */ + const EDITION_UNSPECIFIED = 0; + /** + * Standard edition. + * + * Generated from protobuf enum STANDARD = 1; + */ + const STANDARD = 1; + /** + * Enterprise edition. + * + * Generated from protobuf enum ENTERPRISE = 2; + */ + const ENTERPRISE = 2; + /** + * Enterprise Plus edition. + * + * Generated from protobuf enum ENTERPRISE_PLUS = 3; + */ + const ENTERPRISE_PLUS = 3; + + private static $valueToName = [ + self::EDITION_UNSPECIFIED => 'EDITION_UNSPECIFIED', + self::STANDARD => 'STANDARD', + self::ENTERPRISE => 'ENTERPRISE', + self::ENTERPRISE_PLUS => 'ENTERPRISE_PLUS', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Edition::class, \Google\Cloud\Spanner\Admin\Instance\V1\Instance_Edition::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/Instance/InstanceType.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/Instance/InstanceType.php new file mode 100644 index 000000000000..6e29f52acf69 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/Instance/InstanceType.php @@ -0,0 +1,70 @@ +google.spanner.admin.instance.v1.Instance.InstanceType + */ +class InstanceType +{ + /** + * Not specified. + * + * Generated from protobuf enum INSTANCE_TYPE_UNSPECIFIED = 0; + */ + const INSTANCE_TYPE_UNSPECIFIED = 0; + /** + * Provisioned instances have dedicated resources, standard usage limits and + * support. + * + * Generated from protobuf enum PROVISIONED = 1; + */ + const PROVISIONED = 1; + /** + * Free instances provide no guarantee for dedicated resources, + * [node_count, processing_units] should be 0. They come + * with stricter usage limits and limited support. + * + * Generated from protobuf enum FREE_INSTANCE = 2; + */ + const FREE_INSTANCE = 2; + + private static $valueToName = [ + self::INSTANCE_TYPE_UNSPECIFIED => 'INSTANCE_TYPE_UNSPECIFIED', + self::PROVISIONED => 'PROVISIONED', + self::FREE_INSTANCE => 'FREE_INSTANCE', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(InstanceType::class, \Google\Cloud\Spanner\Admin\Instance\V1\Instance_InstanceType::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/Instance/State.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/Instance/State.php new file mode 100644 index 000000000000..6490899edb93 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/Instance/State.php @@ -0,0 +1,67 @@ +google.spanner.admin.instance.v1.Instance.State + */ +class State +{ + /** + * Not specified. + * + * Generated from protobuf enum STATE_UNSPECIFIED = 0; + */ + const STATE_UNSPECIFIED = 0; + /** + * The instance is still being created. Resources may not be + * available yet, and operations such as database creation may not + * work. + * + * Generated from protobuf enum CREATING = 1; + */ + const CREATING = 1; + /** + * The instance is fully created and ready to do work such as + * creating databases. + * + * Generated from protobuf enum READY = 2; + */ + const READY = 2; + + private static $valueToName = [ + self::STATE_UNSPECIFIED => 'STATE_UNSPECIFIED', + self::CREATING => 'CREATING', + self::READY => 'READY', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(State::class, \Google\Cloud\Spanner\Admin\Instance\V1\Instance_State::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstanceConfig.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstanceConfig.php new file mode 100644 index 000000000000..0fc49ee6a9a1 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstanceConfig.php @@ -0,0 +1,690 @@ +google.spanner.admin.instance.v1.InstanceConfig + */ +class InstanceConfig extends \Google\Protobuf\Internal\Message +{ + /** + * A unique identifier for the instance configuration. Values + * are of the form + * `projects//instanceConfigs/[a-z][-a-z0-9]*`. + * User instance configuration must start with `custom-`. + * + * Generated from protobuf field string name = 1; + */ + protected $name = ''; + /** + * The name of this instance configuration as it appears in UIs. + * + * Generated from protobuf field string display_name = 2; + */ + protected $display_name = ''; + /** + * Output only. Whether this instance configuration is a Google-managed or + * user-managed configuration. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig.Type config_type = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $config_type = 0; + /** + * The geographic placement of nodes in this instance configuration and their + * replication properties. + * To create user-managed configurations, input + * `replicas` must include all replicas in `replicas` of the `base_config` + * and include one or more replicas in the `optional_replicas` of the + * `base_config`. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.ReplicaInfo replicas = 3; + */ + private $replicas; + /** + * Output only. The available optional replicas to choose from for + * user-managed configurations. Populated for Google-managed configurations. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.ReplicaInfo optional_replicas = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $optional_replicas; + /** + * Base configuration name, e.g. projects//instanceConfigs/nam3, + * based on which this configuration is created. Only set for user-managed + * configurations. `base_config` must refer to a configuration of type + * `GOOGLE_MANAGED` in the same project as this configuration. + * + * Generated from protobuf field string base_config = 7 [(.google.api.resource_reference) = { + */ + protected $base_config = ''; + /** + * Cloud Labels are a flexible and lightweight mechanism for organizing cloud + * resources into groups that reflect a customer's organizational needs and + * deployment strategies. Cloud Labels can be used to filter collections of + * resources. They can be used to control how resource metrics are aggregated. + * And they can be used as arguments to policy management rules (e.g. route, + * firewall, load balancing, etc.). + * * Label keys must be between 1 and 63 characters long and must conform to + * the following regular expression: `[a-z][a-z0-9_-]{0,62}`. + * * Label values must be between 0 and 63 characters long and must conform + * to the regular expression `[a-z0-9_-]{0,63}`. + * * No more than 64 labels can be associated with a given resource. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * If you plan to use labels in your own code, please note that additional + * characters may be allowed in the future. Therefore, you are advised to use + * an internal label representation, such as JSON, which doesn't rely upon + * specific characters being disallowed. For example, representing labels + * as the string: name + "_" + value would prove problematic if we were to + * allow "_" in a future release. + * + * Generated from protobuf field map labels = 8; + */ + private $labels; + /** + * etag is used for optimistic concurrency control as a way + * to help prevent simultaneous updates of a instance configuration from + * overwriting each other. It is strongly suggested that systems make use of + * the etag in the read-modify-write cycle to perform instance configuration + * updates in order to avoid race conditions: An etag is returned in the + * response which contains instance configurations, and systems are expected + * to put that etag in the request to update instance configuration to ensure + * that their change is applied to the same version of the instance + * configuration. If no etag is provided in the call to update the instance + * configuration, then the existing instance configuration is overwritten + * blindly. + * + * Generated from protobuf field string etag = 9; + */ + protected $etag = ''; + /** + * Allowed values of the "default_leader" schema option for databases in + * instances that use this instance configuration. + * + * Generated from protobuf field repeated string leader_options = 4; + */ + private $leader_options; + /** + * Output only. If true, the instance configuration is being created or + * updated. If false, there are no ongoing operations for the instance + * configuration. + * + * Generated from protobuf field bool reconciling = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $reconciling = false; + /** + * Output only. The current instance configuration state. Applicable only for + * `USER_MANAGED` configurations. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig.State state = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $state = 0; + /** + * Output only. Describes whether free instances are available to be created + * in this instance configuration. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig.FreeInstanceAvailability free_instance_availability = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $free_instance_availability = 0; + /** + * Output only. The `QuorumType` of the instance configuration. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig.QuorumType quorum_type = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $quorum_type = 0; + /** + * Output only. The storage limit in bytes per processing unit. + * + * Generated from protobuf field int64 storage_limit_per_processing_unit = 19 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $storage_limit_per_processing_unit = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * A unique identifier for the instance configuration. Values + * are of the form + * `projects//instanceConfigs/[a-z][-a-z0-9]*`. + * User instance configuration must start with `custom-`. + * @type string $display_name + * The name of this instance configuration as it appears in UIs. + * @type int $config_type + * Output only. Whether this instance configuration is a Google-managed or + * user-managed configuration. + * @type array<\Google\Cloud\Spanner\Admin\Instance\V1\ReplicaInfo>|\Google\Protobuf\Internal\RepeatedField $replicas + * The geographic placement of nodes in this instance configuration and their + * replication properties. + * To create user-managed configurations, input + * `replicas` must include all replicas in `replicas` of the `base_config` + * and include one or more replicas in the `optional_replicas` of the + * `base_config`. + * @type array<\Google\Cloud\Spanner\Admin\Instance\V1\ReplicaInfo>|\Google\Protobuf\Internal\RepeatedField $optional_replicas + * Output only. The available optional replicas to choose from for + * user-managed configurations. Populated for Google-managed configurations. + * @type string $base_config + * Base configuration name, e.g. projects//instanceConfigs/nam3, + * based on which this configuration is created. Only set for user-managed + * configurations. `base_config` must refer to a configuration of type + * `GOOGLE_MANAGED` in the same project as this configuration. + * @type array|\Google\Protobuf\Internal\MapField $labels + * Cloud Labels are a flexible and lightweight mechanism for organizing cloud + * resources into groups that reflect a customer's organizational needs and + * deployment strategies. Cloud Labels can be used to filter collections of + * resources. They can be used to control how resource metrics are aggregated. + * And they can be used as arguments to policy management rules (e.g. route, + * firewall, load balancing, etc.). + * * Label keys must be between 1 and 63 characters long and must conform to + * the following regular expression: `[a-z][a-z0-9_-]{0,62}`. + * * Label values must be between 0 and 63 characters long and must conform + * to the regular expression `[a-z0-9_-]{0,63}`. + * * No more than 64 labels can be associated with a given resource. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * If you plan to use labels in your own code, please note that additional + * characters may be allowed in the future. Therefore, you are advised to use + * an internal label representation, such as JSON, which doesn't rely upon + * specific characters being disallowed. For example, representing labels + * as the string: name + "_" + value would prove problematic if we were to + * allow "_" in a future release. + * @type string $etag + * etag is used for optimistic concurrency control as a way + * to help prevent simultaneous updates of a instance configuration from + * overwriting each other. It is strongly suggested that systems make use of + * the etag in the read-modify-write cycle to perform instance configuration + * updates in order to avoid race conditions: An etag is returned in the + * response which contains instance configurations, and systems are expected + * to put that etag in the request to update instance configuration to ensure + * that their change is applied to the same version of the instance + * configuration. If no etag is provided in the call to update the instance + * configuration, then the existing instance configuration is overwritten + * blindly. + * @type array|\Google\Protobuf\Internal\RepeatedField $leader_options + * Allowed values of the "default_leader" schema option for databases in + * instances that use this instance configuration. + * @type bool $reconciling + * Output only. If true, the instance configuration is being created or + * updated. If false, there are no ongoing operations for the instance + * configuration. + * @type int $state + * Output only. The current instance configuration state. Applicable only for + * `USER_MANAGED` configurations. + * @type int $free_instance_availability + * Output only. Describes whether free instances are available to be created + * in this instance configuration. + * @type int $quorum_type + * Output only. The `QuorumType` of the instance configuration. + * @type int|string $storage_limit_per_processing_unit + * Output only. The storage limit in bytes per processing unit. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * A unique identifier for the instance configuration. Values + * are of the form + * `projects//instanceConfigs/[a-z][-a-z0-9]*`. + * User instance configuration must start with `custom-`. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * A unique identifier for the instance configuration. Values + * are of the form + * `projects//instanceConfigs/[a-z][-a-z0-9]*`. + * User instance configuration must start with `custom-`. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * The name of this instance configuration as it appears in UIs. + * + * Generated from protobuf field string display_name = 2; + * @return string + */ + public function getDisplayName() + { + return $this->display_name; + } + + /** + * The name of this instance configuration as it appears in UIs. + * + * Generated from protobuf field string display_name = 2; + * @param string $var + * @return $this + */ + public function setDisplayName($var) + { + GPBUtil::checkString($var, True); + $this->display_name = $var; + + return $this; + } + + /** + * Output only. Whether this instance configuration is a Google-managed or + * user-managed configuration. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig.Type config_type = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getConfigType() + { + return $this->config_type; + } + + /** + * Output only. Whether this instance configuration is a Google-managed or + * user-managed configuration. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig.Type config_type = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setConfigType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig\Type::class); + $this->config_type = $var; + + return $this; + } + + /** + * The geographic placement of nodes in this instance configuration and their + * replication properties. + * To create user-managed configurations, input + * `replicas` must include all replicas in `replicas` of the `base_config` + * and include one or more replicas in the `optional_replicas` of the + * `base_config`. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.ReplicaInfo replicas = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getReplicas() + { + return $this->replicas; + } + + /** + * The geographic placement of nodes in this instance configuration and their + * replication properties. + * To create user-managed configurations, input + * `replicas` must include all replicas in `replicas` of the `base_config` + * and include one or more replicas in the `optional_replicas` of the + * `base_config`. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.ReplicaInfo replicas = 3; + * @param array<\Google\Cloud\Spanner\Admin\Instance\V1\ReplicaInfo>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setReplicas($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\Admin\Instance\V1\ReplicaInfo::class); + $this->replicas = $arr; + + return $this; + } + + /** + * Output only. The available optional replicas to choose from for + * user-managed configurations. Populated for Google-managed configurations. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.ReplicaInfo optional_replicas = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOptionalReplicas() + { + return $this->optional_replicas; + } + + /** + * Output only. The available optional replicas to choose from for + * user-managed configurations. Populated for Google-managed configurations. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.ReplicaInfo optional_replicas = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param array<\Google\Cloud\Spanner\Admin\Instance\V1\ReplicaInfo>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOptionalReplicas($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\Admin\Instance\V1\ReplicaInfo::class); + $this->optional_replicas = $arr; + + return $this; + } + + /** + * Base configuration name, e.g. projects//instanceConfigs/nam3, + * based on which this configuration is created. Only set for user-managed + * configurations. `base_config` must refer to a configuration of type + * `GOOGLE_MANAGED` in the same project as this configuration. + * + * Generated from protobuf field string base_config = 7 [(.google.api.resource_reference) = { + * @return string + */ + public function getBaseConfig() + { + return $this->base_config; + } + + /** + * Base configuration name, e.g. projects//instanceConfigs/nam3, + * based on which this configuration is created. Only set for user-managed + * configurations. `base_config` must refer to a configuration of type + * `GOOGLE_MANAGED` in the same project as this configuration. + * + * Generated from protobuf field string base_config = 7 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setBaseConfig($var) + { + GPBUtil::checkString($var, True); + $this->base_config = $var; + + return $this; + } + + /** + * Cloud Labels are a flexible and lightweight mechanism for organizing cloud + * resources into groups that reflect a customer's organizational needs and + * deployment strategies. Cloud Labels can be used to filter collections of + * resources. They can be used to control how resource metrics are aggregated. + * And they can be used as arguments to policy management rules (e.g. route, + * firewall, load balancing, etc.). + * * Label keys must be between 1 and 63 characters long and must conform to + * the following regular expression: `[a-z][a-z0-9_-]{0,62}`. + * * Label values must be between 0 and 63 characters long and must conform + * to the regular expression `[a-z0-9_-]{0,63}`. + * * No more than 64 labels can be associated with a given resource. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * If you plan to use labels in your own code, please note that additional + * characters may be allowed in the future. Therefore, you are advised to use + * an internal label representation, such as JSON, which doesn't rely upon + * specific characters being disallowed. For example, representing labels + * as the string: name + "_" + value would prove problematic if we were to + * allow "_" in a future release. + * + * Generated from protobuf field map labels = 8; + * @return \Google\Protobuf\Internal\MapField + */ + public function getLabels() + { + return $this->labels; + } + + /** + * Cloud Labels are a flexible and lightweight mechanism for organizing cloud + * resources into groups that reflect a customer's organizational needs and + * deployment strategies. Cloud Labels can be used to filter collections of + * resources. They can be used to control how resource metrics are aggregated. + * And they can be used as arguments to policy management rules (e.g. route, + * firewall, load balancing, etc.). + * * Label keys must be between 1 and 63 characters long and must conform to + * the following regular expression: `[a-z][a-z0-9_-]{0,62}`. + * * Label values must be between 0 and 63 characters long and must conform + * to the regular expression `[a-z0-9_-]{0,63}`. + * * No more than 64 labels can be associated with a given resource. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * If you plan to use labels in your own code, please note that additional + * characters may be allowed in the future. Therefore, you are advised to use + * an internal label representation, such as JSON, which doesn't rely upon + * specific characters being disallowed. For example, representing labels + * as the string: name + "_" + value would prove problematic if we were to + * allow "_" in a future release. + * + * Generated from protobuf field map labels = 8; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setLabels($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->labels = $arr; + + return $this; + } + + /** + * etag is used for optimistic concurrency control as a way + * to help prevent simultaneous updates of a instance configuration from + * overwriting each other. It is strongly suggested that systems make use of + * the etag in the read-modify-write cycle to perform instance configuration + * updates in order to avoid race conditions: An etag is returned in the + * response which contains instance configurations, and systems are expected + * to put that etag in the request to update instance configuration to ensure + * that their change is applied to the same version of the instance + * configuration. If no etag is provided in the call to update the instance + * configuration, then the existing instance configuration is overwritten + * blindly. + * + * Generated from protobuf field string etag = 9; + * @return string + */ + public function getEtag() + { + return $this->etag; + } + + /** + * etag is used for optimistic concurrency control as a way + * to help prevent simultaneous updates of a instance configuration from + * overwriting each other. It is strongly suggested that systems make use of + * the etag in the read-modify-write cycle to perform instance configuration + * updates in order to avoid race conditions: An etag is returned in the + * response which contains instance configurations, and systems are expected + * to put that etag in the request to update instance configuration to ensure + * that their change is applied to the same version of the instance + * configuration. If no etag is provided in the call to update the instance + * configuration, then the existing instance configuration is overwritten + * blindly. + * + * Generated from protobuf field string etag = 9; + * @param string $var + * @return $this + */ + public function setEtag($var) + { + GPBUtil::checkString($var, True); + $this->etag = $var; + + return $this; + } + + /** + * Allowed values of the "default_leader" schema option for databases in + * instances that use this instance configuration. + * + * Generated from protobuf field repeated string leader_options = 4; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getLeaderOptions() + { + return $this->leader_options; + } + + /** + * Allowed values of the "default_leader" schema option for databases in + * instances that use this instance configuration. + * + * Generated from protobuf field repeated string leader_options = 4; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setLeaderOptions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->leader_options = $arr; + + return $this; + } + + /** + * Output only. If true, the instance configuration is being created or + * updated. If false, there are no ongoing operations for the instance + * configuration. + * + * Generated from protobuf field bool reconciling = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return bool + */ + public function getReconciling() + { + return $this->reconciling; + } + + /** + * Output only. If true, the instance configuration is being created or + * updated. If false, there are no ongoing operations for the instance + * configuration. + * + * Generated from protobuf field bool reconciling = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param bool $var + * @return $this + */ + public function setReconciling($var) + { + GPBUtil::checkBool($var); + $this->reconciling = $var; + + return $this; + } + + /** + * Output only. The current instance configuration state. Applicable only for + * `USER_MANAGED` configurations. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig.State state = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getState() + { + return $this->state; + } + + /** + * Output only. The current instance configuration state. Applicable only for + * `USER_MANAGED` configurations. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig.State state = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setState($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig\State::class); + $this->state = $var; + + return $this; + } + + /** + * Output only. Describes whether free instances are available to be created + * in this instance configuration. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig.FreeInstanceAvailability free_instance_availability = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getFreeInstanceAvailability() + { + return $this->free_instance_availability; + } + + /** + * Output only. Describes whether free instances are available to be created + * in this instance configuration. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig.FreeInstanceAvailability free_instance_availability = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setFreeInstanceAvailability($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig\FreeInstanceAvailability::class); + $this->free_instance_availability = $var; + + return $this; + } + + /** + * Output only. The `QuorumType` of the instance configuration. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig.QuorumType quorum_type = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getQuorumType() + { + return $this->quorum_type; + } + + /** + * Output only. The `QuorumType` of the instance configuration. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig.QuorumType quorum_type = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setQuorumType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig\QuorumType::class); + $this->quorum_type = $var; + + return $this; + } + + /** + * Output only. The storage limit in bytes per processing unit. + * + * Generated from protobuf field int64 storage_limit_per_processing_unit = 19 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int|string + */ + public function getStorageLimitPerProcessingUnit() + { + return $this->storage_limit_per_processing_unit; + } + + /** + * Output only. The storage limit in bytes per processing unit. + * + * Generated from protobuf field int64 storage_limit_per_processing_unit = 19 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int|string $var + * @return $this + */ + public function setStorageLimitPerProcessingUnit($var) + { + GPBUtil::checkInt64($var); + $this->storage_limit_per_processing_unit = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstanceConfig/FreeInstanceAvailability.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstanceConfig/FreeInstanceAvailability.php new file mode 100644 index 000000000000..ae20bdcc9e24 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstanceConfig/FreeInstanceAvailability.php @@ -0,0 +1,84 @@ +google.spanner.admin.instance.v1.InstanceConfig.FreeInstanceAvailability + */ +class FreeInstanceAvailability +{ + /** + * Not specified. + * + * Generated from protobuf enum FREE_INSTANCE_AVAILABILITY_UNSPECIFIED = 0; + */ + const FREE_INSTANCE_AVAILABILITY_UNSPECIFIED = 0; + /** + * Indicates that free instances are available to be created in this + * instance configuration. + * + * Generated from protobuf enum AVAILABLE = 1; + */ + const AVAILABLE = 1; + /** + * Indicates that free instances are not supported in this instance + * configuration. + * + * Generated from protobuf enum UNSUPPORTED = 2; + */ + const UNSUPPORTED = 2; + /** + * Indicates that free instances are currently not available to be created + * in this instance configuration. + * + * Generated from protobuf enum DISABLED = 3; + */ + const DISABLED = 3; + /** + * Indicates that additional free instances cannot be created in this + * instance configuration because the project has reached its limit of free + * instances. + * + * Generated from protobuf enum QUOTA_EXCEEDED = 4; + */ + const QUOTA_EXCEEDED = 4; + + private static $valueToName = [ + self::FREE_INSTANCE_AVAILABILITY_UNSPECIFIED => 'FREE_INSTANCE_AVAILABILITY_UNSPECIFIED', + self::AVAILABLE => 'AVAILABLE', + self::UNSUPPORTED => 'UNSUPPORTED', + self::DISABLED => 'DISABLED', + self::QUOTA_EXCEEDED => 'QUOTA_EXCEEDED', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(FreeInstanceAvailability::class, \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig_FreeInstanceAvailability::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstanceConfig/QuorumType.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstanceConfig/QuorumType.php new file mode 100644 index 000000000000..19b056f5c710 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstanceConfig/QuorumType.php @@ -0,0 +1,78 @@ +google.spanner.admin.instance.v1.InstanceConfig.QuorumType + */ +class QuorumType +{ + /** + * Quorum type not specified. + * + * Generated from protobuf enum QUORUM_TYPE_UNSPECIFIED = 0; + */ + const QUORUM_TYPE_UNSPECIFIED = 0; + /** + * An instance configuration tagged with `REGION` quorum type forms a write + * quorum in a single region. + * + * Generated from protobuf enum REGION = 1; + */ + const REGION = 1; + /** + * An instance configuration tagged with the `DUAL_REGION` quorum type forms + * a write quorum with exactly two read-write regions in a multi-region + * configuration. + * This instance configuration requires failover in the event of + * regional failures. + * + * Generated from protobuf enum DUAL_REGION = 2; + */ + const DUAL_REGION = 2; + /** + * An instance configuration tagged with the `MULTI_REGION` quorum type + * forms a write quorum from replicas that are spread across more than one + * region in a multi-region configuration. + * + * Generated from protobuf enum MULTI_REGION = 3; + */ + const MULTI_REGION = 3; + + private static $valueToName = [ + self::QUORUM_TYPE_UNSPECIFIED => 'QUORUM_TYPE_UNSPECIFIED', + self::REGION => 'REGION', + self::DUAL_REGION => 'DUAL_REGION', + self::MULTI_REGION => 'MULTI_REGION', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(QuorumType::class, \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig_QuorumType::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstanceConfig/State.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstanceConfig/State.php new file mode 100644 index 000000000000..99a17baaa4f8 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstanceConfig/State.php @@ -0,0 +1,65 @@ +google.spanner.admin.instance.v1.InstanceConfig.State + */ +class State +{ + /** + * Not specified. + * + * Generated from protobuf enum STATE_UNSPECIFIED = 0; + */ + const STATE_UNSPECIFIED = 0; + /** + * The instance configuration is still being created. + * + * Generated from protobuf enum CREATING = 1; + */ + const CREATING = 1; + /** + * The instance configuration is fully created and ready to be used to + * create instances. + * + * Generated from protobuf enum READY = 2; + */ + const READY = 2; + + private static $valueToName = [ + self::STATE_UNSPECIFIED => 'STATE_UNSPECIFIED', + self::CREATING => 'CREATING', + self::READY => 'READY', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(State::class, \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig_State::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstanceConfig/Type.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstanceConfig/Type.php new file mode 100644 index 000000000000..08f5079da568 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstanceConfig/Type.php @@ -0,0 +1,64 @@ +google.spanner.admin.instance.v1.InstanceConfig.Type + */ +class Type +{ + /** + * Unspecified. + * + * Generated from protobuf enum TYPE_UNSPECIFIED = 0; + */ + const TYPE_UNSPECIFIED = 0; + /** + * Google-managed configuration. + * + * Generated from protobuf enum GOOGLE_MANAGED = 1; + */ + const GOOGLE_MANAGED = 1; + /** + * User-managed configuration. + * + * Generated from protobuf enum USER_MANAGED = 2; + */ + const USER_MANAGED = 2; + + private static $valueToName = [ + self::TYPE_UNSPECIFIED => 'TYPE_UNSPECIFIED', + self::GOOGLE_MANAGED => 'GOOGLE_MANAGED', + self::USER_MANAGED => 'USER_MANAGED', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Type::class, \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig_Type::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstancePartition.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstancePartition.php new file mode 100644 index 000000000000..b912f776285f --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstancePartition.php @@ -0,0 +1,568 @@ +google.spanner.admin.instance.v1.InstancePartition + */ +class InstancePartition extends \Google\Protobuf\Internal\Message +{ + /** + * Required. A unique identifier for the instance partition. Values are of the + * form + * `projects//instances//instancePartitions/[a-z][-a-z0-9]*[a-z0-9]`. + * The final segment of the name must be between 2 and 64 characters in + * length. An instance partition's name cannot be changed after the instance + * partition is created. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $name = ''; + /** + * Required. The name of the instance partition's configuration. Values are of + * the form `projects//instanceConfigs/`. See also + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] and + * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. + * + * Generated from protobuf field string config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $config = ''; + /** + * Required. The descriptive name for this instance partition as it appears in + * UIs. Must be unique per project and between 4 and 30 characters in length. + * + * Generated from protobuf field string display_name = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $display_name = ''; + /** + * Output only. The current instance partition state. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstancePartition.State state = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $state = 0; + /** + * Output only. The time at which the instance partition was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $create_time = null; + /** + * Output only. The time at which the instance partition was most recently + * updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $update_time = null; + /** + * Output only. The names of the databases that reference this + * instance partition. Referencing databases should share the parent instance. + * The existence of any referencing database prevents the instance partition + * from being deleted. + * + * Generated from protobuf field repeated string referencing_databases = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $referencing_databases; + /** + * Output only. Deprecated: This field is not populated. + * Output only. The names of the backups that reference this instance + * partition. Referencing backups should share the parent instance. The + * existence of any referencing backup prevents the instance partition from + * being deleted. + * + * Generated from protobuf field repeated string referencing_backups = 11 [deprecated = true, (.google.api.field_behavior) = OUTPUT_ONLY]; + * @deprecated + */ + private $referencing_backups; + /** + * Used for optimistic concurrency control as a way + * to help prevent simultaneous updates of a instance partition from + * overwriting each other. It is strongly suggested that systems make use of + * the etag in the read-modify-write cycle to perform instance partition + * updates in order to avoid race conditions: An etag is returned in the + * response which contains instance partitions, and systems are expected to + * put that etag in the request to update instance partitions to ensure that + * their change will be applied to the same version of the instance partition. + * If no etag is provided in the call to update instance partition, then the + * existing instance partition is overwritten blindly. + * + * Generated from protobuf field string etag = 12; + */ + protected $etag = ''; + protected $compute_capacity; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. A unique identifier for the instance partition. Values are of the + * form + * `projects//instances//instancePartitions/[a-z][-a-z0-9]*[a-z0-9]`. + * The final segment of the name must be between 2 and 64 characters in + * length. An instance partition's name cannot be changed after the instance + * partition is created. + * @type string $config + * Required. The name of the instance partition's configuration. Values are of + * the form `projects//instanceConfigs/`. See also + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] and + * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. + * @type string $display_name + * Required. The descriptive name for this instance partition as it appears in + * UIs. Must be unique per project and between 4 and 30 characters in length. + * @type int $node_count + * The number of nodes allocated to this instance partition. + * Users can set the `node_count` field to specify the target number of + * nodes allocated to the instance partition. + * This may be zero in API responses for instance partitions that are not + * yet in state `READY`. + * @type int $processing_units + * The number of processing units allocated to this instance partition. + * Users can set the `processing_units` field to specify the target number + * of processing units allocated to the instance partition. + * This might be zero in API responses for instance partitions that are not + * yet in the `READY` state. + * @type int $state + * Output only. The current instance partition state. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. The time at which the instance partition was created. + * @type \Google\Protobuf\Timestamp $update_time + * Output only. The time at which the instance partition was most recently + * updated. + * @type array|\Google\Protobuf\Internal\RepeatedField $referencing_databases + * Output only. The names of the databases that reference this + * instance partition. Referencing databases should share the parent instance. + * The existence of any referencing database prevents the instance partition + * from being deleted. + * @type array|\Google\Protobuf\Internal\RepeatedField $referencing_backups + * Output only. Deprecated: This field is not populated. + * Output only. The names of the backups that reference this instance + * partition. Referencing backups should share the parent instance. The + * existence of any referencing backup prevents the instance partition from + * being deleted. + * @type string $etag + * Used for optimistic concurrency control as a way + * to help prevent simultaneous updates of a instance partition from + * overwriting each other. It is strongly suggested that systems make use of + * the etag in the read-modify-write cycle to perform instance partition + * updates in order to avoid race conditions: An etag is returned in the + * response which contains instance partitions, and systems are expected to + * put that etag in the request to update instance partitions to ensure that + * their change will be applied to the same version of the instance partition. + * If no etag is provided in the call to update instance partition, then the + * existing instance partition is overwritten blindly. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. A unique identifier for the instance partition. Values are of the + * form + * `projects//instances//instancePartitions/[a-z][-a-z0-9]*[a-z0-9]`. + * The final segment of the name must be between 2 and 64 characters in + * length. An instance partition's name cannot be changed after the instance + * partition is created. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. A unique identifier for the instance partition. Values are of the + * form + * `projects//instances//instancePartitions/[a-z][-a-z0-9]*[a-z0-9]`. + * The final segment of the name must be between 2 and 64 characters in + * length. An instance partition's name cannot be changed after the instance + * partition is created. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Required. The name of the instance partition's configuration. Values are of + * the form `projects//instanceConfigs/`. See also + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] and + * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. + * + * Generated from protobuf field string config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getConfig() + { + return $this->config; + } + + /** + * Required. The name of the instance partition's configuration. Values are of + * the form `projects//instanceConfigs/`. See also + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] and + * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. + * + * Generated from protobuf field string config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setConfig($var) + { + GPBUtil::checkString($var, True); + $this->config = $var; + + return $this; + } + + /** + * Required. The descriptive name for this instance partition as it appears in + * UIs. Must be unique per project and between 4 and 30 characters in length. + * + * Generated from protobuf field string display_name = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getDisplayName() + { + return $this->display_name; + } + + /** + * Required. The descriptive name for this instance partition as it appears in + * UIs. Must be unique per project and between 4 and 30 characters in length. + * + * Generated from protobuf field string display_name = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setDisplayName($var) + { + GPBUtil::checkString($var, True); + $this->display_name = $var; + + return $this; + } + + /** + * The number of nodes allocated to this instance partition. + * Users can set the `node_count` field to specify the target number of + * nodes allocated to the instance partition. + * This may be zero in API responses for instance partitions that are not + * yet in state `READY`. + * + * Generated from protobuf field int32 node_count = 5; + * @return int + */ + public function getNodeCount() + { + return $this->readOneof(5); + } + + public function hasNodeCount() + { + return $this->hasOneof(5); + } + + /** + * The number of nodes allocated to this instance partition. + * Users can set the `node_count` field to specify the target number of + * nodes allocated to the instance partition. + * This may be zero in API responses for instance partitions that are not + * yet in state `READY`. + * + * Generated from protobuf field int32 node_count = 5; + * @param int $var + * @return $this + */ + public function setNodeCount($var) + { + GPBUtil::checkInt32($var); + $this->writeOneof(5, $var); + + return $this; + } + + /** + * The number of processing units allocated to this instance partition. + * Users can set the `processing_units` field to specify the target number + * of processing units allocated to the instance partition. + * This might be zero in API responses for instance partitions that are not + * yet in the `READY` state. + * + * Generated from protobuf field int32 processing_units = 6; + * @return int + */ + public function getProcessingUnits() + { + return $this->readOneof(6); + } + + public function hasProcessingUnits() + { + return $this->hasOneof(6); + } + + /** + * The number of processing units allocated to this instance partition. + * Users can set the `processing_units` field to specify the target number + * of processing units allocated to the instance partition. + * This might be zero in API responses for instance partitions that are not + * yet in the `READY` state. + * + * Generated from protobuf field int32 processing_units = 6; + * @param int $var + * @return $this + */ + public function setProcessingUnits($var) + { + GPBUtil::checkInt32($var); + $this->writeOneof(6, $var); + + return $this; + } + + /** + * Output only. The current instance partition state. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstancePartition.State state = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getState() + { + return $this->state; + } + + /** + * Output only. The current instance partition state. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstancePartition.State state = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setState($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition\State::class); + $this->state = $var; + + return $this; + } + + /** + * Output only. The time at which the instance partition was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + + /** + * Output only. The time at which the instance partition was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Output only. The time at which the instance partition was most recently + * updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getUpdateTime() + { + return $this->update_time; + } + + public function hasUpdateTime() + { + return isset($this->update_time); + } + + public function clearUpdateTime() + { + unset($this->update_time); + } + + /** + * Output only. The time at which the instance partition was most recently + * updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + + /** + * Output only. The names of the databases that reference this + * instance partition. Referencing databases should share the parent instance. + * The existence of any referencing database prevents the instance partition + * from being deleted. + * + * Generated from protobuf field repeated string referencing_databases = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getReferencingDatabases() + { + return $this->referencing_databases; + } + + /** + * Output only. The names of the databases that reference this + * instance partition. Referencing databases should share the parent instance. + * The existence of any referencing database prevents the instance partition + * from being deleted. + * + * Generated from protobuf field repeated string referencing_databases = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setReferencingDatabases($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->referencing_databases = $arr; + + return $this; + } + + /** + * Output only. Deprecated: This field is not populated. + * Output only. The names of the backups that reference this instance + * partition. Referencing backups should share the parent instance. The + * existence of any referencing backup prevents the instance partition from + * being deleted. + * + * Generated from protobuf field repeated string referencing_backups = 11 [deprecated = true, (.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Internal\RepeatedField + * @deprecated + */ + public function getReferencingBackups() + { + @trigger_error('referencing_backups is deprecated.', E_USER_DEPRECATED); + return $this->referencing_backups; + } + + /** + * Output only. Deprecated: This field is not populated. + * Output only. The names of the backups that reference this instance + * partition. Referencing backups should share the parent instance. The + * existence of any referencing backup prevents the instance partition from + * being deleted. + * + * Generated from protobuf field repeated string referencing_backups = 11 [deprecated = true, (.google.api.field_behavior) = OUTPUT_ONLY]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + * @deprecated + */ + public function setReferencingBackups($var) + { + @trigger_error('referencing_backups is deprecated.', E_USER_DEPRECATED); + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->referencing_backups = $arr; + + return $this; + } + + /** + * Used for optimistic concurrency control as a way + * to help prevent simultaneous updates of a instance partition from + * overwriting each other. It is strongly suggested that systems make use of + * the etag in the read-modify-write cycle to perform instance partition + * updates in order to avoid race conditions: An etag is returned in the + * response which contains instance partitions, and systems are expected to + * put that etag in the request to update instance partitions to ensure that + * their change will be applied to the same version of the instance partition. + * If no etag is provided in the call to update instance partition, then the + * existing instance partition is overwritten blindly. + * + * Generated from protobuf field string etag = 12; + * @return string + */ + public function getEtag() + { + return $this->etag; + } + + /** + * Used for optimistic concurrency control as a way + * to help prevent simultaneous updates of a instance partition from + * overwriting each other. It is strongly suggested that systems make use of + * the etag in the read-modify-write cycle to perform instance partition + * updates in order to avoid race conditions: An etag is returned in the + * response which contains instance partitions, and systems are expected to + * put that etag in the request to update instance partitions to ensure that + * their change will be applied to the same version of the instance partition. + * If no etag is provided in the call to update instance partition, then the + * existing instance partition is overwritten blindly. + * + * Generated from protobuf field string etag = 12; + * @param string $var + * @return $this + */ + public function setEtag($var) + { + GPBUtil::checkString($var, True); + $this->etag = $var; + + return $this; + } + + /** + * @return string + */ + public function getComputeCapacity() + { + return $this->whichOneof("compute_capacity"); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstancePartition/State.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstancePartition/State.php new file mode 100644 index 000000000000..01cf1218b69e --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/InstancePartition/State.php @@ -0,0 +1,67 @@ +google.spanner.admin.instance.v1.InstancePartition.State + */ +class State +{ + /** + * Not specified. + * + * Generated from protobuf enum STATE_UNSPECIFIED = 0; + */ + const STATE_UNSPECIFIED = 0; + /** + * The instance partition is still being created. Resources may not be + * available yet, and operations such as creating placements using this + * instance partition may not work. + * + * Generated from protobuf enum CREATING = 1; + */ + const CREATING = 1; + /** + * The instance partition is fully created and ready to do work such as + * creating placements and using in databases. + * + * Generated from protobuf enum READY = 2; + */ + const READY = 2; + + private static $valueToName = [ + self::STATE_UNSPECIFIED => 'STATE_UNSPECIFIED', + self::CREATING => 'CREATING', + self::READY => 'READY', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(State::class, \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition_State::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstanceConfigOperationsRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstanceConfigOperationsRequest.php new file mode 100644 index 000000000000..4f688ae83d94 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstanceConfigOperationsRequest.php @@ -0,0 +1,349 @@ +google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest + */ +class ListInstanceConfigOperationsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The project of the instance configuration operations. + * Values are of the form `projects/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * An expression that filters the list of returned operations. + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the Operation are eligible for filtering: + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata] + * is + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `done:true` - The operation is complete. + * * `(metadata.@type=` \ + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) + * AND` \ + * `(metadata.instance_config.name:custom-config) AND` \ + * `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata]. + * * The instance configuration name contains "custom-config". + * * The operation started before 2021-03-28T14:50:00Z. + * * The operation resulted in an error. + * + * Generated from protobuf field string filter = 2; + */ + protected $filter = ''; + /** + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3; + */ + protected $page_size = 0; + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.next_page_token] + * from a previous + * [ListInstanceConfigOperationsResponse][google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse] + * to the same `parent` and with the same `filter`. + * + * Generated from protobuf field string page_token = 4; + */ + protected $page_token = ''; + + /** + * @param string $parent Required. The project of the instance configuration operations. + * Values are of the form `projects/`. Please see + * {@see InstanceAdminClient::projectName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Instance\V1\ListInstanceConfigOperationsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The project of the instance configuration operations. + * Values are of the form `projects/`. + * @type string $filter + * An expression that filters the list of returned operations. + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the Operation are eligible for filtering: + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata] + * is + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `done:true` - The operation is complete. + * * `(metadata.@type=` \ + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) + * AND` \ + * `(metadata.instance_config.name:custom-config) AND` \ + * `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata]. + * * The instance configuration name contains "custom-config". + * * The operation started before 2021-03-28T14:50:00Z. + * * The operation resulted in an error. + * @type int $page_size + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @type string $page_token + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.next_page_token] + * from a previous + * [ListInstanceConfigOperationsResponse][google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse] + * to the same `parent` and with the same `filter`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The project of the instance configuration operations. + * Values are of the form `projects/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The project of the instance configuration operations. + * Values are of the form `projects/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * An expression that filters the list of returned operations. + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the Operation are eligible for filtering: + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata] + * is + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `done:true` - The operation is complete. + * * `(metadata.@type=` \ + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) + * AND` \ + * `(metadata.instance_config.name:custom-config) AND` \ + * `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata]. + * * The instance configuration name contains "custom-config". + * * The operation started before 2021-03-28T14:50:00Z. + * * The operation resulted in an error. + * + * Generated from protobuf field string filter = 2; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * An expression that filters the list of returned operations. + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the Operation are eligible for filtering: + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata] + * is + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `done:true` - The operation is complete. + * * `(metadata.@type=` \ + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) + * AND` \ + * `(metadata.instance_config.name:custom-config) AND` \ + * `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata]. + * * The instance configuration name contains "custom-config". + * * The operation started before 2021-03-28T14:50:00Z. + * * The operation resulted in an error. + * + * Generated from protobuf field string filter = 2; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.next_page_token] + * from a previous + * [ListInstanceConfigOperationsResponse][google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse] + * to the same `parent` and with the same `filter`. + * + * Generated from protobuf field string page_token = 4; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.next_page_token] + * from a previous + * [ListInstanceConfigOperationsResponse][google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse] + * to the same `parent` and with the same `filter`. + * + * Generated from protobuf field string page_token = 4; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstanceConfigOperationsResponse.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstanceConfigOperationsResponse.php new file mode 100644 index 000000000000..b21040c453ec --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstanceConfigOperationsResponse.php @@ -0,0 +1,126 @@ +google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse + */ +class ListInstanceConfigOperationsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of matching instance configuration long-running operations. Each + * operation's name will be + * prefixed by the name of the instance configuration. The operation's + * metadata field type + * `metadata.type_url` describes the type of the metadata. + * + * Generated from protobuf field repeated .google.longrunning.Operation operations = 1; + */ + private $operations; + /** + * `next_page_token` can be sent in a subsequent + * [ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations] + * call to fetch more of the matching metadata. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\LongRunning\Operation>|\Google\Protobuf\Internal\RepeatedField $operations + * The list of matching instance configuration long-running operations. Each + * operation's name will be + * prefixed by the name of the instance configuration. The operation's + * metadata field type + * `metadata.type_url` describes the type of the metadata. + * @type string $next_page_token + * `next_page_token` can be sent in a subsequent + * [ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations] + * call to fetch more of the matching metadata. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The list of matching instance configuration long-running operations. Each + * operation's name will be + * prefixed by the name of the instance configuration. The operation's + * metadata field type + * `metadata.type_url` describes the type of the metadata. + * + * Generated from protobuf field repeated .google.longrunning.Operation operations = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOperations() + { + return $this->operations; + } + + /** + * The list of matching instance configuration long-running operations. Each + * operation's name will be + * prefixed by the name of the instance configuration. The operation's + * metadata field type + * `metadata.type_url` describes the type of the metadata. + * + * Generated from protobuf field repeated .google.longrunning.Operation operations = 1; + * @param array<\Google\LongRunning\Operation>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOperations($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\LongRunning\Operation::class); + $this->operations = $arr; + + return $this; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations] + * call to fetch more of the matching metadata. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations] + * call to fetch more of the matching metadata. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstanceConfigsRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstanceConfigsRequest.php new file mode 100644 index 000000000000..8a0b73a6192b --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstanceConfigsRequest.php @@ -0,0 +1,176 @@ +google.spanner.admin.instance.v1.ListInstanceConfigsRequest + */ +class ListInstanceConfigsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the project for which a list of supported instance + * configurations is requested. Values are of the form + * `projects/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Number of instance configurations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2; + */ + protected $page_size = 0; + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstanceConfigsResponse.next_page_token] + * from a previous + * [ListInstanceConfigsResponse][google.spanner.admin.instance.v1.ListInstanceConfigsResponse]. + * + * Generated from protobuf field string page_token = 3; + */ + protected $page_token = ''; + + /** + * @param string $parent Required. The name of the project for which a list of supported instance + * configurations is requested. Values are of the form + * `projects/`. Please see + * {@see InstanceAdminClient::projectName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Instance\V1\ListInstanceConfigsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The name of the project for which a list of supported instance + * configurations is requested. Values are of the form + * `projects/`. + * @type int $page_size + * Number of instance configurations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @type string $page_token + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstanceConfigsResponse.next_page_token] + * from a previous + * [ListInstanceConfigsResponse][google.spanner.admin.instance.v1.ListInstanceConfigsResponse]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the project for which a list of supported instance + * configurations is requested. Values are of the form + * `projects/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The name of the project for which a list of supported instance + * configurations is requested. Values are of the form + * `projects/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Number of instance configurations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Number of instance configurations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstanceConfigsResponse.next_page_token] + * from a previous + * [ListInstanceConfigsResponse][google.spanner.admin.instance.v1.ListInstanceConfigsResponse]. + * + * Generated from protobuf field string page_token = 3; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstanceConfigsResponse.next_page_token] + * from a previous + * [ListInstanceConfigsResponse][google.spanner.admin.instance.v1.ListInstanceConfigsResponse]. + * + * Generated from protobuf field string page_token = 3; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstanceConfigsResponse.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstanceConfigsResponse.php new file mode 100644 index 000000000000..73241c4da20d --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstanceConfigsResponse.php @@ -0,0 +1,110 @@ +google.spanner.admin.instance.v1.ListInstanceConfigsResponse + */ +class ListInstanceConfigsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of requested instance configurations. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.InstanceConfig instance_configs = 1; + */ + private $instance_configs; + /** + * `next_page_token` can be sent in a subsequent + * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs] + * call to fetch more of the matching instance configurations. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig>|\Google\Protobuf\Internal\RepeatedField $instance_configs + * The list of requested instance configurations. + * @type string $next_page_token + * `next_page_token` can be sent in a subsequent + * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs] + * call to fetch more of the matching instance configurations. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The list of requested instance configurations. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.InstanceConfig instance_configs = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getInstanceConfigs() + { + return $this->instance_configs; + } + + /** + * The list of requested instance configurations. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.InstanceConfig instance_configs = 1; + * @param array<\Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setInstanceConfigs($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig::class); + $this->instance_configs = $arr; + + return $this; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs] + * call to fetch more of the matching instance configurations. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs] + * call to fetch more of the matching instance configurations. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancePartitionOperationsRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancePartitionOperationsRequest.php new file mode 100644 index 000000000000..7df93edd57dc --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancePartitionOperationsRequest.php @@ -0,0 +1,413 @@ +google.spanner.admin.instance.v1.ListInstancePartitionOperationsRequest + */ +class ListInstancePartitionOperationsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The parent instance of the instance partition operations. + * Values are of the form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Optional. An expression that filters the list of returned operations. + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the Operation are eligible for filtering: + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [CreateInstancePartitionMetadata][google.spanner.admin.instance.v1.CreateInstancePartitionMetadata] + * is + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstancePartitionMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `done:true` - The operation is complete. + * * `(metadata.@type=` \ + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstancePartitionMetadata) + * AND` \ + * `(metadata.instance_partition.name:custom-instance-partition) AND` \ + * `(metadata.start_time < \"2021-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * [CreateInstancePartitionMetadata][google.spanner.admin.instance.v1.CreateInstancePartitionMetadata]. + * * The instance partition name contains "custom-instance-partition". + * * The operation started before 2021-03-28T14:50:00Z. + * * The operation resulted in an error. + * + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $filter = ''; + /** + * Optional. Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $page_size = 0; + /** + * Optional. If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse.next_page_token] + * from a previous + * [ListInstancePartitionOperationsResponse][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse] + * to the same `parent` and with the same `filter`. + * + * Generated from protobuf field string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $page_token = ''; + /** + * Optional. Deadline used while retrieving metadata for instance partition + * operations. Instance partitions whose operation metadata cannot be + * retrieved within this deadline will be added to + * [unreachable_instance_partitions][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse.unreachable_instance_partitions] + * in + * [ListInstancePartitionOperationsResponse][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse]. + * + * Generated from protobuf field .google.protobuf.Timestamp instance_partition_deadline = 5 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $instance_partition_deadline = null; + + /** + * @param string $parent Required. The parent instance of the instance partition operations. + * Values are of the form `projects//instances/`. Please see + * {@see InstanceAdminClient::instanceName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Instance\V1\ListInstancePartitionOperationsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The parent instance of the instance partition operations. + * Values are of the form `projects//instances/`. + * @type string $filter + * Optional. An expression that filters the list of returned operations. + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the Operation are eligible for filtering: + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [CreateInstancePartitionMetadata][google.spanner.admin.instance.v1.CreateInstancePartitionMetadata] + * is + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstancePartitionMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `done:true` - The operation is complete. + * * `(metadata.@type=` \ + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstancePartitionMetadata) + * AND` \ + * `(metadata.instance_partition.name:custom-instance-partition) AND` \ + * `(metadata.start_time < \"2021-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * [CreateInstancePartitionMetadata][google.spanner.admin.instance.v1.CreateInstancePartitionMetadata]. + * * The instance partition name contains "custom-instance-partition". + * * The operation started before 2021-03-28T14:50:00Z. + * * The operation resulted in an error. + * @type int $page_size + * Optional. Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @type string $page_token + * Optional. If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse.next_page_token] + * from a previous + * [ListInstancePartitionOperationsResponse][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse] + * to the same `parent` and with the same `filter`. + * @type \Google\Protobuf\Timestamp $instance_partition_deadline + * Optional. Deadline used while retrieving metadata for instance partition + * operations. Instance partitions whose operation metadata cannot be + * retrieved within this deadline will be added to + * [unreachable_instance_partitions][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse.unreachable_instance_partitions] + * in + * [ListInstancePartitionOperationsResponse][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The parent instance of the instance partition operations. + * Values are of the form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The parent instance of the instance partition operations. + * Values are of the form `projects//instances/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Optional. An expression that filters the list of returned operations. + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the Operation are eligible for filtering: + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [CreateInstancePartitionMetadata][google.spanner.admin.instance.v1.CreateInstancePartitionMetadata] + * is + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstancePartitionMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `done:true` - The operation is complete. + * * `(metadata.@type=` \ + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstancePartitionMetadata) + * AND` \ + * `(metadata.instance_partition.name:custom-instance-partition) AND` \ + * `(metadata.start_time < \"2021-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * [CreateInstancePartitionMetadata][google.spanner.admin.instance.v1.CreateInstancePartitionMetadata]. + * * The instance partition name contains "custom-instance-partition". + * * The operation started before 2021-03-28T14:50:00Z. + * * The operation resulted in an error. + * + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * Optional. An expression that filters the list of returned operations. + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * The following fields in the Operation are eligible for filtering: + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [CreateInstancePartitionMetadata][google.spanner.admin.instance.v1.CreateInstancePartitionMetadata] + * is + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstancePartitionMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * Here are a few examples: + * * `done:true` - The operation is complete. + * * `(metadata.@type=` \ + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstancePartitionMetadata) + * AND` \ + * `(metadata.instance_partition.name:custom-instance-partition) AND` \ + * `(metadata.start_time < \"2021-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * [CreateInstancePartitionMetadata][google.spanner.admin.instance.v1.CreateInstancePartitionMetadata]. + * * The instance partition name contains "custom-instance-partition". + * * The operation started before 2021-03-28T14:50:00Z. + * * The operation resulted in an error. + * + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * Optional. Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Optional. Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * Optional. If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse.next_page_token] + * from a previous + * [ListInstancePartitionOperationsResponse][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse] + * to the same `parent` and with the same `filter`. + * + * Generated from protobuf field string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Optional. If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse.next_page_token] + * from a previous + * [ListInstancePartitionOperationsResponse][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse] + * to the same `parent` and with the same `filter`. + * + * Generated from protobuf field string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + + /** + * Optional. Deadline used while retrieving metadata for instance partition + * operations. Instance partitions whose operation metadata cannot be + * retrieved within this deadline will be added to + * [unreachable_instance_partitions][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse.unreachable_instance_partitions] + * in + * [ListInstancePartitionOperationsResponse][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse]. + * + * Generated from protobuf field .google.protobuf.Timestamp instance_partition_deadline = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getInstancePartitionDeadline() + { + return $this->instance_partition_deadline; + } + + public function hasInstancePartitionDeadline() + { + return isset($this->instance_partition_deadline); + } + + public function clearInstancePartitionDeadline() + { + unset($this->instance_partition_deadline); + } + + /** + * Optional. Deadline used while retrieving metadata for instance partition + * operations. Instance partitions whose operation metadata cannot be + * retrieved within this deadline will be added to + * [unreachable_instance_partitions][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse.unreachable_instance_partitions] + * in + * [ListInstancePartitionOperationsResponse][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse]. + * + * Generated from protobuf field .google.protobuf.Timestamp instance_partition_deadline = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setInstancePartitionDeadline($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->instance_partition_deadline = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancePartitionOperationsResponse.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancePartitionOperationsResponse.php new file mode 100644 index 000000000000..06b112bd09d0 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancePartitionOperationsResponse.php @@ -0,0 +1,172 @@ +google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse + */ +class ListInstancePartitionOperationsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of matching instance partition long-running operations. Each + * operation's name will be + * prefixed by the instance partition's name. The operation's + * metadata field type + * `metadata.type_url` describes the type of the metadata. + * + * Generated from protobuf field repeated .google.longrunning.Operation operations = 1; + */ + private $operations; + /** + * `next_page_token` can be sent in a subsequent + * [ListInstancePartitionOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstancePartitionOperations] + * call to fetch more of the matching metadata. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + /** + * The list of unreachable instance partitions. + * It includes the names of instance partitions whose operation metadata could + * not be retrieved within + * [instance_partition_deadline][google.spanner.admin.instance.v1.ListInstancePartitionOperationsRequest.instance_partition_deadline]. + * + * Generated from protobuf field repeated string unreachable_instance_partitions = 3; + */ + private $unreachable_instance_partitions; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\LongRunning\Operation>|\Google\Protobuf\Internal\RepeatedField $operations + * The list of matching instance partition long-running operations. Each + * operation's name will be + * prefixed by the instance partition's name. The operation's + * metadata field type + * `metadata.type_url` describes the type of the metadata. + * @type string $next_page_token + * `next_page_token` can be sent in a subsequent + * [ListInstancePartitionOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstancePartitionOperations] + * call to fetch more of the matching metadata. + * @type array|\Google\Protobuf\Internal\RepeatedField $unreachable_instance_partitions + * The list of unreachable instance partitions. + * It includes the names of instance partitions whose operation metadata could + * not be retrieved within + * [instance_partition_deadline][google.spanner.admin.instance.v1.ListInstancePartitionOperationsRequest.instance_partition_deadline]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The list of matching instance partition long-running operations. Each + * operation's name will be + * prefixed by the instance partition's name. The operation's + * metadata field type + * `metadata.type_url` describes the type of the metadata. + * + * Generated from protobuf field repeated .google.longrunning.Operation operations = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOperations() + { + return $this->operations; + } + + /** + * The list of matching instance partition long-running operations. Each + * operation's name will be + * prefixed by the instance partition's name. The operation's + * metadata field type + * `metadata.type_url` describes the type of the metadata. + * + * Generated from protobuf field repeated .google.longrunning.Operation operations = 1; + * @param array<\Google\LongRunning\Operation>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOperations($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\LongRunning\Operation::class); + $this->operations = $arr; + + return $this; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListInstancePartitionOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstancePartitionOperations] + * call to fetch more of the matching metadata. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListInstancePartitionOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstancePartitionOperations] + * call to fetch more of the matching metadata. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + + /** + * The list of unreachable instance partitions. + * It includes the names of instance partitions whose operation metadata could + * not be retrieved within + * [instance_partition_deadline][google.spanner.admin.instance.v1.ListInstancePartitionOperationsRequest.instance_partition_deadline]. + * + * Generated from protobuf field repeated string unreachable_instance_partitions = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getUnreachableInstancePartitions() + { + return $this->unreachable_instance_partitions; + } + + /** + * The list of unreachable instance partitions. + * It includes the names of instance partitions whose operation metadata could + * not be retrieved within + * [instance_partition_deadline][google.spanner.admin.instance.v1.ListInstancePartitionOperationsRequest.instance_partition_deadline]. + * + * Generated from protobuf field repeated string unreachable_instance_partitions = 3; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setUnreachableInstancePartitions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->unreachable_instance_partitions = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancePartitionsRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancePartitionsRequest.php new file mode 100644 index 000000000000..73977cce1e50 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancePartitionsRequest.php @@ -0,0 +1,245 @@ +google.spanner.admin.instance.v1.ListInstancePartitionsRequest + */ +class ListInstancePartitionsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The instance whose instance partitions should be listed. Values + * are of the form `projects//instances/`. Use `{instance} + * = '-'` to list instance partitions for all Instances in a project, e.g., + * `projects/myproject/instances/-`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Number of instance partitions to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2; + */ + protected $page_size = 0; + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstancePartitionsResponse.next_page_token] + * from a previous + * [ListInstancePartitionsResponse][google.spanner.admin.instance.v1.ListInstancePartitionsResponse]. + * + * Generated from protobuf field string page_token = 3; + */ + protected $page_token = ''; + /** + * Optional. Deadline used while retrieving metadata for instance partitions. + * Instance partitions whose metadata cannot be retrieved within this deadline + * will be added to + * [unreachable][google.spanner.admin.instance.v1.ListInstancePartitionsResponse.unreachable] + * in + * [ListInstancePartitionsResponse][google.spanner.admin.instance.v1.ListInstancePartitionsResponse]. + * + * Generated from protobuf field .google.protobuf.Timestamp instance_partition_deadline = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $instance_partition_deadline = null; + + /** + * @param string $parent Required. The instance whose instance partitions should be listed. Values + * are of the form `projects//instances/`. Use `{instance} + * = '-'` to list instance partitions for all Instances in a project, e.g., + * `projects/myproject/instances/-`. Please see + * {@see InstanceAdminClient::instanceName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Instance\V1\ListInstancePartitionsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The instance whose instance partitions should be listed. Values + * are of the form `projects//instances/`. Use `{instance} + * = '-'` to list instance partitions for all Instances in a project, e.g., + * `projects/myproject/instances/-`. + * @type int $page_size + * Number of instance partitions to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * @type string $page_token + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstancePartitionsResponse.next_page_token] + * from a previous + * [ListInstancePartitionsResponse][google.spanner.admin.instance.v1.ListInstancePartitionsResponse]. + * @type \Google\Protobuf\Timestamp $instance_partition_deadline + * Optional. Deadline used while retrieving metadata for instance partitions. + * Instance partitions whose metadata cannot be retrieved within this deadline + * will be added to + * [unreachable][google.spanner.admin.instance.v1.ListInstancePartitionsResponse.unreachable] + * in + * [ListInstancePartitionsResponse][google.spanner.admin.instance.v1.ListInstancePartitionsResponse]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The instance whose instance partitions should be listed. Values + * are of the form `projects//instances/`. Use `{instance} + * = '-'` to list instance partitions for all Instances in a project, e.g., + * `projects/myproject/instances/-`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The instance whose instance partitions should be listed. Values + * are of the form `projects//instances/`. Use `{instance} + * = '-'` to list instance partitions for all Instances in a project, e.g., + * `projects/myproject/instances/-`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Number of instance partitions to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Number of instance partitions to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstancePartitionsResponse.next_page_token] + * from a previous + * [ListInstancePartitionsResponse][google.spanner.admin.instance.v1.ListInstancePartitionsResponse]. + * + * Generated from protobuf field string page_token = 3; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstancePartitionsResponse.next_page_token] + * from a previous + * [ListInstancePartitionsResponse][google.spanner.admin.instance.v1.ListInstancePartitionsResponse]. + * + * Generated from protobuf field string page_token = 3; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + + /** + * Optional. Deadline used while retrieving metadata for instance partitions. + * Instance partitions whose metadata cannot be retrieved within this deadline + * will be added to + * [unreachable][google.spanner.admin.instance.v1.ListInstancePartitionsResponse.unreachable] + * in + * [ListInstancePartitionsResponse][google.spanner.admin.instance.v1.ListInstancePartitionsResponse]. + * + * Generated from protobuf field .google.protobuf.Timestamp instance_partition_deadline = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getInstancePartitionDeadline() + { + return $this->instance_partition_deadline; + } + + public function hasInstancePartitionDeadline() + { + return isset($this->instance_partition_deadline); + } + + public function clearInstancePartitionDeadline() + { + unset($this->instance_partition_deadline); + } + + /** + * Optional. Deadline used while retrieving metadata for instance partitions. + * Instance partitions whose metadata cannot be retrieved within this deadline + * will be added to + * [unreachable][google.spanner.admin.instance.v1.ListInstancePartitionsResponse.unreachable] + * in + * [ListInstancePartitionsResponse][google.spanner.admin.instance.v1.ListInstancePartitionsResponse]. + * + * Generated from protobuf field .google.protobuf.Timestamp instance_partition_deadline = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setInstancePartitionDeadline($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->instance_partition_deadline = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancePartitionsResponse.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancePartitionsResponse.php new file mode 100644 index 000000000000..1aa093dc210b --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancePartitionsResponse.php @@ -0,0 +1,156 @@ +google.spanner.admin.instance.v1.ListInstancePartitionsResponse + */ +class ListInstancePartitionsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of requested instancePartitions. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.InstancePartition instance_partitions = 1; + */ + private $instance_partitions; + /** + * `next_page_token` can be sent in a subsequent + * [ListInstancePartitions][google.spanner.admin.instance.v1.InstanceAdmin.ListInstancePartitions] + * call to fetch more of the matching instance partitions. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + /** + * The list of unreachable instances or instance partitions. + * It includes the names of instances or instance partitions whose metadata + * could not be retrieved within + * [instance_partition_deadline][google.spanner.admin.instance.v1.ListInstancePartitionsRequest.instance_partition_deadline]. + * + * Generated from protobuf field repeated string unreachable = 3; + */ + private $unreachable; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition>|\Google\Protobuf\Internal\RepeatedField $instance_partitions + * The list of requested instancePartitions. + * @type string $next_page_token + * `next_page_token` can be sent in a subsequent + * [ListInstancePartitions][google.spanner.admin.instance.v1.InstanceAdmin.ListInstancePartitions] + * call to fetch more of the matching instance partitions. + * @type array|\Google\Protobuf\Internal\RepeatedField $unreachable + * The list of unreachable instances or instance partitions. + * It includes the names of instances or instance partitions whose metadata + * could not be retrieved within + * [instance_partition_deadline][google.spanner.admin.instance.v1.ListInstancePartitionsRequest.instance_partition_deadline]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The list of requested instancePartitions. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.InstancePartition instance_partitions = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getInstancePartitions() + { + return $this->instance_partitions; + } + + /** + * The list of requested instancePartitions. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.InstancePartition instance_partitions = 1; + * @param array<\Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setInstancePartitions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition::class); + $this->instance_partitions = $arr; + + return $this; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListInstancePartitions][google.spanner.admin.instance.v1.InstanceAdmin.ListInstancePartitions] + * call to fetch more of the matching instance partitions. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListInstancePartitions][google.spanner.admin.instance.v1.InstanceAdmin.ListInstancePartitions] + * call to fetch more of the matching instance partitions. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + + /** + * The list of unreachable instances or instance partitions. + * It includes the names of instances or instance partitions whose metadata + * could not be retrieved within + * [instance_partition_deadline][google.spanner.admin.instance.v1.ListInstancePartitionsRequest.instance_partition_deadline]. + * + * Generated from protobuf field repeated string unreachable = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getUnreachable() + { + return $this->unreachable; + } + + /** + * The list of unreachable instances or instance partitions. + * It includes the names of instances or instance partitions whose metadata + * could not be retrieved within + * [instance_partition_deadline][google.spanner.admin.instance.v1.ListInstancePartitionsRequest.instance_partition_deadline]. + * + * Generated from protobuf field repeated string unreachable = 3; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setUnreachable($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->unreachable = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancesRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancesRequest.php new file mode 100644 index 000000000000..acf67c1d3534 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancesRequest.php @@ -0,0 +1,329 @@ +google.spanner.admin.instance.v1.ListInstancesRequest + */ +class ListInstancesRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the project for which a list of instances is + * requested. Values are of the form `projects/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Number of instances to be returned in the response. If 0 or less, defaults + * to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2; + */ + protected $page_size = 0; + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token] + * from a previous + * [ListInstancesResponse][google.spanner.admin.instance.v1.ListInstancesResponse]. + * + * Generated from protobuf field string page_token = 3; + */ + protected $page_token = ''; + /** + * An expression for filtering the results of the request. Filter rules are + * case insensitive. The fields eligible for filtering are: + * * `name` + * * `display_name` + * * `labels.key` where key is the name of a label + * Some examples of using filters are: + * * `name:*` --> The instance has a name. + * * `name:Howl` --> The instance's name contains the string "howl". + * * `name:HOWL` --> Equivalent to above. + * * `NAME:howl` --> Equivalent to above. + * * `labels.env:*` --> The instance has the label "env". + * * `labels.env:dev` --> The instance has the label "env" and the value of + * the label contains the string "dev". + * * `name:howl labels.env:dev` --> The instance's name contains "howl" and + * it has the label "env" with its value + * containing "dev". + * + * Generated from protobuf field string filter = 4; + */ + protected $filter = ''; + /** + * Deadline used while retrieving metadata for instances. + * Instances whose metadata cannot be retrieved within this deadline will be + * added to + * [unreachable][google.spanner.admin.instance.v1.ListInstancesResponse.unreachable] + * in + * [ListInstancesResponse][google.spanner.admin.instance.v1.ListInstancesResponse]. + * + * Generated from protobuf field .google.protobuf.Timestamp instance_deadline = 5; + */ + protected $instance_deadline = null; + + /** + * @param string $parent Required. The name of the project for which a list of instances is + * requested. Values are of the form `projects/`. Please see + * {@see InstanceAdminClient::projectName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\Admin\Instance\V1\ListInstancesRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The name of the project for which a list of instances is + * requested. Values are of the form `projects/`. + * @type int $page_size + * Number of instances to be returned in the response. If 0 or less, defaults + * to the server's maximum allowed page size. + * @type string $page_token + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token] + * from a previous + * [ListInstancesResponse][google.spanner.admin.instance.v1.ListInstancesResponse]. + * @type string $filter + * An expression for filtering the results of the request. Filter rules are + * case insensitive. The fields eligible for filtering are: + * * `name` + * * `display_name` + * * `labels.key` where key is the name of a label + * Some examples of using filters are: + * * `name:*` --> The instance has a name. + * * `name:Howl` --> The instance's name contains the string "howl". + * * `name:HOWL` --> Equivalent to above. + * * `NAME:howl` --> Equivalent to above. + * * `labels.env:*` --> The instance has the label "env". + * * `labels.env:dev` --> The instance has the label "env" and the value of + * the label contains the string "dev". + * * `name:howl labels.env:dev` --> The instance's name contains "howl" and + * it has the label "env" with its value + * containing "dev". + * @type \Google\Protobuf\Timestamp $instance_deadline + * Deadline used while retrieving metadata for instances. + * Instances whose metadata cannot be retrieved within this deadline will be + * added to + * [unreachable][google.spanner.admin.instance.v1.ListInstancesResponse.unreachable] + * in + * [ListInstancesResponse][google.spanner.admin.instance.v1.ListInstancesResponse]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the project for which a list of instances is + * requested. Values are of the form `projects/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The name of the project for which a list of instances is + * requested. Values are of the form `projects/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Number of instances to be returned in the response. If 0 or less, defaults + * to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Number of instances to be returned in the response. If 0 or less, defaults + * to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token] + * from a previous + * [ListInstancesResponse][google.spanner.admin.instance.v1.ListInstancesResponse]. + * + * Generated from protobuf field string page_token = 3; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token] + * from a previous + * [ListInstancesResponse][google.spanner.admin.instance.v1.ListInstancesResponse]. + * + * Generated from protobuf field string page_token = 3; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + + /** + * An expression for filtering the results of the request. Filter rules are + * case insensitive. The fields eligible for filtering are: + * * `name` + * * `display_name` + * * `labels.key` where key is the name of a label + * Some examples of using filters are: + * * `name:*` --> The instance has a name. + * * `name:Howl` --> The instance's name contains the string "howl". + * * `name:HOWL` --> Equivalent to above. + * * `NAME:howl` --> Equivalent to above. + * * `labels.env:*` --> The instance has the label "env". + * * `labels.env:dev` --> The instance has the label "env" and the value of + * the label contains the string "dev". + * * `name:howl labels.env:dev` --> The instance's name contains "howl" and + * it has the label "env" with its value + * containing "dev". + * + * Generated from protobuf field string filter = 4; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * An expression for filtering the results of the request. Filter rules are + * case insensitive. The fields eligible for filtering are: + * * `name` + * * `display_name` + * * `labels.key` where key is the name of a label + * Some examples of using filters are: + * * `name:*` --> The instance has a name. + * * `name:Howl` --> The instance's name contains the string "howl". + * * `name:HOWL` --> Equivalent to above. + * * `NAME:howl` --> Equivalent to above. + * * `labels.env:*` --> The instance has the label "env". + * * `labels.env:dev` --> The instance has the label "env" and the value of + * the label contains the string "dev". + * * `name:howl labels.env:dev` --> The instance's name contains "howl" and + * it has the label "env" with its value + * containing "dev". + * + * Generated from protobuf field string filter = 4; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * Deadline used while retrieving metadata for instances. + * Instances whose metadata cannot be retrieved within this deadline will be + * added to + * [unreachable][google.spanner.admin.instance.v1.ListInstancesResponse.unreachable] + * in + * [ListInstancesResponse][google.spanner.admin.instance.v1.ListInstancesResponse]. + * + * Generated from protobuf field .google.protobuf.Timestamp instance_deadline = 5; + * @return \Google\Protobuf\Timestamp|null + */ + public function getInstanceDeadline() + { + return $this->instance_deadline; + } + + public function hasInstanceDeadline() + { + return isset($this->instance_deadline); + } + + public function clearInstanceDeadline() + { + unset($this->instance_deadline); + } + + /** + * Deadline used while retrieving metadata for instances. + * Instances whose metadata cannot be retrieved within this deadline will be + * added to + * [unreachable][google.spanner.admin.instance.v1.ListInstancesResponse.unreachable] + * in + * [ListInstancesResponse][google.spanner.admin.instance.v1.ListInstancesResponse]. + * + * Generated from protobuf field .google.protobuf.Timestamp instance_deadline = 5; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setInstanceDeadline($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->instance_deadline = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancesResponse.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancesResponse.php new file mode 100644 index 000000000000..cc134da2aac1 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ListInstancesResponse.php @@ -0,0 +1,156 @@ +google.spanner.admin.instance.v1.ListInstancesResponse + */ +class ListInstancesResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of requested instances. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.Instance instances = 1; + */ + private $instances; + /** + * `next_page_token` can be sent in a subsequent + * [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances] + * call to fetch more of the matching instances. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + /** + * The list of unreachable instances. + * It includes the names of instances whose metadata could not be retrieved + * within + * [instance_deadline][google.spanner.admin.instance.v1.ListInstancesRequest.instance_deadline]. + * + * Generated from protobuf field repeated string unreachable = 3; + */ + private $unreachable; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Spanner\Admin\Instance\V1\Instance>|\Google\Protobuf\Internal\RepeatedField $instances + * The list of requested instances. + * @type string $next_page_token + * `next_page_token` can be sent in a subsequent + * [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances] + * call to fetch more of the matching instances. + * @type array|\Google\Protobuf\Internal\RepeatedField $unreachable + * The list of unreachable instances. + * It includes the names of instances whose metadata could not be retrieved + * within + * [instance_deadline][google.spanner.admin.instance.v1.ListInstancesRequest.instance_deadline]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The list of requested instances. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.Instance instances = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getInstances() + { + return $this->instances; + } + + /** + * The list of requested instances. + * + * Generated from protobuf field repeated .google.spanner.admin.instance.v1.Instance instances = 1; + * @param array<\Google\Cloud\Spanner\Admin\Instance\V1\Instance>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setInstances($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\Admin\Instance\V1\Instance::class); + $this->instances = $arr; + + return $this; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances] + * call to fetch more of the matching instances. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances] + * call to fetch more of the matching instances. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + + /** + * The list of unreachable instances. + * It includes the names of instances whose metadata could not be retrieved + * within + * [instance_deadline][google.spanner.admin.instance.v1.ListInstancesRequest.instance_deadline]. + * + * Generated from protobuf field repeated string unreachable = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getUnreachable() + { + return $this->unreachable; + } + + /** + * The list of unreachable instances. + * It includes the names of instances whose metadata could not be retrieved + * within + * [instance_deadline][google.spanner.admin.instance.v1.ListInstancesRequest.instance_deadline]. + * + * Generated from protobuf field repeated string unreachable = 3; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setUnreachable($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->unreachable = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/MoveInstanceMetadata.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/MoveInstanceMetadata.php new file mode 100644 index 000000000000..e28ddbb7dc57 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/MoveInstanceMetadata.php @@ -0,0 +1,176 @@ +google.spanner.admin.instance.v1.MoveInstanceMetadata + */ +class MoveInstanceMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * The target instance configuration where to move the instance. + * Values are of the form `projects//instanceConfigs/`. + * + * Generated from protobuf field string target_config = 1; + */ + protected $target_config = ''; + /** + * The progress of the + * [MoveInstance][google.spanner.admin.instance.v1.InstanceAdmin.MoveInstance] + * operation. + * [progress_percent][google.spanner.admin.instance.v1.OperationProgress.progress_percent] + * is reset when cancellation is requested. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.OperationProgress progress = 2; + */ + protected $progress = null; + /** + * The time at which this operation was cancelled. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + */ + protected $cancel_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $target_config + * The target instance configuration where to move the instance. + * Values are of the form `projects//instanceConfigs/`. + * @type \Google\Cloud\Spanner\Admin\Instance\V1\OperationProgress $progress + * The progress of the + * [MoveInstance][google.spanner.admin.instance.v1.InstanceAdmin.MoveInstance] + * operation. + * [progress_percent][google.spanner.admin.instance.v1.OperationProgress.progress_percent] + * is reset when cancellation is requested. + * @type \Google\Protobuf\Timestamp $cancel_time + * The time at which this operation was cancelled. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The target instance configuration where to move the instance. + * Values are of the form `projects//instanceConfigs/`. + * + * Generated from protobuf field string target_config = 1; + * @return string + */ + public function getTargetConfig() + { + return $this->target_config; + } + + /** + * The target instance configuration where to move the instance. + * Values are of the form `projects//instanceConfigs/`. + * + * Generated from protobuf field string target_config = 1; + * @param string $var + * @return $this + */ + public function setTargetConfig($var) + { + GPBUtil::checkString($var, True); + $this->target_config = $var; + + return $this; + } + + /** + * The progress of the + * [MoveInstance][google.spanner.admin.instance.v1.InstanceAdmin.MoveInstance] + * operation. + * [progress_percent][google.spanner.admin.instance.v1.OperationProgress.progress_percent] + * is reset when cancellation is requested. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.OperationProgress progress = 2; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\OperationProgress|null + */ + public function getProgress() + { + return $this->progress; + } + + public function hasProgress() + { + return isset($this->progress); + } + + public function clearProgress() + { + unset($this->progress); + } + + /** + * The progress of the + * [MoveInstance][google.spanner.admin.instance.v1.InstanceAdmin.MoveInstance] + * operation. + * [progress_percent][google.spanner.admin.instance.v1.OperationProgress.progress_percent] + * is reset when cancellation is requested. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.OperationProgress progress = 2; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\OperationProgress $var + * @return $this + */ + public function setProgress($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\OperationProgress::class); + $this->progress = $var; + + return $this; + } + + /** + * The time at which this operation was cancelled. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCancelTime() + { + return $this->cancel_time; + } + + public function hasCancelTime() + { + return isset($this->cancel_time); + } + + public function clearCancelTime() + { + unset($this->cancel_time); + } + + /** + * The time at which this operation was cancelled. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCancelTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->cancel_time = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/MoveInstanceRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/MoveInstanceRequest.php new file mode 100644 index 000000000000..eb41cd923ea1 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/MoveInstanceRequest.php @@ -0,0 +1,110 @@ +google.spanner.admin.instance.v1.MoveInstanceRequest + */ +class MoveInstanceRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The instance to move. + * Values are of the form `projects//instances/`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + /** + * Required. The target instance configuration where to move the instance. + * Values are of the form `projects//instanceConfigs/`. + * + * Generated from protobuf field string target_config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $target_config = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The instance to move. + * Values are of the form `projects//instances/`. + * @type string $target_config + * Required. The target instance configuration where to move the instance. + * Values are of the form `projects//instanceConfigs/`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The instance to move. + * Values are of the form `projects//instances/`. + * + * 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. The instance to move. + * Values are of the form `projects//instances/`. + * + * 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; + } + + /** + * Required. The target instance configuration where to move the instance. + * Values are of the form `projects//instanceConfigs/`. + * + * Generated from protobuf field string target_config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getTargetConfig() + { + return $this->target_config; + } + + /** + * Required. The target instance configuration where to move the instance. + * Values are of the form `projects//instanceConfigs/`. + * + * Generated from protobuf field string target_config = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setTargetConfig($var) + { + GPBUtil::checkString($var, True); + $this->target_config = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/MoveInstanceResponse.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/MoveInstanceResponse.php new file mode 100644 index 000000000000..650c679eb1ba --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/MoveInstanceResponse.php @@ -0,0 +1,34 @@ +google.spanner.admin.instance.v1.MoveInstanceResponse + */ +class MoveInstanceResponse extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/OperationProgress.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/OperationProgress.php new file mode 100644 index 000000000000..e6b2e6c751d6 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/OperationProgress.php @@ -0,0 +1,164 @@ +google.spanner.admin.instance.v1.OperationProgress + */ +class OperationProgress extends \Google\Protobuf\Internal\Message +{ + /** + * Percent completion of the operation. + * Values are between 0 and 100 inclusive. + * + * Generated from protobuf field int32 progress_percent = 1; + */ + protected $progress_percent = 0; + /** + * Time the request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + */ + protected $start_time = null; + /** + * If set, the time at which this operation failed or was completed + * successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 3; + */ + protected $end_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $progress_percent + * Percent completion of the operation. + * Values are between 0 and 100 inclusive. + * @type \Google\Protobuf\Timestamp $start_time + * Time the request was received. + * @type \Google\Protobuf\Timestamp $end_time + * If set, the time at which this operation failed or was completed + * successfully. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\Common::initOnce(); + parent::__construct($data); + } + + /** + * Percent completion of the operation. + * Values are between 0 and 100 inclusive. + * + * Generated from protobuf field int32 progress_percent = 1; + * @return int + */ + public function getProgressPercent() + { + return $this->progress_percent; + } + + /** + * Percent completion of the operation. + * Values are between 0 and 100 inclusive. + * + * Generated from protobuf field int32 progress_percent = 1; + * @param int $var + * @return $this + */ + public function setProgressPercent($var) + { + GPBUtil::checkInt32($var); + $this->progress_percent = $var; + + return $this; + } + + /** + * Time the request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + * @return \Google\Protobuf\Timestamp|null + */ + public function getStartTime() + { + return $this->start_time; + } + + public function hasStartTime() + { + return isset($this->start_time); + } + + public function clearStartTime() + { + unset($this->start_time); + } + + /** + * Time the request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setStartTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->start_time = $var; + + return $this; + } + + /** + * If set, the time at which this operation failed or was completed + * successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 3; + * @return \Google\Protobuf\Timestamp|null + */ + public function getEndTime() + { + return $this->end_time; + } + + public function hasEndTime() + { + return isset($this->end_time); + } + + public function clearEndTime() + { + unset($this->end_time); + } + + /** + * If set, the time at which this operation failed or was completed + * successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 3; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setEndTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->end_time = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ReplicaComputeCapacity.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ReplicaComputeCapacity.php new file mode 100644 index 000000000000..551f8e34bf3a --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ReplicaComputeCapacity.php @@ -0,0 +1,169 @@ +google.spanner.admin.instance.v1.ReplicaComputeCapacity + */ +class ReplicaComputeCapacity extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Identifies replicas by specified properties. + * All replicas in the selection have the same amount of compute capacity. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.ReplicaSelection replica_selection = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $replica_selection = null; + protected $compute_capacity; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Instance\V1\ReplicaSelection $replica_selection + * Required. Identifies replicas by specified properties. + * All replicas in the selection have the same amount of compute capacity. + * @type int $node_count + * The number of nodes allocated to each replica. + * This may be zero in API responses for instances that are not yet in + * state `READY`. + * @type int $processing_units + * The number of processing units allocated to each replica. + * This may be zero in API responses for instances that are not yet in + * state `READY`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. Identifies replicas by specified properties. + * All replicas in the selection have the same amount of compute capacity. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.ReplicaSelection replica_selection = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\ReplicaSelection|null + */ + public function getReplicaSelection() + { + return $this->replica_selection; + } + + public function hasReplicaSelection() + { + return isset($this->replica_selection); + } + + public function clearReplicaSelection() + { + unset($this->replica_selection); + } + + /** + * Required. Identifies replicas by specified properties. + * All replicas in the selection have the same amount of compute capacity. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.ReplicaSelection replica_selection = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\ReplicaSelection $var + * @return $this + */ + public function setReplicaSelection($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\ReplicaSelection::class); + $this->replica_selection = $var; + + return $this; + } + + /** + * The number of nodes allocated to each replica. + * This may be zero in API responses for instances that are not yet in + * state `READY`. + * + * Generated from protobuf field int32 node_count = 2; + * @return int + */ + public function getNodeCount() + { + return $this->readOneof(2); + } + + public function hasNodeCount() + { + return $this->hasOneof(2); + } + + /** + * The number of nodes allocated to each replica. + * This may be zero in API responses for instances that are not yet in + * state `READY`. + * + * Generated from protobuf field int32 node_count = 2; + * @param int $var + * @return $this + */ + public function setNodeCount($var) + { + GPBUtil::checkInt32($var); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * The number of processing units allocated to each replica. + * This may be zero in API responses for instances that are not yet in + * state `READY`. + * + * Generated from protobuf field int32 processing_units = 3; + * @return int + */ + public function getProcessingUnits() + { + return $this->readOneof(3); + } + + public function hasProcessingUnits() + { + return $this->hasOneof(3); + } + + /** + * The number of processing units allocated to each replica. + * This may be zero in API responses for instances that are not yet in + * state `READY`. + * + * Generated from protobuf field int32 processing_units = 3; + * @param int $var + * @return $this + */ + public function setProcessingUnits($var) + { + GPBUtil::checkInt32($var); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * @return string + */ + public function getComputeCapacity() + { + return $this->whichOneof("compute_capacity"); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ReplicaInfo.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ReplicaInfo.php new file mode 100644 index 000000000000..c15ef502635c --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ReplicaInfo.php @@ -0,0 +1,145 @@ +google.spanner.admin.instance.v1.ReplicaInfo + */ +class ReplicaInfo extends \Google\Protobuf\Internal\Message +{ + /** + * The location of the serving resources, e.g., "us-central1". + * + * Generated from protobuf field string location = 1; + */ + protected $location = ''; + /** + * The type of replica. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType type = 2; + */ + protected $type = 0; + /** + * If true, this location is designated as the default leader location where + * leader replicas are placed. See the [region types + * documentation](https://cloud.google.com/spanner/docs/instances#region_types) + * for more details. + * + * Generated from protobuf field bool default_leader_location = 3; + */ + protected $default_leader_location = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $location + * The location of the serving resources, e.g., "us-central1". + * @type int $type + * The type of replica. + * @type bool $default_leader_location + * If true, this location is designated as the default leader location where + * leader replicas are placed. See the [region types + * documentation](https://cloud.google.com/spanner/docs/instances#region_types) + * for more details. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The location of the serving resources, e.g., "us-central1". + * + * Generated from protobuf field string location = 1; + * @return string + */ + public function getLocation() + { + return $this->location; + } + + /** + * The location of the serving resources, e.g., "us-central1". + * + * Generated from protobuf field string location = 1; + * @param string $var + * @return $this + */ + public function setLocation($var) + { + GPBUtil::checkString($var, True); + $this->location = $var; + + return $this; + } + + /** + * The type of replica. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType type = 2; + * @return int + */ + public function getType() + { + return $this->type; + } + + /** + * The type of replica. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType type = 2; + * @param int $var + * @return $this + */ + public function setType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Instance\V1\ReplicaInfo\ReplicaType::class); + $this->type = $var; + + return $this; + } + + /** + * If true, this location is designated as the default leader location where + * leader replicas are placed. See the [region types + * documentation](https://cloud.google.com/spanner/docs/instances#region_types) + * for more details. + * + * Generated from protobuf field bool default_leader_location = 3; + * @return bool + */ + public function getDefaultLeaderLocation() + { + return $this->default_leader_location; + } + + /** + * If true, this location is designated as the default leader location where + * leader replicas are placed. See the [region types + * documentation](https://cloud.google.com/spanner/docs/instances#region_types) + * for more details. + * + * Generated from protobuf field bool default_leader_location = 3; + * @param bool $var + * @return $this + */ + public function setDefaultLeaderLocation($var) + { + GPBUtil::checkBool($var); + $this->default_leader_location = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ReplicaInfo/ReplicaType.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ReplicaInfo/ReplicaType.php new file mode 100644 index 000000000000..dbf12281acfc --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ReplicaInfo/ReplicaType.php @@ -0,0 +1,87 @@ +google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType + */ +class ReplicaType +{ + /** + * Not specified. + * + * Generated from protobuf enum TYPE_UNSPECIFIED = 0; + */ + const TYPE_UNSPECIFIED = 0; + /** + * Read-write replicas support both reads and writes. These replicas: + * * Maintain a full copy of your data. + * * Serve reads. + * * Can vote whether to commit a write. + * * Participate in leadership election. + * * Are eligible to become a leader. + * + * Generated from protobuf enum READ_WRITE = 1; + */ + const READ_WRITE = 1; + /** + * Read-only replicas only support reads (not writes). Read-only replicas: + * * Maintain a full copy of your data. + * * Serve reads. + * * Do not participate in voting to commit writes. + * * Are not eligible to become a leader. + * + * Generated from protobuf enum READ_ONLY = 2; + */ + const READ_ONLY = 2; + /** + * Witness replicas don't support reads but do participate in voting to + * commit writes. Witness replicas: + * * Do not maintain a full copy of data. + * * Do not serve reads. + * * Vote whether to commit writes. + * * Participate in leader election but are not eligible to become leader. + * + * Generated from protobuf enum WITNESS = 3; + */ + const WITNESS = 3; + + private static $valueToName = [ + self::TYPE_UNSPECIFIED => 'TYPE_UNSPECIFIED', + self::READ_WRITE => 'READ_WRITE', + self::READ_ONLY => 'READ_ONLY', + self::WITNESS => 'WITNESS', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(ReplicaType::class, \Google\Cloud\Spanner\Admin\Instance\V1\ReplicaInfo_ReplicaType::class); + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ReplicaSelection.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ReplicaSelection.php new file mode 100644 index 000000000000..3485719a4c58 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/ReplicaSelection.php @@ -0,0 +1,67 @@ +google.spanner.admin.instance.v1.ReplicaSelection + */ +class ReplicaSelection extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Name of the location of the replicas (e.g., "us-central1"). + * + * Generated from protobuf field string location = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $location = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $location + * Required. Name of the location of the replicas (e.g., "us-central1"). + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\Common::initOnce(); + parent::__construct($data); + } + + /** + * Required. Name of the location of the replicas (e.g., "us-central1"). + * + * Generated from protobuf field string location = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getLocation() + { + return $this->location; + } + + /** + * Required. Name of the location of the replicas (e.g., "us-central1"). + * + * Generated from protobuf field string location = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setLocation($var) + { + GPBUtil::checkString($var, True); + $this->location = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstanceConfigMetadata.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstanceConfigMetadata.php new file mode 100644 index 000000000000..7f0c794b98c7 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstanceConfigMetadata.php @@ -0,0 +1,174 @@ +google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata + */ +class UpdateInstanceConfigMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * The desired instance configuration after updating. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig instance_config = 1; + */ + protected $instance_config = null; + /** + * The progress of the + * [UpdateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstanceConfig] + * operation. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.OperationProgress progress = 2; + */ + protected $progress = null; + /** + * The time at which this operation was cancelled. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + */ + protected $cancel_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig $instance_config + * The desired instance configuration after updating. + * @type \Google\Cloud\Spanner\Admin\Instance\V1\OperationProgress $progress + * The progress of the + * [UpdateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstanceConfig] + * operation. + * @type \Google\Protobuf\Timestamp $cancel_time + * The time at which this operation was cancelled. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The desired instance configuration after updating. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig instance_config = 1; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig|null + */ + public function getInstanceConfig() + { + return $this->instance_config; + } + + public function hasInstanceConfig() + { + return isset($this->instance_config); + } + + public function clearInstanceConfig() + { + unset($this->instance_config); + } + + /** + * The desired instance configuration after updating. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig instance_config = 1; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig $var + * @return $this + */ + public function setInstanceConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig::class); + $this->instance_config = $var; + + return $this; + } + + /** + * The progress of the + * [UpdateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstanceConfig] + * operation. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.OperationProgress progress = 2; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\OperationProgress|null + */ + public function getProgress() + { + return $this->progress; + } + + public function hasProgress() + { + return isset($this->progress); + } + + public function clearProgress() + { + unset($this->progress); + } + + /** + * The progress of the + * [UpdateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstanceConfig] + * operation. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.OperationProgress progress = 2; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\OperationProgress $var + * @return $this + */ + public function setProgress($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\OperationProgress::class); + $this->progress = $var; + + return $this; + } + + /** + * The time at which this operation was cancelled. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCancelTime() + { + return $this->cancel_time; + } + + public function hasCancelTime() + { + return isset($this->cancel_time); + } + + public function clearCancelTime() + { + unset($this->cancel_time); + } + + /** + * The time at which this operation was cancelled. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCancelTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->cancel_time = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstanceConfigRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstanceConfigRequest.php new file mode 100644 index 000000000000..c4078624f9fc --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstanceConfigRequest.php @@ -0,0 +1,230 @@ +google.spanner.admin.instance.v1.UpdateInstanceConfigRequest + */ +class UpdateInstanceConfigRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The user instance configuration to update, which must always + * include the instance configuration name. Otherwise, only fields mentioned + * in + * [update_mask][google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.update_mask] + * need be included. To prevent conflicts of concurrent updates, + * [etag][google.spanner.admin.instance.v1.InstanceConfig.reconciling] can + * be used. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig instance_config = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $instance_config = null; + /** + * Required. A mask specifying which fields in + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] should be + * updated. The field mask must always be specified; this prevents any future + * fields in [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] + * from being erased accidentally by clients that do not know about them. Only + * display_name and labels can be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $update_mask = null; + /** + * An option to validate, but not actually execute, a request, + * and provide the same response. + * + * Generated from protobuf field bool validate_only = 3; + */ + protected $validate_only = false; + + /** + * @param \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig $instanceConfig Required. The user instance configuration to update, which must always + * include the instance configuration name. Otherwise, only fields mentioned + * in + * [update_mask][google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.update_mask] + * need be included. To prevent conflicts of concurrent updates, + * [etag][google.spanner.admin.instance.v1.InstanceConfig.reconciling] can + * be used. + * @param \Google\Protobuf\FieldMask $updateMask Required. A mask specifying which fields in + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] should be + * updated. The field mask must always be specified; this prevents any future + * fields in [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] + * from being erased accidentally by clients that do not know about them. Only + * display_name and labels can be updated. + * + * @return \Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceConfigRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig $instanceConfig, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setInstanceConfig($instanceConfig) + ->setUpdateMask($updateMask); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig $instance_config + * Required. The user instance configuration to update, which must always + * include the instance configuration name. Otherwise, only fields mentioned + * in + * [update_mask][google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.update_mask] + * need be included. To prevent conflicts of concurrent updates, + * [etag][google.spanner.admin.instance.v1.InstanceConfig.reconciling] can + * be used. + * @type \Google\Protobuf\FieldMask $update_mask + * Required. A mask specifying which fields in + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] should be + * updated. The field mask must always be specified; this prevents any future + * fields in [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] + * from being erased accidentally by clients that do not know about them. Only + * display_name and labels can be updated. + * @type bool $validate_only + * An option to validate, but not actually execute, a request, + * and provide the same response. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The user instance configuration to update, which must always + * include the instance configuration name. Otherwise, only fields mentioned + * in + * [update_mask][google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.update_mask] + * need be included. To prevent conflicts of concurrent updates, + * [etag][google.spanner.admin.instance.v1.InstanceConfig.reconciling] can + * be used. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig instance_config = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig|null + */ + public function getInstanceConfig() + { + return $this->instance_config; + } + + public function hasInstanceConfig() + { + return isset($this->instance_config); + } + + public function clearInstanceConfig() + { + unset($this->instance_config); + } + + /** + * Required. The user instance configuration to update, which must always + * include the instance configuration name. Otherwise, only fields mentioned + * in + * [update_mask][google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.update_mask] + * need be included. To prevent conflicts of concurrent updates, + * [etag][google.spanner.admin.instance.v1.InstanceConfig.reconciling] can + * be used. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstanceConfig instance_config = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig $var + * @return $this + */ + public function setInstanceConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig::class); + $this->instance_config = $var; + + return $this; + } + + /** + * Required. A mask specifying which fields in + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] should be + * updated. The field mask must always be specified; this prevents any future + * fields in [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] + * from being erased accidentally by clients that do not know about them. Only + * display_name and labels can be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\FieldMask|null + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + + /** + * Required. A mask specifying which fields in + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] should be + * updated. The field mask must always be specified; this prevents any future + * fields in [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] + * from being erased accidentally by clients that do not know about them. Only + * display_name and labels can be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + + /** + * An option to validate, but not actually execute, a request, + * and provide the same response. + * + * Generated from protobuf field bool validate_only = 3; + * @return bool + */ + public function getValidateOnly() + { + return $this->validate_only; + } + + /** + * An option to validate, but not actually execute, a request, + * and provide the same response. + * + * Generated from protobuf field bool validate_only = 3; + * @param bool $var + * @return $this + */ + public function setValidateOnly($var) + { + GPBUtil::checkBool($var); + $this->validate_only = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstanceMetadata.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstanceMetadata.php new file mode 100644 index 000000000000..75231230c5bc --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstanceMetadata.php @@ -0,0 +1,260 @@ +google.spanner.admin.instance.v1.UpdateInstanceMetadata + */ +class UpdateInstanceMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * The desired end state of the update. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance instance = 1; + */ + protected $instance = null; + /** + * The time at which + * [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance] + * request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + */ + protected $start_time = null; + /** + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is guaranteed to succeed) and + * cannot be cancelled again. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + */ + protected $cancel_time = null; + /** + * The time at which this operation failed or was completed successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 4; + */ + protected $end_time = null; + /** + * The expected fulfillment period of this update operation. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.FulfillmentPeriod expected_fulfillment_period = 5; + */ + protected $expected_fulfillment_period = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Instance\V1\Instance $instance + * The desired end state of the update. + * @type \Google\Protobuf\Timestamp $start_time + * The time at which + * [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance] + * request was received. + * @type \Google\Protobuf\Timestamp $cancel_time + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is guaranteed to succeed) and + * cannot be cancelled again. + * @type \Google\Protobuf\Timestamp $end_time + * The time at which this operation failed or was completed successfully. + * @type int $expected_fulfillment_period + * The expected fulfillment period of this update operation. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The desired end state of the update. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance instance = 1; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\Instance|null + */ + public function getInstance() + { + return $this->instance; + } + + public function hasInstance() + { + return isset($this->instance); + } + + public function clearInstance() + { + unset($this->instance); + } + + /** + * The desired end state of the update. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance instance = 1; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\Instance $var + * @return $this + */ + public function setInstance($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\Instance::class); + $this->instance = $var; + + return $this; + } + + /** + * The time at which + * [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance] + * request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + * @return \Google\Protobuf\Timestamp|null + */ + public function getStartTime() + { + return $this->start_time; + } + + public function hasStartTime() + { + return isset($this->start_time); + } + + public function clearStartTime() + { + unset($this->start_time); + } + + /** + * The time at which + * [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance] + * request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setStartTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->start_time = $var; + + return $this; + } + + /** + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is guaranteed to succeed) and + * cannot be cancelled again. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCancelTime() + { + return $this->cancel_time; + } + + public function hasCancelTime() + { + return isset($this->cancel_time); + } + + public function clearCancelTime() + { + unset($this->cancel_time); + } + + /** + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is guaranteed to succeed) and + * cannot be cancelled again. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCancelTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->cancel_time = $var; + + return $this; + } + + /** + * The time at which this operation failed or was completed successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 4; + * @return \Google\Protobuf\Timestamp|null + */ + public function getEndTime() + { + return $this->end_time; + } + + public function hasEndTime() + { + return isset($this->end_time); + } + + public function clearEndTime() + { + unset($this->end_time); + } + + /** + * The time at which this operation failed or was completed successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 4; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setEndTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->end_time = $var; + + return $this; + } + + /** + * The expected fulfillment period of this update operation. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.FulfillmentPeriod expected_fulfillment_period = 5; + * @return int + */ + public function getExpectedFulfillmentPeriod() + { + return $this->expected_fulfillment_period; + } + + /** + * The expected fulfillment period of this update operation. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.FulfillmentPeriod expected_fulfillment_period = 5; + * @param int $var + * @return $this + */ + public function setExpectedFulfillmentPeriod($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\Admin\Instance\V1\FulfillmentPeriod::class); + $this->expected_fulfillment_period = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstancePartitionMetadata.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstancePartitionMetadata.php new file mode 100644 index 000000000000..7d36e9dc23bd --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstancePartitionMetadata.php @@ -0,0 +1,226 @@ +google.spanner.admin.instance.v1.UpdateInstancePartitionMetadata + */ +class UpdateInstancePartitionMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * The desired end state of the update. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstancePartition instance_partition = 1; + */ + protected $instance_partition = null; + /** + * The time at which + * [UpdateInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstancePartition] + * request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + */ + protected $start_time = null; + /** + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is guaranteed to succeed) and + * cannot be cancelled again. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + */ + protected $cancel_time = null; + /** + * The time at which this operation failed or was completed successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 4; + */ + protected $end_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition $instance_partition + * The desired end state of the update. + * @type \Google\Protobuf\Timestamp $start_time + * The time at which + * [UpdateInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstancePartition] + * request was received. + * @type \Google\Protobuf\Timestamp $cancel_time + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is guaranteed to succeed) and + * cannot be cancelled again. + * @type \Google\Protobuf\Timestamp $end_time + * The time at which this operation failed or was completed successfully. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * The desired end state of the update. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstancePartition instance_partition = 1; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition|null + */ + public function getInstancePartition() + { + return $this->instance_partition; + } + + public function hasInstancePartition() + { + return isset($this->instance_partition); + } + + public function clearInstancePartition() + { + unset($this->instance_partition); + } + + /** + * The desired end state of the update. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstancePartition instance_partition = 1; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition $var + * @return $this + */ + public function setInstancePartition($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition::class); + $this->instance_partition = $var; + + return $this; + } + + /** + * The time at which + * [UpdateInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstancePartition] + * request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + * @return \Google\Protobuf\Timestamp|null + */ + public function getStartTime() + { + return $this->start_time; + } + + public function hasStartTime() + { + return isset($this->start_time); + } + + public function clearStartTime() + { + unset($this->start_time); + } + + /** + * The time at which + * [UpdateInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstancePartition] + * request was received. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setStartTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->start_time = $var; + + return $this; + } + + /** + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is guaranteed to succeed) and + * cannot be cancelled again. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCancelTime() + { + return $this->cancel_time; + } + + public function hasCancelTime() + { + return isset($this->cancel_time); + } + + public function clearCancelTime() + { + unset($this->cancel_time); + } + + /** + * The time at which this operation was cancelled. If set, this operation is + * in the process of undoing itself (which is guaranteed to succeed) and + * cannot be cancelled again. + * + * Generated from protobuf field .google.protobuf.Timestamp cancel_time = 3; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCancelTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->cancel_time = $var; + + return $this; + } + + /** + * The time at which this operation failed or was completed successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 4; + * @return \Google\Protobuf\Timestamp|null + */ + public function getEndTime() + { + return $this->end_time; + } + + public function hasEndTime() + { + return isset($this->end_time); + } + + public function clearEndTime() + { + unset($this->end_time); + } + + /** + * The time at which this operation failed or was completed successfully. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 4; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setEndTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->end_time = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstancePartitionRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstancePartitionRequest.php new file mode 100644 index 000000000000..8cab2a4ee3fa --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstancePartitionRequest.php @@ -0,0 +1,177 @@ +google.spanner.admin.instance.v1.UpdateInstancePartitionRequest + */ +class UpdateInstancePartitionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The instance partition to update, which must always include the + * instance partition name. Otherwise, only fields mentioned in + * [field_mask][google.spanner.admin.instance.v1.UpdateInstancePartitionRequest.field_mask] + * need be included. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstancePartition instance_partition = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $instance_partition = null; + /** + * Required. A mask specifying which fields in + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition] + * should be updated. The field mask must always be specified; this prevents + * any future fields in + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition] + * from being erased accidentally by clients that do not know about them. + * + * Generated from protobuf field .google.protobuf.FieldMask field_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $field_mask = null; + + /** + * @param \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition $instancePartition Required. The instance partition to update, which must always include the + * instance partition name. Otherwise, only fields mentioned in + * [field_mask][google.spanner.admin.instance.v1.UpdateInstancePartitionRequest.field_mask] + * need be included. + * @param \Google\Protobuf\FieldMask $fieldMask Required. A mask specifying which fields in + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition] + * should be updated. The field mask must always be specified; this prevents + * any future fields in + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition] + * from being erased accidentally by clients that do not know about them. + * + * @return \Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstancePartitionRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition $instancePartition, \Google\Protobuf\FieldMask $fieldMask): self + { + return (new self()) + ->setInstancePartition($instancePartition) + ->setFieldMask($fieldMask); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition $instance_partition + * Required. The instance partition to update, which must always include the + * instance partition name. Otherwise, only fields mentioned in + * [field_mask][google.spanner.admin.instance.v1.UpdateInstancePartitionRequest.field_mask] + * need be included. + * @type \Google\Protobuf\FieldMask $field_mask + * Required. A mask specifying which fields in + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition] + * should be updated. The field mask must always be specified; this prevents + * any future fields in + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition] + * from being erased accidentally by clients that do not know about them. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The instance partition to update, which must always include the + * instance partition name. Otherwise, only fields mentioned in + * [field_mask][google.spanner.admin.instance.v1.UpdateInstancePartitionRequest.field_mask] + * need be included. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstancePartition instance_partition = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition|null + */ + public function getInstancePartition() + { + return $this->instance_partition; + } + + public function hasInstancePartition() + { + return isset($this->instance_partition); + } + + public function clearInstancePartition() + { + unset($this->instance_partition); + } + + /** + * Required. The instance partition to update, which must always include the + * instance partition name. Otherwise, only fields mentioned in + * [field_mask][google.spanner.admin.instance.v1.UpdateInstancePartitionRequest.field_mask] + * need be included. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.InstancePartition instance_partition = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition $var + * @return $this + */ + public function setInstancePartition($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition::class); + $this->instance_partition = $var; + + return $this; + } + + /** + * Required. A mask specifying which fields in + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition] + * should be updated. The field mask must always be specified; this prevents + * any future fields in + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition] + * from being erased accidentally by clients that do not know about them. + * + * Generated from protobuf field .google.protobuf.FieldMask field_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\FieldMask|null + */ + public function getFieldMask() + { + return $this->field_mask; + } + + public function hasFieldMask() + { + return isset($this->field_mask); + } + + public function clearFieldMask() + { + unset($this->field_mask); + } + + /** + * Required. A mask specifying which fields in + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition] + * should be updated. The field mask must always be specified; this prevents + * any future fields in + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition] + * from being erased accidentally by clients that do not know about them. + * + * Generated from protobuf field .google.protobuf.FieldMask field_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setFieldMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->field_mask = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstanceRequest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstanceRequest.php new file mode 100644 index 000000000000..f787f2e812ec --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/proto/src/Google/Cloud/Spanner/Admin/Instance/V1/UpdateInstanceRequest.php @@ -0,0 +1,172 @@ +google.spanner.admin.instance.v1.UpdateInstanceRequest + */ +class UpdateInstanceRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The instance to update, which must always include the instance + * name. Otherwise, only fields mentioned in + * [field_mask][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] + * need be included. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance instance = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $instance = null; + /** + * Required. A mask specifying which fields in + * [Instance][google.spanner.admin.instance.v1.Instance] should be updated. + * The field mask must always be specified; this prevents any future fields in + * [Instance][google.spanner.admin.instance.v1.Instance] from being erased + * accidentally by clients that do not know about them. + * + * Generated from protobuf field .google.protobuf.FieldMask field_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $field_mask = null; + + /** + * @param \Google\Cloud\Spanner\Admin\Instance\V1\Instance $instance Required. The instance to update, which must always include the instance + * name. Otherwise, only fields mentioned in + * [field_mask][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] + * need be included. + * @param \Google\Protobuf\FieldMask $fieldMask Required. A mask specifying which fields in + * [Instance][google.spanner.admin.instance.v1.Instance] should be updated. + * The field mask must always be specified; this prevents any future fields in + * [Instance][google.spanner.admin.instance.v1.Instance] from being erased + * accidentally by clients that do not know about them. + * + * @return \Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Spanner\Admin\Instance\V1\Instance $instance, \Google\Protobuf\FieldMask $fieldMask): self + { + return (new self()) + ->setInstance($instance) + ->setFieldMask($fieldMask); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Instance\V1\Instance $instance + * Required. The instance to update, which must always include the instance + * name. Otherwise, only fields mentioned in + * [field_mask][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] + * need be included. + * @type \Google\Protobuf\FieldMask $field_mask + * Required. A mask specifying which fields in + * [Instance][google.spanner.admin.instance.v1.Instance] should be updated. + * The field mask must always be specified; this prevents any future fields in + * [Instance][google.spanner.admin.instance.v1.Instance] from being erased + * accidentally by clients that do not know about them. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The instance to update, which must always include the instance + * name. Otherwise, only fields mentioned in + * [field_mask][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] + * need be included. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance instance = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\Instance|null + */ + public function getInstance() + { + return $this->instance; + } + + public function hasInstance() + { + return isset($this->instance); + } + + public function clearInstance() + { + unset($this->instance); + } + + /** + * Required. The instance to update, which must always include the instance + * name. Otherwise, only fields mentioned in + * [field_mask][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] + * need be included. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.Instance instance = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\Instance $var + * @return $this + */ + public function setInstance($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\Instance::class); + $this->instance = $var; + + return $this; + } + + /** + * Required. A mask specifying which fields in + * [Instance][google.spanner.admin.instance.v1.Instance] should be updated. + * The field mask must always be specified; this prevents any future fields in + * [Instance][google.spanner.admin.instance.v1.Instance] from being erased + * accidentally by clients that do not know about them. + * + * Generated from protobuf field .google.protobuf.FieldMask field_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\FieldMask|null + */ + public function getFieldMask() + { + return $this->field_mask; + } + + public function hasFieldMask() + { + return isset($this->field_mask); + } + + public function clearFieldMask() + { + unset($this->field_mask); + } + + /** + * Required. A mask specifying which fields in + * [Instance][google.spanner.admin.instance.v1.Instance] should be updated. + * The field mask must always be specified; this prevents any future fields in + * [Instance][google.spanner.admin.instance.v1.Instance] from being erased + * accidentally by clients that do not know about them. + * + * Generated from protobuf field .google.protobuf.FieldMask field_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setFieldMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->field_mask = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/create_instance.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/create_instance.php new file mode 100644 index 000000000000..c3d315021f0d --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/create_instance.php @@ -0,0 +1,155 @@ +/operations/` and + * can be used to track creation of the instance. The + * metadata field type is + * [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. + * The response field type is + * [Instance][google.spanner.admin.instance.v1.Instance], if successful. + * + * @param string $formattedParent The name of the project in which to create the instance. Values + * are of the form `projects/`. Please see + * {@see InstanceAdminClient::projectName()} for help formatting this field. + * @param string $instanceId The ID of the instance to create. Valid identifiers are of the + * form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 characters in + * length. + * @param string $instanceName A unique identifier for the instance, which cannot be changed + * after the instance is created. Values are of the form + * `projects//instances/[a-z][-a-z0-9]*[a-z0-9]`. The final + * segment of the name must be between 2 and 64 characters in length. + * @param string $formattedInstanceConfig The name of the instance's configuration. Values are of the form + * `projects//instanceConfigs/`. See + * also [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] and + * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. Please see + * {@see InstanceAdminClient::instanceConfigName()} for help formatting this field. + * @param string $instanceDisplayName The descriptive name for this instance as it appears in UIs. + * Must be unique per project and between 4 and 30 characters in length. + */ +function create_instance_sample( + string $formattedParent, + string $instanceId, + string $instanceName, + string $formattedInstanceConfig, + string $instanceDisplayName +): void { + // Create a client. + $instanceAdminClient = new InstanceAdminClient(); + + // Prepare the request message. + $instance = (new Instance()) + ->setName($instanceName) + ->setConfig($formattedInstanceConfig) + ->setDisplayName($instanceDisplayName); + $request = (new CreateInstanceRequest()) + ->setParent($formattedParent) + ->setInstanceId($instanceId) + ->setInstance($instance); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $instanceAdminClient->createInstance($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Instance $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * 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 = InstanceAdminClient::projectName('[PROJECT]'); + $instanceId = '[INSTANCE_ID]'; + $instanceName = '[NAME]'; + $formattedInstanceConfig = InstanceAdminClient::instanceConfigName( + '[PROJECT]', + '[INSTANCE_CONFIG]' + ); + $instanceDisplayName = '[DISPLAY_NAME]'; + + create_instance_sample( + $formattedParent, + $instanceId, + $instanceName, + $formattedInstanceConfig, + $instanceDisplayName + ); +} +// [END spanner_v1_generated_InstanceAdmin_CreateInstance_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/create_instance_config.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/create_instance_config.php new file mode 100644 index 000000000000..a84bb609082a --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/create_instance_config.php @@ -0,0 +1,132 @@ +/operations/` and can be used to track + * creation of the instance configuration. The + * metadata field type is + * [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata]. + * The response field type is + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if + * successful. + * + * Authorization requires `spanner.instanceConfigs.create` permission on + * the resource + * [parent][google.spanner.admin.instance.v1.CreateInstanceConfigRequest.parent]. + * + * @param string $formattedParent The name of the project in which to create the instance + * configuration. Values are of the form `projects/`. Please see + * {@see InstanceAdminClient::projectName()} for help formatting this field. + * @param string $instanceConfigId The ID of the instance configuration to create. Valid identifiers + * are of the form `custom-[-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + * characters in length. The `custom-` prefix is required to avoid name + * conflicts with Google-managed configurations. + */ +function create_instance_config_sample(string $formattedParent, string $instanceConfigId): void +{ + // Create a client. + $instanceAdminClient = new InstanceAdminClient(); + + // Prepare the request message. + $instanceConfig = new InstanceConfig(); + $request = (new CreateInstanceConfigRequest()) + ->setParent($formattedParent) + ->setInstanceConfigId($instanceConfigId) + ->setInstanceConfig($instanceConfig); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $instanceAdminClient->createInstanceConfig($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var InstanceConfig $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * 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 = InstanceAdminClient::projectName('[PROJECT]'); + $instanceConfigId = '[INSTANCE_CONFIG_ID]'; + + create_instance_config_sample($formattedParent, $instanceConfigId); +} +// [END spanner_v1_generated_InstanceAdmin_CreateInstanceConfig_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/create_instance_partition.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/create_instance_partition.php new file mode 100644 index 000000000000..09ac8d5ecbf3 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/create_instance_partition.php @@ -0,0 +1,161 @@ +/operations/` and can be used to + * track creation of the instance partition. The + * metadata field type is + * [CreateInstancePartitionMetadata][google.spanner.admin.instance.v1.CreateInstancePartitionMetadata]. + * The response field type is + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition], if + * successful. + * + * @param string $formattedParent The name of the instance in which to create the instance + * partition. Values are of the form + * `projects//instances/`. Please see + * {@see InstanceAdminClient::instanceName()} for help formatting this field. + * @param string $instancePartitionId The ID of the instance partition to create. Valid identifiers are + * of the form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + * characters in length. + * @param string $instancePartitionName A unique identifier for the instance partition. Values are of the + * form + * `projects//instances//instancePartitions/[a-z][-a-z0-9]*[a-z0-9]`. + * The final segment of the name must be between 2 and 64 characters in + * length. An instance partition's name cannot be changed after the instance + * partition is created. + * @param string $formattedInstancePartitionConfig The name of the instance partition's configuration. Values are of + * the form `projects//instanceConfigs/`. See also + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] and + * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. Please see + * {@see InstanceAdminClient::instanceConfigName()} for help formatting this field. + * @param string $instancePartitionDisplayName The descriptive name for this instance partition as it appears in + * UIs. Must be unique per project and between 4 and 30 characters in length. + */ +function create_instance_partition_sample( + string $formattedParent, + string $instancePartitionId, + string $instancePartitionName, + string $formattedInstancePartitionConfig, + string $instancePartitionDisplayName +): void { + // Create a client. + $instanceAdminClient = new InstanceAdminClient(); + + // Prepare the request message. + $instancePartition = (new InstancePartition()) + ->setName($instancePartitionName) + ->setConfig($formattedInstancePartitionConfig) + ->setDisplayName($instancePartitionDisplayName); + $request = (new CreateInstancePartitionRequest()) + ->setParent($formattedParent) + ->setInstancePartitionId($instancePartitionId) + ->setInstancePartition($instancePartition); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $instanceAdminClient->createInstancePartition($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var InstancePartition $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * 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 = InstanceAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + $instancePartitionId = '[INSTANCE_PARTITION_ID]'; + $instancePartitionName = '[NAME]'; + $formattedInstancePartitionConfig = InstanceAdminClient::instanceConfigName( + '[PROJECT]', + '[INSTANCE_CONFIG]' + ); + $instancePartitionDisplayName = '[DISPLAY_NAME]'; + + create_instance_partition_sample( + $formattedParent, + $instancePartitionId, + $instancePartitionName, + $formattedInstancePartitionConfig, + $instancePartitionDisplayName + ); +} +// [END spanner_v1_generated_InstanceAdmin_CreateInstancePartition_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/delete_instance.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/delete_instance.php new file mode 100644 index 000000000000..acf410ee2dd3 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/delete_instance.php @@ -0,0 +1,80 @@ +/instances/` + * Please see {@see InstanceAdminClient::instanceName()} for help formatting this field. + */ +function delete_instance_sample(string $formattedName): void +{ + // Create a client. + $instanceAdminClient = new InstanceAdminClient(); + + // Prepare the request message. + $request = (new DeleteInstanceRequest()) + ->setName($formattedName); + + // Call the API and handle any network failures. + try { + $instanceAdminClient->deleteInstance($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 = InstanceAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + + delete_instance_sample($formattedName); +} +// [END spanner_v1_generated_InstanceAdmin_DeleteInstance_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/delete_instance_config.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/delete_instance_config.php new file mode 100644 index 000000000000..e017057244f2 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/delete_instance_config.php @@ -0,0 +1,78 @@ +/instanceConfigs/` + * Please see {@see InstanceAdminClient::instanceConfigName()} for help formatting this field. + */ +function delete_instance_config_sample(string $formattedName): void +{ + // Create a client. + $instanceAdminClient = new InstanceAdminClient(); + + // Prepare the request message. + $request = (new DeleteInstanceConfigRequest()) + ->setName($formattedName); + + // Call the API and handle any network failures. + try { + $instanceAdminClient->deleteInstanceConfig($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 = InstanceAdminClient::instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + + delete_instance_config_sample($formattedName); +} +// [END spanner_v1_generated_InstanceAdmin_DeleteInstanceConfig_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/delete_instance_partition.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/delete_instance_partition.php new file mode 100644 index 000000000000..fd8162657462 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/delete_instance_partition.php @@ -0,0 +1,81 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + $instanceAdminClient->deleteInstancePartition($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 = InstanceAdminClient::instancePartitionName( + '[PROJECT]', + '[INSTANCE]', + '[INSTANCE_PARTITION]' + ); + + delete_instance_partition_sample($formattedName); +} +// [END spanner_v1_generated_InstanceAdmin_DeleteInstancePartition_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/get_iam_policy.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/get_iam_policy.php new file mode 100644 index 000000000000..617ecc2df332 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/get_iam_policy.php @@ -0,0 +1,75 @@ +setResource($resource); + + // Call the API and handle any network failures. + try { + /** @var Policy $response */ + $response = $instanceAdminClient->getIamPolicy($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 +{ + $resource = '[RESOURCE]'; + + get_iam_policy_sample($resource); +} +// [END spanner_v1_generated_InstanceAdmin_GetIamPolicy_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/get_instance.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/get_instance.php new file mode 100644 index 000000000000..2ab84c8c825c --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/get_instance.php @@ -0,0 +1,72 @@ +/instances/`. Please see + * {@see InstanceAdminClient::instanceName()} for help formatting this field. + */ +function get_instance_sample(string $formattedName): void +{ + // Create a client. + $instanceAdminClient = new InstanceAdminClient(); + + // Prepare the request message. + $request = (new GetInstanceRequest()) + ->setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var Instance $response */ + $response = $instanceAdminClient->getInstance($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 = InstanceAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + + get_instance_sample($formattedName); +} +// [END spanner_v1_generated_InstanceAdmin_GetInstance_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/get_instance_config.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/get_instance_config.php new file mode 100644 index 000000000000..087415caa6da --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/get_instance_config.php @@ -0,0 +1,72 @@ +/instanceConfigs/`. Please see + * {@see InstanceAdminClient::instanceConfigName()} for help formatting this field. + */ +function get_instance_config_sample(string $formattedName): void +{ + // Create a client. + $instanceAdminClient = new InstanceAdminClient(); + + // Prepare the request message. + $request = (new GetInstanceConfigRequest()) + ->setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var InstanceConfig $response */ + $response = $instanceAdminClient->getInstanceConfig($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 = InstanceAdminClient::instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + + get_instance_config_sample($formattedName); +} +// [END spanner_v1_generated_InstanceAdmin_GetInstanceConfig_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/get_instance_partition.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/get_instance_partition.php new file mode 100644 index 000000000000..54ee5059cd63 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/get_instance_partition.php @@ -0,0 +1,77 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var InstancePartition $response */ + $response = $instanceAdminClient->getInstancePartition($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 = InstanceAdminClient::instancePartitionName( + '[PROJECT]', + '[INSTANCE]', + '[INSTANCE_PARTITION]' + ); + + get_instance_partition_sample($formattedName); +} +// [END spanner_v1_generated_InstanceAdmin_GetInstancePartition_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/list_instance_config_operations.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/list_instance_config_operations.php new file mode 100644 index 000000000000..cdd490164b0f --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/list_instance_config_operations.php @@ -0,0 +1,87 @@ +/instanceConfigs//operations/`. + * The long-running operation + * metadata field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. Operations returned are ordered by + * `operation.metadata.value.start_time` in descending order starting + * from the most recently started operation. + * + * @param string $formattedParent The project of the instance configuration operations. + * Values are of the form `projects/`. Please see + * {@see InstanceAdminClient::projectName()} for help formatting this field. + */ +function list_instance_config_operations_sample(string $formattedParent): void +{ + // Create a client. + $instanceAdminClient = new InstanceAdminClient(); + + // Prepare the request message. + $request = (new ListInstanceConfigOperationsRequest()) + ->setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $instanceAdminClient->listInstanceConfigOperations($request); + + /** @var Operation $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()); + } +} + +/** + * 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 = InstanceAdminClient::projectName('[PROJECT]'); + + list_instance_config_operations_sample($formattedParent); +} +// [END spanner_v1_generated_InstanceAdmin_ListInstanceConfigOperations_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/list_instance_configs.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/list_instance_configs.php new file mode 100644 index 000000000000..a68208ba7873 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/list_instance_configs.php @@ -0,0 +1,81 @@ +`. Please see + * {@see InstanceAdminClient::projectName()} for help formatting this field. + */ +function list_instance_configs_sample(string $formattedParent): void +{ + // Create a client. + $instanceAdminClient = new InstanceAdminClient(); + + // Prepare the request message. + $request = (new ListInstanceConfigsRequest()) + ->setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $instanceAdminClient->listInstanceConfigs($request); + + /** @var InstanceConfig $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()); + } +} + +/** + * 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 = InstanceAdminClient::projectName('[PROJECT]'); + + list_instance_configs_sample($formattedParent); +} +// [END spanner_v1_generated_InstanceAdmin_ListInstanceConfigs_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/list_instance_partition_operations.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/list_instance_partition_operations.php new file mode 100644 index 000000000000..0ef611f61375 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/list_instance_partition_operations.php @@ -0,0 +1,90 @@ +/instances//instancePartitions//operations/`. + * The long-running operation + * metadata field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. Operations returned are ordered by + * `operation.metadata.value.start_time` in descending order starting from the + * most recently started operation. + * + * Authorization requires `spanner.instancePartitionOperations.list` + * permission on the resource + * [parent][google.spanner.admin.instance.v1.ListInstancePartitionOperationsRequest.parent]. + * + * @param string $formattedParent The parent instance of the instance partition operations. + * Values are of the form `projects//instances/`. Please see + * {@see InstanceAdminClient::instanceName()} for help formatting this field. + */ +function list_instance_partition_operations_sample(string $formattedParent): void +{ + // Create a client. + $instanceAdminClient = new InstanceAdminClient(); + + // Prepare the request message. + $request = (new ListInstancePartitionOperationsRequest()) + ->setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $instanceAdminClient->listInstancePartitionOperations($request); + + /** @var Operation $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()); + } +} + +/** + * 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 = InstanceAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + + list_instance_partition_operations_sample($formattedParent); +} +// [END spanner_v1_generated_InstanceAdmin_ListInstancePartitionOperations_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/list_instance_partitions.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/list_instance_partitions.php new file mode 100644 index 000000000000..a8651e105f97 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/list_instance_partitions.php @@ -0,0 +1,79 @@ +/instances/`. Use `{instance} + * = '-'` to list instance partitions for all Instances in a project, e.g., + * `projects/myproject/instances/-`. Please see + * {@see InstanceAdminClient::instanceName()} for help formatting this field. + */ +function list_instance_partitions_sample(string $formattedParent): void +{ + // Create a client. + $instanceAdminClient = new InstanceAdminClient(); + + // Prepare the request message. + $request = (new ListInstancePartitionsRequest()) + ->setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $instanceAdminClient->listInstancePartitions($request); + + /** @var InstancePartition $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()); + } +} + +/** + * 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 = InstanceAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + + list_instance_partitions_sample($formattedParent); +} +// [END spanner_v1_generated_InstanceAdmin_ListInstancePartitions_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/list_instances.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/list_instances.php new file mode 100644 index 000000000000..4017eba45eef --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/list_instances.php @@ -0,0 +1,77 @@ +`. Please see + * {@see InstanceAdminClient::projectName()} for help formatting this field. + */ +function list_instances_sample(string $formattedParent): void +{ + // Create a client. + $instanceAdminClient = new InstanceAdminClient(); + + // Prepare the request message. + $request = (new ListInstancesRequest()) + ->setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $instanceAdminClient->listInstances($request); + + /** @var Instance $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()); + } +} + +/** + * 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 = InstanceAdminClient::projectName('[PROJECT]'); + + list_instances_sample($formattedParent); +} +// [END spanner_v1_generated_InstanceAdmin_ListInstances_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/move_instance.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/move_instance.php new file mode 100644 index 000000000000..b8dd949e9572 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/move_instance.php @@ -0,0 +1,149 @@ +/operations/` and can be used to track + * the move instance operation. The + * metadata field type is + * [MoveInstanceMetadata][google.spanner.admin.instance.v1.MoveInstanceMetadata]. + * The response field type is + * [Instance][google.spanner.admin.instance.v1.Instance], + * if successful. + * Cancelling the operation sets its metadata's + * [cancel_time][google.spanner.admin.instance.v1.MoveInstanceMetadata.cancel_time]. + * Cancellation is not immediate because it involves moving any data + * previously moved to the target instance configuration back to the original + * instance configuration. You can use this operation to track the progress of + * the cancellation. Upon successful completion of the cancellation, the + * operation terminates with `CANCELLED` status. + * + * If not cancelled, upon completion of the returned operation: + * + * * The instance successfully moves to the target instance + * configuration. + * * You are billed for compute and storage in target instance + * configuration. + * + * Authorization requires the `spanner.instances.update` permission on + * the resource [instance][google.spanner.admin.instance.v1.Instance]. + * + * For more details, see + * [Move an instance](https://cloud.google.com/spanner/docs/move-instance). + * + * @param string $formattedName The instance to move. + * Values are of the form `projects//instances/`. Please see + * {@see InstanceAdminClient::instanceName()} for help formatting this field. + * @param string $formattedTargetConfig The target instance configuration where to move the instance. + * Values are of the form `projects//instanceConfigs/`. Please see + * {@see InstanceAdminClient::instanceConfigName()} for help formatting this field. + */ +function move_instance_sample(string $formattedName, string $formattedTargetConfig): void +{ + // Create a client. + $instanceAdminClient = new InstanceAdminClient(); + + // Prepare the request message. + $request = (new MoveInstanceRequest()) + ->setName($formattedName) + ->setTargetConfig($formattedTargetConfig); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $instanceAdminClient->moveInstance($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var MoveInstanceResponse $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * 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 = InstanceAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + $formattedTargetConfig = InstanceAdminClient::instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + + move_instance_sample($formattedName, $formattedTargetConfig); +} +// [END spanner_v1_generated_InstanceAdmin_MoveInstance_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/set_iam_policy.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/set_iam_policy.php new file mode 100644 index 000000000000..29f85e9f6741 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/set_iam_policy.php @@ -0,0 +1,77 @@ +setResource($resource) + ->setPolicy($policy); + + // Call the API and handle any network failures. + try { + /** @var Policy $response */ + $response = $instanceAdminClient->setIamPolicy($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 +{ + $resource = '[RESOURCE]'; + + set_iam_policy_sample($resource); +} +// [END spanner_v1_generated_InstanceAdmin_SetIamPolicy_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/test_iam_permissions.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/test_iam_permissions.php new file mode 100644 index 000000000000..583d9f9dc77c --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/test_iam_permissions.php @@ -0,0 +1,83 @@ +setResource($resource) + ->setPermissions($permissions); + + // Call the API and handle any network failures. + try { + /** @var TestIamPermissionsResponse $response */ + $response = $instanceAdminClient->testIamPermissions($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 +{ + $resource = '[RESOURCE]'; + $permissionsElement = '[PERMISSIONS]'; + + test_iam_permissions_sample($resource, $permissionsElement); +} +// [END spanner_v1_generated_InstanceAdmin_TestIamPermissions_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/update_instance.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/update_instance.php new file mode 100644 index 000000000000..f30c0c375cbc --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/update_instance.php @@ -0,0 +1,145 @@ +/operations/` and + * can be used to track the instance modification. The + * metadata field type is + * [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. + * The response field type is + * [Instance][google.spanner.admin.instance.v1.Instance], if successful. + * + * Authorization requires `spanner.instances.update` permission on + * the resource [name][google.spanner.admin.instance.v1.Instance.name]. + * + * @param string $instanceName A unique identifier for the instance, which cannot be changed + * after the instance is created. Values are of the form + * `projects//instances/[a-z][-a-z0-9]*[a-z0-9]`. The final + * segment of the name must be between 2 and 64 characters in length. + * @param string $formattedInstanceConfig The name of the instance's configuration. Values are of the form + * `projects//instanceConfigs/`. See + * also [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] and + * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. Please see + * {@see InstanceAdminClient::instanceConfigName()} for help formatting this field. + * @param string $instanceDisplayName The descriptive name for this instance as it appears in UIs. + * Must be unique per project and between 4 and 30 characters in length. + */ +function update_instance_sample( + string $instanceName, + string $formattedInstanceConfig, + string $instanceDisplayName +): void { + // Create a client. + $instanceAdminClient = new InstanceAdminClient(); + + // Prepare the request message. + $instance = (new Instance()) + ->setName($instanceName) + ->setConfig($formattedInstanceConfig) + ->setDisplayName($instanceDisplayName); + $fieldMask = new FieldMask(); + $request = (new UpdateInstanceRequest()) + ->setInstance($instance) + ->setFieldMask($fieldMask); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $instanceAdminClient->updateInstance($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Instance $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * 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 +{ + $instanceName = '[NAME]'; + $formattedInstanceConfig = InstanceAdminClient::instanceConfigName( + '[PROJECT]', + '[INSTANCE_CONFIG]' + ); + $instanceDisplayName = '[DISPLAY_NAME]'; + + update_instance_sample($instanceName, $formattedInstanceConfig, $instanceDisplayName); +} +// [END spanner_v1_generated_InstanceAdmin_UpdateInstance_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/update_instance_config.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/update_instance_config.php new file mode 100644 index 000000000000..edf4ddd0b4f9 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/update_instance_config.php @@ -0,0 +1,117 @@ +/operations/` and can be used to track + * the instance configuration modification. The + * metadata field type is + * [UpdateInstanceConfigMetadata][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata]. + * The response field type is + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if + * successful. + * + * Authorization requires `spanner.instanceConfigs.update` permission on + * the resource [name][google.spanner.admin.instance.v1.InstanceConfig.name]. + * + * 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 update_instance_config_sample(): void +{ + // Create a client. + $instanceAdminClient = new InstanceAdminClient(); + + // Prepare the request message. + $instanceConfig = new InstanceConfig(); + $updateMask = new FieldMask(); + $request = (new UpdateInstanceConfigRequest()) + ->setInstanceConfig($instanceConfig) + ->setUpdateMask($updateMask); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $instanceAdminClient->updateInstanceConfig($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var InstanceConfig $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END spanner_v1_generated_InstanceAdmin_UpdateInstanceConfig_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/update_instance_partition.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/update_instance_partition.php new file mode 100644 index 000000000000..2f61f333c720 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/samples/V1/InstanceAdminClient/update_instance_partition.php @@ -0,0 +1,155 @@ +/operations/` and can be used to + * track the instance partition modification. The + * metadata field type is + * [UpdateInstancePartitionMetadata][google.spanner.admin.instance.v1.UpdateInstancePartitionMetadata]. + * The response field type is + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition], if + * successful. + * + * Authorization requires `spanner.instancePartitions.update` permission on + * the resource + * [name][google.spanner.admin.instance.v1.InstancePartition.name]. + * + * @param string $instancePartitionName A unique identifier for the instance partition. Values are of the + * form + * `projects//instances//instancePartitions/[a-z][-a-z0-9]*[a-z0-9]`. + * The final segment of the name must be between 2 and 64 characters in + * length. An instance partition's name cannot be changed after the instance + * partition is created. + * @param string $formattedInstancePartitionConfig The name of the instance partition's configuration. Values are of + * the form `projects//instanceConfigs/`. See also + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] and + * [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. Please see + * {@see InstanceAdminClient::instanceConfigName()} for help formatting this field. + * @param string $instancePartitionDisplayName The descriptive name for this instance partition as it appears in + * UIs. Must be unique per project and between 4 and 30 characters in length. + */ +function update_instance_partition_sample( + string $instancePartitionName, + string $formattedInstancePartitionConfig, + string $instancePartitionDisplayName +): void { + // Create a client. + $instanceAdminClient = new InstanceAdminClient(); + + // Prepare the request message. + $instancePartition = (new InstancePartition()) + ->setName($instancePartitionName) + ->setConfig($formattedInstancePartitionConfig) + ->setDisplayName($instancePartitionDisplayName); + $fieldMask = new FieldMask(); + $request = (new UpdateInstancePartitionRequest()) + ->setInstancePartition($instancePartition) + ->setFieldMask($fieldMask); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $instanceAdminClient->updateInstancePartition($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var InstancePartition $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * 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 +{ + $instancePartitionName = '[NAME]'; + $formattedInstancePartitionConfig = InstanceAdminClient::instanceConfigName( + '[PROJECT]', + '[INSTANCE_CONFIG]' + ); + $instancePartitionDisplayName = '[DISPLAY_NAME]'; + + update_instance_partition_sample( + $instancePartitionName, + $formattedInstancePartitionConfig, + $instancePartitionDisplayName + ); +} +// [END spanner_v1_generated_InstanceAdmin_UpdateInstancePartition_sync] diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/src/V1/Client/InstanceAdminClient.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/src/V1/Client/InstanceAdminClient.php new file mode 100644 index 000000000000..c1f1fc7a5355 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/src/V1/Client/InstanceAdminClient.php @@ -0,0 +1,1302 @@ + createInstanceAsync(CreateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface createInstanceConfigAsync(CreateInstanceConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface createInstancePartitionAsync(CreateInstancePartitionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstanceAsync(DeleteInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstanceConfigAsync(DeleteInstanceConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstancePartitionAsync(DeleteInstancePartitionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceAsync(GetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceConfigAsync(GetInstanceConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstancePartitionAsync(GetInstancePartitionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstanceConfigOperationsAsync(ListInstanceConfigOperationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstanceConfigsAsync(ListInstanceConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstancePartitionOperationsAsync(ListInstancePartitionOperationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstancePartitionsAsync(ListInstancePartitionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstancesAsync(ListInstancesRequest $request, array $optionalArgs = []) + * @method PromiseInterface moveInstanceAsync(MoveInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInstanceAsync(UpdateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInstanceConfigAsync(UpdateInstanceConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInstancePartitionAsync(UpdateInstancePartitionRequest $request, array $optionalArgs = []) + */ +final class InstanceAdminClient +{ + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.spanner.admin.instance.v1.InstanceAdmin'; + + /** + * The default address of the service. + * + * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. + */ + private const SERVICE_ADDRESS = 'spanner.googleapis.com'; + + /** The address template of the service. */ + private const SERVICE_ADDRESS_TEMPLATE = 'spanner.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', + 'https://www.googleapis.com/auth/spanner.admin', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/instance_admin_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/instance_admin_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/instance_admin_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/instance_admin_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * instance_config resource. + * + * @param string $project + * @param string $instanceConfig + * + * @return string The formatted instance_config resource. + */ + public static function instanceConfigName(string $project, string $instanceConfig): string + { + return self::getPathTemplate('instanceConfig')->render([ + 'project' => $project, + 'instance_config' => $instanceConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * instance_partition resource. + * + * @param string $project + * @param string $instance + * @param string $instancePartition + * + * @return string The formatted instance_partition resource. + */ + public static function instancePartitionName(string $project, string $instance, string $instancePartition): string + { + return self::getPathTemplate('instancePartition')->render([ + 'project' => $project, + 'instance' => $instance, + 'instance_partition' => $instancePartition, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a project + * resource. + * + * @param string $project + * + * @return string The formatted project resource. + */ + public static function projectName(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - instance: projects/{project}/instances/{instance} + * - instanceConfig: projects/{project}/instanceConfigs/{instance_config} + * - instancePartition: projects/{project}/instances/{instance}/instancePartitions/{instance_partition} + * - project: projects/{project} + * + * 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. + * + * Setting the "SPANNER_EMULATOR_HOST" environment variable will automatically set + * the API Endpoint to the value specified in the variable, as well as ensure that + * empty credentials are used in the transport layer. + * + * @param array $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 'spanner.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * 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 + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @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 + * } + * + * @throws ValidationException + */ + public function __construct(array $options = []) + { + $options = $this->setDefaultEmulatorConfig($options); + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($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); + } + + /** + * Creates an instance and begins preparing it to begin serving. The + * returned long-running operation + * can be used to track the progress of preparing the new + * instance. The instance name is assigned by the caller. If the + * named instance already exists, `CreateInstance` returns + * `ALREADY_EXISTS`. + * + * Immediately upon completion of this request: + * + * * The instance is readable via the API, with all requested attributes + * but no allocated resources. Its state is `CREATING`. + * + * Until completion of the returned operation: + * + * * Cancelling the operation renders the instance immediately unreadable + * via the API. + * * The instance can be deleted. + * * All other attempts to modify the instance are rejected. + * + * Upon completion of the returned operation: + * + * * Billing for all successfully-allocated resources begins (some types + * may have lower than the requested levels). + * * Databases can be created in the instance. + * * The instance's allocated resource levels are readable via the API. + * * The instance's state becomes `READY`. + * + * The returned long-running operation will + * have a name of the format `/operations/` and + * can be used to track creation of the instance. The + * metadata field type is + * [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. + * The response field type is + * [Instance][google.spanner.admin.instance.v1.Instance], if successful. + * + * The async variant is {@see InstanceAdminClient::createInstanceAsync()} . + * + * @example samples/V1/InstanceAdminClient/create_instance.php + * + * @param CreateInstanceRequest $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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); + } + + /** + * Creates an instance configuration and begins preparing it to be used. The + * returned long-running operation + * can be used to track the progress of preparing the new + * instance configuration. The instance configuration name is assigned by the + * caller. If the named instance configuration already exists, + * `CreateInstanceConfig` returns `ALREADY_EXISTS`. + * + * Immediately after the request returns: + * + * * The instance configuration is readable via the API, with all requested + * attributes. The instance configuration's + * [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + * field is set to true. Its state is `CREATING`. + * + * While the operation is pending: + * + * * Cancelling the operation renders the instance configuration immediately + * unreadable via the API. + * * Except for deleting the creating resource, all other attempts to modify + * the instance configuration are rejected. + * + * Upon completion of the returned operation: + * + * * Instances can be created using the instance configuration. + * * The instance configuration's + * [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + * field becomes false. Its state becomes `READY`. + * + * The returned long-running operation will + * have a name of the format + * `/operations/` and can be used to track + * creation of the instance configuration. The + * metadata field type is + * [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata]. + * The response field type is + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if + * successful. + * + * Authorization requires `spanner.instanceConfigs.create` permission on + * the resource + * [parent][google.spanner.admin.instance.v1.CreateInstanceConfigRequest.parent]. + * + * The async variant is {@see InstanceAdminClient::createInstanceConfigAsync()} . + * + * @example samples/V1/InstanceAdminClient/create_instance_config.php + * + * @param CreateInstanceConfigRequest $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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInstanceConfig(CreateInstanceConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstanceConfig', $request, $callOptions)->wait(); + } + + /** + * Creates an instance partition and begins preparing it to be used. The + * returned long-running operation + * can be used to track the progress of preparing the new instance partition. + * The instance partition name is assigned by the caller. If the named + * instance partition already exists, `CreateInstancePartition` returns + * `ALREADY_EXISTS`. + * + * Immediately upon completion of this request: + * + * * The instance partition is readable via the API, with all requested + * attributes but no allocated resources. Its state is `CREATING`. + * + * Until completion of the returned operation: + * + * * Cancelling the operation renders the instance partition immediately + * unreadable via the API. + * * The instance partition can be deleted. + * * All other attempts to modify the instance partition are rejected. + * + * Upon completion of the returned operation: + * + * * Billing for all successfully-allocated resources begins (some types + * may have lower than the requested levels). + * * Databases can start using this instance partition. + * * The instance partition's allocated resource levels are readable via the + * API. + * * The instance partition's state becomes `READY`. + * + * The returned long-running operation will + * have a name of the format + * `/operations/` and can be used to + * track creation of the instance partition. The + * metadata field type is + * [CreateInstancePartitionMetadata][google.spanner.admin.instance.v1.CreateInstancePartitionMetadata]. + * The response field type is + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition], if + * successful. + * + * The async variant is {@see InstanceAdminClient::createInstancePartitionAsync()} + * . + * + * @example samples/V1/InstanceAdminClient/create_instance_partition.php + * + * @param CreateInstancePartitionRequest $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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInstancePartition(CreateInstancePartitionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstancePartition', $request, $callOptions)->wait(); + } + + /** + * Deletes an instance. + * + * Immediately upon completion of the request: + * + * * Billing ceases for all of the instance's reserved resources. + * + * Soon afterward: + * + * * The instance and *all of its databases* immediately and + * irrevocably disappear from the API. All data in the databases + * is permanently deleted. + * + * The async variant is {@see InstanceAdminClient::deleteInstanceAsync()} . + * + * @example samples/V1/InstanceAdminClient/delete_instance.php + * + * @param DeleteInstanceRequest $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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); + } + + /** + * Deletes the instance configuration. Deletion is only allowed when no + * instances are using the configuration. If any instances are using + * the configuration, returns `FAILED_PRECONDITION`. + * + * Only user-managed configurations can be deleted. + * + * Authorization requires `spanner.instanceConfigs.delete` permission on + * the resource [name][google.spanner.admin.instance.v1.InstanceConfig.name]. + * + * The async variant is {@see InstanceAdminClient::deleteInstanceConfigAsync()} . + * + * @example samples/V1/InstanceAdminClient/delete_instance_config.php + * + * @param DeleteInstanceConfigRequest $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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstanceConfig(DeleteInstanceConfigRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteInstanceConfig', $request, $callOptions)->wait(); + } + + /** + * Deletes an existing instance partition. Requires that the + * instance partition is not used by any database or backup and is not the + * default instance partition of an instance. + * + * Authorization requires `spanner.instancePartitions.delete` permission on + * the resource + * [name][google.spanner.admin.instance.v1.InstancePartition.name]. + * + * The async variant is {@see InstanceAdminClient::deleteInstancePartitionAsync()} + * . + * + * @example samples/V1/InstanceAdminClient/delete_instance_partition.php + * + * @param DeleteInstancePartitionRequest $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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstancePartition(DeleteInstancePartitionRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteInstancePartition', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for an instance resource. Returns an empty + * policy if an instance exists but does not have a policy set. + * + * Authorization requires `spanner.instances.getIamPolicy` on + * [resource][google.iam.v1.GetIamPolicyRequest.resource]. + * + * The async variant is {@see InstanceAdminClient::getIamPolicyAsync()} . + * + * @example samples/V1/InstanceAdminClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets information about a particular instance. + * + * The async variant is {@see InstanceAdminClient::getInstanceAsync()} . + * + * @example samples/V1/InstanceAdminClient/get_instance.php + * + * @param GetInstanceRequest $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 Instance + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance + { + return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); + } + + /** + * Gets information about a particular instance configuration. + * + * The async variant is {@see InstanceAdminClient::getInstanceConfigAsync()} . + * + * @example samples/V1/InstanceAdminClient/get_instance_config.php + * + * @param GetInstanceConfigRequest $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 InstanceConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstanceConfig(GetInstanceConfigRequest $request, array $callOptions = []): InstanceConfig + { + return $this->startApiCall('GetInstanceConfig', $request, $callOptions)->wait(); + } + + /** + * Gets information about a particular instance partition. + * + * The async variant is {@see InstanceAdminClient::getInstancePartitionAsync()} . + * + * @example samples/V1/InstanceAdminClient/get_instance_partition.php + * + * @param GetInstancePartitionRequest $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 InstancePartition + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstancePartition(GetInstancePartitionRequest $request, array $callOptions = []): InstancePartition + { + return $this->startApiCall('GetInstancePartition', $request, $callOptions)->wait(); + } + + /** + * Lists the user-managed instance configuration long-running + * operations in the given project. An instance + * configuration operation has a name of the form + * `projects//instanceConfigs//operations/`. + * The long-running operation + * metadata field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. Operations returned are ordered by + * `operation.metadata.value.start_time` in descending order starting + * from the most recently started operation. + * + * The async variant is + * {@see InstanceAdminClient::listInstanceConfigOperationsAsync()} . + * + * @example samples/V1/InstanceAdminClient/list_instance_config_operations.php + * + * @param ListInstanceConfigOperationsRequest $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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstanceConfigOperations(ListInstanceConfigOperationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstanceConfigOperations', $request, $callOptions); + } + + /** + * Lists the supported instance configurations for a given project. + * + * Returns both Google-managed configurations and user-managed + * configurations. + * + * The async variant is {@see InstanceAdminClient::listInstanceConfigsAsync()} . + * + * @example samples/V1/InstanceAdminClient/list_instance_configs.php + * + * @param ListInstanceConfigsRequest $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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstanceConfigs(ListInstanceConfigsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstanceConfigs', $request, $callOptions); + } + + /** + * Lists instance partition long-running operations in the given instance. + * An instance partition operation has a name of the form + * `projects//instances//instancePartitions//operations/`. + * The long-running operation + * metadata field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. Operations returned are ordered by + * `operation.metadata.value.start_time` in descending order starting from the + * most recently started operation. + * + * Authorization requires `spanner.instancePartitionOperations.list` + * permission on the resource + * [parent][google.spanner.admin.instance.v1.ListInstancePartitionOperationsRequest.parent]. + * + * The async variant is + * {@see InstanceAdminClient::listInstancePartitionOperationsAsync()} . + * + * @example samples/V1/InstanceAdminClient/list_instance_partition_operations.php + * + * @param ListInstancePartitionOperationsRequest $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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstancePartitionOperations(ListInstancePartitionOperationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstancePartitionOperations', $request, $callOptions); + } + + /** + * Lists all instance partitions for the given instance. + * + * The async variant is {@see InstanceAdminClient::listInstancePartitionsAsync()} . + * + * @example samples/V1/InstanceAdminClient/list_instance_partitions.php + * + * @param ListInstancePartitionsRequest $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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstancePartitions(ListInstancePartitionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstancePartitions', $request, $callOptions); + } + + /** + * Lists all instances in the given project. + * + * The async variant is {@see InstanceAdminClient::listInstancesAsync()} . + * + * @example samples/V1/InstanceAdminClient/list_instances.php + * + * @param ListInstancesRequest $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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstances', $request, $callOptions); + } + + /** + * Moves an instance to the target instance configuration. You can use the + * returned long-running operation to track + * the progress of moving the instance. + * + * `MoveInstance` returns `FAILED_PRECONDITION` if the instance meets any of + * the following criteria: + * + * * Is undergoing a move to a different instance configuration + * * Has backups + * * Has an ongoing update + * * Contains any CMEK-enabled databases + * * Is a free trial instance + * + * While the operation is pending: + * + * * All other attempts to modify the instance, including changes to its + * compute capacity, are rejected. + * * The following database and backup admin operations are rejected: + * + * * `DatabaseAdmin.CreateDatabase` + * * `DatabaseAdmin.UpdateDatabaseDdl` (disabled if default_leader is + * specified in the request.) + * * `DatabaseAdmin.RestoreDatabase` + * * `DatabaseAdmin.CreateBackup` + * * `DatabaseAdmin.CopyBackup` + * + * * Both the source and target instance configurations are subject to + * hourly compute and storage charges. + * * The instance might experience higher read-write latencies and a higher + * transaction abort rate. However, moving an instance doesn't cause any + * downtime. + * + * The returned long-running operation has + * a name of the format + * `/operations/` and can be used to track + * the move instance operation. The + * metadata field type is + * [MoveInstanceMetadata][google.spanner.admin.instance.v1.MoveInstanceMetadata]. + * The response field type is + * [Instance][google.spanner.admin.instance.v1.Instance], + * if successful. + * Cancelling the operation sets its metadata's + * [cancel_time][google.spanner.admin.instance.v1.MoveInstanceMetadata.cancel_time]. + * Cancellation is not immediate because it involves moving any data + * previously moved to the target instance configuration back to the original + * instance configuration. You can use this operation to track the progress of + * the cancellation. Upon successful completion of the cancellation, the + * operation terminates with `CANCELLED` status. + * + * If not cancelled, upon completion of the returned operation: + * + * * The instance successfully moves to the target instance + * configuration. + * * You are billed for compute and storage in target instance + * configuration. + * + * Authorization requires the `spanner.instances.update` permission on + * the resource [instance][google.spanner.admin.instance.v1.Instance]. + * + * For more details, see + * [Move an instance](https://cloud.google.com/spanner/docs/move-instance). + * + * The async variant is {@see InstanceAdminClient::moveInstanceAsync()} . + * + * @example samples/V1/InstanceAdminClient/move_instance.php + * + * @param MoveInstanceRequest $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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function moveInstance(MoveInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('MoveInstance', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on an instance resource. Replaces any + * existing policy. + * + * Authorization requires `spanner.instances.setIamPolicy` on + * [resource][google.iam.v1.SetIamPolicyRequest.resource]. + * + * The async variant is {@see InstanceAdminClient::setIamPolicyAsync()} . + * + * @example samples/V1/InstanceAdminClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that the caller has on the specified instance resource. + * + * Attempting this RPC on a non-existent Cloud Spanner instance resource will + * result in a NOT_FOUND error if the user has `spanner.instances.list` + * permission on the containing Google Cloud Project. Otherwise returns an + * empty set of permissions. + * + * The async variant is {@see InstanceAdminClient::testIamPermissionsAsync()} . + * + * @example samples/V1/InstanceAdminClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates an instance, and begins allocating or releasing resources + * as requested. The returned long-running operation can be used to track the + * progress of updating the instance. If the named instance does not + * exist, returns `NOT_FOUND`. + * + * Immediately upon completion of this request: + * + * * For resource types for which a decrease in the instance's allocation + * has been requested, billing is based on the newly-requested level. + * + * Until completion of the returned operation: + * + * * Cancelling the operation sets its metadata's + * [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], + * and begins restoring resources to their pre-request values. The + * operation is guaranteed to succeed at undoing all resource changes, + * after which point it terminates with a `CANCELLED` status. + * * All other attempts to modify the instance are rejected. + * * Reading the instance via the API continues to give the pre-request + * resource levels. + * + * Upon completion of the returned operation: + * + * * Billing begins for all successfully-allocated resources (some types + * may have lower than the requested levels). + * * All newly-reserved resources are available for serving the instance's + * tables. + * * The instance's new resource levels are readable via the API. + * + * The returned long-running operation will + * have a name of the format `/operations/` and + * can be used to track the instance modification. The + * metadata field type is + * [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. + * The response field type is + * [Instance][google.spanner.admin.instance.v1.Instance], if successful. + * + * Authorization requires `spanner.instances.update` permission on + * the resource [name][google.spanner.admin.instance.v1.Instance.name]. + * + * The async variant is {@see InstanceAdminClient::updateInstanceAsync()} . + * + * @example samples/V1/InstanceAdminClient/update_instance.php + * + * @param UpdateInstanceRequest $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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInstance(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); + } + + /** + * Updates an instance configuration. The returned + * long-running operation can be used to track + * the progress of updating the instance. If the named instance configuration + * does not exist, returns `NOT_FOUND`. + * + * Only user-managed configurations can be updated. + * + * Immediately after the request returns: + * + * * The instance configuration's + * [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + * field is set to true. + * + * While the operation is pending: + * + * * Cancelling the operation sets its metadata's + * [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.cancel_time]. + * The operation is guaranteed to succeed at undoing all changes, after + * which point it terminates with a `CANCELLED` status. + * * All other attempts to modify the instance configuration are rejected. + * * Reading the instance configuration via the API continues to give the + * pre-request values. + * + * Upon completion of the returned operation: + * + * * Creating instances using the instance configuration uses the new + * values. + * * The new values of the instance configuration are readable via the API. + * * The instance configuration's + * [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + * field becomes false. + * + * The returned long-running operation will + * have a name of the format + * `/operations/` and can be used to track + * the instance configuration modification. The + * metadata field type is + * [UpdateInstanceConfigMetadata][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata]. + * The response field type is + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if + * successful. + * + * Authorization requires `spanner.instanceConfigs.update` permission on + * the resource [name][google.spanner.admin.instance.v1.InstanceConfig.name]. + * + * The async variant is {@see InstanceAdminClient::updateInstanceConfigAsync()} . + * + * @example samples/V1/InstanceAdminClient/update_instance_config.php + * + * @param UpdateInstanceConfigRequest $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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInstanceConfig(UpdateInstanceConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateInstanceConfig', $request, $callOptions)->wait(); + } + + /** + * Updates an instance partition, and begins allocating or releasing resources + * as requested. The returned long-running operation can be used to track the + * progress of updating the instance partition. If the named instance + * partition does not exist, returns `NOT_FOUND`. + * + * Immediately upon completion of this request: + * + * * For resource types for which a decrease in the instance partition's + * allocation has been requested, billing is based on the newly-requested + * level. + * + * Until completion of the returned operation: + * + * * Cancelling the operation sets its metadata's + * [cancel_time][google.spanner.admin.instance.v1.UpdateInstancePartitionMetadata.cancel_time], + * and begins restoring resources to their pre-request values. The + * operation is guaranteed to succeed at undoing all resource changes, + * after which point it terminates with a `CANCELLED` status. + * * All other attempts to modify the instance partition are rejected. + * * Reading the instance partition via the API continues to give the + * pre-request resource levels. + * + * Upon completion of the returned operation: + * + * * Billing begins for all successfully-allocated resources (some types + * may have lower than the requested levels). + * * All newly-reserved resources are available for serving the instance + * partition's tables. + * * The instance partition's new resource levels are readable via the API. + * + * The returned long-running operation will + * have a name of the format + * `/operations/` and can be used to + * track the instance partition modification. The + * metadata field type is + * [UpdateInstancePartitionMetadata][google.spanner.admin.instance.v1.UpdateInstancePartitionMetadata]. + * The response field type is + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition], if + * successful. + * + * Authorization requires `spanner.instancePartitions.update` permission on + * the resource + * [name][google.spanner.admin.instance.v1.InstancePartition.name]. + * + * The async variant is {@see InstanceAdminClient::updateInstancePartitionAsync()} + * . + * + * @example samples/V1/InstanceAdminClient/update_instance_partition.php + * + * @param UpdateInstancePartitionRequest $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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInstancePartition(UpdateInstancePartitionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateInstancePartition', $request, $callOptions)->wait(); + } + + /** Configure the gapic configuration to use a service emulator. */ + private function setDefaultEmulatorConfig(array $options): array + { + $emulatorHost = getenv('SPANNER_EMULATOR_HOST'); + if (empty($emulatorHost)) { + return $options; + } + + if ($scheme = parse_url($emulatorHost, PHP_URL_SCHEME)) { + $search = $scheme . '://'; + $emulatorHost = str_replace($search, '', $emulatorHost); + } + + $options['apiEndpoint'] ??= $emulatorHost; + $options['transportConfig']['grpc']['stubOpts']['credentials'] ??= ChannelCredentials::createInsecure(); + $options['credentials'] ??= new InsecureCredentialsWrapper(); + return $options; + } +} diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/src/V1/Gapic/InstanceAdminGapicClient.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/src/V1/Gapic/InstanceAdminGapicClient.php new file mode 100644 index 000000000000..63fccc62ceb7 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/src/V1/Gapic/InstanceAdminGapicClient.php @@ -0,0 +1,2277 @@ +projectName('[PROJECT]'); + * $instanceId = 'instance_id'; + * $instance = new Instance(); + * $operationResponse = $instanceAdminClient->createInstance($formattedParent, $instanceId, $instance); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $instanceAdminClient->createInstance($formattedParent, $instanceId, $instance); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $instanceAdminClient->resumeOperation($operationName, 'createInstance'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * 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. + * + * @deprecated Please use the new service client {@see \Google\Cloud\Spanner\Admin\Instance\V1\Client\InstanceAdminClient}. + */ +class InstanceAdminGapicClient +{ + use GapicClientTrait; + + /** The name of the service. */ + const SERVICE_NAME = 'google.spanner.admin.instance.v1.InstanceAdmin'; + + /** + * The default address of the service. + * + * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. + */ + const SERVICE_ADDRESS = 'spanner.googleapis.com'; + + /** The address template of the service. */ + private const SERVICE_ADDRESS_TEMPLATE = 'spanner.UNIVERSE_DOMAIN'; + + /** The default port of the service. */ + const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/spanner.admin', + ]; + + private static $instanceNameTemplate; + + private static $instanceConfigNameTemplate; + + private static $instancePartitionNameTemplate; + + private static $projectNameTemplate; + + private static $pathTemplateMap; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/instance_admin_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/instance_admin_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/instance_admin_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/instance_admin_rest_client_config.php', + ], + ], + ]; + } + + private static function getInstanceNameTemplate() + { + if (self::$instanceNameTemplate == null) { + self::$instanceNameTemplate = new PathTemplate('projects/{project}/instances/{instance}'); + } + + return self::$instanceNameTemplate; + } + + private static function getInstanceConfigNameTemplate() + { + if (self::$instanceConfigNameTemplate == null) { + self::$instanceConfigNameTemplate = new PathTemplate('projects/{project}/instanceConfigs/{instance_config}'); + } + + return self::$instanceConfigNameTemplate; + } + + private static function getInstancePartitionNameTemplate() + { + if (self::$instancePartitionNameTemplate == null) { + self::$instancePartitionNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/instancePartitions/{instance_partition}'); + } + + return self::$instancePartitionNameTemplate; + } + + private static function getProjectNameTemplate() + { + if (self::$projectNameTemplate == null) { + self::$projectNameTemplate = new PathTemplate('projects/{project}'); + } + + return self::$projectNameTemplate; + } + + private static function getPathTemplateMap() + { + if (self::$pathTemplateMap == null) { + self::$pathTemplateMap = [ + 'instance' => self::getInstanceNameTemplate(), + 'instanceConfig' => self::getInstanceConfigNameTemplate(), + 'instancePartition' => self::getInstancePartitionNameTemplate(), + 'project' => self::getProjectNameTemplate(), + ]; + } + + return self::$pathTemplateMap; + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName($project, $instance) + { + return self::getInstanceNameTemplate()->render([ + 'project' => $project, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * instance_config resource. + * + * @param string $project + * @param string $instanceConfig + * + * @return string The formatted instance_config resource. + */ + public static function instanceConfigName($project, $instanceConfig) + { + return self::getInstanceConfigNameTemplate()->render([ + 'project' => $project, + 'instance_config' => $instanceConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * instance_partition resource. + * + * @param string $project + * @param string $instance + * @param string $instancePartition + * + * @return string The formatted instance_partition resource. + */ + public static function instancePartitionName($project, $instance, $instancePartition) + { + return self::getInstancePartitionNameTemplate()->render([ + 'project' => $project, + 'instance' => $instance, + 'instance_partition' => $instancePartition, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a project + * resource. + * + * @param string $project + * + * @return string The formatted project resource. + */ + public static function projectName($project) + { + return self::getProjectNameTemplate()->render([ + 'project' => $project, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - instance: projects/{project}/instances/{instance} + * - instanceConfig: projects/{project}/instanceConfigs/{instance_config} + * - instancePartition: projects/{project}/instances/{instance}/instancePartitions/{instance_partition} + * - project: projects/{project} + * + * 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($formattedName, $template = null) + { + $templateMap = self::getPathTemplateMap(); + if ($template) { + if (!isset($templateMap[$template])) { + throw new ValidationException("Template name $template does not exist"); + } + + return $templateMap[$template]->match($formattedName); + } + + foreach ($templateMap as $templateName => $pathTemplate) { + try { + return $pathTemplate->match($formattedName); + } catch (ValidationException $ex) { + // Swallow the exception to continue trying other path templates + } + } + + throw new ValidationException("Input did not match any known format. Input: $formattedName"); + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Constructor. + * + * @param array $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 'spanner.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * 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 + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @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. + * } + * + * @throws ValidationException + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** + * Creates an instance and begins preparing it to begin serving. The + * returned long-running operation + * can be used to track the progress of preparing the new + * instance. The instance name is assigned by the caller. If the + * named instance already exists, `CreateInstance` returns + * `ALREADY_EXISTS`. + * + * Immediately upon completion of this request: + * + * * The instance is readable via the API, with all requested attributes + * but no allocated resources. Its state is `CREATING`. + * + * Until completion of the returned operation: + * + * * Cancelling the operation renders the instance immediately unreadable + * via the API. + * * The instance can be deleted. + * * All other attempts to modify the instance are rejected. + * + * Upon completion of the returned operation: + * + * * Billing for all successfully-allocated resources begins (some types + * may have lower than the requested levels). + * * Databases can be created in the instance. + * * The instance's allocated resource levels are readable via the API. + * * The instance's state becomes `READY`. + * + * The returned long-running operation will + * have a name of the format `/operations/` and + * can be used to track creation of the instance. The + * metadata field type is + * [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. + * The response field type is + * [Instance][google.spanner.admin.instance.v1.Instance], if successful. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $formattedParent = $instanceAdminClient->projectName('[PROJECT]'); + * $instanceId = 'instance_id'; + * $instance = new Instance(); + * $operationResponse = $instanceAdminClient->createInstance($formattedParent, $instanceId, $instance); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $instanceAdminClient->createInstance($formattedParent, $instanceId, $instance); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $instanceAdminClient->resumeOperation($operationName, 'createInstance'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The name of the project in which to create the instance. Values + * are of the form `projects/`. + * @param string $instanceId Required. The ID of the instance to create. Valid identifiers are of the + * form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 characters in + * length. + * @param Instance $instance Required. The instance to create. The name may be omitted, but if + * specified must be `/instances/`. + * @param array $optionalArgs { + * 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 \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function createInstance($parent, $instanceId, $instance, array $optionalArgs = []) + { + $request = new CreateInstanceRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setInstanceId($instanceId); + $request->setInstance($instance); + $requestParamHeaders['parent'] = $parent; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('CreateInstance', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } + + /** + * Creates an instance configuration and begins preparing it to be used. The + * returned long-running operation + * can be used to track the progress of preparing the new + * instance configuration. The instance configuration name is assigned by the + * caller. If the named instance configuration already exists, + * `CreateInstanceConfig` returns `ALREADY_EXISTS`. + * + * Immediately after the request returns: + * + * * The instance configuration is readable via the API, with all requested + * attributes. The instance configuration's + * [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + * field is set to true. Its state is `CREATING`. + * + * While the operation is pending: + * + * * Cancelling the operation renders the instance configuration immediately + * unreadable via the API. + * * Except for deleting the creating resource, all other attempts to modify + * the instance configuration are rejected. + * + * Upon completion of the returned operation: + * + * * Instances can be created using the instance configuration. + * * The instance configuration's + * [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + * field becomes false. Its state becomes `READY`. + * + * The returned long-running operation will + * have a name of the format + * `/operations/` and can be used to track + * creation of the instance configuration. The + * metadata field type is + * [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata]. + * The response field type is + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if + * successful. + * + * Authorization requires `spanner.instanceConfigs.create` permission on + * the resource + * [parent][google.spanner.admin.instance.v1.CreateInstanceConfigRequest.parent]. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $formattedParent = $instanceAdminClient->projectName('[PROJECT]'); + * $instanceConfigId = 'instance_config_id'; + * $instanceConfig = new InstanceConfig(); + * $operationResponse = $instanceAdminClient->createInstanceConfig($formattedParent, $instanceConfigId, $instanceConfig); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $instanceAdminClient->createInstanceConfig($formattedParent, $instanceConfigId, $instanceConfig); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $instanceAdminClient->resumeOperation($operationName, 'createInstanceConfig'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The name of the project in which to create the instance + * configuration. Values are of the form `projects/`. + * @param string $instanceConfigId Required. The ID of the instance configuration to create. Valid identifiers + * are of the form `custom-[-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + * characters in length. The `custom-` prefix is required to avoid name + * conflicts with Google-managed configurations. + * @param InstanceConfig $instanceConfig Required. The `InstanceConfig` proto of the configuration to create. + * `instance_config.name` must be + * `/instanceConfigs/`. + * `instance_config.base_config` must be a Google-managed configuration name, + * e.g. /instanceConfigs/us-east1, /instanceConfigs/nam3. + * @param array $optionalArgs { + * Optional. + * + * @type bool $validateOnly + * An option to validate, but not actually execute, a request, + * and provide the same response. + * @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 \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function createInstanceConfig($parent, $instanceConfigId, $instanceConfig, array $optionalArgs = []) + { + $request = new CreateInstanceConfigRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setInstanceConfigId($instanceConfigId); + $request->setInstanceConfig($instanceConfig); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['validateOnly'])) { + $request->setValidateOnly($optionalArgs['validateOnly']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('CreateInstanceConfig', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } + + /** + * Creates an instance partition and begins preparing it to be used. The + * returned long-running operation + * can be used to track the progress of preparing the new instance partition. + * The instance partition name is assigned by the caller. If the named + * instance partition already exists, `CreateInstancePartition` returns + * `ALREADY_EXISTS`. + * + * Immediately upon completion of this request: + * + * * The instance partition is readable via the API, with all requested + * attributes but no allocated resources. Its state is `CREATING`. + * + * Until completion of the returned operation: + * + * * Cancelling the operation renders the instance partition immediately + * unreadable via the API. + * * The instance partition can be deleted. + * * All other attempts to modify the instance partition are rejected. + * + * Upon completion of the returned operation: + * + * * Billing for all successfully-allocated resources begins (some types + * may have lower than the requested levels). + * * Databases can start using this instance partition. + * * The instance partition's allocated resource levels are readable via the + * API. + * * The instance partition's state becomes `READY`. + * + * The returned long-running operation will + * have a name of the format + * `/operations/` and can be used to + * track creation of the instance partition. The + * metadata field type is + * [CreateInstancePartitionMetadata][google.spanner.admin.instance.v1.CreateInstancePartitionMetadata]. + * The response field type is + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition], if + * successful. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $formattedParent = $instanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * $instancePartitionId = 'instance_partition_id'; + * $instancePartition = new InstancePartition(); + * $operationResponse = $instanceAdminClient->createInstancePartition($formattedParent, $instancePartitionId, $instancePartition); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $instanceAdminClient->createInstancePartition($formattedParent, $instancePartitionId, $instancePartition); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $instanceAdminClient->resumeOperation($operationName, 'createInstancePartition'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The name of the instance in which to create the instance + * partition. Values are of the form + * `projects//instances/`. + * @param string $instancePartitionId Required. The ID of the instance partition to create. Valid identifiers are + * of the form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + * characters in length. + * @param InstancePartition $instancePartition Required. The instance partition to create. The instance_partition.name may + * be omitted, but if specified must be + * `/instancePartitions/`. + * @param array $optionalArgs { + * 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 \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function createInstancePartition($parent, $instancePartitionId, $instancePartition, array $optionalArgs = []) + { + $request = new CreateInstancePartitionRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setInstancePartitionId($instancePartitionId); + $request->setInstancePartition($instancePartition); + $requestParamHeaders['parent'] = $parent; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('CreateInstancePartition', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } + + /** + * Deletes an instance. + * + * Immediately upon completion of the request: + * + * * Billing ceases for all of the instance's reserved resources. + * + * Soon afterward: + * + * * The instance and *all of its databases* immediately and + * irrevocably disappear from the API. All data in the databases + * is permanently deleted. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $formattedName = $instanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * $instanceAdminClient->deleteInstance($formattedName); + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the instance to be deleted. Values are of the form + * `projects//instances/` + * @param array $optionalArgs { + * 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. + * } + * + * @throws ApiException if the remote call fails + */ + public function deleteInstance($name, array $optionalArgs = []) + { + $request = new DeleteInstanceRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteInstance', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Deletes the instance configuration. Deletion is only allowed when no + * instances are using the configuration. If any instances are using + * the configuration, returns `FAILED_PRECONDITION`. + * + * Only user-managed configurations can be deleted. + * + * Authorization requires `spanner.instanceConfigs.delete` permission on + * the resource [name][google.spanner.admin.instance.v1.InstanceConfig.name]. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $formattedName = $instanceAdminClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + * $instanceAdminClient->deleteInstanceConfig($formattedName); + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the instance configuration to be deleted. + * Values are of the form + * `projects//instanceConfigs/` + * @param array $optionalArgs { + * Optional. + * + * @type string $etag + * Used for optimistic concurrency control as a way to help prevent + * simultaneous deletes of an instance configuration from overwriting each + * other. If not empty, the API + * only deletes the instance configuration when the etag provided matches the + * current status of the requested instance configuration. Otherwise, deletes + * the instance configuration without checking the current status of the + * requested instance configuration. + * @type bool $validateOnly + * An option to validate, but not actually execute, a request, + * and provide the same response. + * @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. + * } + * + * @throws ApiException if the remote call fails + */ + public function deleteInstanceConfig($name, array $optionalArgs = []) + { + $request = new DeleteInstanceConfigRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['etag'])) { + $request->setEtag($optionalArgs['etag']); + } + + if (isset($optionalArgs['validateOnly'])) { + $request->setValidateOnly($optionalArgs['validateOnly']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteInstanceConfig', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Deletes an existing instance partition. Requires that the + * instance partition is not used by any database or backup and is not the + * default instance partition of an instance. + * + * Authorization requires `spanner.instancePartitions.delete` permission on + * the resource + * [name][google.spanner.admin.instance.v1.InstancePartition.name]. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $formattedName = $instanceAdminClient->instancePartitionName('[PROJECT]', '[INSTANCE]', '[INSTANCE_PARTITION]'); + * $instanceAdminClient->deleteInstancePartition($formattedName); + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the instance partition to be deleted. + * Values are of the form + * `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}` + * @param array $optionalArgs { + * Optional. + * + * @type string $etag + * Optional. If not empty, the API only deletes the instance partition when + * the etag provided matches the current status of the requested instance + * partition. Otherwise, deletes the instance partition without checking the + * current status of the requested instance partition. + * @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. + * } + * + * @throws ApiException if the remote call fails + */ + public function deleteInstancePartition($name, array $optionalArgs = []) + { + $request = new DeleteInstancePartitionRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['etag'])) { + $request->setEtag($optionalArgs['etag']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteInstancePartition', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Gets the access control policy for an instance resource. Returns an empty + * policy if an instance exists but does not have a policy set. + * + * Authorization requires `spanner.instances.getIamPolicy` on + * [resource][google.iam.v1.GetIamPolicyRequest.resource]. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $resource = 'resource'; + * $response = $instanceAdminClient->getIamPolicy($resource); + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $resource REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param array $optionalArgs { + * Optional. + * + * @type GetPolicyOptions $options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @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 \Google\Cloud\Iam\V1\Policy + * + * @throws ApiException if the remote call fails + */ + public function getIamPolicy($resource, array $optionalArgs = []) + { + $request = new GetIamPolicyRequest(); + $requestParamHeaders = []; + $request->setResource($resource); + $requestParamHeaders['resource'] = $resource; + if (isset($optionalArgs['options'])) { + $request->setOptions($optionalArgs['options']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetIamPolicy', Policy::class, $optionalArgs, $request)->wait(); + } + + /** + * Gets information about a particular instance. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $formattedName = $instanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * $response = $instanceAdminClient->getInstance($formattedName); + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the requested instance. Values are of the form + * `projects//instances/`. + * @param array $optionalArgs { + * Optional. + * + * @type FieldMask $fieldMask + * If field_mask is present, specifies the subset of + * [Instance][google.spanner.admin.instance.v1.Instance] fields that should be + * returned. If absent, all + * [Instance][google.spanner.admin.instance.v1.Instance] fields are returned. + * @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 \Google\Cloud\Spanner\Admin\Instance\V1\Instance + * + * @throws ApiException if the remote call fails + */ + public function getInstance($name, array $optionalArgs = []) + { + $request = new GetInstanceRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['fieldMask'])) { + $request->setFieldMask($optionalArgs['fieldMask']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetInstance', Instance::class, $optionalArgs, $request)->wait(); + } + + /** + * Gets information about a particular instance configuration. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $formattedName = $instanceAdminClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + * $response = $instanceAdminClient->getInstanceConfig($formattedName); + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the requested instance configuration. Values are of + * the form `projects//instanceConfigs/`. + * @param array $optionalArgs { + * 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 \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig + * + * @throws ApiException if the remote call fails + */ + public function getInstanceConfig($name, array $optionalArgs = []) + { + $request = new GetInstanceConfigRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetInstanceConfig', InstanceConfig::class, $optionalArgs, $request)->wait(); + } + + /** + * Gets information about a particular instance partition. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $formattedName = $instanceAdminClient->instancePartitionName('[PROJECT]', '[INSTANCE]', '[INSTANCE_PARTITION]'); + * $response = $instanceAdminClient->getInstancePartition($formattedName); + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the requested instance partition. Values are of + * the form + * `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}`. + * @param array $optionalArgs { + * 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 \Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition + * + * @throws ApiException if the remote call fails + */ + public function getInstancePartition($name, array $optionalArgs = []) + { + $request = new GetInstancePartitionRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetInstancePartition', InstancePartition::class, $optionalArgs, $request)->wait(); + } + + /** + * Lists the user-managed instance configuration long-running + * operations in the given project. An instance + * configuration operation has a name of the form + * `projects//instanceConfigs//operations/`. + * The long-running operation + * metadata field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. Operations returned are ordered by + * `operation.metadata.value.start_time` in descending order starting + * from the most recently started operation. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $formattedParent = $instanceAdminClient->projectName('[PROJECT]'); + * // Iterate over pages of elements + * $pagedResponse = $instanceAdminClient->listInstanceConfigOperations($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $instanceAdminClient->listInstanceConfigOperations($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The project of the instance configuration operations. + * Values are of the form `projects/`. + * @param array $optionalArgs { + * Optional. + * + * @type string $filter + * An expression that filters the list of returned operations. + * + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the Operation are eligible for filtering: + * + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata] + * is + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `done:true` - The operation is complete. + * * `(metadata.@type=` \ + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) + * AND` \ + * `(metadata.instance_config.name:custom-config) AND` \ + * `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata]. + * * The instance configuration name contains "custom-config". + * * The operation started before 2021-03-28T14:50:00Z. + * * The operation resulted in an error. + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @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 \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listInstanceConfigOperations($parent, array $optionalArgs = []) + { + $request = new ListInstanceConfigOperationsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } + + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListInstanceConfigOperations', $optionalArgs, ListInstanceConfigOperationsResponse::class, $request); + } + + /** + * Lists the supported instance configurations for a given project. + * + * Returns both Google-managed configurations and user-managed + * configurations. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $formattedParent = $instanceAdminClient->projectName('[PROJECT]'); + * // Iterate over pages of elements + * $pagedResponse = $instanceAdminClient->listInstanceConfigs($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $instanceAdminClient->listInstanceConfigs($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The name of the project for which a list of supported instance + * configurations is requested. Values are of the form + * `projects/`. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @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 \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listInstanceConfigs($parent, array $optionalArgs = []) + { + $request = new ListInstanceConfigsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListInstanceConfigs', $optionalArgs, ListInstanceConfigsResponse::class, $request); + } + + /** + * Lists instance partition long-running operations in the given instance. + * An instance partition operation has a name of the form + * `projects//instances//instancePartitions//operations/`. + * The long-running operation + * metadata field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. Operations returned are ordered by + * `operation.metadata.value.start_time` in descending order starting from the + * most recently started operation. + * + * Authorization requires `spanner.instancePartitionOperations.list` + * permission on the resource + * [parent][google.spanner.admin.instance.v1.ListInstancePartitionOperationsRequest.parent]. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $formattedParent = $instanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * // Iterate over pages of elements + * $pagedResponse = $instanceAdminClient->listInstancePartitionOperations($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $instanceAdminClient->listInstancePartitionOperations($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The parent instance of the instance partition operations. + * Values are of the form `projects//instances/`. + * @param array $optionalArgs { + * Optional. + * + * @type string $filter + * Optional. An expression that filters the list of returned operations. + * + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the Operation are eligible for filtering: + * + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * [CreateInstancePartitionMetadata][google.spanner.admin.instance.v1.CreateInstancePartitionMetadata] + * is + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstancePartitionMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `done:true` - The operation is complete. + * * `(metadata.@type=` \ + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstancePartitionMetadata) + * AND` \ + * `(metadata.instance_partition.name:custom-instance-partition) AND` \ + * `(metadata.start_time < \"2021-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * [CreateInstancePartitionMetadata][google.spanner.admin.instance.v1.CreateInstancePartitionMetadata]. + * * The instance partition name contains "custom-instance-partition". + * * The operation started before 2021-03-28T14:50:00Z. + * * The operation resulted in an error. + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type Timestamp $instancePartitionDeadline + * Optional. Deadline used while retrieving metadata for instance partition + * operations. Instance partitions whose operation metadata cannot be + * retrieved within this deadline will be added to + * [unreachable_instance_partitions][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse.unreachable_instance_partitions] + * in + * [ListInstancePartitionOperationsResponse][google.spanner.admin.instance.v1.ListInstancePartitionOperationsResponse]. + * @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 \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listInstancePartitionOperations($parent, array $optionalArgs = []) + { + $request = new ListInstancePartitionOperationsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } + + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + if (isset($optionalArgs['instancePartitionDeadline'])) { + $request->setInstancePartitionDeadline($optionalArgs['instancePartitionDeadline']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListInstancePartitionOperations', $optionalArgs, ListInstancePartitionOperationsResponse::class, $request); + } + + /** + * Lists all instance partitions for the given instance. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $formattedParent = $instanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * // Iterate over pages of elements + * $pagedResponse = $instanceAdminClient->listInstancePartitions($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $instanceAdminClient->listInstancePartitions($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The instance whose instance partitions should be listed. Values + * are of the form `projects//instances/`. Use `{instance} + * = '-'` to list instance partitions for all Instances in a project, e.g., + * `projects/myproject/instances/-`. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type Timestamp $instancePartitionDeadline + * Optional. Deadline used while retrieving metadata for instance partitions. + * Instance partitions whose metadata cannot be retrieved within this deadline + * will be added to + * [unreachable][google.spanner.admin.instance.v1.ListInstancePartitionsResponse.unreachable] + * in + * [ListInstancePartitionsResponse][google.spanner.admin.instance.v1.ListInstancePartitionsResponse]. + * @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 \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listInstancePartitions($parent, array $optionalArgs = []) + { + $request = new ListInstancePartitionsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + if (isset($optionalArgs['instancePartitionDeadline'])) { + $request->setInstancePartitionDeadline($optionalArgs['instancePartitionDeadline']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListInstancePartitions', $optionalArgs, ListInstancePartitionsResponse::class, $request); + } + + /** + * Lists all instances in the given project. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $formattedParent = $instanceAdminClient->projectName('[PROJECT]'); + * // Iterate over pages of elements + * $pagedResponse = $instanceAdminClient->listInstances($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $instanceAdminClient->listInstances($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $parent Required. The name of the project for which a list of instances is + * requested. Values are of the form `projects/`. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type string $filter + * An expression for filtering the results of the request. Filter rules are + * case insensitive. The fields eligible for filtering are: + * + * * `name` + * * `display_name` + * * `labels.key` where key is the name of a label + * + * Some examples of using filters are: + * + * * `name:*` --> The instance has a name. + * * `name:Howl` --> The instance's name contains the string "howl". + * * `name:HOWL` --> Equivalent to above. + * * `NAME:howl` --> Equivalent to above. + * * `labels.env:*` --> The instance has the label "env". + * * `labels.env:dev` --> The instance has the label "env" and the value of + * the label contains the string "dev". + * * `name:howl labels.env:dev` --> The instance's name contains "howl" and + * it has the label "env" with its value + * containing "dev". + * @type Timestamp $instanceDeadline + * Deadline used while retrieving metadata for instances. + * Instances whose metadata cannot be retrieved within this deadline will be + * added to + * [unreachable][google.spanner.admin.instance.v1.ListInstancesResponse.unreachable] + * in + * [ListInstancesResponse][google.spanner.admin.instance.v1.ListInstancesResponse]. + * @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 \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listInstances($parent, array $optionalArgs = []) + { + $request = new ListInstancesRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } + + if (isset($optionalArgs['instanceDeadline'])) { + $request->setInstanceDeadline($optionalArgs['instanceDeadline']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListInstances', $optionalArgs, ListInstancesResponse::class, $request); + } + + /** + * Moves an instance to the target instance configuration. You can use the + * returned long-running operation to track + * the progress of moving the instance. + * + * `MoveInstance` returns `FAILED_PRECONDITION` if the instance meets any of + * the following criteria: + * + * * Is undergoing a move to a different instance configuration + * * Has backups + * * Has an ongoing update + * * Contains any CMEK-enabled databases + * * Is a free trial instance + * + * While the operation is pending: + * + * * All other attempts to modify the instance, including changes to its + * compute capacity, are rejected. + * * The following database and backup admin operations are rejected: + * + * * `DatabaseAdmin.CreateDatabase` + * * `DatabaseAdmin.UpdateDatabaseDdl` (disabled if default_leader is + * specified in the request.) + * * `DatabaseAdmin.RestoreDatabase` + * * `DatabaseAdmin.CreateBackup` + * * `DatabaseAdmin.CopyBackup` + * + * * Both the source and target instance configurations are subject to + * hourly compute and storage charges. + * * The instance might experience higher read-write latencies and a higher + * transaction abort rate. However, moving an instance doesn't cause any + * downtime. + * + * The returned long-running operation has + * a name of the format + * `/operations/` and can be used to track + * the move instance operation. The + * metadata field type is + * [MoveInstanceMetadata][google.spanner.admin.instance.v1.MoveInstanceMetadata]. + * The response field type is + * [Instance][google.spanner.admin.instance.v1.Instance], + * if successful. + * Cancelling the operation sets its metadata's + * [cancel_time][google.spanner.admin.instance.v1.MoveInstanceMetadata.cancel_time]. + * Cancellation is not immediate because it involves moving any data + * previously moved to the target instance configuration back to the original + * instance configuration. You can use this operation to track the progress of + * the cancellation. Upon successful completion of the cancellation, the + * operation terminates with `CANCELLED` status. + * + * If not cancelled, upon completion of the returned operation: + * + * * The instance successfully moves to the target instance + * configuration. + * * You are billed for compute and storage in target instance + * configuration. + * + * Authorization requires the `spanner.instances.update` permission on + * the resource [instance][google.spanner.admin.instance.v1.Instance]. + * + * For more details, see + * [Move an instance](https://cloud.google.com/spanner/docs/move-instance). + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $formattedName = $instanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); + * $formattedTargetConfig = $instanceAdminClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + * $operationResponse = $instanceAdminClient->moveInstance($formattedName, $formattedTargetConfig); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $instanceAdminClient->moveInstance($formattedName, $formattedTargetConfig); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $instanceAdminClient->resumeOperation($operationName, 'moveInstance'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $name Required. The instance to move. + * Values are of the form `projects//instances/`. + * @param string $targetConfig Required. The target instance configuration where to move the instance. + * Values are of the form `projects//instanceConfigs/`. + * @param array $optionalArgs { + * 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 \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function moveInstance($name, $targetConfig, array $optionalArgs = []) + { + $request = new MoveInstanceRequest(); + $requestParamHeaders = []; + $request->setName($name); + $request->setTargetConfig($targetConfig); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('MoveInstance', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } + + /** + * Sets the access control policy on an instance resource. Replaces any + * existing policy. + * + * Authorization requires `spanner.instances.setIamPolicy` on + * [resource][google.iam.v1.SetIamPolicyRequest.resource]. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $resource = 'resource'; + * $policy = new Policy(); + * $response = $instanceAdminClient->setIamPolicy($resource, $policy); + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $resource REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param Policy $policy REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param array $optionalArgs { + * Optional. + * + * @type FieldMask $updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @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 \Google\Cloud\Iam\V1\Policy + * + * @throws ApiException if the remote call fails + */ + public function setIamPolicy($resource, $policy, array $optionalArgs = []) + { + $request = new SetIamPolicyRequest(); + $requestParamHeaders = []; + $request->setResource($resource); + $request->setPolicy($policy); + $requestParamHeaders['resource'] = $resource; + if (isset($optionalArgs['updateMask'])) { + $request->setUpdateMask($optionalArgs['updateMask']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('SetIamPolicy', Policy::class, $optionalArgs, $request)->wait(); + } + + /** + * Returns permissions that the caller has on the specified instance resource. + * + * Attempting this RPC on a non-existent Cloud Spanner instance resource will + * result in a NOT_FOUND error if the user has `spanner.instances.list` + * permission on the containing Google Cloud Project. Otherwise returns an + * empty set of permissions. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $resource = 'resource'; + * $permissions = []; + * $response = $instanceAdminClient->testIamPermissions($resource, $permissions); + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param string $resource REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param string[] $permissions The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param array $optionalArgs { + * 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 \Google\Cloud\Iam\V1\TestIamPermissionsResponse + * + * @throws ApiException if the remote call fails + */ + public function testIamPermissions($resource, $permissions, array $optionalArgs = []) + { + $request = new TestIamPermissionsRequest(); + $requestParamHeaders = []; + $request->setResource($resource); + $request->setPermissions($permissions); + $requestParamHeaders['resource'] = $resource; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('TestIamPermissions', TestIamPermissionsResponse::class, $optionalArgs, $request)->wait(); + } + + /** + * Updates an instance, and begins allocating or releasing resources + * as requested. The returned long-running operation can be used to track the + * progress of updating the instance. If the named instance does not + * exist, returns `NOT_FOUND`. + * + * Immediately upon completion of this request: + * + * * For resource types for which a decrease in the instance's allocation + * has been requested, billing is based on the newly-requested level. + * + * Until completion of the returned operation: + * + * * Cancelling the operation sets its metadata's + * [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], + * and begins restoring resources to their pre-request values. The + * operation is guaranteed to succeed at undoing all resource changes, + * after which point it terminates with a `CANCELLED` status. + * * All other attempts to modify the instance are rejected. + * * Reading the instance via the API continues to give the pre-request + * resource levels. + * + * Upon completion of the returned operation: + * + * * Billing begins for all successfully-allocated resources (some types + * may have lower than the requested levels). + * * All newly-reserved resources are available for serving the instance's + * tables. + * * The instance's new resource levels are readable via the API. + * + * The returned long-running operation will + * have a name of the format `/operations/` and + * can be used to track the instance modification. The + * metadata field type is + * [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. + * The response field type is + * [Instance][google.spanner.admin.instance.v1.Instance], if successful. + * + * Authorization requires `spanner.instances.update` permission on + * the resource [name][google.spanner.admin.instance.v1.Instance.name]. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $instance = new Instance(); + * $fieldMask = new FieldMask(); + * $operationResponse = $instanceAdminClient->updateInstance($instance, $fieldMask); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $instanceAdminClient->updateInstance($instance, $fieldMask); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $instanceAdminClient->resumeOperation($operationName, 'updateInstance'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param Instance $instance Required. The instance to update, which must always include the instance + * name. Otherwise, only fields mentioned in + * [field_mask][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] + * need be included. + * @param FieldMask $fieldMask Required. A mask specifying which fields in + * [Instance][google.spanner.admin.instance.v1.Instance] should be updated. + * The field mask must always be specified; this prevents any future fields in + * [Instance][google.spanner.admin.instance.v1.Instance] from being erased + * accidentally by clients that do not know about them. + * @param array $optionalArgs { + * 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 \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function updateInstance($instance, $fieldMask, array $optionalArgs = []) + { + $request = new UpdateInstanceRequest(); + $requestParamHeaders = []; + $request->setInstance($instance); + $request->setFieldMask($fieldMask); + $requestParamHeaders['instance.name'] = $instance->getName(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('UpdateInstance', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } + + /** + * Updates an instance configuration. The returned + * long-running operation can be used to track + * the progress of updating the instance. If the named instance configuration + * does not exist, returns `NOT_FOUND`. + * + * Only user-managed configurations can be updated. + * + * Immediately after the request returns: + * + * * The instance configuration's + * [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + * field is set to true. + * + * While the operation is pending: + * + * * Cancelling the operation sets its metadata's + * [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.cancel_time]. + * The operation is guaranteed to succeed at undoing all changes, after + * which point it terminates with a `CANCELLED` status. + * * All other attempts to modify the instance configuration are rejected. + * * Reading the instance configuration via the API continues to give the + * pre-request values. + * + * Upon completion of the returned operation: + * + * * Creating instances using the instance configuration uses the new + * values. + * * The new values of the instance configuration are readable via the API. + * * The instance configuration's + * [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + * field becomes false. + * + * The returned long-running operation will + * have a name of the format + * `/operations/` and can be used to track + * the instance configuration modification. The + * metadata field type is + * [UpdateInstanceConfigMetadata][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata]. + * The response field type is + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if + * successful. + * + * Authorization requires `spanner.instanceConfigs.update` permission on + * the resource [name][google.spanner.admin.instance.v1.InstanceConfig.name]. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $instanceConfig = new InstanceConfig(); + * $updateMask = new FieldMask(); + * $operationResponse = $instanceAdminClient->updateInstanceConfig($instanceConfig, $updateMask); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $instanceAdminClient->updateInstanceConfig($instanceConfig, $updateMask); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $instanceAdminClient->resumeOperation($operationName, 'updateInstanceConfig'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param InstanceConfig $instanceConfig Required. The user instance configuration to update, which must always + * include the instance configuration name. Otherwise, only fields mentioned + * in + * [update_mask][google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.update_mask] + * need be included. To prevent conflicts of concurrent updates, + * [etag][google.spanner.admin.instance.v1.InstanceConfig.reconciling] can + * be used. + * @param FieldMask $updateMask Required. A mask specifying which fields in + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] should be + * updated. The field mask must always be specified; this prevents any future + * fields in [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] + * from being erased accidentally by clients that do not know about them. Only + * display_name and labels can be updated. + * @param array $optionalArgs { + * Optional. + * + * @type bool $validateOnly + * An option to validate, but not actually execute, a request, + * and provide the same response. + * @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 \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function updateInstanceConfig($instanceConfig, $updateMask, array $optionalArgs = []) + { + $request = new UpdateInstanceConfigRequest(); + $requestParamHeaders = []; + $request->setInstanceConfig($instanceConfig); + $request->setUpdateMask($updateMask); + $requestParamHeaders['instance_config.name'] = $instanceConfig->getName(); + if (isset($optionalArgs['validateOnly'])) { + $request->setValidateOnly($optionalArgs['validateOnly']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('UpdateInstanceConfig', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } + + /** + * Updates an instance partition, and begins allocating or releasing resources + * as requested. The returned long-running operation can be used to track the + * progress of updating the instance partition. If the named instance + * partition does not exist, returns `NOT_FOUND`. + * + * Immediately upon completion of this request: + * + * * For resource types for which a decrease in the instance partition's + * allocation has been requested, billing is based on the newly-requested + * level. + * + * Until completion of the returned operation: + * + * * Cancelling the operation sets its metadata's + * [cancel_time][google.spanner.admin.instance.v1.UpdateInstancePartitionMetadata.cancel_time], + * and begins restoring resources to their pre-request values. The + * operation is guaranteed to succeed at undoing all resource changes, + * after which point it terminates with a `CANCELLED` status. + * * All other attempts to modify the instance partition are rejected. + * * Reading the instance partition via the API continues to give the + * pre-request resource levels. + * + * Upon completion of the returned operation: + * + * * Billing begins for all successfully-allocated resources (some types + * may have lower than the requested levels). + * * All newly-reserved resources are available for serving the instance + * partition's tables. + * * The instance partition's new resource levels are readable via the API. + * + * The returned long-running operation will + * have a name of the format + * `/operations/` and can be used to + * track the instance partition modification. The + * metadata field type is + * [UpdateInstancePartitionMetadata][google.spanner.admin.instance.v1.UpdateInstancePartitionMetadata]. + * The response field type is + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition], if + * successful. + * + * Authorization requires `spanner.instancePartitions.update` permission on + * the resource + * [name][google.spanner.admin.instance.v1.InstancePartition.name]. + * + * Sample code: + * ``` + * $instanceAdminClient = new InstanceAdminClient(); + * try { + * $instancePartition = new InstancePartition(); + * $fieldMask = new FieldMask(); + * $operationResponse = $instanceAdminClient->updateInstancePartition($instancePartition, $fieldMask); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $instanceAdminClient->updateInstancePartition($instancePartition, $fieldMask); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $instanceAdminClient->resumeOperation($operationName, 'updateInstancePartition'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $instanceAdminClient->close(); + * } + * ``` + * + * @param InstancePartition $instancePartition Required. The instance partition to update, which must always include the + * instance partition name. Otherwise, only fields mentioned in + * [field_mask][google.spanner.admin.instance.v1.UpdateInstancePartitionRequest.field_mask] + * need be included. + * @param FieldMask $fieldMask Required. A mask specifying which fields in + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition] + * should be updated. The field mask must always be specified; this prevents + * any future fields in + * [InstancePartition][google.spanner.admin.instance.v1.InstancePartition] + * from being erased accidentally by clients that do not know about them. + * @param array $optionalArgs { + * 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 \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function updateInstancePartition($instancePartition, $fieldMask, array $optionalArgs = []) + { + $request = new UpdateInstancePartitionRequest(); + $requestParamHeaders = []; + $request->setInstancePartition($instancePartition); + $request->setFieldMask($fieldMask); + $requestParamHeaders['instance_partition.name'] = $instancePartition->getName(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('UpdateInstancePartition', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } +} diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/src/V1/InstanceAdminClient.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/src/V1/InstanceAdminClient.php new file mode 100644 index 000000000000..0c7e3e10d313 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/src/V1/InstanceAdminClient.php @@ -0,0 +1,34 @@ + [ + 'google.spanner.admin.instance.v1.InstanceAdmin' => [ + 'CreateInstance' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\Instance', + 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\CreateInstanceMetadata', + 'initialPollDelayMillis' => '20000', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '45000', + 'totalPollTimeoutMillis' => '86400000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'CreateInstanceConfig' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig', + 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\CreateInstanceConfigMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'CreateInstancePartition' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition', + 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\CreateInstancePartitionMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'MoveInstance' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\MoveInstanceResponse', + 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\MoveInstanceMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'UpdateInstance' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\Instance', + 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceMetadata', + 'initialPollDelayMillis' => '20000', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '45000', + 'totalPollTimeoutMillis' => '86400000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'instance.name', + 'fieldAccessors' => [ + 'getInstance', + 'getName', + ], + ], + ], + ], + 'UpdateInstanceConfig' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig', + 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceConfigMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'instance_config.name', + 'fieldAccessors' => [ + 'getInstanceConfig', + 'getName', + ], + ], + ], + ], + 'UpdateInstancePartition' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition', + 'metadataReturnType' => '\Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstancePartitionMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'instance_partition.name', + 'fieldAccessors' => [ + 'getInstancePartition', + 'getName', + ], + ], + ], + ], + 'DeleteInstance' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'DeleteInstanceConfig' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'DeleteInstancePartition' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetIamPolicy' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Iam\V1\Policy', + 'headerParams' => [ + [ + 'keyName' => 'resource', + 'fieldAccessors' => [ + 'getResource', + ], + ], + ], + ], + 'GetInstance' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Instance\V1\Instance', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetInstanceConfig' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetInstancePartition' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'ListInstanceConfigOperations' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getOperations', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Instance\V1\ListInstanceConfigOperationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'ListInstanceConfigs' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getInstanceConfigs', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Instance\V1\ListInstanceConfigsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'ListInstancePartitionOperations' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getOperations', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Instance\V1\ListInstancePartitionOperationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'ListInstancePartitions' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getInstancePartitions', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Instance\V1\ListInstancePartitionsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'ListInstances' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getInstances', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Spanner\Admin\Instance\V1\ListInstancesResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'SetIamPolicy' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Iam\V1\Policy', + 'headerParams' => [ + [ + 'keyName' => 'resource', + 'fieldAccessors' => [ + 'getResource', + ], + ], + ], + ], + 'TestIamPermissions' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Iam\V1\TestIamPermissionsResponse', + 'headerParams' => [ + [ + 'keyName' => 'resource', + 'fieldAccessors' => [ + 'getResource', + ], + ], + ], + ], + 'templateMap' => [ + 'instance' => 'projects/{project}/instances/{instance}', + 'instanceConfig' => 'projects/{project}/instanceConfigs/{instance_config}', + 'instancePartition' => 'projects/{project}/instances/{instance}/instancePartitions/{instance_partition}', + 'project' => 'projects/{project}', + ], + ], + ], +]; diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/src/V1/resources/instance_admin_rest_client_config.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/src/V1/resources/instance_admin_rest_client_config.php new file mode 100644 index 000000000000..1f11b12ff0d9 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/src/V1/resources/instance_admin_rest_client_config.php @@ -0,0 +1,343 @@ + [ + 'google.longrunning.Operations' => [ + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}:cancel', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}:cancel', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + 'google.spanner.admin.instance.v1.InstanceAdmin' => [ + 'CreateInstance' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*}/instances', + 'body' => '*', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'CreateInstanceConfig' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*}/instanceConfigs', + 'body' => '*', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'CreateInstancePartition' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*/instances/*}/instancePartitions', + 'body' => '*', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteInstance' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteInstanceConfig' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instanceConfigs/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteInstancePartition' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/instancePartitions/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetIamPolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*}:getIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'GetInstance' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetInstanceConfig' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instanceConfigs/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetInstancePartition' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/instancePartitions/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListInstanceConfigOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*}/instanceConfigOperations', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'ListInstanceConfigs' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*}/instanceConfigs', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'ListInstancePartitionOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/instances/*}/instancePartitionOperations', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'ListInstancePartitions' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/instances/*}/instancePartitions', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'ListInstances' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*}/instances', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'MoveInstance' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/instances/*}:move', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'SetIamPolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*}:setIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'TestIamPermissions' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/instances/*}:testIamPermissions', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'UpdateInstance' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{instance.name=projects/*/instances/*}', + 'body' => '*', + 'placeholders' => [ + 'instance.name' => [ + 'getters' => [ + 'getInstance', + 'getName', + ], + ], + ], + ], + 'UpdateInstanceConfig' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{instance_config.name=projects/*/instanceConfigs/*}', + 'body' => '*', + 'placeholders' => [ + 'instance_config.name' => [ + 'getters' => [ + 'getInstanceConfig', + 'getName', + ], + ], + ], + ], + 'UpdateInstancePartition' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{instance_partition.name=projects/*/instances/*/instancePartitions/*}', + 'body' => '*', + 'placeholders' => [ + 'instance_partition.name' => [ + 'getters' => [ + 'getInstancePartition', + 'getName', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/tests/Unit/V1/Client/InstanceAdminClientTest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/tests/Unit/V1/Client/InstanceAdminClientTest.php new file mode 100644 index 000000000000..8af298f11c03 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/tests/Unit/V1/Client/InstanceAdminClientTest.php @@ -0,0 +1,2172 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return InstanceAdminClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new InstanceAdminClient($options); + } + + /** @test */ + public function createInstanceTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $config = 'config-1354792126'; + $displayName = 'displayName1615086568'; + $nodeCount = 1539922066; + $processingUnits = 329117885; + $expectedResponse = new Instance(); + $expectedResponse->setName($name); + $expectedResponse->setConfig($config); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setNodeCount($nodeCount); + $expectedResponse->setProcessingUnits($processingUnits); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createInstanceTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $instanceId = 'instanceId-2101995259'; + $instance = new Instance(); + $instanceName = 'instanceName-737857344'; + $instance->setName($instanceName); + $instanceConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $instance->setConfig($instanceConfig); + $instanceDisplayName = 'instanceDisplayName1824500376'; + $instance->setDisplayName($instanceDisplayName); + $request = (new CreateInstanceRequest()) + ->setParent($formattedParent) + ->setInstanceId($instanceId) + ->setInstance($instance); + $response = $gapicClient->createInstance($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/CreateInstance', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getInstanceId(); + $this->assertProtobufEquals($instanceId, $actualValue); + $actualValue = $actualApiRequestObject->getInstance(); + $this->assertProtobufEquals($instance, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createInstanceTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createInstanceExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $instanceId = 'instanceId-2101995259'; + $instance = new Instance(); + $instanceName = 'instanceName-737857344'; + $instance->setName($instanceName); + $instanceConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $instance->setConfig($instanceConfig); + $instanceDisplayName = 'instanceDisplayName1824500376'; + $instance->setDisplayName($instanceDisplayName); + $request = (new CreateInstanceRequest()) + ->setParent($formattedParent) + ->setInstanceId($instanceId) + ->setInstance($instance); + $response = $gapicClient->createInstance($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createInstanceTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createInstanceConfigTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createInstanceConfigTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $baseConfig = 'baseConfig1990483056'; + $etag = 'etag3123477'; + $reconciling = false; + $storageLimitPerProcessingUnit = 1769187130; + $expectedResponse = new InstanceConfig(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setBaseConfig($baseConfig); + $expectedResponse->setEtag($etag); + $expectedResponse->setReconciling($reconciling); + $expectedResponse->setStorageLimitPerProcessingUnit($storageLimitPerProcessingUnit); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createInstanceConfigTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $instanceConfigId = 'instanceConfigId-1789417458'; + $instanceConfig = new InstanceConfig(); + $request = (new CreateInstanceConfigRequest()) + ->setParent($formattedParent) + ->setInstanceConfigId($instanceConfigId) + ->setInstanceConfig($instanceConfig); + $response = $gapicClient->createInstanceConfig($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/CreateInstanceConfig', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getInstanceConfigId(); + $this->assertProtobufEquals($instanceConfigId, $actualValue); + $actualValue = $actualApiRequestObject->getInstanceConfig(); + $this->assertProtobufEquals($instanceConfig, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createInstanceConfigTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createInstanceConfigExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createInstanceConfigTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $instanceConfigId = 'instanceConfigId-1789417458'; + $instanceConfig = new InstanceConfig(); + $request = (new CreateInstanceConfigRequest()) + ->setParent($formattedParent) + ->setInstanceConfigId($instanceConfigId) + ->setInstanceConfig($instanceConfig); + $response = $gapicClient->createInstanceConfig($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createInstanceConfigTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createInstancePartitionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createInstancePartitionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $config = 'config-1354792126'; + $displayName = 'displayName1615086568'; + $nodeCount = 1539922066; + $etag = 'etag3123477'; + $expectedResponse = new InstancePartition(); + $expectedResponse->setName($name); + $expectedResponse->setConfig($config); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setNodeCount($nodeCount); + $expectedResponse->setEtag($etag); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createInstancePartitionTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $instancePartitionId = 'instancePartitionId288435706'; + $instancePartition = new InstancePartition(); + $instancePartitionName = 'instancePartitionName1272312320'; + $instancePartition->setName($instancePartitionName); + $instancePartitionConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $instancePartition->setConfig($instancePartitionConfig); + $instancePartitionDisplayName = 'instancePartitionDisplayName1175388504'; + $instancePartition->setDisplayName($instancePartitionDisplayName); + $request = (new CreateInstancePartitionRequest()) + ->setParent($formattedParent) + ->setInstancePartitionId($instancePartitionId) + ->setInstancePartition($instancePartition); + $response = $gapicClient->createInstancePartition($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/CreateInstancePartition', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getInstancePartitionId(); + $this->assertProtobufEquals($instancePartitionId, $actualValue); + $actualValue = $actualApiRequestObject->getInstancePartition(); + $this->assertProtobufEquals($instancePartition, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createInstancePartitionTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createInstancePartitionExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createInstancePartitionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $instancePartitionId = 'instancePartitionId288435706'; + $instancePartition = new InstancePartition(); + $instancePartitionName = 'instancePartitionName1272312320'; + $instancePartition->setName($instancePartitionName); + $instancePartitionConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $instancePartition->setConfig($instancePartitionConfig); + $instancePartitionDisplayName = 'instancePartitionDisplayName1175388504'; + $instancePartition->setDisplayName($instancePartitionDisplayName); + $request = (new CreateInstancePartitionRequest()) + ->setParent($formattedParent) + ->setInstancePartitionId($instancePartitionId) + ->setInstancePartition($instancePartition); + $response = $gapicClient->createInstancePartition($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createInstancePartitionTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function deleteInstanceTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $request = (new DeleteInstanceRequest()) + ->setName($formattedName); + $gapicClient->deleteInstance($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/DeleteInstance', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteInstanceExceptionTest() + { + $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->instanceName('[PROJECT]', '[INSTANCE]'); + $request = (new DeleteInstanceRequest()) + ->setName($formattedName); + try { + $gapicClient->deleteInstance($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 deleteInstanceConfigTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $request = (new DeleteInstanceConfigRequest()) + ->setName($formattedName); + $gapicClient->deleteInstanceConfig($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/DeleteInstanceConfig', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteInstanceConfigExceptionTest() + { + $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->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $request = (new DeleteInstanceConfigRequest()) + ->setName($formattedName); + try { + $gapicClient->deleteInstanceConfig($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 deleteInstancePartitionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->instancePartitionName('[PROJECT]', '[INSTANCE]', '[INSTANCE_PARTITION]'); + $request = (new DeleteInstancePartitionRequest()) + ->setName($formattedName); + $gapicClient->deleteInstancePartition($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/DeleteInstancePartition', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteInstancePartitionExceptionTest() + { + $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->instancePartitionName('[PROJECT]', '[INSTANCE]', '[INSTANCE_PARTITION]'); + $request = (new DeleteInstancePartitionRequest()) + ->setName($formattedName); + try { + $gapicClient->deleteInstancePartition($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 getIamPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $version = 351608024; + $etag = '21'; + $expectedResponse = new Policy(); + $expectedResponse->setVersion($version); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $request = (new GetIamPolicyRequest()) + ->setResource($resource); + $response = $gapicClient->getIamPolicy($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/GetIamPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getIamPolicyExceptionTest() + { + $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 + $resource = 'resource-341064690'; + $request = (new GetIamPolicyRequest()) + ->setResource($resource); + try { + $gapicClient->getIamPolicy($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 getInstanceTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $config = 'config-1354792126'; + $displayName = 'displayName1615086568'; + $nodeCount = 1539922066; + $processingUnits = 329117885; + $expectedResponse = new Instance(); + $expectedResponse->setName($name2); + $expectedResponse->setConfig($config); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setNodeCount($nodeCount); + $expectedResponse->setProcessingUnits($processingUnits); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $request = (new GetInstanceRequest()) + ->setName($formattedName); + $response = $gapicClient->getInstance($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/GetInstance', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getInstanceExceptionTest() + { + $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->instanceName('[PROJECT]', '[INSTANCE]'); + $request = (new GetInstanceRequest()) + ->setName($formattedName); + try { + $gapicClient->getInstance($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 getInstanceConfigTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $displayName = 'displayName1615086568'; + $baseConfig = 'baseConfig1990483056'; + $etag = 'etag3123477'; + $reconciling = false; + $storageLimitPerProcessingUnit = 1769187130; + $expectedResponse = new InstanceConfig(); + $expectedResponse->setName($name2); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setBaseConfig($baseConfig); + $expectedResponse->setEtag($etag); + $expectedResponse->setReconciling($reconciling); + $expectedResponse->setStorageLimitPerProcessingUnit($storageLimitPerProcessingUnit); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $request = (new GetInstanceConfigRequest()) + ->setName($formattedName); + $response = $gapicClient->getInstanceConfig($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/GetInstanceConfig', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getInstanceConfigExceptionTest() + { + $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->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $request = (new GetInstanceConfigRequest()) + ->setName($formattedName); + try { + $gapicClient->getInstanceConfig($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 getInstancePartitionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $config = 'config-1354792126'; + $displayName = 'displayName1615086568'; + $nodeCount = 1539922066; + $etag = 'etag3123477'; + $expectedResponse = new InstancePartition(); + $expectedResponse->setName($name2); + $expectedResponse->setConfig($config); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setNodeCount($nodeCount); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->instancePartitionName('[PROJECT]', '[INSTANCE]', '[INSTANCE_PARTITION]'); + $request = (new GetInstancePartitionRequest()) + ->setName($formattedName); + $response = $gapicClient->getInstancePartition($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/GetInstancePartition', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getInstancePartitionExceptionTest() + { + $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->instancePartitionName('[PROJECT]', '[INSTANCE]', '[INSTANCE_PARTITION]'); + $request = (new GetInstancePartitionRequest()) + ->setName($formattedName); + try { + $gapicClient->getInstancePartition($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 listInstanceConfigOperationsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $operationsElement = new Operation(); + $operations = [ + $operationsElement, + ]; + $expectedResponse = new ListInstanceConfigOperationsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setOperations($operations); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $request = (new ListInstanceConfigOperationsRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listInstanceConfigOperations($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getOperations()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/ListInstanceConfigOperations', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listInstanceConfigOperationsExceptionTest() + { + $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 + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $request = (new ListInstanceConfigOperationsRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listInstanceConfigOperations($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 listInstanceConfigsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $instanceConfigsElement = new InstanceConfig(); + $instanceConfigs = [ + $instanceConfigsElement, + ]; + $expectedResponse = new ListInstanceConfigsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setInstanceConfigs($instanceConfigs); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $request = (new ListInstanceConfigsRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listInstanceConfigs($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getInstanceConfigs()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/ListInstanceConfigs', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listInstanceConfigsExceptionTest() + { + $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 + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $request = (new ListInstanceConfigsRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listInstanceConfigs($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 listInstancePartitionOperationsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $operationsElement = new Operation(); + $operations = [ + $operationsElement, + ]; + $expectedResponse = new ListInstancePartitionOperationsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setOperations($operations); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $request = (new ListInstancePartitionOperationsRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listInstancePartitionOperations($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getOperations()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/ListInstancePartitionOperations', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listInstancePartitionOperationsExceptionTest() + { + $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 + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $request = (new ListInstancePartitionOperationsRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listInstancePartitionOperations($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 listInstancePartitionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $instancePartitionsElement = new InstancePartition(); + $instancePartitions = [ + $instancePartitionsElement, + ]; + $expectedResponse = new ListInstancePartitionsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setInstancePartitions($instancePartitions); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $request = (new ListInstancePartitionsRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listInstancePartitions($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getInstancePartitions()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/ListInstancePartitions', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listInstancePartitionsExceptionTest() + { + $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 + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $request = (new ListInstancePartitionsRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listInstancePartitions($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 listInstancesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $instancesElement = new Instance(); + $instances = [ + $instancesElement, + ]; + $expectedResponse = new ListInstancesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setInstances($instances); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $request = (new ListInstancesRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listInstances($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getInstances()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/ListInstances', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listInstancesExceptionTest() + { + $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 + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $request = (new ListInstancesRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listInstances($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 moveInstanceTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/moveInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new MoveInstanceResponse(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/moveInstanceTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedName = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $formattedTargetConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $request = (new MoveInstanceRequest()) + ->setName($formattedName) + ->setTargetConfig($formattedTargetConfig); + $response = $gapicClient->moveInstance($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/MoveInstance', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $actualValue = $actualApiRequestObject->getTargetConfig(); + $this->assertProtobufEquals($formattedTargetConfig, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/moveInstanceTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function moveInstanceExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/moveInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $formattedTargetConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $request = (new MoveInstanceRequest()) + ->setName($formattedName) + ->setTargetConfig($formattedTargetConfig); + $response = $gapicClient->moveInstance($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/moveInstanceTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function setIamPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $version = 351608024; + $etag = '21'; + $expectedResponse = new Policy(); + $expectedResponse->setVersion($version); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $policy = new Policy(); + $request = (new SetIamPolicyRequest()) + ->setResource($resource) + ->setPolicy($policy); + $response = $gapicClient->setIamPolicy($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/SetIamPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $actualValue = $actualRequestObject->getPolicy(); + $this->assertProtobufEquals($policy, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function setIamPolicyExceptionTest() + { + $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 + $resource = 'resource-341064690'; + $policy = new Policy(); + $request = (new SetIamPolicyRequest()) + ->setResource($resource) + ->setPolicy($policy); + try { + $gapicClient->setIamPolicy($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 testIamPermissionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new TestIamPermissionsResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $permissions = []; + $request = (new TestIamPermissionsRequest()) + ->setResource($resource) + ->setPermissions($permissions); + $response = $gapicClient->testIamPermissions($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/TestIamPermissions', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $actualValue = $actualRequestObject->getPermissions(); + $this->assertProtobufEquals($permissions, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function testIamPermissionsExceptionTest() + { + $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 + $resource = 'resource-341064690'; + $permissions = []; + $request = (new TestIamPermissionsRequest()) + ->setResource($resource) + ->setPermissions($permissions); + try { + $gapicClient->testIamPermissions($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 updateInstanceTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $config = 'config-1354792126'; + $displayName = 'displayName1615086568'; + $nodeCount = 1539922066; + $processingUnits = 329117885; + $expectedResponse = new Instance(); + $expectedResponse->setName($name); + $expectedResponse->setConfig($config); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setNodeCount($nodeCount); + $expectedResponse->setProcessingUnits($processingUnits); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/updateInstanceTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $instance = new Instance(); + $instanceName = 'instanceName-737857344'; + $instance->setName($instanceName); + $instanceConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $instance->setConfig($instanceConfig); + $instanceDisplayName = 'instanceDisplayName1824500376'; + $instance->setDisplayName($instanceDisplayName); + $fieldMask = new FieldMask(); + $request = (new UpdateInstanceRequest()) + ->setInstance($instance) + ->setFieldMask($fieldMask); + $response = $gapicClient->updateInstance($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/UpdateInstance', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getInstance(); + $this->assertProtobufEquals($instance, $actualValue); + $actualValue = $actualApiRequestObject->getFieldMask(); + $this->assertProtobufEquals($fieldMask, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateInstanceTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateInstanceExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $instance = new Instance(); + $instanceName = 'instanceName-737857344'; + $instance->setName($instanceName); + $instanceConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $instance->setConfig($instanceConfig); + $instanceDisplayName = 'instanceDisplayName1824500376'; + $instance->setDisplayName($instanceDisplayName); + $fieldMask = new FieldMask(); + $request = (new UpdateInstanceRequest()) + ->setInstance($instance) + ->setFieldMask($fieldMask); + $response = $gapicClient->updateInstance($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateInstanceTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateInstanceConfigTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateInstanceConfigTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $baseConfig = 'baseConfig1990483056'; + $etag = 'etag3123477'; + $reconciling = false; + $storageLimitPerProcessingUnit = 1769187130; + $expectedResponse = new InstanceConfig(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setBaseConfig($baseConfig); + $expectedResponse->setEtag($etag); + $expectedResponse->setReconciling($reconciling); + $expectedResponse->setStorageLimitPerProcessingUnit($storageLimitPerProcessingUnit); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/updateInstanceConfigTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $instanceConfig = new InstanceConfig(); + $updateMask = new FieldMask(); + $request = (new UpdateInstanceConfigRequest()) + ->setInstanceConfig($instanceConfig) + ->setUpdateMask($updateMask); + $response = $gapicClient->updateInstanceConfig($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/UpdateInstanceConfig', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getInstanceConfig(); + $this->assertProtobufEquals($instanceConfig, $actualValue); + $actualValue = $actualApiRequestObject->getUpdateMask(); + $this->assertProtobufEquals($updateMask, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateInstanceConfigTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateInstanceConfigExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateInstanceConfigTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $instanceConfig = new InstanceConfig(); + $updateMask = new FieldMask(); + $request = (new UpdateInstanceConfigRequest()) + ->setInstanceConfig($instanceConfig) + ->setUpdateMask($updateMask); + $response = $gapicClient->updateInstanceConfig($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateInstanceConfigTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateInstancePartitionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateInstancePartitionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $config = 'config-1354792126'; + $displayName = 'displayName1615086568'; + $nodeCount = 1539922066; + $etag = 'etag3123477'; + $expectedResponse = new InstancePartition(); + $expectedResponse->setName($name); + $expectedResponse->setConfig($config); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setNodeCount($nodeCount); + $expectedResponse->setEtag($etag); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/updateInstancePartitionTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $instancePartition = new InstancePartition(); + $instancePartitionName = 'instancePartitionName1272312320'; + $instancePartition->setName($instancePartitionName); + $instancePartitionConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $instancePartition->setConfig($instancePartitionConfig); + $instancePartitionDisplayName = 'instancePartitionDisplayName1175388504'; + $instancePartition->setDisplayName($instancePartitionDisplayName); + $fieldMask = new FieldMask(); + $request = (new UpdateInstancePartitionRequest()) + ->setInstancePartition($instancePartition) + ->setFieldMask($fieldMask); + $response = $gapicClient->updateInstancePartition($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/UpdateInstancePartition', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getInstancePartition(); + $this->assertProtobufEquals($instancePartition, $actualValue); + $actualValue = $actualApiRequestObject->getFieldMask(); + $this->assertProtobufEquals($fieldMask, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateInstancePartitionTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateInstancePartitionExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateInstancePartitionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $instancePartition = new InstancePartition(); + $instancePartitionName = 'instancePartitionName1272312320'; + $instancePartition->setName($instancePartitionName); + $instancePartitionConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $instancePartition->setConfig($instancePartitionConfig); + $instancePartitionDisplayName = 'instancePartitionDisplayName1175388504'; + $instancePartition->setDisplayName($instancePartitionDisplayName); + $fieldMask = new FieldMask(); + $request = (new UpdateInstancePartitionRequest()) + ->setInstancePartition($instancePartition) + ->setFieldMask($fieldMask); + $response = $gapicClient->updateInstancePartition($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateInstancePartitionTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createInstanceAsyncTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $config = 'config-1354792126'; + $displayName = 'displayName1615086568'; + $nodeCount = 1539922066; + $processingUnits = 329117885; + $expectedResponse = new Instance(); + $expectedResponse->setName($name); + $expectedResponse->setConfig($config); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setNodeCount($nodeCount); + $expectedResponse->setProcessingUnits($processingUnits); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createInstanceTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $instanceId = 'instanceId-2101995259'; + $instance = new Instance(); + $instanceName = 'instanceName-737857344'; + $instance->setName($instanceName); + $instanceConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $instance->setConfig($instanceConfig); + $instanceDisplayName = 'instanceDisplayName1824500376'; + $instance->setDisplayName($instanceDisplayName); + $request = (new CreateInstanceRequest()) + ->setParent($formattedParent) + ->setInstanceId($instanceId) + ->setInstance($instance); + $response = $gapicClient->createInstanceAsync($request)->wait(); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/CreateInstance', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getInstanceId(); + $this->assertProtobufEquals($instanceId, $actualValue); + $actualValue = $actualApiRequestObject->getInstance(); + $this->assertProtobufEquals($instance, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createInstanceTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } +} diff --git a/owl-bot-staging/Spanner/v1/Admin/Instance/v1/tests/Unit/V1/InstanceAdminClientTest.php b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/tests/Unit/V1/InstanceAdminClientTest.php new file mode 100644 index 000000000000..dbe048dd5628 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/Admin/Instance/v1/tests/Unit/V1/InstanceAdminClientTest.php @@ -0,0 +1,1955 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return InstanceAdminClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new InstanceAdminClient($options); + } + + /** @test */ + public function createInstanceTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $config = 'config-1354792126'; + $displayName = 'displayName1615086568'; + $nodeCount = 1539922066; + $processingUnits = 329117885; + $expectedResponse = new Instance(); + $expectedResponse->setName($name); + $expectedResponse->setConfig($config); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setNodeCount($nodeCount); + $expectedResponse->setProcessingUnits($processingUnits); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createInstanceTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $instanceId = 'instanceId-2101995259'; + $instance = new Instance(); + $instanceName = 'instanceName-737857344'; + $instance->setName($instanceName); + $instanceConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $instance->setConfig($instanceConfig); + $instanceDisplayName = 'instanceDisplayName1824500376'; + $instance->setDisplayName($instanceDisplayName); + $response = $gapicClient->createInstance($formattedParent, $instanceId, $instance); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/CreateInstance', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getInstanceId(); + $this->assertProtobufEquals($instanceId, $actualValue); + $actualValue = $actualApiRequestObject->getInstance(); + $this->assertProtobufEquals($instance, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createInstanceTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createInstanceExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $instanceId = 'instanceId-2101995259'; + $instance = new Instance(); + $instanceName = 'instanceName-737857344'; + $instance->setName($instanceName); + $instanceConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $instance->setConfig($instanceConfig); + $instanceDisplayName = 'instanceDisplayName1824500376'; + $instance->setDisplayName($instanceDisplayName); + $response = $gapicClient->createInstance($formattedParent, $instanceId, $instance); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createInstanceTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createInstanceConfigTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createInstanceConfigTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $baseConfig = 'baseConfig1990483056'; + $etag = 'etag3123477'; + $reconciling = false; + $storageLimitPerProcessingUnit = 1769187130; + $expectedResponse = new InstanceConfig(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setBaseConfig($baseConfig); + $expectedResponse->setEtag($etag); + $expectedResponse->setReconciling($reconciling); + $expectedResponse->setStorageLimitPerProcessingUnit($storageLimitPerProcessingUnit); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createInstanceConfigTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $instanceConfigId = 'instanceConfigId-1789417458'; + $instanceConfig = new InstanceConfig(); + $response = $gapicClient->createInstanceConfig($formattedParent, $instanceConfigId, $instanceConfig); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/CreateInstanceConfig', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getInstanceConfigId(); + $this->assertProtobufEquals($instanceConfigId, $actualValue); + $actualValue = $actualApiRequestObject->getInstanceConfig(); + $this->assertProtobufEquals($instanceConfig, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createInstanceConfigTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createInstanceConfigExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createInstanceConfigTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $instanceConfigId = 'instanceConfigId-1789417458'; + $instanceConfig = new InstanceConfig(); + $response = $gapicClient->createInstanceConfig($formattedParent, $instanceConfigId, $instanceConfig); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createInstanceConfigTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createInstancePartitionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createInstancePartitionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $config = 'config-1354792126'; + $displayName = 'displayName1615086568'; + $nodeCount = 1539922066; + $etag = 'etag3123477'; + $expectedResponse = new InstancePartition(); + $expectedResponse->setName($name); + $expectedResponse->setConfig($config); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setNodeCount($nodeCount); + $expectedResponse->setEtag($etag); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createInstancePartitionTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $instancePartitionId = 'instancePartitionId288435706'; + $instancePartition = new InstancePartition(); + $instancePartitionName = 'instancePartitionName1272312320'; + $instancePartition->setName($instancePartitionName); + $instancePartitionConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $instancePartition->setConfig($instancePartitionConfig); + $instancePartitionDisplayName = 'instancePartitionDisplayName1175388504'; + $instancePartition->setDisplayName($instancePartitionDisplayName); + $response = $gapicClient->createInstancePartition($formattedParent, $instancePartitionId, $instancePartition); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/CreateInstancePartition', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getInstancePartitionId(); + $this->assertProtobufEquals($instancePartitionId, $actualValue); + $actualValue = $actualApiRequestObject->getInstancePartition(); + $this->assertProtobufEquals($instancePartition, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createInstancePartitionTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createInstancePartitionExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createInstancePartitionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $instancePartitionId = 'instancePartitionId288435706'; + $instancePartition = new InstancePartition(); + $instancePartitionName = 'instancePartitionName1272312320'; + $instancePartition->setName($instancePartitionName); + $instancePartitionConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $instancePartition->setConfig($instancePartitionConfig); + $instancePartitionDisplayName = 'instancePartitionDisplayName1175388504'; + $instancePartition->setDisplayName($instancePartitionDisplayName); + $response = $gapicClient->createInstancePartition($formattedParent, $instancePartitionId, $instancePartition); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createInstancePartitionTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function deleteInstanceTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $gapicClient->deleteInstance($formattedName); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/DeleteInstance', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteInstanceExceptionTest() + { + $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->instanceName('[PROJECT]', '[INSTANCE]'); + try { + $gapicClient->deleteInstance($formattedName); + // 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 deleteInstanceConfigTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $gapicClient->deleteInstanceConfig($formattedName); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/DeleteInstanceConfig', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteInstanceConfigExceptionTest() + { + $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->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + try { + $gapicClient->deleteInstanceConfig($formattedName); + // 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 deleteInstancePartitionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->instancePartitionName('[PROJECT]', '[INSTANCE]', '[INSTANCE_PARTITION]'); + $gapicClient->deleteInstancePartition($formattedName); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/DeleteInstancePartition', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteInstancePartitionExceptionTest() + { + $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->instancePartitionName('[PROJECT]', '[INSTANCE]', '[INSTANCE_PARTITION]'); + try { + $gapicClient->deleteInstancePartition($formattedName); + // 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 getIamPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $version = 351608024; + $etag = '21'; + $expectedResponse = new Policy(); + $expectedResponse->setVersion($version); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $response = $gapicClient->getIamPolicy($resource); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/GetIamPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getIamPolicyExceptionTest() + { + $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 + $resource = 'resource-341064690'; + try { + $gapicClient->getIamPolicy($resource); + // 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 getInstanceTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $config = 'config-1354792126'; + $displayName = 'displayName1615086568'; + $nodeCount = 1539922066; + $processingUnits = 329117885; + $expectedResponse = new Instance(); + $expectedResponse->setName($name2); + $expectedResponse->setConfig($config); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setNodeCount($nodeCount); + $expectedResponse->setProcessingUnits($processingUnits); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $response = $gapicClient->getInstance($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/GetInstance', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getInstanceExceptionTest() + { + $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->instanceName('[PROJECT]', '[INSTANCE]'); + try { + $gapicClient->getInstance($formattedName); + // 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 getInstanceConfigTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $displayName = 'displayName1615086568'; + $baseConfig = 'baseConfig1990483056'; + $etag = 'etag3123477'; + $reconciling = false; + $storageLimitPerProcessingUnit = 1769187130; + $expectedResponse = new InstanceConfig(); + $expectedResponse->setName($name2); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setBaseConfig($baseConfig); + $expectedResponse->setEtag($etag); + $expectedResponse->setReconciling($reconciling); + $expectedResponse->setStorageLimitPerProcessingUnit($storageLimitPerProcessingUnit); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $response = $gapicClient->getInstanceConfig($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/GetInstanceConfig', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getInstanceConfigExceptionTest() + { + $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->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + try { + $gapicClient->getInstanceConfig($formattedName); + // 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 getInstancePartitionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $config = 'config-1354792126'; + $displayName = 'displayName1615086568'; + $nodeCount = 1539922066; + $etag = 'etag3123477'; + $expectedResponse = new InstancePartition(); + $expectedResponse->setName($name2); + $expectedResponse->setConfig($config); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setNodeCount($nodeCount); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->instancePartitionName('[PROJECT]', '[INSTANCE]', '[INSTANCE_PARTITION]'); + $response = $gapicClient->getInstancePartition($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/GetInstancePartition', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getInstancePartitionExceptionTest() + { + $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->instancePartitionName('[PROJECT]', '[INSTANCE]', '[INSTANCE_PARTITION]'); + try { + $gapicClient->getInstancePartition($formattedName); + // 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 listInstanceConfigOperationsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $operationsElement = new Operation(); + $operations = [ + $operationsElement, + ]; + $expectedResponse = new ListInstanceConfigOperationsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setOperations($operations); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $response = $gapicClient->listInstanceConfigOperations($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getOperations()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/ListInstanceConfigOperations', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listInstanceConfigOperationsExceptionTest() + { + $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 + $formattedParent = $gapicClient->projectName('[PROJECT]'); + try { + $gapicClient->listInstanceConfigOperations($formattedParent); + // 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 listInstanceConfigsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $instanceConfigsElement = new InstanceConfig(); + $instanceConfigs = [ + $instanceConfigsElement, + ]; + $expectedResponse = new ListInstanceConfigsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setInstanceConfigs($instanceConfigs); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $response = $gapicClient->listInstanceConfigs($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getInstanceConfigs()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/ListInstanceConfigs', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listInstanceConfigsExceptionTest() + { + $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 + $formattedParent = $gapicClient->projectName('[PROJECT]'); + try { + $gapicClient->listInstanceConfigs($formattedParent); + // 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 listInstancePartitionOperationsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $operationsElement = new Operation(); + $operations = [ + $operationsElement, + ]; + $expectedResponse = new ListInstancePartitionOperationsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setOperations($operations); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $response = $gapicClient->listInstancePartitionOperations($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getOperations()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/ListInstancePartitionOperations', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listInstancePartitionOperationsExceptionTest() + { + $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 + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + try { + $gapicClient->listInstancePartitionOperations($formattedParent); + // 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 listInstancePartitionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $instancePartitionsElement = new InstancePartition(); + $instancePartitions = [ + $instancePartitionsElement, + ]; + $expectedResponse = new ListInstancePartitionsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setInstancePartitions($instancePartitions); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $response = $gapicClient->listInstancePartitions($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getInstancePartitions()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/ListInstancePartitions', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listInstancePartitionsExceptionTest() + { + $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 + $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + try { + $gapicClient->listInstancePartitions($formattedParent); + // 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 listInstancesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $instancesElement = new Instance(); + $instances = [ + $instancesElement, + ]; + $expectedResponse = new ListInstancesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setInstances($instances); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $response = $gapicClient->listInstances($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getInstances()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/ListInstances', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listInstancesExceptionTest() + { + $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 + $formattedParent = $gapicClient->projectName('[PROJECT]'); + try { + $gapicClient->listInstances($formattedParent); + // 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 moveInstanceTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/moveInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new MoveInstanceResponse(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/moveInstanceTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedName = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $formattedTargetConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $response = $gapicClient->moveInstance($formattedName, $formattedTargetConfig); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/MoveInstance', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $actualValue = $actualApiRequestObject->getTargetConfig(); + $this->assertProtobufEquals($formattedTargetConfig, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/moveInstanceTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function moveInstanceExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/moveInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); + $formattedTargetConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $response = $gapicClient->moveInstance($formattedName, $formattedTargetConfig); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/moveInstanceTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function setIamPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $version = 351608024; + $etag = '21'; + $expectedResponse = new Policy(); + $expectedResponse->setVersion($version); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $policy = new Policy(); + $response = $gapicClient->setIamPolicy($resource, $policy); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/SetIamPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $actualValue = $actualRequestObject->getPolicy(); + $this->assertProtobufEquals($policy, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function setIamPolicyExceptionTest() + { + $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 + $resource = 'resource-341064690'; + $policy = new Policy(); + try { + $gapicClient->setIamPolicy($resource, $policy); + // 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 testIamPermissionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new TestIamPermissionsResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $permissions = []; + $response = $gapicClient->testIamPermissions($resource, $permissions); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/TestIamPermissions', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $actualValue = $actualRequestObject->getPermissions(); + $this->assertProtobufEquals($permissions, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function testIamPermissionsExceptionTest() + { + $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 + $resource = 'resource-341064690'; + $permissions = []; + try { + $gapicClient->testIamPermissions($resource, $permissions); + // 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 updateInstanceTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $config = 'config-1354792126'; + $displayName = 'displayName1615086568'; + $nodeCount = 1539922066; + $processingUnits = 329117885; + $expectedResponse = new Instance(); + $expectedResponse->setName($name); + $expectedResponse->setConfig($config); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setNodeCount($nodeCount); + $expectedResponse->setProcessingUnits($processingUnits); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/updateInstanceTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $instance = new Instance(); + $instanceName = 'instanceName-737857344'; + $instance->setName($instanceName); + $instanceConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $instance->setConfig($instanceConfig); + $instanceDisplayName = 'instanceDisplayName1824500376'; + $instance->setDisplayName($instanceDisplayName); + $fieldMask = new FieldMask(); + $response = $gapicClient->updateInstance($instance, $fieldMask); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/UpdateInstance', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getInstance(); + $this->assertProtobufEquals($instance, $actualValue); + $actualValue = $actualApiRequestObject->getFieldMask(); + $this->assertProtobufEquals($fieldMask, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateInstanceTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateInstanceExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateInstanceTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $instance = new Instance(); + $instanceName = 'instanceName-737857344'; + $instance->setName($instanceName); + $instanceConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $instance->setConfig($instanceConfig); + $instanceDisplayName = 'instanceDisplayName1824500376'; + $instance->setDisplayName($instanceDisplayName); + $fieldMask = new FieldMask(); + $response = $gapicClient->updateInstance($instance, $fieldMask); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateInstanceTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateInstanceConfigTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateInstanceConfigTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $baseConfig = 'baseConfig1990483056'; + $etag = 'etag3123477'; + $reconciling = false; + $storageLimitPerProcessingUnit = 1769187130; + $expectedResponse = new InstanceConfig(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setBaseConfig($baseConfig); + $expectedResponse->setEtag($etag); + $expectedResponse->setReconciling($reconciling); + $expectedResponse->setStorageLimitPerProcessingUnit($storageLimitPerProcessingUnit); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/updateInstanceConfigTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $instanceConfig = new InstanceConfig(); + $updateMask = new FieldMask(); + $response = $gapicClient->updateInstanceConfig($instanceConfig, $updateMask); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/UpdateInstanceConfig', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getInstanceConfig(); + $this->assertProtobufEquals($instanceConfig, $actualValue); + $actualValue = $actualApiRequestObject->getUpdateMask(); + $this->assertProtobufEquals($updateMask, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateInstanceConfigTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateInstanceConfigExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateInstanceConfigTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $instanceConfig = new InstanceConfig(); + $updateMask = new FieldMask(); + $response = $gapicClient->updateInstanceConfig($instanceConfig, $updateMask); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateInstanceConfigTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateInstancePartitionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateInstancePartitionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $config = 'config-1354792126'; + $displayName = 'displayName1615086568'; + $nodeCount = 1539922066; + $etag = 'etag3123477'; + $expectedResponse = new InstancePartition(); + $expectedResponse->setName($name); + $expectedResponse->setConfig($config); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setNodeCount($nodeCount); + $expectedResponse->setEtag($etag); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/updateInstancePartitionTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $instancePartition = new InstancePartition(); + $instancePartitionName = 'instancePartitionName1272312320'; + $instancePartition->setName($instancePartitionName); + $instancePartitionConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $instancePartition->setConfig($instancePartitionConfig); + $instancePartitionDisplayName = 'instancePartitionDisplayName1175388504'; + $instancePartition->setDisplayName($instancePartitionDisplayName); + $fieldMask = new FieldMask(); + $response = $gapicClient->updateInstancePartition($instancePartition, $fieldMask); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.admin.instance.v1.InstanceAdmin/UpdateInstancePartition', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getInstancePartition(); + $this->assertProtobufEquals($instancePartition, $actualValue); + $actualValue = $actualApiRequestObject->getFieldMask(); + $this->assertProtobufEquals($fieldMask, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateInstancePartitionTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateInstancePartitionExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateInstancePartitionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $instancePartition = new InstancePartition(); + $instancePartitionName = 'instancePartitionName1272312320'; + $instancePartition->setName($instancePartitionName); + $instancePartitionConfig = $gapicClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]'); + $instancePartition->setConfig($instancePartitionConfig); + $instancePartitionDisplayName = 'instancePartitionDisplayName1175388504'; + $instancePartition->setDisplayName($instancePartitionDisplayName); + $fieldMask = new FieldMask(); + $response = $gapicClient->updateInstancePartition($instancePartition, $fieldMask); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateInstancePartitionTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } +} diff --git a/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/CommitResponse.php b/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/CommitResponse.php new file mode 100644 index 000000000000..b5451ada8ff4 Binary files /dev/null and b/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/CommitResponse.php differ diff --git a/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/Keys.php b/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/Keys.php new file mode 100644 index 000000000000..07acede2f29a Binary files /dev/null and b/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/Keys.php differ diff --git a/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/Mutation.php b/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/Mutation.php new file mode 100644 index 000000000000..cf7179a94320 Binary files /dev/null and b/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/Mutation.php differ diff --git a/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/QueryPlan.php b/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/QueryPlan.php new file mode 100644 index 000000000000..4b17b952279c Binary files /dev/null and b/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/QueryPlan.php differ diff --git a/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/ResultSet.php b/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/ResultSet.php new file mode 100644 index 000000000000..f702c5d7c9b9 Binary files /dev/null and b/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/ResultSet.php differ diff --git a/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/Spanner.php b/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/Spanner.php new file mode 100644 index 000000000000..bd5f04d2a43b Binary files /dev/null and b/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/Spanner.php differ diff --git a/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/Transaction.php b/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/Transaction.php new file mode 100644 index 000000000000..d7fd2b4b2856 Binary files /dev/null and b/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/Transaction.php differ diff --git a/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/Type.php b/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/Type.php new file mode 100644 index 000000000000..e58489a57e21 Binary files /dev/null and b/owl-bot-staging/Spanner/v1/proto/src/GPBMetadata/Google/Spanner/V1/Type.php differ diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BatchCreateSessionsRequest.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BatchCreateSessionsRequest.php new file mode 100644 index 000000000000..f76a48fe2104 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BatchCreateSessionsRequest.php @@ -0,0 +1,187 @@ +google.spanner.v1.BatchCreateSessionsRequest + */ +class BatchCreateSessionsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The database in which the new sessions are created. + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $database = ''; + /** + * Parameters to be applied to each created session. + * + * Generated from protobuf field .google.spanner.v1.Session session_template = 2; + */ + protected $session_template = null; + /** + * Required. The number of sessions to be created in this batch call. + * The API may return fewer than the requested number of sessions. If a + * specific number of sessions are desired, the client can make additional + * calls to BatchCreateSessions (adjusting + * [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] + * as necessary). + * + * Generated from protobuf field int32 session_count = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $session_count = 0; + + /** + * @param string $database Required. The database in which the new sessions are created. Please see + * {@see SpannerClient::databaseName()} for help formatting this field. + * @param int $sessionCount Required. The number of sessions to be created in this batch call. + * The API may return fewer than the requested number of sessions. If a + * specific number of sessions are desired, the client can make additional + * calls to BatchCreateSessions (adjusting + * [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] + * as necessary). + * + * @return \Google\Cloud\Spanner\V1\BatchCreateSessionsRequest + * + * @experimental + */ + public static function build(string $database, int $sessionCount): self + { + return (new self()) + ->setDatabase($database) + ->setSessionCount($sessionCount); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $database + * Required. The database in which the new sessions are created. + * @type \Google\Cloud\Spanner\V1\Session $session_template + * Parameters to be applied to each created session. + * @type int $session_count + * Required. The number of sessions to be created in this batch call. + * The API may return fewer than the requested number of sessions. If a + * specific number of sessions are desired, the client can make additional + * calls to BatchCreateSessions (adjusting + * [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] + * as necessary). + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Required. The database in which the new sessions are created. + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getDatabase() + { + return $this->database; + } + + /** + * Required. The database in which the new sessions are created. + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setDatabase($var) + { + GPBUtil::checkString($var, True); + $this->database = $var; + + return $this; + } + + /** + * Parameters to be applied to each created session. + * + * Generated from protobuf field .google.spanner.v1.Session session_template = 2; + * @return \Google\Cloud\Spanner\V1\Session|null + */ + public function getSessionTemplate() + { + return $this->session_template; + } + + public function hasSessionTemplate() + { + return isset($this->session_template); + } + + public function clearSessionTemplate() + { + unset($this->session_template); + } + + /** + * Parameters to be applied to each created session. + * + * Generated from protobuf field .google.spanner.v1.Session session_template = 2; + * @param \Google\Cloud\Spanner\V1\Session $var + * @return $this + */ + public function setSessionTemplate($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\Session::class); + $this->session_template = $var; + + return $this; + } + + /** + * Required. The number of sessions to be created in this batch call. + * The API may return fewer than the requested number of sessions. If a + * specific number of sessions are desired, the client can make additional + * calls to BatchCreateSessions (adjusting + * [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] + * as necessary). + * + * Generated from protobuf field int32 session_count = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return int + */ + public function getSessionCount() + { + return $this->session_count; + } + + /** + * Required. The number of sessions to be created in this batch call. + * The API may return fewer than the requested number of sessions. If a + * specific number of sessions are desired, the client can make additional + * calls to BatchCreateSessions (adjusting + * [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] + * as necessary). + * + * Generated from protobuf field int32 session_count = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param int $var + * @return $this + */ + public function setSessionCount($var) + { + GPBUtil::checkInt32($var); + $this->session_count = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BatchCreateSessionsResponse.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BatchCreateSessionsResponse.php new file mode 100644 index 000000000000..ff411489ae3b --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BatchCreateSessionsResponse.php @@ -0,0 +1,68 @@ +google.spanner.v1.BatchCreateSessionsResponse + */ +class BatchCreateSessionsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The freshly created sessions. + * + * Generated from protobuf field repeated .google.spanner.v1.Session session = 1; + */ + private $session; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Spanner\V1\Session>|\Google\Protobuf\Internal\RepeatedField $session + * The freshly created sessions. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * The freshly created sessions. + * + * Generated from protobuf field repeated .google.spanner.v1.Session session = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getSession() + { + return $this->session; + } + + /** + * The freshly created sessions. + * + * Generated from protobuf field repeated .google.spanner.v1.Session session = 1; + * @param array<\Google\Cloud\Spanner\V1\Session>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setSession($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\Session::class); + $this->session = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BatchWriteRequest.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BatchWriteRequest.php new file mode 100644 index 000000000000..d5467dbbe1e9 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BatchWriteRequest.php @@ -0,0 +1,235 @@ +google.spanner.v1.BatchWriteRequest + */ +class BatchWriteRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The session in which the batch request is to be run. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $session = ''; + /** + * Common options for this request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 3; + */ + protected $request_options = null; + /** + * Required. The groups of mutations to be applied. + * + * Generated from protobuf field repeated .google.spanner.v1.BatchWriteRequest.MutationGroup mutation_groups = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + private $mutation_groups; + /** + * Optional. When `exclude_txn_from_change_streams` is set to `true`: + * * Mutations from all transactions in this batch write operation will not + * be recorded in change streams with DDL option `allow_txn_exclusion=true` + * that are tracking columns modified by these transactions. + * * Mutations from all transactions in this batch write operation will be + * recorded in change streams with DDL option `allow_txn_exclusion=false or + * not set` that are tracking columns modified by these transactions. + * When `exclude_txn_from_change_streams` is set to `false` or not set, + * mutations from all transactions in this batch write operation will be + * recorded in all change streams that are tracking columns modified by these + * transactions. + * + * Generated from protobuf field bool exclude_txn_from_change_streams = 5 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $exclude_txn_from_change_streams = false; + + /** + * @param string $session Required. The session in which the batch request is to be run. Please see + * {@see SpannerClient::sessionName()} for help formatting this field. + * @param \Google\Cloud\Spanner\V1\BatchWriteRequest\MutationGroup[] $mutationGroups Required. The groups of mutations to be applied. + * + * @return \Google\Cloud\Spanner\V1\BatchWriteRequest + * + * @experimental + */ + public static function build(string $session, array $mutationGroups): self + { + return (new self()) + ->setSession($session) + ->setMutationGroups($mutationGroups); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $session + * Required. The session in which the batch request is to be run. + * @type \Google\Cloud\Spanner\V1\RequestOptions $request_options + * Common options for this request. + * @type array<\Google\Cloud\Spanner\V1\BatchWriteRequest\MutationGroup>|\Google\Protobuf\Internal\RepeatedField $mutation_groups + * Required. The groups of mutations to be applied. + * @type bool $exclude_txn_from_change_streams + * Optional. When `exclude_txn_from_change_streams` is set to `true`: + * * Mutations from all transactions in this batch write operation will not + * be recorded in change streams with DDL option `allow_txn_exclusion=true` + * that are tracking columns modified by these transactions. + * * Mutations from all transactions in this batch write operation will be + * recorded in change streams with DDL option `allow_txn_exclusion=false or + * not set` that are tracking columns modified by these transactions. + * When `exclude_txn_from_change_streams` is set to `false` or not set, + * mutations from all transactions in this batch write operation will be + * recorded in all change streams that are tracking columns modified by these + * transactions. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Required. The session in which the batch request is to be run. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getSession() + { + return $this->session; + } + + /** + * Required. The session in which the batch request is to be run. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setSession($var) + { + GPBUtil::checkString($var, True); + $this->session = $var; + + return $this; + } + + /** + * Common options for this request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 3; + * @return \Google\Cloud\Spanner\V1\RequestOptions|null + */ + public function getRequestOptions() + { + return $this->request_options; + } + + public function hasRequestOptions() + { + return isset($this->request_options); + } + + public function clearRequestOptions() + { + unset($this->request_options); + } + + /** + * Common options for this request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 3; + * @param \Google\Cloud\Spanner\V1\RequestOptions $var + * @return $this + */ + public function setRequestOptions($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\RequestOptions::class); + $this->request_options = $var; + + return $this; + } + + /** + * Required. The groups of mutations to be applied. + * + * Generated from protobuf field repeated .google.spanner.v1.BatchWriteRequest.MutationGroup mutation_groups = 4 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getMutationGroups() + { + return $this->mutation_groups; + } + + /** + * Required. The groups of mutations to be applied. + * + * Generated from protobuf field repeated .google.spanner.v1.BatchWriteRequest.MutationGroup mutation_groups = 4 [(.google.api.field_behavior) = REQUIRED]; + * @param array<\Google\Cloud\Spanner\V1\BatchWriteRequest\MutationGroup>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setMutationGroups($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\BatchWriteRequest\MutationGroup::class); + $this->mutation_groups = $arr; + + return $this; + } + + /** + * Optional. When `exclude_txn_from_change_streams` is set to `true`: + * * Mutations from all transactions in this batch write operation will not + * be recorded in change streams with DDL option `allow_txn_exclusion=true` + * that are tracking columns modified by these transactions. + * * Mutations from all transactions in this batch write operation will be + * recorded in change streams with DDL option `allow_txn_exclusion=false or + * not set` that are tracking columns modified by these transactions. + * When `exclude_txn_from_change_streams` is set to `false` or not set, + * mutations from all transactions in this batch write operation will be + * recorded in all change streams that are tracking columns modified by these + * transactions. + * + * Generated from protobuf field bool exclude_txn_from_change_streams = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getExcludeTxnFromChangeStreams() + { + return $this->exclude_txn_from_change_streams; + } + + /** + * Optional. When `exclude_txn_from_change_streams` is set to `true`: + * * Mutations from all transactions in this batch write operation will not + * be recorded in change streams with DDL option `allow_txn_exclusion=true` + * that are tracking columns modified by these transactions. + * * Mutations from all transactions in this batch write operation will be + * recorded in change streams with DDL option `allow_txn_exclusion=false or + * not set` that are tracking columns modified by these transactions. + * When `exclude_txn_from_change_streams` is set to `false` or not set, + * mutations from all transactions in this batch write operation will be + * recorded in all change streams that are tracking columns modified by these + * transactions. + * + * Generated from protobuf field bool exclude_txn_from_change_streams = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setExcludeTxnFromChangeStreams($var) + { + GPBUtil::checkBool($var); + $this->exclude_txn_from_change_streams = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BatchWriteRequest/MutationGroup.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BatchWriteRequest/MutationGroup.php new file mode 100644 index 000000000000..22d04c7f4b91 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BatchWriteRequest/MutationGroup.php @@ -0,0 +1,72 @@ +google.spanner.v1.BatchWriteRequest.MutationGroup + */ +class MutationGroup extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The mutations in this group. + * + * Generated from protobuf field repeated .google.spanner.v1.Mutation mutations = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $mutations; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Spanner\V1\Mutation>|\Google\Protobuf\Internal\RepeatedField $mutations + * Required. The mutations in this group. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Required. The mutations in this group. + * + * Generated from protobuf field repeated .google.spanner.v1.Mutation mutations = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getMutations() + { + return $this->mutations; + } + + /** + * Required. The mutations in this group. + * + * Generated from protobuf field repeated .google.spanner.v1.Mutation mutations = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param array<\Google\Cloud\Spanner\V1\Mutation>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setMutations($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\Mutation::class); + $this->mutations = $arr; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(MutationGroup::class, \Google\Cloud\Spanner\V1\BatchWriteRequest_MutationGroup::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BatchWriteResponse.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BatchWriteResponse.php new file mode 100644 index 000000000000..efcb9bc2ddb9 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BatchWriteResponse.php @@ -0,0 +1,163 @@ +google.spanner.v1.BatchWriteResponse + */ +class BatchWriteResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The mutation groups applied in this batch. The values index into the + * `mutation_groups` field in the corresponding `BatchWriteRequest`. + * + * Generated from protobuf field repeated int32 indexes = 1; + */ + private $indexes; + /** + * An `OK` status indicates success. Any other status indicates a failure. + * + * Generated from protobuf field .google.rpc.Status status = 2; + */ + protected $status = null; + /** + * The commit timestamp of the transaction that applied this batch. + * Present if `status` is `OK`, absent otherwise. + * + * Generated from protobuf field .google.protobuf.Timestamp commit_timestamp = 3; + */ + protected $commit_timestamp = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array|\Google\Protobuf\Internal\RepeatedField $indexes + * The mutation groups applied in this batch. The values index into the + * `mutation_groups` field in the corresponding `BatchWriteRequest`. + * @type \Google\Rpc\Status $status + * An `OK` status indicates success. Any other status indicates a failure. + * @type \Google\Protobuf\Timestamp $commit_timestamp + * The commit timestamp of the transaction that applied this batch. + * Present if `status` is `OK`, absent otherwise. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * The mutation groups applied in this batch. The values index into the + * `mutation_groups` field in the corresponding `BatchWriteRequest`. + * + * Generated from protobuf field repeated int32 indexes = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getIndexes() + { + return $this->indexes; + } + + /** + * The mutation groups applied in this batch. The values index into the + * `mutation_groups` field in the corresponding `BatchWriteRequest`. + * + * Generated from protobuf field repeated int32 indexes = 1; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setIndexes($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); + $this->indexes = $arr; + + return $this; + } + + /** + * An `OK` status indicates success. Any other status indicates a failure. + * + * Generated from protobuf field .google.rpc.Status status = 2; + * @return \Google\Rpc\Status|null + */ + public function getStatus() + { + return $this->status; + } + + public function hasStatus() + { + return isset($this->status); + } + + public function clearStatus() + { + unset($this->status); + } + + /** + * An `OK` status indicates success. Any other status indicates a failure. + * + * Generated from protobuf field .google.rpc.Status status = 2; + * @param \Google\Rpc\Status $var + * @return $this + */ + public function setStatus($var) + { + GPBUtil::checkMessage($var, \Google\Rpc\Status::class); + $this->status = $var; + + return $this; + } + + /** + * The commit timestamp of the transaction that applied this batch. + * Present if `status` is `OK`, absent otherwise. + * + * Generated from protobuf field .google.protobuf.Timestamp commit_timestamp = 3; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCommitTimestamp() + { + return $this->commit_timestamp; + } + + public function hasCommitTimestamp() + { + return isset($this->commit_timestamp); + } + + public function clearCommitTimestamp() + { + unset($this->commit_timestamp); + } + + /** + * The commit timestamp of the transaction that applied this batch. + * Present if `status` is `OK`, absent otherwise. + * + * Generated from protobuf field .google.protobuf.Timestamp commit_timestamp = 3; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCommitTimestamp($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->commit_timestamp = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BeginTransactionRequest.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BeginTransactionRequest.php new file mode 100644 index 000000000000..835d6d602d59 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/BeginTransactionRequest.php @@ -0,0 +1,252 @@ +google.spanner.v1.BeginTransactionRequest + */ +class BeginTransactionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The session in which the transaction runs. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $session = ''; + /** + * Required. Options for the new transaction. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions options = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $options = null; + /** + * Common options for this request. + * Priority is ignored for this request. Setting the priority in this + * request_options struct will not do anything. To set the priority for a + * transaction, set it on the reads and writes that are part of this + * transaction instead. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 3; + */ + protected $request_options = null; + /** + * Optional. Required for read-write transactions on a multiplexed session + * that commit mutations but do not perform any reads or queries. Clients + * should randomly select one of the mutations from the mutation set and send + * it as a part of this request. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.Mutation mutation_key = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $mutation_key = null; + + /** + * @param string $session Required. The session in which the transaction runs. Please see + * {@see SpannerClient::sessionName()} for help formatting this field. + * @param \Google\Cloud\Spanner\V1\TransactionOptions $options Required. Options for the new transaction. + * + * @return \Google\Cloud\Spanner\V1\BeginTransactionRequest + * + * @experimental + */ + public static function build(string $session, \Google\Cloud\Spanner\V1\TransactionOptions $options): self + { + return (new self()) + ->setSession($session) + ->setOptions($options); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $session + * Required. The session in which the transaction runs. + * @type \Google\Cloud\Spanner\V1\TransactionOptions $options + * Required. Options for the new transaction. + * @type \Google\Cloud\Spanner\V1\RequestOptions $request_options + * Common options for this request. + * Priority is ignored for this request. Setting the priority in this + * request_options struct will not do anything. To set the priority for a + * transaction, set it on the reads and writes that are part of this + * transaction instead. + * @type \Google\Cloud\Spanner\V1\Mutation $mutation_key + * Optional. Required for read-write transactions on a multiplexed session + * that commit mutations but do not perform any reads or queries. Clients + * should randomly select one of the mutations from the mutation set and send + * it as a part of this request. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Required. The session in which the transaction runs. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getSession() + { + return $this->session; + } + + /** + * Required. The session in which the transaction runs. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setSession($var) + { + GPBUtil::checkString($var, True); + $this->session = $var; + + return $this; + } + + /** + * Required. Options for the new transaction. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions options = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\V1\TransactionOptions|null + */ + public function getOptions() + { + return $this->options; + } + + public function hasOptions() + { + return isset($this->options); + } + + public function clearOptions() + { + unset($this->options); + } + + /** + * Required. Options for the new transaction. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions options = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\V1\TransactionOptions $var + * @return $this + */ + public function setOptions($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\TransactionOptions::class); + $this->options = $var; + + return $this; + } + + /** + * Common options for this request. + * Priority is ignored for this request. Setting the priority in this + * request_options struct will not do anything. To set the priority for a + * transaction, set it on the reads and writes that are part of this + * transaction instead. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 3; + * @return \Google\Cloud\Spanner\V1\RequestOptions|null + */ + public function getRequestOptions() + { + return $this->request_options; + } + + public function hasRequestOptions() + { + return isset($this->request_options); + } + + public function clearRequestOptions() + { + unset($this->request_options); + } + + /** + * Common options for this request. + * Priority is ignored for this request. Setting the priority in this + * request_options struct will not do anything. To set the priority for a + * transaction, set it on the reads and writes that are part of this + * transaction instead. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 3; + * @param \Google\Cloud\Spanner\V1\RequestOptions $var + * @return $this + */ + public function setRequestOptions($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\RequestOptions::class); + $this->request_options = $var; + + return $this; + } + + /** + * Optional. Required for read-write transactions on a multiplexed session + * that commit mutations but do not perform any reads or queries. Clients + * should randomly select one of the mutations from the mutation set and send + * it as a part of this request. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.Mutation mutation_key = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Spanner\V1\Mutation|null + */ + public function getMutationKey() + { + return $this->mutation_key; + } + + public function hasMutationKey() + { + return isset($this->mutation_key); + } + + public function clearMutationKey() + { + unset($this->mutation_key); + } + + /** + * Optional. Required for read-write transactions on a multiplexed session + * that commit mutations but do not perform any reads or queries. Clients + * should randomly select one of the mutations from the mutation set and send + * it as a part of this request. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.Mutation mutation_key = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Spanner\V1\Mutation $var + * @return $this + */ + public function setMutationKey($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\Mutation::class); + $this->mutation_key = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/CommitRequest.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/CommitRequest.php new file mode 100644 index 000000000000..1c5bec6a1abc --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/CommitRequest.php @@ -0,0 +1,466 @@ +google.spanner.v1.CommitRequest + */ +class CommitRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The session in which the transaction to be committed is running. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $session = ''; + /** + * The mutations to be executed when this transaction commits. All + * mutations are applied atomically, in the order they appear in + * this list. + * + * Generated from protobuf field repeated .google.spanner.v1.Mutation mutations = 4; + */ + private $mutations; + /** + * If `true`, then statistics related to the transaction will be included in + * the [CommitResponse][google.spanner.v1.CommitResponse.commit_stats]. + * Default value is `false`. + * + * Generated from protobuf field bool return_commit_stats = 5; + */ + protected $return_commit_stats = false; + /** + * Optional. The amount of latency this request is willing to incur in order + * to improve throughput. If this field is not set, Spanner assumes requests + * are relatively latency sensitive and automatically determines an + * appropriate delay time. You can specify a batching delay value between 0 + * and 500 ms. + * + * Generated from protobuf field .google.protobuf.Duration max_commit_delay = 8 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $max_commit_delay = null; + /** + * Common options for this request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 6; + */ + protected $request_options = null; + /** + * Optional. If the read-write transaction was executed on a multiplexed + * session, the precommit token with the highest sequence number received in + * this transaction attempt, should be included here. Failing to do so will + * result in a FailedPrecondition error. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.MultiplexedSessionPrecommitToken precommit_token = 9 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $precommit_token = null; + protected $transaction; + + /** + * @param string $session Required. The session in which the transaction to be committed is running. Please see + * {@see SpannerClient::sessionName()} for help formatting this field. + * @param string $transactionId Commit a previously-started transaction. + * @param \Google\Cloud\Spanner\V1\Mutation[] $mutations The mutations to be executed when this transaction commits. All + * mutations are applied atomically, in the order they appear in + * this list. + * + * @return \Google\Cloud\Spanner\V1\CommitRequest + * + * @experimental + */ + public static function build(string $session, string $transactionId, array $mutations): self + { + return (new self()) + ->setSession($session) + ->setTransactionId($transactionId) + ->setMutations($mutations); + } + + /** + * @param string $session Required. The session in which the transaction to be committed is running. Please see + * {@see SpannerClient::sessionName()} for help formatting this field. + * @param \Google\Cloud\Spanner\V1\TransactionOptions $singleUseTransaction Execute mutations in a temporary transaction. Note that unlike + * commit of a previously-started transaction, commit with a + * temporary transaction is non-idempotent. That is, if the + * `CommitRequest` is sent to Cloud Spanner more than once (for + * instance, due to retries in the application, or in the + * transport library), it is possible that the mutations are + * executed more than once. If this is undesirable, use + * [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and + * [Commit][google.spanner.v1.Spanner.Commit] instead. + * @param \Google\Cloud\Spanner\V1\Mutation[] $mutations The mutations to be executed when this transaction commits. All + * mutations are applied atomically, in the order they appear in + * this list. + * + * @return \Google\Cloud\Spanner\V1\CommitRequest + * + * @experimental + */ + public static function buildFromSessionSingleUseTransactionMutations(string $session, \Google\Cloud\Spanner\V1\TransactionOptions $singleUseTransaction, array $mutations): self + { + return (new self()) + ->setSession($session) + ->setSingleUseTransaction($singleUseTransaction) + ->setMutations($mutations); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $session + * Required. The session in which the transaction to be committed is running. + * @type string $transaction_id + * Commit a previously-started transaction. + * @type \Google\Cloud\Spanner\V1\TransactionOptions $single_use_transaction + * Execute mutations in a temporary transaction. Note that unlike + * commit of a previously-started transaction, commit with a + * temporary transaction is non-idempotent. That is, if the + * `CommitRequest` is sent to Cloud Spanner more than once (for + * instance, due to retries in the application, or in the + * transport library), it is possible that the mutations are + * executed more than once. If this is undesirable, use + * [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and + * [Commit][google.spanner.v1.Spanner.Commit] instead. + * @type array<\Google\Cloud\Spanner\V1\Mutation>|\Google\Protobuf\Internal\RepeatedField $mutations + * The mutations to be executed when this transaction commits. All + * mutations are applied atomically, in the order they appear in + * this list. + * @type bool $return_commit_stats + * If `true`, then statistics related to the transaction will be included in + * the [CommitResponse][google.spanner.v1.CommitResponse.commit_stats]. + * Default value is `false`. + * @type \Google\Protobuf\Duration $max_commit_delay + * Optional. The amount of latency this request is willing to incur in order + * to improve throughput. If this field is not set, Spanner assumes requests + * are relatively latency sensitive and automatically determines an + * appropriate delay time. You can specify a batching delay value between 0 + * and 500 ms. + * @type \Google\Cloud\Spanner\V1\RequestOptions $request_options + * Common options for this request. + * @type \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken $precommit_token + * Optional. If the read-write transaction was executed on a multiplexed + * session, the precommit token with the highest sequence number received in + * this transaction attempt, should be included here. Failing to do so will + * result in a FailedPrecondition error. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Required. The session in which the transaction to be committed is running. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getSession() + { + return $this->session; + } + + /** + * Required. The session in which the transaction to be committed is running. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setSession($var) + { + GPBUtil::checkString($var, True); + $this->session = $var; + + return $this; + } + + /** + * Commit a previously-started transaction. + * + * Generated from protobuf field bytes transaction_id = 2; + * @return string + */ + public function getTransactionId() + { + return $this->readOneof(2); + } + + public function hasTransactionId() + { + return $this->hasOneof(2); + } + + /** + * Commit a previously-started transaction. + * + * Generated from protobuf field bytes transaction_id = 2; + * @param string $var + * @return $this + */ + public function setTransactionId($var) + { + GPBUtil::checkString($var, False); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * Execute mutations in a temporary transaction. Note that unlike + * commit of a previously-started transaction, commit with a + * temporary transaction is non-idempotent. That is, if the + * `CommitRequest` is sent to Cloud Spanner more than once (for + * instance, due to retries in the application, or in the + * transport library), it is possible that the mutations are + * executed more than once. If this is undesirable, use + * [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and + * [Commit][google.spanner.v1.Spanner.Commit] instead. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions single_use_transaction = 3; + * @return \Google\Cloud\Spanner\V1\TransactionOptions|null + */ + public function getSingleUseTransaction() + { + return $this->readOneof(3); + } + + public function hasSingleUseTransaction() + { + return $this->hasOneof(3); + } + + /** + * Execute mutations in a temporary transaction. Note that unlike + * commit of a previously-started transaction, commit with a + * temporary transaction is non-idempotent. That is, if the + * `CommitRequest` is sent to Cloud Spanner more than once (for + * instance, due to retries in the application, or in the + * transport library), it is possible that the mutations are + * executed more than once. If this is undesirable, use + * [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and + * [Commit][google.spanner.v1.Spanner.Commit] instead. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions single_use_transaction = 3; + * @param \Google\Cloud\Spanner\V1\TransactionOptions $var + * @return $this + */ + public function setSingleUseTransaction($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\TransactionOptions::class); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * The mutations to be executed when this transaction commits. All + * mutations are applied atomically, in the order they appear in + * this list. + * + * Generated from protobuf field repeated .google.spanner.v1.Mutation mutations = 4; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getMutations() + { + return $this->mutations; + } + + /** + * The mutations to be executed when this transaction commits. All + * mutations are applied atomically, in the order they appear in + * this list. + * + * Generated from protobuf field repeated .google.spanner.v1.Mutation mutations = 4; + * @param array<\Google\Cloud\Spanner\V1\Mutation>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setMutations($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\Mutation::class); + $this->mutations = $arr; + + return $this; + } + + /** + * If `true`, then statistics related to the transaction will be included in + * the [CommitResponse][google.spanner.v1.CommitResponse.commit_stats]. + * Default value is `false`. + * + * Generated from protobuf field bool return_commit_stats = 5; + * @return bool + */ + public function getReturnCommitStats() + { + return $this->return_commit_stats; + } + + /** + * If `true`, then statistics related to the transaction will be included in + * the [CommitResponse][google.spanner.v1.CommitResponse.commit_stats]. + * Default value is `false`. + * + * Generated from protobuf field bool return_commit_stats = 5; + * @param bool $var + * @return $this + */ + public function setReturnCommitStats($var) + { + GPBUtil::checkBool($var); + $this->return_commit_stats = $var; + + return $this; + } + + /** + * Optional. The amount of latency this request is willing to incur in order + * to improve throughput. If this field is not set, Spanner assumes requests + * are relatively latency sensitive and automatically determines an + * appropriate delay time. You can specify a batching delay value between 0 + * and 500 ms. + * + * Generated from protobuf field .google.protobuf.Duration max_commit_delay = 8 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Duration|null + */ + public function getMaxCommitDelay() + { + return $this->max_commit_delay; + } + + public function hasMaxCommitDelay() + { + return isset($this->max_commit_delay); + } + + public function clearMaxCommitDelay() + { + unset($this->max_commit_delay); + } + + /** + * Optional. The amount of latency this request is willing to incur in order + * to improve throughput. If this field is not set, Spanner assumes requests + * are relatively latency sensitive and automatically determines an + * appropriate delay time. You can specify a batching delay value between 0 + * and 500 ms. + * + * Generated from protobuf field .google.protobuf.Duration max_commit_delay = 8 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setMaxCommitDelay($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->max_commit_delay = $var; + + return $this; + } + + /** + * Common options for this request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 6; + * @return \Google\Cloud\Spanner\V1\RequestOptions|null + */ + public function getRequestOptions() + { + return $this->request_options; + } + + public function hasRequestOptions() + { + return isset($this->request_options); + } + + public function clearRequestOptions() + { + unset($this->request_options); + } + + /** + * Common options for this request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 6; + * @param \Google\Cloud\Spanner\V1\RequestOptions $var + * @return $this + */ + public function setRequestOptions($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\RequestOptions::class); + $this->request_options = $var; + + return $this; + } + + /** + * Optional. If the read-write transaction was executed on a multiplexed + * session, the precommit token with the highest sequence number received in + * this transaction attempt, should be included here. Failing to do so will + * result in a FailedPrecondition error. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.MultiplexedSessionPrecommitToken precommit_token = 9 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken|null + */ + public function getPrecommitToken() + { + return $this->precommit_token; + } + + public function hasPrecommitToken() + { + return isset($this->precommit_token); + } + + public function clearPrecommitToken() + { + unset($this->precommit_token); + } + + /** + * Optional. If the read-write transaction was executed on a multiplexed + * session, the precommit token with the highest sequence number received in + * this transaction attempt, should be included here. Failing to do so will + * result in a FailedPrecondition error. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.MultiplexedSessionPrecommitToken precommit_token = 9 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken $var + * @return $this + */ + public function setPrecommitToken($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken::class); + $this->precommit_token = $var; + + return $this; + } + + /** + * @return string + */ + public function getTransaction() + { + return $this->whichOneof("transaction"); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/CommitResponse.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/CommitResponse.php new file mode 100644 index 000000000000..2259fc08d33c --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/CommitResponse.php @@ -0,0 +1,174 @@ +google.spanner.v1.CommitResponse + */ +class CommitResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The Cloud Spanner timestamp at which the transaction committed. + * + * Generated from protobuf field .google.protobuf.Timestamp commit_timestamp = 1; + */ + protected $commit_timestamp = null; + /** + * The statistics about this Commit. Not returned by default. + * For more information, see + * [CommitRequest.return_commit_stats][google.spanner.v1.CommitRequest.return_commit_stats]. + * + * Generated from protobuf field .google.spanner.v1.CommitResponse.CommitStats commit_stats = 2; + */ + protected $commit_stats = null; + protected $MultiplexedSessionRetry; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\Timestamp $commit_timestamp + * The Cloud Spanner timestamp at which the transaction committed. + * @type \Google\Cloud\Spanner\V1\CommitResponse\CommitStats $commit_stats + * The statistics about this Commit. Not returned by default. + * For more information, see + * [CommitRequest.return_commit_stats][google.spanner.v1.CommitRequest.return_commit_stats]. + * @type \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken $precommit_token + * If specified, transaction has not committed yet. + * Clients must retry the commit with the new precommit token. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\CommitResponse::initOnce(); + parent::__construct($data); + } + + /** + * The Cloud Spanner timestamp at which the transaction committed. + * + * Generated from protobuf field .google.protobuf.Timestamp commit_timestamp = 1; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCommitTimestamp() + { + return $this->commit_timestamp; + } + + public function hasCommitTimestamp() + { + return isset($this->commit_timestamp); + } + + public function clearCommitTimestamp() + { + unset($this->commit_timestamp); + } + + /** + * The Cloud Spanner timestamp at which the transaction committed. + * + * Generated from protobuf field .google.protobuf.Timestamp commit_timestamp = 1; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCommitTimestamp($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->commit_timestamp = $var; + + return $this; + } + + /** + * The statistics about this Commit. Not returned by default. + * For more information, see + * [CommitRequest.return_commit_stats][google.spanner.v1.CommitRequest.return_commit_stats]. + * + * Generated from protobuf field .google.spanner.v1.CommitResponse.CommitStats commit_stats = 2; + * @return \Google\Cloud\Spanner\V1\CommitResponse\CommitStats|null + */ + public function getCommitStats() + { + return $this->commit_stats; + } + + public function hasCommitStats() + { + return isset($this->commit_stats); + } + + public function clearCommitStats() + { + unset($this->commit_stats); + } + + /** + * The statistics about this Commit. Not returned by default. + * For more information, see + * [CommitRequest.return_commit_stats][google.spanner.v1.CommitRequest.return_commit_stats]. + * + * Generated from protobuf field .google.spanner.v1.CommitResponse.CommitStats commit_stats = 2; + * @param \Google\Cloud\Spanner\V1\CommitResponse\CommitStats $var + * @return $this + */ + public function setCommitStats($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\CommitResponse\CommitStats::class); + $this->commit_stats = $var; + + return $this; + } + + /** + * If specified, transaction has not committed yet. + * Clients must retry the commit with the new precommit token. + * + * Generated from protobuf field .google.spanner.v1.MultiplexedSessionPrecommitToken precommit_token = 4; + * @return \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken|null + */ + public function getPrecommitToken() + { + return $this->readOneof(4); + } + + public function hasPrecommitToken() + { + return $this->hasOneof(4); + } + + /** + * If specified, transaction has not committed yet. + * Clients must retry the commit with the new precommit token. + * + * Generated from protobuf field .google.spanner.v1.MultiplexedSessionPrecommitToken precommit_token = 4; + * @param \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken $var + * @return $this + */ + public function setPrecommitToken($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken::class); + $this->writeOneof(4, $var); + + return $this; + } + + /** + * @return string + */ + public function getMultiplexedSessionRetry() + { + return $this->whichOneof("MultiplexedSessionRetry"); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/CommitResponse/CommitStats.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/CommitResponse/CommitStats.php new file mode 100644 index 000000000000..0f853f3c78fa --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/CommitResponse/CommitStats.php @@ -0,0 +1,94 @@ +google.spanner.v1.CommitResponse.CommitStats + */ +class CommitStats extends \Google\Protobuf\Internal\Message +{ + /** + * The total number of mutations for the transaction. Knowing the + * `mutation_count` value can help you maximize the number of mutations + * in a transaction and minimize the number of API round trips. You can + * also monitor this value to prevent transactions from exceeding the system + * [limit](https://cloud.google.com/spanner/quotas#limits_for_creating_reading_updating_and_deleting_data). + * If the number of mutations exceeds the limit, the server returns + * [INVALID_ARGUMENT](https://cloud.google.com/spanner/docs/reference/rest/v1/Code#ENUM_VALUES.INVALID_ARGUMENT). + * + * Generated from protobuf field int64 mutation_count = 1; + */ + protected $mutation_count = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int|string $mutation_count + * The total number of mutations for the transaction. Knowing the + * `mutation_count` value can help you maximize the number of mutations + * in a transaction and minimize the number of API round trips. You can + * also monitor this value to prevent transactions from exceeding the system + * [limit](https://cloud.google.com/spanner/quotas#limits_for_creating_reading_updating_and_deleting_data). + * If the number of mutations exceeds the limit, the server returns + * [INVALID_ARGUMENT](https://cloud.google.com/spanner/docs/reference/rest/v1/Code#ENUM_VALUES.INVALID_ARGUMENT). + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\CommitResponse::initOnce(); + parent::__construct($data); + } + + /** + * The total number of mutations for the transaction. Knowing the + * `mutation_count` value can help you maximize the number of mutations + * in a transaction and minimize the number of API round trips. You can + * also monitor this value to prevent transactions from exceeding the system + * [limit](https://cloud.google.com/spanner/quotas#limits_for_creating_reading_updating_and_deleting_data). + * If the number of mutations exceeds the limit, the server returns + * [INVALID_ARGUMENT](https://cloud.google.com/spanner/docs/reference/rest/v1/Code#ENUM_VALUES.INVALID_ARGUMENT). + * + * Generated from protobuf field int64 mutation_count = 1; + * @return int|string + */ + public function getMutationCount() + { + return $this->mutation_count; + } + + /** + * The total number of mutations for the transaction. Knowing the + * `mutation_count` value can help you maximize the number of mutations + * in a transaction and minimize the number of API round trips. You can + * also monitor this value to prevent transactions from exceeding the system + * [limit](https://cloud.google.com/spanner/quotas#limits_for_creating_reading_updating_and_deleting_data). + * If the number of mutations exceeds the limit, the server returns + * [INVALID_ARGUMENT](https://cloud.google.com/spanner/docs/reference/rest/v1/Code#ENUM_VALUES.INVALID_ARGUMENT). + * + * Generated from protobuf field int64 mutation_count = 1; + * @param int|string $var + * @return $this + */ + public function setMutationCount($var) + { + GPBUtil::checkInt64($var); + $this->mutation_count = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(CommitStats::class, \Google\Cloud\Spanner\V1\CommitResponse_CommitStats::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/CreateSessionRequest.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/CreateSessionRequest.php new file mode 100644 index 000000000000..f76760ba06a8 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/CreateSessionRequest.php @@ -0,0 +1,125 @@ +google.spanner.v1.CreateSessionRequest + */ +class CreateSessionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The database in which the new session is created. + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $database = ''; + /** + * Required. The session to create. + * + * Generated from protobuf field .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $session = null; + + /** + * @param string $database Required. The database in which the new session is created. Please see + * {@see SpannerClient::databaseName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\V1\CreateSessionRequest + * + * @experimental + */ + public static function build(string $database): self + { + return (new self()) + ->setDatabase($database); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $database + * Required. The database in which the new session is created. + * @type \Google\Cloud\Spanner\V1\Session $session + * Required. The session to create. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Required. The database in which the new session is created. + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getDatabase() + { + return $this->database; + } + + /** + * Required. The database in which the new session is created. + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setDatabase($var) + { + GPBUtil::checkString($var, True); + $this->database = $var; + + return $this; + } + + /** + * Required. The session to create. + * + * Generated from protobuf field .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\V1\Session|null + */ + public function getSession() + { + return $this->session; + } + + public function hasSession() + { + return isset($this->session); + } + + public function clearSession() + { + unset($this->session); + } + + /** + * Required. The session to create. + * + * Generated from protobuf field .google.spanner.v1.Session session = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\V1\Session $var + * @return $this + */ + public function setSession($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\Session::class); + $this->session = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DeleteSessionRequest.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DeleteSessionRequest.php new file mode 100644 index 000000000000..0bf9497d1ccc --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DeleteSessionRequest.php @@ -0,0 +1,81 @@ +google.spanner.v1.DeleteSessionRequest + */ +class DeleteSessionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the session to delete. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. The name of the session to delete. Please see + * {@see SpannerClient::sessionName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\V1\DeleteSessionRequest + * + * @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. The name of the session to delete. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the session to delete. + * + * 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. The name of the session to delete. + * + * 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/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DirectedReadOptions.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DirectedReadOptions.php new file mode 100644 index 000000000000..c6983461e086 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DirectedReadOptions.php @@ -0,0 +1,129 @@ +google.spanner.v1.DirectedReadOptions + */ +class DirectedReadOptions extends \Google\Protobuf\Internal\Message +{ + protected $replicas; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\V1\DirectedReadOptions\IncludeReplicas $include_replicas + * Include_replicas indicates the order of replicas (as they appear in + * this list) to process the request. If auto_failover_disabled is set to + * true and all replicas are exhausted without finding a healthy replica, + * Spanner will wait for a replica in the list to become available, requests + * may fail due to `DEADLINE_EXCEEDED` errors. + * @type \Google\Cloud\Spanner\V1\DirectedReadOptions\ExcludeReplicas $exclude_replicas + * Exclude_replicas indicates that specified replicas should be excluded + * from serving requests. Spanner will not route requests to the replicas + * in this list. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Include_replicas indicates the order of replicas (as they appear in + * this list) to process the request. If auto_failover_disabled is set to + * true and all replicas are exhausted without finding a healthy replica, + * Spanner will wait for a replica in the list to become available, requests + * may fail due to `DEADLINE_EXCEEDED` errors. + * + * Generated from protobuf field .google.spanner.v1.DirectedReadOptions.IncludeReplicas include_replicas = 1; + * @return \Google\Cloud\Spanner\V1\DirectedReadOptions\IncludeReplicas|null + */ + public function getIncludeReplicas() + { + return $this->readOneof(1); + } + + public function hasIncludeReplicas() + { + return $this->hasOneof(1); + } + + /** + * Include_replicas indicates the order of replicas (as they appear in + * this list) to process the request. If auto_failover_disabled is set to + * true and all replicas are exhausted without finding a healthy replica, + * Spanner will wait for a replica in the list to become available, requests + * may fail due to `DEADLINE_EXCEEDED` errors. + * + * Generated from protobuf field .google.spanner.v1.DirectedReadOptions.IncludeReplicas include_replicas = 1; + * @param \Google\Cloud\Spanner\V1\DirectedReadOptions\IncludeReplicas $var + * @return $this + */ + public function setIncludeReplicas($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\DirectedReadOptions\IncludeReplicas::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * Exclude_replicas indicates that specified replicas should be excluded + * from serving requests. Spanner will not route requests to the replicas + * in this list. + * + * Generated from protobuf field .google.spanner.v1.DirectedReadOptions.ExcludeReplicas exclude_replicas = 2; + * @return \Google\Cloud\Spanner\V1\DirectedReadOptions\ExcludeReplicas|null + */ + public function getExcludeReplicas() + { + return $this->readOneof(2); + } + + public function hasExcludeReplicas() + { + return $this->hasOneof(2); + } + + /** + * Exclude_replicas indicates that specified replicas should be excluded + * from serving requests. Spanner will not route requests to the replicas + * in this list. + * + * Generated from protobuf field .google.spanner.v1.DirectedReadOptions.ExcludeReplicas exclude_replicas = 2; + * @param \Google\Cloud\Spanner\V1\DirectedReadOptions\ExcludeReplicas $var + * @return $this + */ + public function setExcludeReplicas($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\DirectedReadOptions\ExcludeReplicas::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * @return string + */ + public function getReplicas() + { + return $this->whichOneof("replicas"); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DirectedReadOptions/ExcludeReplicas.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DirectedReadOptions/ExcludeReplicas.php new file mode 100644 index 000000000000..913c6fba2724 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DirectedReadOptions/ExcludeReplicas.php @@ -0,0 +1,71 @@ +google.spanner.v1.DirectedReadOptions.ExcludeReplicas + */ +class ExcludeReplicas extends \Google\Protobuf\Internal\Message +{ + /** + * The directed read replica selector. + * + * Generated from protobuf field repeated .google.spanner.v1.DirectedReadOptions.ReplicaSelection replica_selections = 1; + */ + private $replica_selections; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Spanner\V1\DirectedReadOptions\ReplicaSelection>|\Google\Protobuf\Internal\RepeatedField $replica_selections + * The directed read replica selector. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * The directed read replica selector. + * + * Generated from protobuf field repeated .google.spanner.v1.DirectedReadOptions.ReplicaSelection replica_selections = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getReplicaSelections() + { + return $this->replica_selections; + } + + /** + * The directed read replica selector. + * + * Generated from protobuf field repeated .google.spanner.v1.DirectedReadOptions.ReplicaSelection replica_selections = 1; + * @param array<\Google\Cloud\Spanner\V1\DirectedReadOptions\ReplicaSelection>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setReplicaSelections($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\DirectedReadOptions\ReplicaSelection::class); + $this->replica_selections = $arr; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(ExcludeReplicas::class, \Google\Cloud\Spanner\V1\DirectedReadOptions_ExcludeReplicas::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DirectedReadOptions/IncludeReplicas.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DirectedReadOptions/IncludeReplicas.php new file mode 100644 index 000000000000..82047d57919f --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DirectedReadOptions/IncludeReplicas.php @@ -0,0 +1,113 @@ +google.spanner.v1.DirectedReadOptions.IncludeReplicas + */ +class IncludeReplicas extends \Google\Protobuf\Internal\Message +{ + /** + * The directed read replica selector. + * + * Generated from protobuf field repeated .google.spanner.v1.DirectedReadOptions.ReplicaSelection replica_selections = 1; + */ + private $replica_selections; + /** + * If true, Spanner will not route requests to a replica outside the + * include_replicas list when all of the specified replicas are unavailable + * or unhealthy. Default value is `false`. + * + * Generated from protobuf field bool auto_failover_disabled = 2; + */ + protected $auto_failover_disabled = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Spanner\V1\DirectedReadOptions\ReplicaSelection>|\Google\Protobuf\Internal\RepeatedField $replica_selections + * The directed read replica selector. + * @type bool $auto_failover_disabled + * If true, Spanner will not route requests to a replica outside the + * include_replicas list when all of the specified replicas are unavailable + * or unhealthy. Default value is `false`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * The directed read replica selector. + * + * Generated from protobuf field repeated .google.spanner.v1.DirectedReadOptions.ReplicaSelection replica_selections = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getReplicaSelections() + { + return $this->replica_selections; + } + + /** + * The directed read replica selector. + * + * Generated from protobuf field repeated .google.spanner.v1.DirectedReadOptions.ReplicaSelection replica_selections = 1; + * @param array<\Google\Cloud\Spanner\V1\DirectedReadOptions\ReplicaSelection>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setReplicaSelections($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\DirectedReadOptions\ReplicaSelection::class); + $this->replica_selections = $arr; + + return $this; + } + + /** + * If true, Spanner will not route requests to a replica outside the + * include_replicas list when all of the specified replicas are unavailable + * or unhealthy. Default value is `false`. + * + * Generated from protobuf field bool auto_failover_disabled = 2; + * @return bool + */ + public function getAutoFailoverDisabled() + { + return $this->auto_failover_disabled; + } + + /** + * If true, Spanner will not route requests to a replica outside the + * include_replicas list when all of the specified replicas are unavailable + * or unhealthy. Default value is `false`. + * + * Generated from protobuf field bool auto_failover_disabled = 2; + * @param bool $var + * @return $this + */ + public function setAutoFailoverDisabled($var) + { + GPBUtil::checkBool($var); + $this->auto_failover_disabled = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(IncludeReplicas::class, \Google\Cloud\Spanner\V1\DirectedReadOptions_IncludeReplicas::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DirectedReadOptions/ReplicaSelection.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DirectedReadOptions/ReplicaSelection.php new file mode 100644 index 000000000000..634c7345e1a1 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DirectedReadOptions/ReplicaSelection.php @@ -0,0 +1,118 @@ + The "us-east1" replica(s) of any available type + * will be used to process the request. + * * `type:READ_ONLY` --> The "READ_ONLY" type replica(s) in nearest + * available location will be used to process the + * request. + * * `location:us-east1 type:READ_ONLY` --> The "READ_ONLY" type replica(s) + * in location "us-east1" will be used to process + * the request. + * + * Generated from protobuf message google.spanner.v1.DirectedReadOptions.ReplicaSelection + */ +class ReplicaSelection extends \Google\Protobuf\Internal\Message +{ + /** + * The location or region of the serving requests, e.g. "us-east1". + * + * Generated from protobuf field string location = 1; + */ + protected $location = ''; + /** + * The type of replica. + * + * Generated from protobuf field .google.spanner.v1.DirectedReadOptions.ReplicaSelection.Type type = 2; + */ + protected $type = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $location + * The location or region of the serving requests, e.g. "us-east1". + * @type int $type + * The type of replica. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * The location or region of the serving requests, e.g. "us-east1". + * + * Generated from protobuf field string location = 1; + * @return string + */ + public function getLocation() + { + return $this->location; + } + + /** + * The location or region of the serving requests, e.g. "us-east1". + * + * Generated from protobuf field string location = 1; + * @param string $var + * @return $this + */ + public function setLocation($var) + { + GPBUtil::checkString($var, True); + $this->location = $var; + + return $this; + } + + /** + * The type of replica. + * + * Generated from protobuf field .google.spanner.v1.DirectedReadOptions.ReplicaSelection.Type type = 2; + * @return int + */ + public function getType() + { + return $this->type; + } + + /** + * The type of replica. + * + * Generated from protobuf field .google.spanner.v1.DirectedReadOptions.ReplicaSelection.Type type = 2; + * @param int $var + * @return $this + */ + public function setType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\V1\DirectedReadOptions\ReplicaSelection\Type::class); + $this->type = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(ReplicaSelection::class, \Google\Cloud\Spanner\V1\DirectedReadOptions_ReplicaSelection::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DirectedReadOptions/ReplicaSelection/Type.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DirectedReadOptions/ReplicaSelection/Type.php new file mode 100644 index 000000000000..94b7d304ad1b --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/DirectedReadOptions/ReplicaSelection/Type.php @@ -0,0 +1,64 @@ +google.spanner.v1.DirectedReadOptions.ReplicaSelection.Type + */ +class Type +{ + /** + * Not specified. + * + * Generated from protobuf enum TYPE_UNSPECIFIED = 0; + */ + const TYPE_UNSPECIFIED = 0; + /** + * Read-write replicas support both reads and writes. + * + * Generated from protobuf enum READ_WRITE = 1; + */ + const READ_WRITE = 1; + /** + * Read-only replicas only support reads (not writes). + * + * Generated from protobuf enum READ_ONLY = 2; + */ + const READ_ONLY = 2; + + private static $valueToName = [ + self::TYPE_UNSPECIFIED => 'TYPE_UNSPECIFIED', + self::READ_WRITE => 'READ_WRITE', + self::READ_ONLY => 'READ_ONLY', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Type::class, \Google\Cloud\Spanner\V1\DirectedReadOptions_ReplicaSelection_Type::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteBatchDmlRequest.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteBatchDmlRequest.php new file mode 100644 index 000000000000..37c878c7e14a --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteBatchDmlRequest.php @@ -0,0 +1,337 @@ +google.spanner.v1.ExecuteBatchDmlRequest + */ +class ExecuteBatchDmlRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The session in which the DML statements should be performed. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $session = ''; + /** + * Required. The transaction to use. Must be a read-write transaction. + * To protect against replays, single-use transactions are not supported. The + * caller must either supply an existing transaction ID or begin a new + * transaction. + * + * Generated from protobuf field .google.spanner.v1.TransactionSelector transaction = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $transaction = null; + /** + * Required. The list of statements to execute in this batch. Statements are + * executed serially, such that the effects of statement `i` are visible to + * statement `i+1`. Each statement must be a DML statement. Execution stops at + * the first failed statement; the remaining statements are not executed. + * Callers must provide at least one statement. + * + * Generated from protobuf field repeated .google.spanner.v1.ExecuteBatchDmlRequest.Statement statements = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + private $statements; + /** + * Required. A per-transaction sequence number used to identify this request. + * This field makes each request idempotent such that if the request is + * received multiple times, at most one will succeed. + * The sequence number must be monotonically increasing within the + * transaction. If a request arrives for the first time with an out-of-order + * sequence number, the transaction may be aborted. Replays of previously + * handled requests will yield the same response as the first execution. + * + * Generated from protobuf field int64 seqno = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $seqno = 0; + /** + * Common options for this request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 5; + */ + protected $request_options = null; + /** + * Optional. If set to true, this request marks the end of the transaction. + * The transaction should be committed or aborted after these statements + * execute, and attempts to execute any other requests against this + * transaction (including reads and queries) will be rejected. + * Setting this option may cause some error reporting to be deferred until + * commit time (e.g. validation of unique constraints). Given this, successful + * execution of statements should not be assumed until a subsequent Commit + * call completes successfully. + * + * Generated from protobuf field bool last_statements = 6 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $last_statements = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $session + * Required. The session in which the DML statements should be performed. + * @type \Google\Cloud\Spanner\V1\TransactionSelector $transaction + * Required. The transaction to use. Must be a read-write transaction. + * To protect against replays, single-use transactions are not supported. The + * caller must either supply an existing transaction ID or begin a new + * transaction. + * @type array<\Google\Cloud\Spanner\V1\ExecuteBatchDmlRequest\Statement>|\Google\Protobuf\Internal\RepeatedField $statements + * Required. The list of statements to execute in this batch. Statements are + * executed serially, such that the effects of statement `i` are visible to + * statement `i+1`. Each statement must be a DML statement. Execution stops at + * the first failed statement; the remaining statements are not executed. + * Callers must provide at least one statement. + * @type int|string $seqno + * Required. A per-transaction sequence number used to identify this request. + * This field makes each request idempotent such that if the request is + * received multiple times, at most one will succeed. + * The sequence number must be monotonically increasing within the + * transaction. If a request arrives for the first time with an out-of-order + * sequence number, the transaction may be aborted. Replays of previously + * handled requests will yield the same response as the first execution. + * @type \Google\Cloud\Spanner\V1\RequestOptions $request_options + * Common options for this request. + * @type bool $last_statements + * Optional. If set to true, this request marks the end of the transaction. + * The transaction should be committed or aborted after these statements + * execute, and attempts to execute any other requests against this + * transaction (including reads and queries) will be rejected. + * Setting this option may cause some error reporting to be deferred until + * commit time (e.g. validation of unique constraints). Given this, successful + * execution of statements should not be assumed until a subsequent Commit + * call completes successfully. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Required. The session in which the DML statements should be performed. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getSession() + { + return $this->session; + } + + /** + * Required. The session in which the DML statements should be performed. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setSession($var) + { + GPBUtil::checkString($var, True); + $this->session = $var; + + return $this; + } + + /** + * Required. The transaction to use. Must be a read-write transaction. + * To protect against replays, single-use transactions are not supported. The + * caller must either supply an existing transaction ID or begin a new + * transaction. + * + * Generated from protobuf field .google.spanner.v1.TransactionSelector transaction = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\V1\TransactionSelector|null + */ + public function getTransaction() + { + return $this->transaction; + } + + public function hasTransaction() + { + return isset($this->transaction); + } + + public function clearTransaction() + { + unset($this->transaction); + } + + /** + * Required. The transaction to use. Must be a read-write transaction. + * To protect against replays, single-use transactions are not supported. The + * caller must either supply an existing transaction ID or begin a new + * transaction. + * + * Generated from protobuf field .google.spanner.v1.TransactionSelector transaction = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\V1\TransactionSelector $var + * @return $this + */ + public function setTransaction($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\TransactionSelector::class); + $this->transaction = $var; + + return $this; + } + + /** + * Required. The list of statements to execute in this batch. Statements are + * executed serially, such that the effects of statement `i` are visible to + * statement `i+1`. Each statement must be a DML statement. Execution stops at + * the first failed statement; the remaining statements are not executed. + * Callers must provide at least one statement. + * + * Generated from protobuf field repeated .google.spanner.v1.ExecuteBatchDmlRequest.Statement statements = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getStatements() + { + return $this->statements; + } + + /** + * Required. The list of statements to execute in this batch. Statements are + * executed serially, such that the effects of statement `i` are visible to + * statement `i+1`. Each statement must be a DML statement. Execution stops at + * the first failed statement; the remaining statements are not executed. + * Callers must provide at least one statement. + * + * Generated from protobuf field repeated .google.spanner.v1.ExecuteBatchDmlRequest.Statement statements = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param array<\Google\Cloud\Spanner\V1\ExecuteBatchDmlRequest\Statement>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setStatements($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\ExecuteBatchDmlRequest\Statement::class); + $this->statements = $arr; + + return $this; + } + + /** + * Required. A per-transaction sequence number used to identify this request. + * This field makes each request idempotent such that if the request is + * received multiple times, at most one will succeed. + * The sequence number must be monotonically increasing within the + * transaction. If a request arrives for the first time with an out-of-order + * sequence number, the transaction may be aborted. Replays of previously + * handled requests will yield the same response as the first execution. + * + * Generated from protobuf field int64 seqno = 4 [(.google.api.field_behavior) = REQUIRED]; + * @return int|string + */ + public function getSeqno() + { + return $this->seqno; + } + + /** + * Required. A per-transaction sequence number used to identify this request. + * This field makes each request idempotent such that if the request is + * received multiple times, at most one will succeed. + * The sequence number must be monotonically increasing within the + * transaction. If a request arrives for the first time with an out-of-order + * sequence number, the transaction may be aborted. Replays of previously + * handled requests will yield the same response as the first execution. + * + * Generated from protobuf field int64 seqno = 4 [(.google.api.field_behavior) = REQUIRED]; + * @param int|string $var + * @return $this + */ + public function setSeqno($var) + { + GPBUtil::checkInt64($var); + $this->seqno = $var; + + return $this; + } + + /** + * Common options for this request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 5; + * @return \Google\Cloud\Spanner\V1\RequestOptions|null + */ + public function getRequestOptions() + { + return $this->request_options; + } + + public function hasRequestOptions() + { + return isset($this->request_options); + } + + public function clearRequestOptions() + { + unset($this->request_options); + } + + /** + * Common options for this request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 5; + * @param \Google\Cloud\Spanner\V1\RequestOptions $var + * @return $this + */ + public function setRequestOptions($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\RequestOptions::class); + $this->request_options = $var; + + return $this; + } + + /** + * Optional. If set to true, this request marks the end of the transaction. + * The transaction should be committed or aborted after these statements + * execute, and attempts to execute any other requests against this + * transaction (including reads and queries) will be rejected. + * Setting this option may cause some error reporting to be deferred until + * commit time (e.g. validation of unique constraints). Given this, successful + * execution of statements should not be assumed until a subsequent Commit + * call completes successfully. + * + * Generated from protobuf field bool last_statements = 6 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getLastStatements() + { + return $this->last_statements; + } + + /** + * Optional. If set to true, this request marks the end of the transaction. + * The transaction should be committed or aborted after these statements + * execute, and attempts to execute any other requests against this + * transaction (including reads and queries) will be rejected. + * Setting this option may cause some error reporting to be deferred until + * commit time (e.g. validation of unique constraints). Given this, successful + * execution of statements should not be assumed until a subsequent Commit + * call completes successfully. + * + * Generated from protobuf field bool last_statements = 6 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setLastStatements($var) + { + GPBUtil::checkBool($var); + $this->last_statements = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteBatchDmlRequest/Statement.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteBatchDmlRequest/Statement.php new file mode 100644 index 000000000000..aba8c0bd42cd --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteBatchDmlRequest/Statement.php @@ -0,0 +1,208 @@ +google.spanner.v1.ExecuteBatchDmlRequest.Statement + */ +class Statement extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The DML string. + * + * Generated from protobuf field string sql = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $sql = ''; + /** + * Parameter names and values that bind to placeholders in the DML string. + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names can contain + * letters, numbers, and underscores. + * Parameters can appear anywhere that a literal value is expected. The + * same parameter name can be used more than once, for example: + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * It is an error to execute a SQL statement with unbound parameters. + * + * Generated from protobuf field .google.protobuf.Struct params = 2; + */ + protected $params = null; + /** + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in + * [params][google.spanner.v1.ExecuteBatchDmlRequest.Statement.params] as + * JSON strings. + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL statement parameters. See the + * definition of [Type][google.spanner.v1.Type] for more information + * about SQL types. + * + * Generated from protobuf field map param_types = 3; + */ + private $param_types; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $sql + * Required. The DML string. + * @type \Google\Protobuf\Struct $params + * Parameter names and values that bind to placeholders in the DML string. + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names can contain + * letters, numbers, and underscores. + * Parameters can appear anywhere that a literal value is expected. The + * same parameter name can be used more than once, for example: + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * It is an error to execute a SQL statement with unbound parameters. + * @type array|\Google\Protobuf\Internal\MapField $param_types + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in + * [params][google.spanner.v1.ExecuteBatchDmlRequest.Statement.params] as + * JSON strings. + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL statement parameters. See the + * definition of [Type][google.spanner.v1.Type] for more information + * about SQL types. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Required. The DML string. + * + * Generated from protobuf field string sql = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getSql() + { + return $this->sql; + } + + /** + * Required. The DML string. + * + * Generated from protobuf field string sql = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setSql($var) + { + GPBUtil::checkString($var, True); + $this->sql = $var; + + return $this; + } + + /** + * Parameter names and values that bind to placeholders in the DML string. + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names can contain + * letters, numbers, and underscores. + * Parameters can appear anywhere that a literal value is expected. The + * same parameter name can be used more than once, for example: + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * It is an error to execute a SQL statement with unbound parameters. + * + * Generated from protobuf field .google.protobuf.Struct params = 2; + * @return \Google\Protobuf\Struct|null + */ + public function getParams() + { + return $this->params; + } + + public function hasParams() + { + return isset($this->params); + } + + public function clearParams() + { + unset($this->params); + } + + /** + * Parameter names and values that bind to placeholders in the DML string. + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names can contain + * letters, numbers, and underscores. + * Parameters can appear anywhere that a literal value is expected. The + * same parameter name can be used more than once, for example: + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * It is an error to execute a SQL statement with unbound parameters. + * + * Generated from protobuf field .google.protobuf.Struct params = 2; + * @param \Google\Protobuf\Struct $var + * @return $this + */ + public function setParams($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Struct::class); + $this->params = $var; + + return $this; + } + + /** + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in + * [params][google.spanner.v1.ExecuteBatchDmlRequest.Statement.params] as + * JSON strings. + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL statement parameters. See the + * definition of [Type][google.spanner.v1.Type] for more information + * about SQL types. + * + * Generated from protobuf field map param_types = 3; + * @return \Google\Protobuf\Internal\MapField + */ + public function getParamTypes() + { + return $this->param_types; + } + + /** + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in + * [params][google.spanner.v1.ExecuteBatchDmlRequest.Statement.params] as + * JSON strings. + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL statement parameters. See the + * definition of [Type][google.spanner.v1.Type] for more information + * about SQL types. + * + * Generated from protobuf field map param_types = 3; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setParamTypes($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\Type::class); + $this->param_types = $arr; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Statement::class, \Google\Cloud\Spanner\V1\ExecuteBatchDmlRequest_Statement::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteBatchDmlResponse.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteBatchDmlResponse.php new file mode 100644 index 000000000000..af904f7019f8 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteBatchDmlResponse.php @@ -0,0 +1,235 @@ +google.spanner.v1.ExecuteBatchDmlResponse + */ +class ExecuteBatchDmlResponse extends \Google\Protobuf\Internal\Message +{ + /** + * One [ResultSet][google.spanner.v1.ResultSet] for each statement in the + * request that ran successfully, in the same order as the statements in the + * request. Each [ResultSet][google.spanner.v1.ResultSet] does not contain any + * rows. The [ResultSetStats][google.spanner.v1.ResultSetStats] in each + * [ResultSet][google.spanner.v1.ResultSet] contain the number of rows + * modified by the statement. + * Only the first [ResultSet][google.spanner.v1.ResultSet] in the response + * contains valid [ResultSetMetadata][google.spanner.v1.ResultSetMetadata]. + * + * Generated from protobuf field repeated .google.spanner.v1.ResultSet result_sets = 1; + */ + private $result_sets; + /** + * If all DML statements are executed successfully, the status is `OK`. + * Otherwise, the error status of the first failed statement. + * + * Generated from protobuf field .google.rpc.Status status = 2; + */ + protected $status = null; + /** + * Optional. A precommit token will be included if the read-write transaction + * is on a multiplexed session. + * The precommit token with the highest sequence number from this transaction + * attempt should be passed to the + * [Commit][google.spanner.v1.Spanner.Commit] request for this transaction. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.MultiplexedSessionPrecommitToken precommit_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $precommit_token = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Spanner\V1\ResultSet>|\Google\Protobuf\Internal\RepeatedField $result_sets + * One [ResultSet][google.spanner.v1.ResultSet] for each statement in the + * request that ran successfully, in the same order as the statements in the + * request. Each [ResultSet][google.spanner.v1.ResultSet] does not contain any + * rows. The [ResultSetStats][google.spanner.v1.ResultSetStats] in each + * [ResultSet][google.spanner.v1.ResultSet] contain the number of rows + * modified by the statement. + * Only the first [ResultSet][google.spanner.v1.ResultSet] in the response + * contains valid [ResultSetMetadata][google.spanner.v1.ResultSetMetadata]. + * @type \Google\Rpc\Status $status + * If all DML statements are executed successfully, the status is `OK`. + * Otherwise, the error status of the first failed statement. + * @type \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken $precommit_token + * Optional. A precommit token will be included if the read-write transaction + * is on a multiplexed session. + * The precommit token with the highest sequence number from this transaction + * attempt should be passed to the + * [Commit][google.spanner.v1.Spanner.Commit] request for this transaction. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * One [ResultSet][google.spanner.v1.ResultSet] for each statement in the + * request that ran successfully, in the same order as the statements in the + * request. Each [ResultSet][google.spanner.v1.ResultSet] does not contain any + * rows. The [ResultSetStats][google.spanner.v1.ResultSetStats] in each + * [ResultSet][google.spanner.v1.ResultSet] contain the number of rows + * modified by the statement. + * Only the first [ResultSet][google.spanner.v1.ResultSet] in the response + * contains valid [ResultSetMetadata][google.spanner.v1.ResultSetMetadata]. + * + * Generated from protobuf field repeated .google.spanner.v1.ResultSet result_sets = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getResultSets() + { + return $this->result_sets; + } + + /** + * One [ResultSet][google.spanner.v1.ResultSet] for each statement in the + * request that ran successfully, in the same order as the statements in the + * request. Each [ResultSet][google.spanner.v1.ResultSet] does not contain any + * rows. The [ResultSetStats][google.spanner.v1.ResultSetStats] in each + * [ResultSet][google.spanner.v1.ResultSet] contain the number of rows + * modified by the statement. + * Only the first [ResultSet][google.spanner.v1.ResultSet] in the response + * contains valid [ResultSetMetadata][google.spanner.v1.ResultSetMetadata]. + * + * Generated from protobuf field repeated .google.spanner.v1.ResultSet result_sets = 1; + * @param array<\Google\Cloud\Spanner\V1\ResultSet>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setResultSets($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\ResultSet::class); + $this->result_sets = $arr; + + return $this; + } + + /** + * If all DML statements are executed successfully, the status is `OK`. + * Otherwise, the error status of the first failed statement. + * + * Generated from protobuf field .google.rpc.Status status = 2; + * @return \Google\Rpc\Status|null + */ + public function getStatus() + { + return $this->status; + } + + public function hasStatus() + { + return isset($this->status); + } + + public function clearStatus() + { + unset($this->status); + } + + /** + * If all DML statements are executed successfully, the status is `OK`. + * Otherwise, the error status of the first failed statement. + * + * Generated from protobuf field .google.rpc.Status status = 2; + * @param \Google\Rpc\Status $var + * @return $this + */ + public function setStatus($var) + { + GPBUtil::checkMessage($var, \Google\Rpc\Status::class); + $this->status = $var; + + return $this; + } + + /** + * Optional. A precommit token will be included if the read-write transaction + * is on a multiplexed session. + * The precommit token with the highest sequence number from this transaction + * attempt should be passed to the + * [Commit][google.spanner.v1.Spanner.Commit] request for this transaction. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.MultiplexedSessionPrecommitToken precommit_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken|null + */ + public function getPrecommitToken() + { + return $this->precommit_token; + } + + public function hasPrecommitToken() + { + return isset($this->precommit_token); + } + + public function clearPrecommitToken() + { + unset($this->precommit_token); + } + + /** + * Optional. A precommit token will be included if the read-write transaction + * is on a multiplexed session. + * The precommit token with the highest sequence number from this transaction + * attempt should be passed to the + * [Commit][google.spanner.v1.Spanner.Commit] request for this transaction. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.MultiplexedSessionPrecommitToken precommit_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken $var + * @return $this + */ + public function setPrecommitToken($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken::class); + $this->precommit_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteSqlRequest.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteSqlRequest.php new file mode 100644 index 000000000000..6733a35ca0b9 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteSqlRequest.php @@ -0,0 +1,764 @@ +google.spanner.v1.ExecuteSqlRequest + */ +class ExecuteSqlRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The session in which the SQL query should be performed. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $session = ''; + /** + * The transaction to use. + * For queries, if none is provided, the default is a temporary read-only + * transaction with strong concurrency. + * Standard DML statements require a read-write transaction. To protect + * against replays, single-use transactions are not supported. The caller + * must either supply an existing transaction ID or begin a new transaction. + * Partitioned DML requires an existing Partitioned DML transaction ID. + * + * Generated from protobuf field .google.spanner.v1.TransactionSelector transaction = 2; + */ + protected $transaction = null; + /** + * Required. The SQL string. + * + * Generated from protobuf field string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $sql = ''; + /** + * Parameter names and values that bind to placeholders in the SQL string. + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names must conform + * to the naming requirements of identifiers as specified at + * https://cloud.google.com/spanner/docs/lexical#identifiers. + * Parameters can appear anywhere that a literal value is expected. The same + * parameter name can be used more than once, for example: + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * It is an error to execute a SQL statement with unbound parameters. + * + * Generated from protobuf field .google.protobuf.Struct params = 4; + */ + protected $params = null; + /** + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in + * [params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings. + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL statement parameters. See the + * definition of [Type][google.spanner.v1.Type] for more information + * about SQL types. + * + * Generated from protobuf field map param_types = 5; + */ + private $param_types; + /** + * If this request is resuming a previously interrupted SQL statement + * execution, `resume_token` should be copied from the last + * [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the + * interruption. Doing this enables the new SQL statement execution to resume + * where the last one left off. The rest of the request parameters must + * exactly match the request that yielded this token. + * + * Generated from protobuf field bytes resume_token = 6; + */ + protected $resume_token = ''; + /** + * Used to control the amount of debugging information returned in + * [ResultSetStats][google.spanner.v1.ResultSetStats]. If + * [partition_token][google.spanner.v1.ExecuteSqlRequest.partition_token] is + * set, [query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] can only + * be set to + * [QueryMode.NORMAL][google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL]. + * + * Generated from protobuf field .google.spanner.v1.ExecuteSqlRequest.QueryMode query_mode = 7; + */ + protected $query_mode = 0; + /** + * If present, results will be restricted to the specified partition + * previously created using PartitionQuery(). There must be an exact + * match for the values of fields common to this message and the + * PartitionQueryRequest message used to create this partition_token. + * + * Generated from protobuf field bytes partition_token = 8; + */ + protected $partition_token = ''; + /** + * A per-transaction sequence number used to identify this request. This field + * makes each request idempotent such that if the request is received multiple + * times, at most one will succeed. + * The sequence number must be monotonically increasing within the + * transaction. If a request arrives for the first time with an out-of-order + * sequence number, the transaction may be aborted. Replays of previously + * handled requests will yield the same response as the first execution. + * Required for DML statements. Ignored for queries. + * + * Generated from protobuf field int64 seqno = 9; + */ + protected $seqno = 0; + /** + * Query optimizer configuration to use for the given query. + * + * Generated from protobuf field .google.spanner.v1.ExecuteSqlRequest.QueryOptions query_options = 10; + */ + protected $query_options = null; + /** + * Common options for this request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 11; + */ + protected $request_options = null; + /** + * Directed read options for this request. + * + * Generated from protobuf field .google.spanner.v1.DirectedReadOptions directed_read_options = 15; + */ + protected $directed_read_options = null; + /** + * If this is for a partitioned query and this field is set to `true`, the + * request is executed with Spanner Data Boost independent compute resources. + * If the field is set to `true` but the request does not set + * `partition_token`, the API returns an `INVALID_ARGUMENT` error. + * + * Generated from protobuf field bool data_boost_enabled = 16; + */ + protected $data_boost_enabled = false; + /** + * Optional. If set to true, this statement marks the end of the transaction. + * The transaction should be committed or aborted after this statement + * executes, and attempts to execute any other requests against this + * transaction (including reads and queries) will be rejected. + * For DML statements, setting this option may cause some error reporting to + * be deferred until commit time (e.g. validation of unique constraints). + * Given this, successful execution of a DML statement should not be assumed + * until a subsequent Commit call completes successfully. + * + * Generated from protobuf field bool last_statement = 17 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $last_statement = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $session + * Required. The session in which the SQL query should be performed. + * @type \Google\Cloud\Spanner\V1\TransactionSelector $transaction + * The transaction to use. + * For queries, if none is provided, the default is a temporary read-only + * transaction with strong concurrency. + * Standard DML statements require a read-write transaction. To protect + * against replays, single-use transactions are not supported. The caller + * must either supply an existing transaction ID or begin a new transaction. + * Partitioned DML requires an existing Partitioned DML transaction ID. + * @type string $sql + * Required. The SQL string. + * @type \Google\Protobuf\Struct $params + * Parameter names and values that bind to placeholders in the SQL string. + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names must conform + * to the naming requirements of identifiers as specified at + * https://cloud.google.com/spanner/docs/lexical#identifiers. + * Parameters can appear anywhere that a literal value is expected. The same + * parameter name can be used more than once, for example: + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * It is an error to execute a SQL statement with unbound parameters. + * @type array|\Google\Protobuf\Internal\MapField $param_types + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in + * [params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings. + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL statement parameters. See the + * definition of [Type][google.spanner.v1.Type] for more information + * about SQL types. + * @type string $resume_token + * If this request is resuming a previously interrupted SQL statement + * execution, `resume_token` should be copied from the last + * [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the + * interruption. Doing this enables the new SQL statement execution to resume + * where the last one left off. The rest of the request parameters must + * exactly match the request that yielded this token. + * @type int $query_mode + * Used to control the amount of debugging information returned in + * [ResultSetStats][google.spanner.v1.ResultSetStats]. If + * [partition_token][google.spanner.v1.ExecuteSqlRequest.partition_token] is + * set, [query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] can only + * be set to + * [QueryMode.NORMAL][google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL]. + * @type string $partition_token + * If present, results will be restricted to the specified partition + * previously created using PartitionQuery(). There must be an exact + * match for the values of fields common to this message and the + * PartitionQueryRequest message used to create this partition_token. + * @type int|string $seqno + * A per-transaction sequence number used to identify this request. This field + * makes each request idempotent such that if the request is received multiple + * times, at most one will succeed. + * The sequence number must be monotonically increasing within the + * transaction. If a request arrives for the first time with an out-of-order + * sequence number, the transaction may be aborted. Replays of previously + * handled requests will yield the same response as the first execution. + * Required for DML statements. Ignored for queries. + * @type \Google\Cloud\Spanner\V1\ExecuteSqlRequest\QueryOptions $query_options + * Query optimizer configuration to use for the given query. + * @type \Google\Cloud\Spanner\V1\RequestOptions $request_options + * Common options for this request. + * @type \Google\Cloud\Spanner\V1\DirectedReadOptions $directed_read_options + * Directed read options for this request. + * @type bool $data_boost_enabled + * If this is for a partitioned query and this field is set to `true`, the + * request is executed with Spanner Data Boost independent compute resources. + * If the field is set to `true` but the request does not set + * `partition_token`, the API returns an `INVALID_ARGUMENT` error. + * @type bool $last_statement + * Optional. If set to true, this statement marks the end of the transaction. + * The transaction should be committed or aborted after this statement + * executes, and attempts to execute any other requests against this + * transaction (including reads and queries) will be rejected. + * For DML statements, setting this option may cause some error reporting to + * be deferred until commit time (e.g. validation of unique constraints). + * Given this, successful execution of a DML statement should not be assumed + * until a subsequent Commit call completes successfully. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Required. The session in which the SQL query should be performed. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getSession() + { + return $this->session; + } + + /** + * Required. The session in which the SQL query should be performed. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setSession($var) + { + GPBUtil::checkString($var, True); + $this->session = $var; + + return $this; + } + + /** + * The transaction to use. + * For queries, if none is provided, the default is a temporary read-only + * transaction with strong concurrency. + * Standard DML statements require a read-write transaction. To protect + * against replays, single-use transactions are not supported. The caller + * must either supply an existing transaction ID or begin a new transaction. + * Partitioned DML requires an existing Partitioned DML transaction ID. + * + * Generated from protobuf field .google.spanner.v1.TransactionSelector transaction = 2; + * @return \Google\Cloud\Spanner\V1\TransactionSelector|null + */ + public function getTransaction() + { + return $this->transaction; + } + + public function hasTransaction() + { + return isset($this->transaction); + } + + public function clearTransaction() + { + unset($this->transaction); + } + + /** + * The transaction to use. + * For queries, if none is provided, the default is a temporary read-only + * transaction with strong concurrency. + * Standard DML statements require a read-write transaction. To protect + * against replays, single-use transactions are not supported. The caller + * must either supply an existing transaction ID or begin a new transaction. + * Partitioned DML requires an existing Partitioned DML transaction ID. + * + * Generated from protobuf field .google.spanner.v1.TransactionSelector transaction = 2; + * @param \Google\Cloud\Spanner\V1\TransactionSelector $var + * @return $this + */ + public function setTransaction($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\TransactionSelector::class); + $this->transaction = $var; + + return $this; + } + + /** + * Required. The SQL string. + * + * Generated from protobuf field string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getSql() + { + return $this->sql; + } + + /** + * Required. The SQL string. + * + * Generated from protobuf field string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setSql($var) + { + GPBUtil::checkString($var, True); + $this->sql = $var; + + return $this; + } + + /** + * Parameter names and values that bind to placeholders in the SQL string. + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names must conform + * to the naming requirements of identifiers as specified at + * https://cloud.google.com/spanner/docs/lexical#identifiers. + * Parameters can appear anywhere that a literal value is expected. The same + * parameter name can be used more than once, for example: + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * It is an error to execute a SQL statement with unbound parameters. + * + * Generated from protobuf field .google.protobuf.Struct params = 4; + * @return \Google\Protobuf\Struct|null + */ + public function getParams() + { + return $this->params; + } + + public function hasParams() + { + return isset($this->params); + } + + public function clearParams() + { + unset($this->params); + } + + /** + * Parameter names and values that bind to placeholders in the SQL string. + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names must conform + * to the naming requirements of identifiers as specified at + * https://cloud.google.com/spanner/docs/lexical#identifiers. + * Parameters can appear anywhere that a literal value is expected. The same + * parameter name can be used more than once, for example: + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * It is an error to execute a SQL statement with unbound parameters. + * + * Generated from protobuf field .google.protobuf.Struct params = 4; + * @param \Google\Protobuf\Struct $var + * @return $this + */ + public function setParams($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Struct::class); + $this->params = $var; + + return $this; + } + + /** + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in + * [params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings. + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL statement parameters. See the + * definition of [Type][google.spanner.v1.Type] for more information + * about SQL types. + * + * Generated from protobuf field map param_types = 5; + * @return \Google\Protobuf\Internal\MapField + */ + public function getParamTypes() + { + return $this->param_types; + } + + /** + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in + * [params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings. + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL statement parameters. See the + * definition of [Type][google.spanner.v1.Type] for more information + * about SQL types. + * + * Generated from protobuf field map param_types = 5; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setParamTypes($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\Type::class); + $this->param_types = $arr; + + return $this; + } + + /** + * If this request is resuming a previously interrupted SQL statement + * execution, `resume_token` should be copied from the last + * [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the + * interruption. Doing this enables the new SQL statement execution to resume + * where the last one left off. The rest of the request parameters must + * exactly match the request that yielded this token. + * + * Generated from protobuf field bytes resume_token = 6; + * @return string + */ + public function getResumeToken() + { + return $this->resume_token; + } + + /** + * If this request is resuming a previously interrupted SQL statement + * execution, `resume_token` should be copied from the last + * [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the + * interruption. Doing this enables the new SQL statement execution to resume + * where the last one left off. The rest of the request parameters must + * exactly match the request that yielded this token. + * + * Generated from protobuf field bytes resume_token = 6; + * @param string $var + * @return $this + */ + public function setResumeToken($var) + { + GPBUtil::checkString($var, False); + $this->resume_token = $var; + + return $this; + } + + /** + * Used to control the amount of debugging information returned in + * [ResultSetStats][google.spanner.v1.ResultSetStats]. If + * [partition_token][google.spanner.v1.ExecuteSqlRequest.partition_token] is + * set, [query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] can only + * be set to + * [QueryMode.NORMAL][google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL]. + * + * Generated from protobuf field .google.spanner.v1.ExecuteSqlRequest.QueryMode query_mode = 7; + * @return int + */ + public function getQueryMode() + { + return $this->query_mode; + } + + /** + * Used to control the amount of debugging information returned in + * [ResultSetStats][google.spanner.v1.ResultSetStats]. If + * [partition_token][google.spanner.v1.ExecuteSqlRequest.partition_token] is + * set, [query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] can only + * be set to + * [QueryMode.NORMAL][google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL]. + * + * Generated from protobuf field .google.spanner.v1.ExecuteSqlRequest.QueryMode query_mode = 7; + * @param int $var + * @return $this + */ + public function setQueryMode($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\V1\ExecuteSqlRequest\QueryMode::class); + $this->query_mode = $var; + + return $this; + } + + /** + * If present, results will be restricted to the specified partition + * previously created using PartitionQuery(). There must be an exact + * match for the values of fields common to this message and the + * PartitionQueryRequest message used to create this partition_token. + * + * Generated from protobuf field bytes partition_token = 8; + * @return string + */ + public function getPartitionToken() + { + return $this->partition_token; + } + + /** + * If present, results will be restricted to the specified partition + * previously created using PartitionQuery(). There must be an exact + * match for the values of fields common to this message and the + * PartitionQueryRequest message used to create this partition_token. + * + * Generated from protobuf field bytes partition_token = 8; + * @param string $var + * @return $this + */ + public function setPartitionToken($var) + { + GPBUtil::checkString($var, False); + $this->partition_token = $var; + + return $this; + } + + /** + * A per-transaction sequence number used to identify this request. This field + * makes each request idempotent such that if the request is received multiple + * times, at most one will succeed. + * The sequence number must be monotonically increasing within the + * transaction. If a request arrives for the first time with an out-of-order + * sequence number, the transaction may be aborted. Replays of previously + * handled requests will yield the same response as the first execution. + * Required for DML statements. Ignored for queries. + * + * Generated from protobuf field int64 seqno = 9; + * @return int|string + */ + public function getSeqno() + { + return $this->seqno; + } + + /** + * A per-transaction sequence number used to identify this request. This field + * makes each request idempotent such that if the request is received multiple + * times, at most one will succeed. + * The sequence number must be monotonically increasing within the + * transaction. If a request arrives for the first time with an out-of-order + * sequence number, the transaction may be aborted. Replays of previously + * handled requests will yield the same response as the first execution. + * Required for DML statements. Ignored for queries. + * + * Generated from protobuf field int64 seqno = 9; + * @param int|string $var + * @return $this + */ + public function setSeqno($var) + { + GPBUtil::checkInt64($var); + $this->seqno = $var; + + return $this; + } + + /** + * Query optimizer configuration to use for the given query. + * + * Generated from protobuf field .google.spanner.v1.ExecuteSqlRequest.QueryOptions query_options = 10; + * @return \Google\Cloud\Spanner\V1\ExecuteSqlRequest\QueryOptions|null + */ + public function getQueryOptions() + { + return $this->query_options; + } + + public function hasQueryOptions() + { + return isset($this->query_options); + } + + public function clearQueryOptions() + { + unset($this->query_options); + } + + /** + * Query optimizer configuration to use for the given query. + * + * Generated from protobuf field .google.spanner.v1.ExecuteSqlRequest.QueryOptions query_options = 10; + * @param \Google\Cloud\Spanner\V1\ExecuteSqlRequest\QueryOptions $var + * @return $this + */ + public function setQueryOptions($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\ExecuteSqlRequest\QueryOptions::class); + $this->query_options = $var; + + return $this; + } + + /** + * Common options for this request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 11; + * @return \Google\Cloud\Spanner\V1\RequestOptions|null + */ + public function getRequestOptions() + { + return $this->request_options; + } + + public function hasRequestOptions() + { + return isset($this->request_options); + } + + public function clearRequestOptions() + { + unset($this->request_options); + } + + /** + * Common options for this request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 11; + * @param \Google\Cloud\Spanner\V1\RequestOptions $var + * @return $this + */ + public function setRequestOptions($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\RequestOptions::class); + $this->request_options = $var; + + return $this; + } + + /** + * Directed read options for this request. + * + * Generated from protobuf field .google.spanner.v1.DirectedReadOptions directed_read_options = 15; + * @return \Google\Cloud\Spanner\V1\DirectedReadOptions|null + */ + public function getDirectedReadOptions() + { + return $this->directed_read_options; + } + + public function hasDirectedReadOptions() + { + return isset($this->directed_read_options); + } + + public function clearDirectedReadOptions() + { + unset($this->directed_read_options); + } + + /** + * Directed read options for this request. + * + * Generated from protobuf field .google.spanner.v1.DirectedReadOptions directed_read_options = 15; + * @param \Google\Cloud\Spanner\V1\DirectedReadOptions $var + * @return $this + */ + public function setDirectedReadOptions($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\DirectedReadOptions::class); + $this->directed_read_options = $var; + + return $this; + } + + /** + * If this is for a partitioned query and this field is set to `true`, the + * request is executed with Spanner Data Boost independent compute resources. + * If the field is set to `true` but the request does not set + * `partition_token`, the API returns an `INVALID_ARGUMENT` error. + * + * Generated from protobuf field bool data_boost_enabled = 16; + * @return bool + */ + public function getDataBoostEnabled() + { + return $this->data_boost_enabled; + } + + /** + * If this is for a partitioned query and this field is set to `true`, the + * request is executed with Spanner Data Boost independent compute resources. + * If the field is set to `true` but the request does not set + * `partition_token`, the API returns an `INVALID_ARGUMENT` error. + * + * Generated from protobuf field bool data_boost_enabled = 16; + * @param bool $var + * @return $this + */ + public function setDataBoostEnabled($var) + { + GPBUtil::checkBool($var); + $this->data_boost_enabled = $var; + + return $this; + } + + /** + * Optional. If set to true, this statement marks the end of the transaction. + * The transaction should be committed or aborted after this statement + * executes, and attempts to execute any other requests against this + * transaction (including reads and queries) will be rejected. + * For DML statements, setting this option may cause some error reporting to + * be deferred until commit time (e.g. validation of unique constraints). + * Given this, successful execution of a DML statement should not be assumed + * until a subsequent Commit call completes successfully. + * + * Generated from protobuf field bool last_statement = 17 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getLastStatement() + { + return $this->last_statement; + } + + /** + * Optional. If set to true, this statement marks the end of the transaction. + * The transaction should be committed or aborted after this statement + * executes, and attempts to execute any other requests against this + * transaction (including reads and queries) will be rejected. + * For DML statements, setting this option may cause some error reporting to + * be deferred until commit time (e.g. validation of unique constraints). + * Given this, successful execution of a DML statement should not be assumed + * until a subsequent Commit call completes successfully. + * + * Generated from protobuf field bool last_statement = 17 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setLastStatement($var) + { + GPBUtil::checkBool($var); + $this->last_statement = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteSqlRequest/QueryMode.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteSqlRequest/QueryMode.php new file mode 100644 index 000000000000..43c3ed48f97b --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteSqlRequest/QueryMode.php @@ -0,0 +1,84 @@ +google.spanner.v1.ExecuteSqlRequest.QueryMode + */ +class QueryMode +{ + /** + * The default mode. Only the statement results are returned. + * + * Generated from protobuf enum NORMAL = 0; + */ + const NORMAL = 0; + /** + * This mode returns only the query plan, without any results or + * execution statistics information. + * + * Generated from protobuf enum PLAN = 1; + */ + const PLAN = 1; + /** + * This mode returns the query plan, overall execution statistics, + * operator level execution statistics along with the results. This has a + * performance overhead compared to the other modes. It is not recommended + * to use this mode for production traffic. + * + * Generated from protobuf enum PROFILE = 2; + */ + const PROFILE = 2; + /** + * This mode returns the overall (but not operator-level) execution + * statistics along with the results. + * + * Generated from protobuf enum WITH_STATS = 3; + */ + const WITH_STATS = 3; + /** + * This mode returns the query plan, overall (but not operator-level) + * execution statistics along with the results. + * + * Generated from protobuf enum WITH_PLAN_AND_STATS = 4; + */ + const WITH_PLAN_AND_STATS = 4; + + private static $valueToName = [ + self::NORMAL => 'NORMAL', + self::PLAN => 'PLAN', + self::PROFILE => 'PROFILE', + self::WITH_STATS => 'WITH_STATS', + self::WITH_PLAN_AND_STATS => 'WITH_PLAN_AND_STATS', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(QueryMode::class, \Google\Cloud\Spanner\V1\ExecuteSqlRequest_QueryMode::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteSqlRequest/QueryOptions.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteSqlRequest/QueryOptions.php new file mode 100644 index 000000000000..d821f6f3bbef --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ExecuteSqlRequest/QueryOptions.php @@ -0,0 +1,232 @@ +google.spanner.v1.ExecuteSqlRequest.QueryOptions + */ +class QueryOptions extends \Google\Protobuf\Internal\Message +{ + /** + * An option to control the selection of optimizer version. + * This parameter allows individual queries to pick different query + * optimizer versions. + * Specifying `latest` as a value instructs Cloud Spanner to use the + * latest supported query optimizer version. If not specified, Cloud Spanner + * uses the optimizer version set at the database level options. Any other + * positive integer (from the list of supported optimizer versions) + * overrides the default optimizer version for query execution. + * The list of supported optimizer versions can be queried from + * SPANNER_SYS.SUPPORTED_OPTIMIZER_VERSIONS. + * Executing a SQL statement with an invalid optimizer version fails with + * an `INVALID_ARGUMENT` error. + * See + * https://cloud.google.com/spanner/docs/query-optimizer/manage-query-optimizer + * for more information on managing the query optimizer. + * The `optimizer_version` statement hint has precedence over this setting. + * + * Generated from protobuf field string optimizer_version = 1; + */ + protected $optimizer_version = ''; + /** + * An option to control the selection of optimizer statistics package. + * This parameter allows individual queries to use a different query + * optimizer statistics package. + * Specifying `latest` as a value instructs Cloud Spanner to use the latest + * generated statistics package. If not specified, Cloud Spanner uses + * the statistics package set at the database level options, or the latest + * package if the database option is not set. + * The statistics package requested by the query has to be exempt from + * garbage collection. This can be achieved with the following DDL + * statement: + * ``` + * ALTER STATISTICS SET OPTIONS (allow_gc=false) + * ``` + * The list of available statistics packages can be queried from + * `INFORMATION_SCHEMA.SPANNER_STATISTICS`. + * Executing a SQL statement with an invalid optimizer statistics package + * or with a statistics package that allows garbage collection fails with + * an `INVALID_ARGUMENT` error. + * + * Generated from protobuf field string optimizer_statistics_package = 2; + */ + protected $optimizer_statistics_package = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $optimizer_version + * An option to control the selection of optimizer version. + * This parameter allows individual queries to pick different query + * optimizer versions. + * Specifying `latest` as a value instructs Cloud Spanner to use the + * latest supported query optimizer version. If not specified, Cloud Spanner + * uses the optimizer version set at the database level options. Any other + * positive integer (from the list of supported optimizer versions) + * overrides the default optimizer version for query execution. + * The list of supported optimizer versions can be queried from + * SPANNER_SYS.SUPPORTED_OPTIMIZER_VERSIONS. + * Executing a SQL statement with an invalid optimizer version fails with + * an `INVALID_ARGUMENT` error. + * See + * https://cloud.google.com/spanner/docs/query-optimizer/manage-query-optimizer + * for more information on managing the query optimizer. + * The `optimizer_version` statement hint has precedence over this setting. + * @type string $optimizer_statistics_package + * An option to control the selection of optimizer statistics package. + * This parameter allows individual queries to use a different query + * optimizer statistics package. + * Specifying `latest` as a value instructs Cloud Spanner to use the latest + * generated statistics package. If not specified, Cloud Spanner uses + * the statistics package set at the database level options, or the latest + * package if the database option is not set. + * The statistics package requested by the query has to be exempt from + * garbage collection. This can be achieved with the following DDL + * statement: + * ``` + * ALTER STATISTICS SET OPTIONS (allow_gc=false) + * ``` + * The list of available statistics packages can be queried from + * `INFORMATION_SCHEMA.SPANNER_STATISTICS`. + * Executing a SQL statement with an invalid optimizer statistics package + * or with a statistics package that allows garbage collection fails with + * an `INVALID_ARGUMENT` error. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * An option to control the selection of optimizer version. + * This parameter allows individual queries to pick different query + * optimizer versions. + * Specifying `latest` as a value instructs Cloud Spanner to use the + * latest supported query optimizer version. If not specified, Cloud Spanner + * uses the optimizer version set at the database level options. Any other + * positive integer (from the list of supported optimizer versions) + * overrides the default optimizer version for query execution. + * The list of supported optimizer versions can be queried from + * SPANNER_SYS.SUPPORTED_OPTIMIZER_VERSIONS. + * Executing a SQL statement with an invalid optimizer version fails with + * an `INVALID_ARGUMENT` error. + * See + * https://cloud.google.com/spanner/docs/query-optimizer/manage-query-optimizer + * for more information on managing the query optimizer. + * The `optimizer_version` statement hint has precedence over this setting. + * + * Generated from protobuf field string optimizer_version = 1; + * @return string + */ + public function getOptimizerVersion() + { + return $this->optimizer_version; + } + + /** + * An option to control the selection of optimizer version. + * This parameter allows individual queries to pick different query + * optimizer versions. + * Specifying `latest` as a value instructs Cloud Spanner to use the + * latest supported query optimizer version. If not specified, Cloud Spanner + * uses the optimizer version set at the database level options. Any other + * positive integer (from the list of supported optimizer versions) + * overrides the default optimizer version for query execution. + * The list of supported optimizer versions can be queried from + * SPANNER_SYS.SUPPORTED_OPTIMIZER_VERSIONS. + * Executing a SQL statement with an invalid optimizer version fails with + * an `INVALID_ARGUMENT` error. + * See + * https://cloud.google.com/spanner/docs/query-optimizer/manage-query-optimizer + * for more information on managing the query optimizer. + * The `optimizer_version` statement hint has precedence over this setting. + * + * Generated from protobuf field string optimizer_version = 1; + * @param string $var + * @return $this + */ + public function setOptimizerVersion($var) + { + GPBUtil::checkString($var, True); + $this->optimizer_version = $var; + + return $this; + } + + /** + * An option to control the selection of optimizer statistics package. + * This parameter allows individual queries to use a different query + * optimizer statistics package. + * Specifying `latest` as a value instructs Cloud Spanner to use the latest + * generated statistics package. If not specified, Cloud Spanner uses + * the statistics package set at the database level options, or the latest + * package if the database option is not set. + * The statistics package requested by the query has to be exempt from + * garbage collection. This can be achieved with the following DDL + * statement: + * ``` + * ALTER STATISTICS SET OPTIONS (allow_gc=false) + * ``` + * The list of available statistics packages can be queried from + * `INFORMATION_SCHEMA.SPANNER_STATISTICS`. + * Executing a SQL statement with an invalid optimizer statistics package + * or with a statistics package that allows garbage collection fails with + * an `INVALID_ARGUMENT` error. + * + * Generated from protobuf field string optimizer_statistics_package = 2; + * @return string + */ + public function getOptimizerStatisticsPackage() + { + return $this->optimizer_statistics_package; + } + + /** + * An option to control the selection of optimizer statistics package. + * This parameter allows individual queries to use a different query + * optimizer statistics package. + * Specifying `latest` as a value instructs Cloud Spanner to use the latest + * generated statistics package. If not specified, Cloud Spanner uses + * the statistics package set at the database level options, or the latest + * package if the database option is not set. + * The statistics package requested by the query has to be exempt from + * garbage collection. This can be achieved with the following DDL + * statement: + * ``` + * ALTER STATISTICS SET OPTIONS (allow_gc=false) + * ``` + * The list of available statistics packages can be queried from + * `INFORMATION_SCHEMA.SPANNER_STATISTICS`. + * Executing a SQL statement with an invalid optimizer statistics package + * or with a statistics package that allows garbage collection fails with + * an `INVALID_ARGUMENT` error. + * + * Generated from protobuf field string optimizer_statistics_package = 2; + * @param string $var + * @return $this + */ + public function setOptimizerStatisticsPackage($var) + { + GPBUtil::checkString($var, True); + $this->optimizer_statistics_package = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(QueryOptions::class, \Google\Cloud\Spanner\V1\ExecuteSqlRequest_QueryOptions::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/GetSessionRequest.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/GetSessionRequest.php new file mode 100644 index 000000000000..3e1ca94c5883 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/GetSessionRequest.php @@ -0,0 +1,81 @@ +google.spanner.v1.GetSessionRequest + */ +class GetSessionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the session to retrieve. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. The name of the session to retrieve. Please see + * {@see SpannerClient::sessionName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\V1\GetSessionRequest + * + * @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. The name of the session to retrieve. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the session to retrieve. + * + * 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. The name of the session to retrieve. + * + * 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/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/KeyRange.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/KeyRange.php new file mode 100644 index 000000000000..4b65e7b846ef --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/KeyRange.php @@ -0,0 +1,255 @@ +google.spanner.v1.KeyRange + */ +class KeyRange extends \Google\Protobuf\Internal\Message +{ + protected $start_key_type; + protected $end_key_type; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\ListValue $start_closed + * If the start is closed, then the range includes all rows whose + * first `len(start_closed)` key columns exactly match `start_closed`. + * @type \Google\Protobuf\ListValue $start_open + * If the start is open, then the range excludes rows whose first + * `len(start_open)` key columns exactly match `start_open`. + * @type \Google\Protobuf\ListValue $end_closed + * If the end is closed, then the range includes all rows whose + * first `len(end_closed)` key columns exactly match `end_closed`. + * @type \Google\Protobuf\ListValue $end_open + * If the end is open, then the range excludes rows whose first + * `len(end_open)` key columns exactly match `end_open`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Keys::initOnce(); + parent::__construct($data); + } + + /** + * If the start is closed, then the range includes all rows whose + * first `len(start_closed)` key columns exactly match `start_closed`. + * + * Generated from protobuf field .google.protobuf.ListValue start_closed = 1; + * @return \Google\Protobuf\ListValue|null + */ + public function getStartClosed() + { + return $this->readOneof(1); + } + + public function hasStartClosed() + { + return $this->hasOneof(1); + } + + /** + * If the start is closed, then the range includes all rows whose + * first `len(start_closed)` key columns exactly match `start_closed`. + * + * Generated from protobuf field .google.protobuf.ListValue start_closed = 1; + * @param \Google\Protobuf\ListValue $var + * @return $this + */ + public function setStartClosed($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\ListValue::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * If the start is open, then the range excludes rows whose first + * `len(start_open)` key columns exactly match `start_open`. + * + * Generated from protobuf field .google.protobuf.ListValue start_open = 2; + * @return \Google\Protobuf\ListValue|null + */ + public function getStartOpen() + { + return $this->readOneof(2); + } + + public function hasStartOpen() + { + return $this->hasOneof(2); + } + + /** + * If the start is open, then the range excludes rows whose first + * `len(start_open)` key columns exactly match `start_open`. + * + * Generated from protobuf field .google.protobuf.ListValue start_open = 2; + * @param \Google\Protobuf\ListValue $var + * @return $this + */ + public function setStartOpen($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\ListValue::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * If the end is closed, then the range includes all rows whose + * first `len(end_closed)` key columns exactly match `end_closed`. + * + * Generated from protobuf field .google.protobuf.ListValue end_closed = 3; + * @return \Google\Protobuf\ListValue|null + */ + public function getEndClosed() + { + return $this->readOneof(3); + } + + public function hasEndClosed() + { + return $this->hasOneof(3); + } + + /** + * If the end is closed, then the range includes all rows whose + * first `len(end_closed)` key columns exactly match `end_closed`. + * + * Generated from protobuf field .google.protobuf.ListValue end_closed = 3; + * @param \Google\Protobuf\ListValue $var + * @return $this + */ + public function setEndClosed($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\ListValue::class); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * If the end is open, then the range excludes rows whose first + * `len(end_open)` key columns exactly match `end_open`. + * + * Generated from protobuf field .google.protobuf.ListValue end_open = 4; + * @return \Google\Protobuf\ListValue|null + */ + public function getEndOpen() + { + return $this->readOneof(4); + } + + public function hasEndOpen() + { + return $this->hasOneof(4); + } + + /** + * If the end is open, then the range excludes rows whose first + * `len(end_open)` key columns exactly match `end_open`. + * + * Generated from protobuf field .google.protobuf.ListValue end_open = 4; + * @param \Google\Protobuf\ListValue $var + * @return $this + */ + public function setEndOpen($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\ListValue::class); + $this->writeOneof(4, $var); + + return $this; + } + + /** + * @return string + */ + public function getStartKeyType() + { + return $this->whichOneof("start_key_type"); + } + + /** + * @return string + */ + public function getEndKeyType() + { + return $this->whichOneof("end_key_type"); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/KeySet.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/KeySet.php new file mode 100644 index 000000000000..29121208ba59 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/KeySet.php @@ -0,0 +1,164 @@ +google.spanner.v1.KeySet + */ +class KeySet extends \Google\Protobuf\Internal\Message +{ + /** + * A list of specific keys. Entries in `keys` should have exactly as + * many elements as there are columns in the primary or index key + * with which this `KeySet` is used. Individual key values are + * encoded as described [here][google.spanner.v1.TypeCode]. + * + * Generated from protobuf field repeated .google.protobuf.ListValue keys = 1; + */ + private $keys; + /** + * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about + * key range specifications. + * + * Generated from protobuf field repeated .google.spanner.v1.KeyRange ranges = 2; + */ + private $ranges; + /** + * For convenience `all` can be set to `true` to indicate that this + * `KeySet` matches all keys in the table or index. Note that any keys + * specified in `keys` or `ranges` are only yielded once. + * + * Generated from protobuf field bool all = 3; + */ + protected $all = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Protobuf\ListValue>|\Google\Protobuf\Internal\RepeatedField $keys + * A list of specific keys. Entries in `keys` should have exactly as + * many elements as there are columns in the primary or index key + * with which this `KeySet` is used. Individual key values are + * encoded as described [here][google.spanner.v1.TypeCode]. + * @type array<\Google\Cloud\Spanner\V1\KeyRange>|\Google\Protobuf\Internal\RepeatedField $ranges + * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about + * key range specifications. + * @type bool $all + * For convenience `all` can be set to `true` to indicate that this + * `KeySet` matches all keys in the table or index. Note that any keys + * specified in `keys` or `ranges` are only yielded once. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Keys::initOnce(); + parent::__construct($data); + } + + /** + * A list of specific keys. Entries in `keys` should have exactly as + * many elements as there are columns in the primary or index key + * with which this `KeySet` is used. Individual key values are + * encoded as described [here][google.spanner.v1.TypeCode]. + * + * Generated from protobuf field repeated .google.protobuf.ListValue keys = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getKeys() + { + return $this->keys; + } + + /** + * A list of specific keys. Entries in `keys` should have exactly as + * many elements as there are columns in the primary or index key + * with which this `KeySet` is used. Individual key values are + * encoded as described [here][google.spanner.v1.TypeCode]. + * + * Generated from protobuf field repeated .google.protobuf.ListValue keys = 1; + * @param array<\Google\Protobuf\ListValue>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setKeys($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\ListValue::class); + $this->keys = $arr; + + return $this; + } + + /** + * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about + * key range specifications. + * + * Generated from protobuf field repeated .google.spanner.v1.KeyRange ranges = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getRanges() + { + return $this->ranges; + } + + /** + * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about + * key range specifications. + * + * Generated from protobuf field repeated .google.spanner.v1.KeyRange ranges = 2; + * @param array<\Google\Cloud\Spanner\V1\KeyRange>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setRanges($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\KeyRange::class); + $this->ranges = $arr; + + return $this; + } + + /** + * For convenience `all` can be set to `true` to indicate that this + * `KeySet` matches all keys in the table or index. Note that any keys + * specified in `keys` or `ranges` are only yielded once. + * + * Generated from protobuf field bool all = 3; + * @return bool + */ + public function getAll() + { + return $this->all; + } + + /** + * For convenience `all` can be set to `true` to indicate that this + * `KeySet` matches all keys in the table or index. Note that any keys + * specified in `keys` or `ranges` are only yielded once. + * + * Generated from protobuf field bool all = 3; + * @param bool $var + * @return $this + */ + public function setAll($var) + { + GPBUtil::checkBool($var); + $this->all = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ListSessionsRequest.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ListSessionsRequest.php new file mode 100644 index 000000000000..d3fd205fce8d --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ListSessionsRequest.php @@ -0,0 +1,223 @@ +google.spanner.v1.ListSessionsRequest + */ +class ListSessionsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The database in which to list sessions. + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $database = ''; + /** + * Number of sessions to be returned in the response. If 0 or less, defaults + * to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2; + */ + protected $page_size = 0; + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.v1.ListSessionsResponse.next_page_token] + * from a previous + * [ListSessionsResponse][google.spanner.v1.ListSessionsResponse]. + * + * Generated from protobuf field string page_token = 3; + */ + protected $page_token = ''; + /** + * An expression for filtering the results of the request. Filter rules are + * case insensitive. The fields eligible for filtering are: + * * `labels.key` where key is the name of a label + * Some examples of using filters are: + * * `labels.env:*` --> The session has the label "env". + * * `labels.env:dev` --> The session has the label "env" and the value of + * the label contains the string "dev". + * + * Generated from protobuf field string filter = 4; + */ + protected $filter = ''; + + /** + * @param string $database Required. The database in which to list sessions. Please see + * {@see SpannerClient::databaseName()} for help formatting this field. + * + * @return \Google\Cloud\Spanner\V1\ListSessionsRequest + * + * @experimental + */ + public static function build(string $database): self + { + return (new self()) + ->setDatabase($database); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $database + * Required. The database in which to list sessions. + * @type int $page_size + * Number of sessions to be returned in the response. If 0 or less, defaults + * to the server's maximum allowed page size. + * @type string $page_token + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.v1.ListSessionsResponse.next_page_token] + * from a previous + * [ListSessionsResponse][google.spanner.v1.ListSessionsResponse]. + * @type string $filter + * An expression for filtering the results of the request. Filter rules are + * case insensitive. The fields eligible for filtering are: + * * `labels.key` where key is the name of a label + * Some examples of using filters are: + * * `labels.env:*` --> The session has the label "env". + * * `labels.env:dev` --> The session has the label "env" and the value of + * the label contains the string "dev". + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Required. The database in which to list sessions. + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getDatabase() + { + return $this->database; + } + + /** + * Required. The database in which to list sessions. + * + * Generated from protobuf field string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setDatabase($var) + { + GPBUtil::checkString($var, True); + $this->database = $var; + + return $this; + } + + /** + * Number of sessions to be returned in the response. If 0 or less, defaults + * to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Number of sessions to be returned in the response. If 0 or less, defaults + * to the server's maximum allowed page size. + * + * Generated from protobuf field int32 page_size = 2; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.v1.ListSessionsResponse.next_page_token] + * from a previous + * [ListSessionsResponse][google.spanner.v1.ListSessionsResponse]. + * + * Generated from protobuf field string page_token = 3; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * If non-empty, `page_token` should contain a + * [next_page_token][google.spanner.v1.ListSessionsResponse.next_page_token] + * from a previous + * [ListSessionsResponse][google.spanner.v1.ListSessionsResponse]. + * + * Generated from protobuf field string page_token = 3; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + + /** + * An expression for filtering the results of the request. Filter rules are + * case insensitive. The fields eligible for filtering are: + * * `labels.key` where key is the name of a label + * Some examples of using filters are: + * * `labels.env:*` --> The session has the label "env". + * * `labels.env:dev` --> The session has the label "env" and the value of + * the label contains the string "dev". + * + * Generated from protobuf field string filter = 4; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * An expression for filtering the results of the request. Filter rules are + * case insensitive. The fields eligible for filtering are: + * * `labels.key` where key is the name of a label + * Some examples of using filters are: + * * `labels.env:*` --> The session has the label "env". + * * `labels.env:dev` --> The session has the label "env" and the value of + * the label contains the string "dev". + * + * Generated from protobuf field string filter = 4; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ListSessionsResponse.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ListSessionsResponse.php new file mode 100644 index 000000000000..0d8cff32a984 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ListSessionsResponse.php @@ -0,0 +1,109 @@ +google.spanner.v1.ListSessionsResponse + */ +class ListSessionsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of requested sessions. + * + * Generated from protobuf field repeated .google.spanner.v1.Session sessions = 1; + */ + private $sessions; + /** + * `next_page_token` can be sent in a subsequent + * [ListSessions][google.spanner.v1.Spanner.ListSessions] call to fetch more + * of the matching sessions. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Spanner\V1\Session>|\Google\Protobuf\Internal\RepeatedField $sessions + * The list of requested sessions. + * @type string $next_page_token + * `next_page_token` can be sent in a subsequent + * [ListSessions][google.spanner.v1.Spanner.ListSessions] call to fetch more + * of the matching sessions. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * The list of requested sessions. + * + * Generated from protobuf field repeated .google.spanner.v1.Session sessions = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getSessions() + { + return $this->sessions; + } + + /** + * The list of requested sessions. + * + * Generated from protobuf field repeated .google.spanner.v1.Session sessions = 1; + * @param array<\Google\Cloud\Spanner\V1\Session>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setSessions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\Session::class); + $this->sessions = $arr; + + return $this; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListSessions][google.spanner.v1.Spanner.ListSessions] call to fetch more + * of the matching sessions. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * `next_page_token` can be sent in a subsequent + * [ListSessions][google.spanner.v1.Spanner.ListSessions] call to fetch more + * of the matching sessions. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/MultiplexedSessionPrecommitToken.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/MultiplexedSessionPrecommitToken.php new file mode 100644 index 000000000000..85495ac60b56 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/MultiplexedSessionPrecommitToken.php @@ -0,0 +1,112 @@ +google.spanner.v1.MultiplexedSessionPrecommitToken + */ +class MultiplexedSessionPrecommitToken extends \Google\Protobuf\Internal\Message +{ + /** + * Opaque precommit token. + * + * Generated from protobuf field bytes precommit_token = 1; + */ + protected $precommit_token = ''; + /** + * An incrementing seq number is generated on every precommit token + * that is returned. Clients should remember the precommit token with the + * highest sequence number from the current transaction attempt. + * + * Generated from protobuf field int32 seq_num = 2; + */ + protected $seq_num = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $precommit_token + * Opaque precommit token. + * @type int $seq_num + * An incrementing seq number is generated on every precommit token + * that is returned. Clients should remember the precommit token with the + * highest sequence number from the current transaction attempt. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Transaction::initOnce(); + parent::__construct($data); + } + + /** + * Opaque precommit token. + * + * Generated from protobuf field bytes precommit_token = 1; + * @return string + */ + public function getPrecommitToken() + { + return $this->precommit_token; + } + + /** + * Opaque precommit token. + * + * Generated from protobuf field bytes precommit_token = 1; + * @param string $var + * @return $this + */ + public function setPrecommitToken($var) + { + GPBUtil::checkString($var, False); + $this->precommit_token = $var; + + return $this; + } + + /** + * An incrementing seq number is generated on every precommit token + * that is returned. Clients should remember the precommit token with the + * highest sequence number from the current transaction attempt. + * + * Generated from protobuf field int32 seq_num = 2; + * @return int + */ + public function getSeqNum() + { + return $this->seq_num; + } + + /** + * An incrementing seq number is generated on every precommit token + * that is returned. Clients should remember the precommit token with the + * highest sequence number from the current transaction attempt. + * + * Generated from protobuf field int32 seq_num = 2; + * @param int $var + * @return $this + */ + public function setSeqNum($var) + { + GPBUtil::checkInt32($var); + $this->seq_num = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Mutation.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Mutation.php new file mode 100644 index 000000000000..82cb3686bb9a --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Mutation.php @@ -0,0 +1,254 @@ +google.spanner.v1.Mutation + */ +class Mutation extends \Google\Protobuf\Internal\Message +{ + protected $operation; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\V1\Mutation\Write $insert + * Insert new rows in a table. If any of the rows already exist, + * the write or transaction fails with error `ALREADY_EXISTS`. + * @type \Google\Cloud\Spanner\V1\Mutation\Write $update + * Update existing rows in a table. If any of the rows does not + * already exist, the transaction fails with error `NOT_FOUND`. + * @type \Google\Cloud\Spanner\V1\Mutation\Write $insert_or_update + * Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, then + * its column values are overwritten with the ones provided. Any + * column values not explicitly written are preserved. + * When using [insert_or_update][google.spanner.v1.Mutation.insert_or_update], just as when using [insert][google.spanner.v1.Mutation.insert], all `NOT + * NULL` columns in the table must be given a value. This holds true + * even when the row already exists and will therefore actually be updated. + * @type \Google\Cloud\Spanner\V1\Mutation\Write $replace + * Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, it is + * deleted, and the column values provided are inserted + * instead. Unlike [insert_or_update][google.spanner.v1.Mutation.insert_or_update], this means any values not + * explicitly written become `NULL`. + * In an interleaved table, if you create the child table with the + * `ON DELETE CASCADE` annotation, then replacing a parent row + * also deletes the child rows. Otherwise, you must delete the + * child rows before you replace the parent row. + * @type \Google\Cloud\Spanner\V1\Mutation\Delete $delete + * Delete rows from a table. Succeeds whether or not the named + * rows were present. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Mutation::initOnce(); + parent::__construct($data); + } + + /** + * Insert new rows in a table. If any of the rows already exist, + * the write or transaction fails with error `ALREADY_EXISTS`. + * + * Generated from protobuf field .google.spanner.v1.Mutation.Write insert = 1; + * @return \Google\Cloud\Spanner\V1\Mutation\Write|null + */ + public function getInsert() + { + return $this->readOneof(1); + } + + public function hasInsert() + { + return $this->hasOneof(1); + } + + /** + * Insert new rows in a table. If any of the rows already exist, + * the write or transaction fails with error `ALREADY_EXISTS`. + * + * Generated from protobuf field .google.spanner.v1.Mutation.Write insert = 1; + * @param \Google\Cloud\Spanner\V1\Mutation\Write $var + * @return $this + */ + public function setInsert($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\Mutation\Write::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * Update existing rows in a table. If any of the rows does not + * already exist, the transaction fails with error `NOT_FOUND`. + * + * Generated from protobuf field .google.spanner.v1.Mutation.Write update = 2; + * @return \Google\Cloud\Spanner\V1\Mutation\Write|null + */ + public function getUpdate() + { + return $this->readOneof(2); + } + + public function hasUpdate() + { + return $this->hasOneof(2); + } + + /** + * Update existing rows in a table. If any of the rows does not + * already exist, the transaction fails with error `NOT_FOUND`. + * + * Generated from protobuf field .google.spanner.v1.Mutation.Write update = 2; + * @param \Google\Cloud\Spanner\V1\Mutation\Write $var + * @return $this + */ + public function setUpdate($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\Mutation\Write::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, then + * its column values are overwritten with the ones provided. Any + * column values not explicitly written are preserved. + * When using [insert_or_update][google.spanner.v1.Mutation.insert_or_update], just as when using [insert][google.spanner.v1.Mutation.insert], all `NOT + * NULL` columns in the table must be given a value. This holds true + * even when the row already exists and will therefore actually be updated. + * + * Generated from protobuf field .google.spanner.v1.Mutation.Write insert_or_update = 3; + * @return \Google\Cloud\Spanner\V1\Mutation\Write|null + */ + public function getInsertOrUpdate() + { + return $this->readOneof(3); + } + + public function hasInsertOrUpdate() + { + return $this->hasOneof(3); + } + + /** + * Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, then + * its column values are overwritten with the ones provided. Any + * column values not explicitly written are preserved. + * When using [insert_or_update][google.spanner.v1.Mutation.insert_or_update], just as when using [insert][google.spanner.v1.Mutation.insert], all `NOT + * NULL` columns in the table must be given a value. This holds true + * even when the row already exists and will therefore actually be updated. + * + * Generated from protobuf field .google.spanner.v1.Mutation.Write insert_or_update = 3; + * @param \Google\Cloud\Spanner\V1\Mutation\Write $var + * @return $this + */ + public function setInsertOrUpdate($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\Mutation\Write::class); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, it is + * deleted, and the column values provided are inserted + * instead. Unlike [insert_or_update][google.spanner.v1.Mutation.insert_or_update], this means any values not + * explicitly written become `NULL`. + * In an interleaved table, if you create the child table with the + * `ON DELETE CASCADE` annotation, then replacing a parent row + * also deletes the child rows. Otherwise, you must delete the + * child rows before you replace the parent row. + * + * Generated from protobuf field .google.spanner.v1.Mutation.Write replace = 4; + * @return \Google\Cloud\Spanner\V1\Mutation\Write|null + */ + public function getReplace() + { + return $this->readOneof(4); + } + + public function hasReplace() + { + return $this->hasOneof(4); + } + + /** + * Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, it is + * deleted, and the column values provided are inserted + * instead. Unlike [insert_or_update][google.spanner.v1.Mutation.insert_or_update], this means any values not + * explicitly written become `NULL`. + * In an interleaved table, if you create the child table with the + * `ON DELETE CASCADE` annotation, then replacing a parent row + * also deletes the child rows. Otherwise, you must delete the + * child rows before you replace the parent row. + * + * Generated from protobuf field .google.spanner.v1.Mutation.Write replace = 4; + * @param \Google\Cloud\Spanner\V1\Mutation\Write $var + * @return $this + */ + public function setReplace($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\Mutation\Write::class); + $this->writeOneof(4, $var); + + return $this; + } + + /** + * Delete rows from a table. Succeeds whether or not the named + * rows were present. + * + * Generated from protobuf field .google.spanner.v1.Mutation.Delete delete = 5; + * @return \Google\Cloud\Spanner\V1\Mutation\Delete|null + */ + public function getDelete() + { + return $this->readOneof(5); + } + + public function hasDelete() + { + return $this->hasOneof(5); + } + + /** + * Delete rows from a table. Succeeds whether or not the named + * rows were present. + * + * Generated from protobuf field .google.spanner.v1.Mutation.Delete delete = 5; + * @param \Google\Cloud\Spanner\V1\Mutation\Delete $var + * @return $this + */ + public function setDelete($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\Mutation\Delete::class); + $this->writeOneof(5, $var); + + return $this; + } + + /** + * @return string + */ + public function getOperation() + { + return $this->whichOneof("operation"); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Mutation/Delete.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Mutation/Delete.php new file mode 100644 index 000000000000..db49cf9dc249 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Mutation/Delete.php @@ -0,0 +1,134 @@ +google.spanner.v1.Mutation.Delete + */ +class Delete extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The table whose rows will be deleted. + * + * Generated from protobuf field string table = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $table = ''; + /** + * Required. The primary keys of the rows within [table][google.spanner.v1.Mutation.Delete.table] to delete. The + * primary keys must be specified in the order in which they appear in the + * `PRIMARY KEY()` clause of the table's equivalent DDL statement (the DDL + * statement used to create the table). + * Delete is idempotent. The transaction will succeed even if some or all + * rows do not exist. + * + * Generated from protobuf field .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $key_set = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $table + * Required. The table whose rows will be deleted. + * @type \Google\Cloud\Spanner\V1\KeySet $key_set + * Required. The primary keys of the rows within [table][google.spanner.v1.Mutation.Delete.table] to delete. The + * primary keys must be specified in the order in which they appear in the + * `PRIMARY KEY()` clause of the table's equivalent DDL statement (the DDL + * statement used to create the table). + * Delete is idempotent. The transaction will succeed even if some or all + * rows do not exist. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Mutation::initOnce(); + parent::__construct($data); + } + + /** + * Required. The table whose rows will be deleted. + * + * Generated from protobuf field string table = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getTable() + { + return $this->table; + } + + /** + * Required. The table whose rows will be deleted. + * + * Generated from protobuf field string table = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setTable($var) + { + GPBUtil::checkString($var, True); + $this->table = $var; + + return $this; + } + + /** + * Required. The primary keys of the rows within [table][google.spanner.v1.Mutation.Delete.table] to delete. The + * primary keys must be specified in the order in which they appear in the + * `PRIMARY KEY()` clause of the table's equivalent DDL statement (the DDL + * statement used to create the table). + * Delete is idempotent. The transaction will succeed even if some or all + * rows do not exist. + * + * Generated from protobuf field .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\V1\KeySet|null + */ + public function getKeySet() + { + return $this->key_set; + } + + public function hasKeySet() + { + return isset($this->key_set); + } + + public function clearKeySet() + { + unset($this->key_set); + } + + /** + * Required. The primary keys of the rows within [table][google.spanner.v1.Mutation.Delete.table] to delete. The + * primary keys must be specified in the order in which they appear in the + * `PRIMARY KEY()` clause of the table's equivalent DDL statement (the DDL + * statement used to create the table). + * Delete is idempotent. The transaction will succeed even if some or all + * rows do not exist. + * + * Generated from protobuf field .google.spanner.v1.KeySet key_set = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\V1\KeySet $var + * @return $this + */ + public function setKeySet($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\KeySet::class); + $this->key_set = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Delete::class, \Google\Cloud\Spanner\V1\Mutation_Delete::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Mutation/Write.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Mutation/Write.php new file mode 100644 index 000000000000..8e08ca69d213 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Mutation/Write.php @@ -0,0 +1,179 @@ +google.spanner.v1.Mutation.Write + */ +class Write extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The table whose rows will be written. + * + * Generated from protobuf field string table = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $table = ''; + /** + * The names of the columns in [table][google.spanner.v1.Mutation.Write.table] to be written. + * The list of columns must contain enough columns to allow + * Cloud Spanner to derive values for all primary key columns in the + * row(s) to be modified. + * + * Generated from protobuf field repeated string columns = 2; + */ + private $columns; + /** + * The values to be written. `values` can contain more than one + * list of values. If it does, then multiple rows are written, one + * for each entry in `values`. Each list in `values` must have + * exactly as many entries as there are entries in [columns][google.spanner.v1.Mutation.Write.columns] + * above. Sending multiple lists is equivalent to sending multiple + * `Mutation`s, each containing one `values` entry and repeating + * [table][google.spanner.v1.Mutation.Write.table] and [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in each list are + * encoded as described [here][google.spanner.v1.TypeCode]. + * + * Generated from protobuf field repeated .google.protobuf.ListValue values = 3; + */ + private $values; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $table + * Required. The table whose rows will be written. + * @type array|\Google\Protobuf\Internal\RepeatedField $columns + * The names of the columns in [table][google.spanner.v1.Mutation.Write.table] to be written. + * The list of columns must contain enough columns to allow + * Cloud Spanner to derive values for all primary key columns in the + * row(s) to be modified. + * @type array<\Google\Protobuf\ListValue>|\Google\Protobuf\Internal\RepeatedField $values + * The values to be written. `values` can contain more than one + * list of values. If it does, then multiple rows are written, one + * for each entry in `values`. Each list in `values` must have + * exactly as many entries as there are entries in [columns][google.spanner.v1.Mutation.Write.columns] + * above. Sending multiple lists is equivalent to sending multiple + * `Mutation`s, each containing one `values` entry and repeating + * [table][google.spanner.v1.Mutation.Write.table] and [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in each list are + * encoded as described [here][google.spanner.v1.TypeCode]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Mutation::initOnce(); + parent::__construct($data); + } + + /** + * Required. The table whose rows will be written. + * + * Generated from protobuf field string table = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getTable() + { + return $this->table; + } + + /** + * Required. The table whose rows will be written. + * + * Generated from protobuf field string table = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setTable($var) + { + GPBUtil::checkString($var, True); + $this->table = $var; + + return $this; + } + + /** + * The names of the columns in [table][google.spanner.v1.Mutation.Write.table] to be written. + * The list of columns must contain enough columns to allow + * Cloud Spanner to derive values for all primary key columns in the + * row(s) to be modified. + * + * Generated from protobuf field repeated string columns = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getColumns() + { + return $this->columns; + } + + /** + * The names of the columns in [table][google.spanner.v1.Mutation.Write.table] to be written. + * The list of columns must contain enough columns to allow + * Cloud Spanner to derive values for all primary key columns in the + * row(s) to be modified. + * + * Generated from protobuf field repeated string columns = 2; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setColumns($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->columns = $arr; + + return $this; + } + + /** + * The values to be written. `values` can contain more than one + * list of values. If it does, then multiple rows are written, one + * for each entry in `values`. Each list in `values` must have + * exactly as many entries as there are entries in [columns][google.spanner.v1.Mutation.Write.columns] + * above. Sending multiple lists is equivalent to sending multiple + * `Mutation`s, each containing one `values` entry and repeating + * [table][google.spanner.v1.Mutation.Write.table] and [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in each list are + * encoded as described [here][google.spanner.v1.TypeCode]. + * + * Generated from protobuf field repeated .google.protobuf.ListValue values = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getValues() + { + return $this->values; + } + + /** + * The values to be written. `values` can contain more than one + * list of values. If it does, then multiple rows are written, one + * for each entry in `values`. Each list in `values` must have + * exactly as many entries as there are entries in [columns][google.spanner.v1.Mutation.Write.columns] + * above. Sending multiple lists is equivalent to sending multiple + * `Mutation`s, each containing one `values` entry and repeating + * [table][google.spanner.v1.Mutation.Write.table] and [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in each list are + * encoded as described [here][google.spanner.v1.TypeCode]. + * + * Generated from protobuf field repeated .google.protobuf.ListValue values = 3; + * @param array<\Google\Protobuf\ListValue>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setValues($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\ListValue::class); + $this->values = $arr; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Write::class, \Google\Cloud\Spanner\V1\Mutation_Write::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PartialResultSet.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PartialResultSet.php new file mode 100644 index 000000000000..dd0f33180421 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PartialResultSet.php @@ -0,0 +1,573 @@ +google.spanner.v1.PartialResultSet + */ +class PartialResultSet extends \Google\Protobuf\Internal\Message +{ + /** + * Metadata about the result set, such as row type information. + * Only present in the first response. + * + * Generated from protobuf field .google.spanner.v1.ResultSetMetadata metadata = 1; + */ + protected $metadata = null; + /** + * A streamed result set consists of a stream of values, which might + * be split into many `PartialResultSet` messages to accommodate + * large rows and/or large values. Every N complete values defines a + * row, where N is equal to the number of entries in + * [metadata.row_type.fields][google.spanner.v1.StructType.fields]. + * Most values are encoded based on type as described + * [here][google.spanner.v1.TypeCode]. + * It is possible that the last value in values is "chunked", + * meaning that the rest of the value is sent in subsequent + * `PartialResultSet`(s). This is denoted by the [chunked_value][google.spanner.v1.PartialResultSet.chunked_value] + * field. Two or more chunked values can be merged to form a + * complete value as follows: + * * `bool/number/null`: cannot be chunked + * * `string`: concatenate the strings + * * `list`: concatenate the lists. If the last element in a list is a + * `string`, `list`, or `object`, merge it with the first element in + * the next list by applying these rules recursively. + * * `object`: concatenate the (field name, field value) pairs. If a + * field name is duplicated, then apply these rules recursively + * to merge the field values. + * Some examples of merging: + * # Strings are concatenated. + * "foo", "bar" => "foobar" + * # Lists of non-strings are concatenated. + * [2, 3], [4] => [2, 3, 4] + * # Lists are concatenated, but the last and first elements are merged + * # because they are strings. + * ["a", "b"], ["c", "d"] => ["a", "bc", "d"] + * # Lists are concatenated, but the last and first elements are merged + * # because they are lists. Recursively, the last and first elements + * # of the inner lists are merged because they are strings. + * ["a", ["b", "c"]], [["d"], "e"] => ["a", ["b", "cd"], "e"] + * # Non-overlapping object fields are combined. + * {"a": "1"}, {"b": "2"} => {"a": "1", "b": 2"} + * # Overlapping object fields are merged. + * {"a": "1"}, {"a": "2"} => {"a": "12"} + * # Examples of merging objects containing lists of strings. + * {"a": ["1"]}, {"a": ["2"]} => {"a": ["12"]} + * For a more complete example, suppose a streaming SQL query is + * yielding a result set whose rows contain a single string + * field. The following `PartialResultSet`s might be yielded: + * { + * "metadata": { ... } + * "values": ["Hello", "W"] + * "chunked_value": true + * "resume_token": "Af65..." + * } + * { + * "values": ["orl"] + * "chunked_value": true + * "resume_token": "Bqp2..." + * } + * { + * "values": ["d"] + * "resume_token": "Zx1B..." + * } + * This sequence of `PartialResultSet`s encodes two rows, one + * containing the field value `"Hello"`, and a second containing the + * field value `"World" = "W" + "orl" + "d"`. + * + * Generated from protobuf field repeated .google.protobuf.Value values = 2; + */ + private $values; + /** + * If true, then the final value in [values][google.spanner.v1.PartialResultSet.values] is chunked, and must + * be combined with more values from subsequent `PartialResultSet`s + * to obtain a complete field value. + * + * Generated from protobuf field bool chunked_value = 3; + */ + protected $chunked_value = false; + /** + * Streaming calls might be interrupted for a variety of reasons, such + * as TCP connection loss. If this occurs, the stream of results can + * be resumed by re-sending the original request and including + * `resume_token`. Note that executing any other transaction in the + * same session invalidates the token. + * + * Generated from protobuf field bytes resume_token = 4; + */ + protected $resume_token = ''; + /** + * Query plan and execution statistics for the statement that produced this + * streaming result set. These can be requested by setting + * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] and are sent + * only once with the last response in the stream. + * This field will also be present in the last response for DML + * statements. + * + * Generated from protobuf field .google.spanner.v1.ResultSetStats stats = 5; + */ + protected $stats = null; + /** + * Optional. A precommit token will be included if the read-write transaction + * is on a multiplexed session. + * The precommit token with the highest sequence number from this transaction + * attempt should be passed to the + * [Commit][google.spanner.v1.Spanner.Commit] request for this transaction. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.MultiplexedSessionPrecommitToken precommit_token = 8 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $precommit_token = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\V1\ResultSetMetadata $metadata + * Metadata about the result set, such as row type information. + * Only present in the first response. + * @type array<\Google\Protobuf\Value>|\Google\Protobuf\Internal\RepeatedField $values + * A streamed result set consists of a stream of values, which might + * be split into many `PartialResultSet` messages to accommodate + * large rows and/or large values. Every N complete values defines a + * row, where N is equal to the number of entries in + * [metadata.row_type.fields][google.spanner.v1.StructType.fields]. + * Most values are encoded based on type as described + * [here][google.spanner.v1.TypeCode]. + * It is possible that the last value in values is "chunked", + * meaning that the rest of the value is sent in subsequent + * `PartialResultSet`(s). This is denoted by the [chunked_value][google.spanner.v1.PartialResultSet.chunked_value] + * field. Two or more chunked values can be merged to form a + * complete value as follows: + * * `bool/number/null`: cannot be chunked + * * `string`: concatenate the strings + * * `list`: concatenate the lists. If the last element in a list is a + * `string`, `list`, or `object`, merge it with the first element in + * the next list by applying these rules recursively. + * * `object`: concatenate the (field name, field value) pairs. If a + * field name is duplicated, then apply these rules recursively + * to merge the field values. + * Some examples of merging: + * # Strings are concatenated. + * "foo", "bar" => "foobar" + * # Lists of non-strings are concatenated. + * [2, 3], [4] => [2, 3, 4] + * # Lists are concatenated, but the last and first elements are merged + * # because they are strings. + * ["a", "b"], ["c", "d"] => ["a", "bc", "d"] + * # Lists are concatenated, but the last and first elements are merged + * # because they are lists. Recursively, the last and first elements + * # of the inner lists are merged because they are strings. + * ["a", ["b", "c"]], [["d"], "e"] => ["a", ["b", "cd"], "e"] + * # Non-overlapping object fields are combined. + * {"a": "1"}, {"b": "2"} => {"a": "1", "b": 2"} + * # Overlapping object fields are merged. + * {"a": "1"}, {"a": "2"} => {"a": "12"} + * # Examples of merging objects containing lists of strings. + * {"a": ["1"]}, {"a": ["2"]} => {"a": ["12"]} + * For a more complete example, suppose a streaming SQL query is + * yielding a result set whose rows contain a single string + * field. The following `PartialResultSet`s might be yielded: + * { + * "metadata": { ... } + * "values": ["Hello", "W"] + * "chunked_value": true + * "resume_token": "Af65..." + * } + * { + * "values": ["orl"] + * "chunked_value": true + * "resume_token": "Bqp2..." + * } + * { + * "values": ["d"] + * "resume_token": "Zx1B..." + * } + * This sequence of `PartialResultSet`s encodes two rows, one + * containing the field value `"Hello"`, and a second containing the + * field value `"World" = "W" + "orl" + "d"`. + * @type bool $chunked_value + * If true, then the final value in [values][google.spanner.v1.PartialResultSet.values] is chunked, and must + * be combined with more values from subsequent `PartialResultSet`s + * to obtain a complete field value. + * @type string $resume_token + * Streaming calls might be interrupted for a variety of reasons, such + * as TCP connection loss. If this occurs, the stream of results can + * be resumed by re-sending the original request and including + * `resume_token`. Note that executing any other transaction in the + * same session invalidates the token. + * @type \Google\Cloud\Spanner\V1\ResultSetStats $stats + * Query plan and execution statistics for the statement that produced this + * streaming result set. These can be requested by setting + * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] and are sent + * only once with the last response in the stream. + * This field will also be present in the last response for DML + * statements. + * @type \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken $precommit_token + * Optional. A precommit token will be included if the read-write transaction + * is on a multiplexed session. + * The precommit token with the highest sequence number from this transaction + * attempt should be passed to the + * [Commit][google.spanner.v1.Spanner.Commit] request for this transaction. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\ResultSet::initOnce(); + parent::__construct($data); + } + + /** + * Metadata about the result set, such as row type information. + * Only present in the first response. + * + * Generated from protobuf field .google.spanner.v1.ResultSetMetadata metadata = 1; + * @return \Google\Cloud\Spanner\V1\ResultSetMetadata|null + */ + public function getMetadata() + { + return $this->metadata; + } + + public function hasMetadata() + { + return isset($this->metadata); + } + + public function clearMetadata() + { + unset($this->metadata); + } + + /** + * Metadata about the result set, such as row type information. + * Only present in the first response. + * + * Generated from protobuf field .google.spanner.v1.ResultSetMetadata metadata = 1; + * @param \Google\Cloud\Spanner\V1\ResultSetMetadata $var + * @return $this + */ + public function setMetadata($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\ResultSetMetadata::class); + $this->metadata = $var; + + return $this; + } + + /** + * A streamed result set consists of a stream of values, which might + * be split into many `PartialResultSet` messages to accommodate + * large rows and/or large values. Every N complete values defines a + * row, where N is equal to the number of entries in + * [metadata.row_type.fields][google.spanner.v1.StructType.fields]. + * Most values are encoded based on type as described + * [here][google.spanner.v1.TypeCode]. + * It is possible that the last value in values is "chunked", + * meaning that the rest of the value is sent in subsequent + * `PartialResultSet`(s). This is denoted by the [chunked_value][google.spanner.v1.PartialResultSet.chunked_value] + * field. Two or more chunked values can be merged to form a + * complete value as follows: + * * `bool/number/null`: cannot be chunked + * * `string`: concatenate the strings + * * `list`: concatenate the lists. If the last element in a list is a + * `string`, `list`, or `object`, merge it with the first element in + * the next list by applying these rules recursively. + * * `object`: concatenate the (field name, field value) pairs. If a + * field name is duplicated, then apply these rules recursively + * to merge the field values. + * Some examples of merging: + * # Strings are concatenated. + * "foo", "bar" => "foobar" + * # Lists of non-strings are concatenated. + * [2, 3], [4] => [2, 3, 4] + * # Lists are concatenated, but the last and first elements are merged + * # because they are strings. + * ["a", "b"], ["c", "d"] => ["a", "bc", "d"] + * # Lists are concatenated, but the last and first elements are merged + * # because they are lists. Recursively, the last and first elements + * # of the inner lists are merged because they are strings. + * ["a", ["b", "c"]], [["d"], "e"] => ["a", ["b", "cd"], "e"] + * # Non-overlapping object fields are combined. + * {"a": "1"}, {"b": "2"} => {"a": "1", "b": 2"} + * # Overlapping object fields are merged. + * {"a": "1"}, {"a": "2"} => {"a": "12"} + * # Examples of merging objects containing lists of strings. + * {"a": ["1"]}, {"a": ["2"]} => {"a": ["12"]} + * For a more complete example, suppose a streaming SQL query is + * yielding a result set whose rows contain a single string + * field. The following `PartialResultSet`s might be yielded: + * { + * "metadata": { ... } + * "values": ["Hello", "W"] + * "chunked_value": true + * "resume_token": "Af65..." + * } + * { + * "values": ["orl"] + * "chunked_value": true + * "resume_token": "Bqp2..." + * } + * { + * "values": ["d"] + * "resume_token": "Zx1B..." + * } + * This sequence of `PartialResultSet`s encodes two rows, one + * containing the field value `"Hello"`, and a second containing the + * field value `"World" = "W" + "orl" + "d"`. + * + * Generated from protobuf field repeated .google.protobuf.Value values = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getValues() + { + return $this->values; + } + + /** + * A streamed result set consists of a stream of values, which might + * be split into many `PartialResultSet` messages to accommodate + * large rows and/or large values. Every N complete values defines a + * row, where N is equal to the number of entries in + * [metadata.row_type.fields][google.spanner.v1.StructType.fields]. + * Most values are encoded based on type as described + * [here][google.spanner.v1.TypeCode]. + * It is possible that the last value in values is "chunked", + * meaning that the rest of the value is sent in subsequent + * `PartialResultSet`(s). This is denoted by the [chunked_value][google.spanner.v1.PartialResultSet.chunked_value] + * field. Two or more chunked values can be merged to form a + * complete value as follows: + * * `bool/number/null`: cannot be chunked + * * `string`: concatenate the strings + * * `list`: concatenate the lists. If the last element in a list is a + * `string`, `list`, or `object`, merge it with the first element in + * the next list by applying these rules recursively. + * * `object`: concatenate the (field name, field value) pairs. If a + * field name is duplicated, then apply these rules recursively + * to merge the field values. + * Some examples of merging: + * # Strings are concatenated. + * "foo", "bar" => "foobar" + * # Lists of non-strings are concatenated. + * [2, 3], [4] => [2, 3, 4] + * # Lists are concatenated, but the last and first elements are merged + * # because they are strings. + * ["a", "b"], ["c", "d"] => ["a", "bc", "d"] + * # Lists are concatenated, but the last and first elements are merged + * # because they are lists. Recursively, the last and first elements + * # of the inner lists are merged because they are strings. + * ["a", ["b", "c"]], [["d"], "e"] => ["a", ["b", "cd"], "e"] + * # Non-overlapping object fields are combined. + * {"a": "1"}, {"b": "2"} => {"a": "1", "b": 2"} + * # Overlapping object fields are merged. + * {"a": "1"}, {"a": "2"} => {"a": "12"} + * # Examples of merging objects containing lists of strings. + * {"a": ["1"]}, {"a": ["2"]} => {"a": ["12"]} + * For a more complete example, suppose a streaming SQL query is + * yielding a result set whose rows contain a single string + * field. The following `PartialResultSet`s might be yielded: + * { + * "metadata": { ... } + * "values": ["Hello", "W"] + * "chunked_value": true + * "resume_token": "Af65..." + * } + * { + * "values": ["orl"] + * "chunked_value": true + * "resume_token": "Bqp2..." + * } + * { + * "values": ["d"] + * "resume_token": "Zx1B..." + * } + * This sequence of `PartialResultSet`s encodes two rows, one + * containing the field value `"Hello"`, and a second containing the + * field value `"World" = "W" + "orl" + "d"`. + * + * Generated from protobuf field repeated .google.protobuf.Value values = 2; + * @param array<\Google\Protobuf\Value>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setValues($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Value::class); + $this->values = $arr; + + return $this; + } + + /** + * If true, then the final value in [values][google.spanner.v1.PartialResultSet.values] is chunked, and must + * be combined with more values from subsequent `PartialResultSet`s + * to obtain a complete field value. + * + * Generated from protobuf field bool chunked_value = 3; + * @return bool + */ + public function getChunkedValue() + { + return $this->chunked_value; + } + + /** + * If true, then the final value in [values][google.spanner.v1.PartialResultSet.values] is chunked, and must + * be combined with more values from subsequent `PartialResultSet`s + * to obtain a complete field value. + * + * Generated from protobuf field bool chunked_value = 3; + * @param bool $var + * @return $this + */ + public function setChunkedValue($var) + { + GPBUtil::checkBool($var); + $this->chunked_value = $var; + + return $this; + } + + /** + * Streaming calls might be interrupted for a variety of reasons, such + * as TCP connection loss. If this occurs, the stream of results can + * be resumed by re-sending the original request and including + * `resume_token`. Note that executing any other transaction in the + * same session invalidates the token. + * + * Generated from protobuf field bytes resume_token = 4; + * @return string + */ + public function getResumeToken() + { + return $this->resume_token; + } + + /** + * Streaming calls might be interrupted for a variety of reasons, such + * as TCP connection loss. If this occurs, the stream of results can + * be resumed by re-sending the original request and including + * `resume_token`. Note that executing any other transaction in the + * same session invalidates the token. + * + * Generated from protobuf field bytes resume_token = 4; + * @param string $var + * @return $this + */ + public function setResumeToken($var) + { + GPBUtil::checkString($var, False); + $this->resume_token = $var; + + return $this; + } + + /** + * Query plan and execution statistics for the statement that produced this + * streaming result set. These can be requested by setting + * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] and are sent + * only once with the last response in the stream. + * This field will also be present in the last response for DML + * statements. + * + * Generated from protobuf field .google.spanner.v1.ResultSetStats stats = 5; + * @return \Google\Cloud\Spanner\V1\ResultSetStats|null + */ + public function getStats() + { + return $this->stats; + } + + public function hasStats() + { + return isset($this->stats); + } + + public function clearStats() + { + unset($this->stats); + } + + /** + * Query plan and execution statistics for the statement that produced this + * streaming result set. These can be requested by setting + * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] and are sent + * only once with the last response in the stream. + * This field will also be present in the last response for DML + * statements. + * + * Generated from protobuf field .google.spanner.v1.ResultSetStats stats = 5; + * @param \Google\Cloud\Spanner\V1\ResultSetStats $var + * @return $this + */ + public function setStats($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\ResultSetStats::class); + $this->stats = $var; + + return $this; + } + + /** + * Optional. A precommit token will be included if the read-write transaction + * is on a multiplexed session. + * The precommit token with the highest sequence number from this transaction + * attempt should be passed to the + * [Commit][google.spanner.v1.Spanner.Commit] request for this transaction. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.MultiplexedSessionPrecommitToken precommit_token = 8 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken|null + */ + public function getPrecommitToken() + { + return $this->precommit_token; + } + + public function hasPrecommitToken() + { + return isset($this->precommit_token); + } + + public function clearPrecommitToken() + { + unset($this->precommit_token); + } + + /** + * Optional. A precommit token will be included if the read-write transaction + * is on a multiplexed session. + * The precommit token with the highest sequence number from this transaction + * attempt should be passed to the + * [Commit][google.spanner.v1.Spanner.Commit] request for this transaction. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.MultiplexedSessionPrecommitToken precommit_token = 8 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken $var + * @return $this + */ + public function setPrecommitToken($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken::class); + $this->precommit_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Partition.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Partition.php new file mode 100644 index 000000000000..02b7e70d0762 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Partition.php @@ -0,0 +1,76 @@ +google.spanner.v1.Partition + */ +class Partition extends \Google\Protobuf\Internal\Message +{ + /** + * This token can be passed to Read, StreamingRead, ExecuteSql, or + * ExecuteStreamingSql requests to restrict the results to those identified by + * this partition token. + * + * Generated from protobuf field bytes partition_token = 1; + */ + protected $partition_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $partition_token + * This token can be passed to Read, StreamingRead, ExecuteSql, or + * ExecuteStreamingSql requests to restrict the results to those identified by + * this partition token. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * This token can be passed to Read, StreamingRead, ExecuteSql, or + * ExecuteStreamingSql requests to restrict the results to those identified by + * this partition token. + * + * Generated from protobuf field bytes partition_token = 1; + * @return string + */ + public function getPartitionToken() + { + return $this->partition_token; + } + + /** + * This token can be passed to Read, StreamingRead, ExecuteSql, or + * ExecuteStreamingSql requests to restrict the results to those identified by + * this partition token. + * + * Generated from protobuf field bytes partition_token = 1; + * @param string $var + * @return $this + */ + public function setPartitionToken($var) + { + GPBUtil::checkString($var, False); + $this->partition_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PartitionOptions.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PartitionOptions.php new file mode 100644 index 000000000000..fa726b5f9161 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PartitionOptions.php @@ -0,0 +1,142 @@ +google.spanner.v1.PartitionOptions + */ +class PartitionOptions extends \Google\Protobuf\Internal\Message +{ + /** + * **Note:** This hint is currently ignored by PartitionQuery and + * PartitionRead requests. + * The desired data size for each partition generated. The default for this + * option is currently 1 GiB. This is only a hint. The actual size of each + * partition may be smaller or larger than this size request. + * + * Generated from protobuf field int64 partition_size_bytes = 1; + */ + protected $partition_size_bytes = 0; + /** + * **Note:** This hint is currently ignored by PartitionQuery and + * PartitionRead requests. + * The desired maximum number of partitions to return. For example, this may + * be set to the number of workers available. The default for this option + * is currently 10,000. The maximum value is currently 200,000. This is only + * a hint. The actual number of partitions returned may be smaller or larger + * than this maximum count request. + * + * Generated from protobuf field int64 max_partitions = 2; + */ + protected $max_partitions = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int|string $partition_size_bytes + * **Note:** This hint is currently ignored by PartitionQuery and + * PartitionRead requests. + * The desired data size for each partition generated. The default for this + * option is currently 1 GiB. This is only a hint. The actual size of each + * partition may be smaller or larger than this size request. + * @type int|string $max_partitions + * **Note:** This hint is currently ignored by PartitionQuery and + * PartitionRead requests. + * The desired maximum number of partitions to return. For example, this may + * be set to the number of workers available. The default for this option + * is currently 10,000. The maximum value is currently 200,000. This is only + * a hint. The actual number of partitions returned may be smaller or larger + * than this maximum count request. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * **Note:** This hint is currently ignored by PartitionQuery and + * PartitionRead requests. + * The desired data size for each partition generated. The default for this + * option is currently 1 GiB. This is only a hint. The actual size of each + * partition may be smaller or larger than this size request. + * + * Generated from protobuf field int64 partition_size_bytes = 1; + * @return int|string + */ + public function getPartitionSizeBytes() + { + return $this->partition_size_bytes; + } + + /** + * **Note:** This hint is currently ignored by PartitionQuery and + * PartitionRead requests. + * The desired data size for each partition generated. The default for this + * option is currently 1 GiB. This is only a hint. The actual size of each + * partition may be smaller or larger than this size request. + * + * Generated from protobuf field int64 partition_size_bytes = 1; + * @param int|string $var + * @return $this + */ + public function setPartitionSizeBytes($var) + { + GPBUtil::checkInt64($var); + $this->partition_size_bytes = $var; + + return $this; + } + + /** + * **Note:** This hint is currently ignored by PartitionQuery and + * PartitionRead requests. + * The desired maximum number of partitions to return. For example, this may + * be set to the number of workers available. The default for this option + * is currently 10,000. The maximum value is currently 200,000. This is only + * a hint. The actual number of partitions returned may be smaller or larger + * than this maximum count request. + * + * Generated from protobuf field int64 max_partitions = 2; + * @return int|string + */ + public function getMaxPartitions() + { + return $this->max_partitions; + } + + /** + * **Note:** This hint is currently ignored by PartitionQuery and + * PartitionRead requests. + * The desired maximum number of partitions to return. For example, this may + * be set to the number of workers available. The default for this option + * is currently 10,000. The maximum value is currently 200,000. This is only + * a hint. The actual number of partitions returned may be smaller or larger + * than this maximum count request. + * + * Generated from protobuf field int64 max_partitions = 2; + * @param int|string $var + * @return $this + */ + public function setMaxPartitions($var) + { + GPBUtil::checkInt64($var); + $this->max_partitions = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PartitionQueryRequest.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PartitionQueryRequest.php new file mode 100644 index 000000000000..98df014e6b07 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PartitionQueryRequest.php @@ -0,0 +1,367 @@ +google.spanner.v1.PartitionQueryRequest + */ +class PartitionQueryRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The session used to create the partitions. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $session = ''; + /** + * Read only snapshot transactions are supported, read/write and single use + * transactions are not. + * + * Generated from protobuf field .google.spanner.v1.TransactionSelector transaction = 2; + */ + protected $transaction = null; + /** + * Required. The query request to generate partitions for. The request will + * fail if the query is not root partitionable. For a query to be root + * partitionable, it needs to satisfy a few conditions. For example, if the + * query execution plan contains a distributed union operator, then it must be + * the first operator in the plan. For more information about other + * conditions, see [Read data in + * parallel](https://cloud.google.com/spanner/docs/reads#read_data_in_parallel). + * The query request must not contain DML commands, such as INSERT, UPDATE, or + * DELETE. Use + * [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] with a + * PartitionedDml transaction for large, partition-friendly DML operations. + * + * Generated from protobuf field string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $sql = ''; + /** + * Parameter names and values that bind to placeholders in the SQL string. + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names can contain + * letters, numbers, and underscores. + * Parameters can appear anywhere that a literal value is expected. The same + * parameter name can be used more than once, for example: + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * It is an error to execute a SQL statement with unbound parameters. + * + * Generated from protobuf field .google.protobuf.Struct params = 4; + */ + protected $params = null; + /** + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in + * [params][google.spanner.v1.PartitionQueryRequest.params] as JSON strings. + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL query parameters. See the + * definition of [Type][google.spanner.v1.Type] for more information + * about SQL types. + * + * Generated from protobuf field map param_types = 5; + */ + private $param_types; + /** + * Additional options that affect how many partitions are created. + * + * Generated from protobuf field .google.spanner.v1.PartitionOptions partition_options = 6; + */ + protected $partition_options = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $session + * Required. The session used to create the partitions. + * @type \Google\Cloud\Spanner\V1\TransactionSelector $transaction + * Read only snapshot transactions are supported, read/write and single use + * transactions are not. + * @type string $sql + * Required. The query request to generate partitions for. The request will + * fail if the query is not root partitionable. For a query to be root + * partitionable, it needs to satisfy a few conditions. For example, if the + * query execution plan contains a distributed union operator, then it must be + * the first operator in the plan. For more information about other + * conditions, see [Read data in + * parallel](https://cloud.google.com/spanner/docs/reads#read_data_in_parallel). + * The query request must not contain DML commands, such as INSERT, UPDATE, or + * DELETE. Use + * [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] with a + * PartitionedDml transaction for large, partition-friendly DML operations. + * @type \Google\Protobuf\Struct $params + * Parameter names and values that bind to placeholders in the SQL string. + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names can contain + * letters, numbers, and underscores. + * Parameters can appear anywhere that a literal value is expected. The same + * parameter name can be used more than once, for example: + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * It is an error to execute a SQL statement with unbound parameters. + * @type array|\Google\Protobuf\Internal\MapField $param_types + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in + * [params][google.spanner.v1.PartitionQueryRequest.params] as JSON strings. + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL query parameters. See the + * definition of [Type][google.spanner.v1.Type] for more information + * about SQL types. + * @type \Google\Cloud\Spanner\V1\PartitionOptions $partition_options + * Additional options that affect how many partitions are created. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Required. The session used to create the partitions. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getSession() + { + return $this->session; + } + + /** + * Required. The session used to create the partitions. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setSession($var) + { + GPBUtil::checkString($var, True); + $this->session = $var; + + return $this; + } + + /** + * Read only snapshot transactions are supported, read/write and single use + * transactions are not. + * + * Generated from protobuf field .google.spanner.v1.TransactionSelector transaction = 2; + * @return \Google\Cloud\Spanner\V1\TransactionSelector|null + */ + public function getTransaction() + { + return $this->transaction; + } + + public function hasTransaction() + { + return isset($this->transaction); + } + + public function clearTransaction() + { + unset($this->transaction); + } + + /** + * Read only snapshot transactions are supported, read/write and single use + * transactions are not. + * + * Generated from protobuf field .google.spanner.v1.TransactionSelector transaction = 2; + * @param \Google\Cloud\Spanner\V1\TransactionSelector $var + * @return $this + */ + public function setTransaction($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\TransactionSelector::class); + $this->transaction = $var; + + return $this; + } + + /** + * Required. The query request to generate partitions for. The request will + * fail if the query is not root partitionable. For a query to be root + * partitionable, it needs to satisfy a few conditions. For example, if the + * query execution plan contains a distributed union operator, then it must be + * the first operator in the plan. For more information about other + * conditions, see [Read data in + * parallel](https://cloud.google.com/spanner/docs/reads#read_data_in_parallel). + * The query request must not contain DML commands, such as INSERT, UPDATE, or + * DELETE. Use + * [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] with a + * PartitionedDml transaction for large, partition-friendly DML operations. + * + * Generated from protobuf field string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getSql() + { + return $this->sql; + } + + /** + * Required. The query request to generate partitions for. The request will + * fail if the query is not root partitionable. For a query to be root + * partitionable, it needs to satisfy a few conditions. For example, if the + * query execution plan contains a distributed union operator, then it must be + * the first operator in the plan. For more information about other + * conditions, see [Read data in + * parallel](https://cloud.google.com/spanner/docs/reads#read_data_in_parallel). + * The query request must not contain DML commands, such as INSERT, UPDATE, or + * DELETE. Use + * [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] with a + * PartitionedDml transaction for large, partition-friendly DML operations. + * + * Generated from protobuf field string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setSql($var) + { + GPBUtil::checkString($var, True); + $this->sql = $var; + + return $this; + } + + /** + * Parameter names and values that bind to placeholders in the SQL string. + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names can contain + * letters, numbers, and underscores. + * Parameters can appear anywhere that a literal value is expected. The same + * parameter name can be used more than once, for example: + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * It is an error to execute a SQL statement with unbound parameters. + * + * Generated from protobuf field .google.protobuf.Struct params = 4; + * @return \Google\Protobuf\Struct|null + */ + public function getParams() + { + return $this->params; + } + + public function hasParams() + { + return isset($this->params); + } + + public function clearParams() + { + unset($this->params); + } + + /** + * Parameter names and values that bind to placeholders in the SQL string. + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names can contain + * letters, numbers, and underscores. + * Parameters can appear anywhere that a literal value is expected. The same + * parameter name can be used more than once, for example: + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * It is an error to execute a SQL statement with unbound parameters. + * + * Generated from protobuf field .google.protobuf.Struct params = 4; + * @param \Google\Protobuf\Struct $var + * @return $this + */ + public function setParams($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Struct::class); + $this->params = $var; + + return $this; + } + + /** + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in + * [params][google.spanner.v1.PartitionQueryRequest.params] as JSON strings. + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL query parameters. See the + * definition of [Type][google.spanner.v1.Type] for more information + * about SQL types. + * + * Generated from protobuf field map param_types = 5; + * @return \Google\Protobuf\Internal\MapField + */ + public function getParamTypes() + { + return $this->param_types; + } + + /** + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in + * [params][google.spanner.v1.PartitionQueryRequest.params] as JSON strings. + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL query parameters. See the + * definition of [Type][google.spanner.v1.Type] for more information + * about SQL types. + * + * Generated from protobuf field map param_types = 5; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setParamTypes($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\Type::class); + $this->param_types = $arr; + + return $this; + } + + /** + * Additional options that affect how many partitions are created. + * + * Generated from protobuf field .google.spanner.v1.PartitionOptions partition_options = 6; + * @return \Google\Cloud\Spanner\V1\PartitionOptions|null + */ + public function getPartitionOptions() + { + return $this->partition_options; + } + + public function hasPartitionOptions() + { + return isset($this->partition_options); + } + + public function clearPartitionOptions() + { + unset($this->partition_options); + } + + /** + * Additional options that affect how many partitions are created. + * + * Generated from protobuf field .google.spanner.v1.PartitionOptions partition_options = 6; + * @param \Google\Cloud\Spanner\V1\PartitionOptions $var + * @return $this + */ + public function setPartitionOptions($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\PartitionOptions::class); + $this->partition_options = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PartitionReadRequest.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PartitionReadRequest.php new file mode 100644 index 000000000000..abf0b47074e2 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PartitionReadRequest.php @@ -0,0 +1,361 @@ +google.spanner.v1.PartitionReadRequest + */ +class PartitionReadRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The session used to create the partitions. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $session = ''; + /** + * Read only snapshot transactions are supported, read/write and single use + * transactions are not. + * + * Generated from protobuf field .google.spanner.v1.TransactionSelector transaction = 2; + */ + protected $transaction = null; + /** + * Required. The name of the table in the database to be read. + * + * Generated from protobuf field string table = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $table = ''; + /** + * If non-empty, the name of an index on + * [table][google.spanner.v1.PartitionReadRequest.table]. This index is used + * instead of the table primary key when interpreting + * [key_set][google.spanner.v1.PartitionReadRequest.key_set] and sorting + * result rows. See [key_set][google.spanner.v1.PartitionReadRequest.key_set] + * for further information. + * + * Generated from protobuf field string index = 4; + */ + protected $index = ''; + /** + * The columns of [table][google.spanner.v1.PartitionReadRequest.table] to be + * returned for each row matching this request. + * + * Generated from protobuf field repeated string columns = 5; + */ + private $columns; + /** + * Required. `key_set` identifies the rows to be yielded. `key_set` names the + * primary keys of the rows in + * [table][google.spanner.v1.PartitionReadRequest.table] to be yielded, unless + * [index][google.spanner.v1.PartitionReadRequest.index] is present. If + * [index][google.spanner.v1.PartitionReadRequest.index] is present, then + * [key_set][google.spanner.v1.PartitionReadRequest.key_set] instead names + * index keys in [index][google.spanner.v1.PartitionReadRequest.index]. + * It is not an error for the `key_set` to name rows that do not + * exist in the database. Read yields nothing for nonexistent rows. + * + * Generated from protobuf field .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $key_set = null; + /** + * Additional options that affect how many partitions are created. + * + * Generated from protobuf field .google.spanner.v1.PartitionOptions partition_options = 9; + */ + protected $partition_options = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $session + * Required. The session used to create the partitions. + * @type \Google\Cloud\Spanner\V1\TransactionSelector $transaction + * Read only snapshot transactions are supported, read/write and single use + * transactions are not. + * @type string $table + * Required. The name of the table in the database to be read. + * @type string $index + * If non-empty, the name of an index on + * [table][google.spanner.v1.PartitionReadRequest.table]. This index is used + * instead of the table primary key when interpreting + * [key_set][google.spanner.v1.PartitionReadRequest.key_set] and sorting + * result rows. See [key_set][google.spanner.v1.PartitionReadRequest.key_set] + * for further information. + * @type array|\Google\Protobuf\Internal\RepeatedField $columns + * The columns of [table][google.spanner.v1.PartitionReadRequest.table] to be + * returned for each row matching this request. + * @type \Google\Cloud\Spanner\V1\KeySet $key_set + * Required. `key_set` identifies the rows to be yielded. `key_set` names the + * primary keys of the rows in + * [table][google.spanner.v1.PartitionReadRequest.table] to be yielded, unless + * [index][google.spanner.v1.PartitionReadRequest.index] is present. If + * [index][google.spanner.v1.PartitionReadRequest.index] is present, then + * [key_set][google.spanner.v1.PartitionReadRequest.key_set] instead names + * index keys in [index][google.spanner.v1.PartitionReadRequest.index]. + * It is not an error for the `key_set` to name rows that do not + * exist in the database. Read yields nothing for nonexistent rows. + * @type \Google\Cloud\Spanner\V1\PartitionOptions $partition_options + * Additional options that affect how many partitions are created. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Required. The session used to create the partitions. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getSession() + { + return $this->session; + } + + /** + * Required. The session used to create the partitions. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setSession($var) + { + GPBUtil::checkString($var, True); + $this->session = $var; + + return $this; + } + + /** + * Read only snapshot transactions are supported, read/write and single use + * transactions are not. + * + * Generated from protobuf field .google.spanner.v1.TransactionSelector transaction = 2; + * @return \Google\Cloud\Spanner\V1\TransactionSelector|null + */ + public function getTransaction() + { + return $this->transaction; + } + + public function hasTransaction() + { + return isset($this->transaction); + } + + public function clearTransaction() + { + unset($this->transaction); + } + + /** + * Read only snapshot transactions are supported, read/write and single use + * transactions are not. + * + * Generated from protobuf field .google.spanner.v1.TransactionSelector transaction = 2; + * @param \Google\Cloud\Spanner\V1\TransactionSelector $var + * @return $this + */ + public function setTransaction($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\TransactionSelector::class); + $this->transaction = $var; + + return $this; + } + + /** + * Required. The name of the table in the database to be read. + * + * Generated from protobuf field string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getTable() + { + return $this->table; + } + + /** + * Required. The name of the table in the database to be read. + * + * Generated from protobuf field string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setTable($var) + { + GPBUtil::checkString($var, True); + $this->table = $var; + + return $this; + } + + /** + * If non-empty, the name of an index on + * [table][google.spanner.v1.PartitionReadRequest.table]. This index is used + * instead of the table primary key when interpreting + * [key_set][google.spanner.v1.PartitionReadRequest.key_set] and sorting + * result rows. See [key_set][google.spanner.v1.PartitionReadRequest.key_set] + * for further information. + * + * Generated from protobuf field string index = 4; + * @return string + */ + public function getIndex() + { + return $this->index; + } + + /** + * If non-empty, the name of an index on + * [table][google.spanner.v1.PartitionReadRequest.table]. This index is used + * instead of the table primary key when interpreting + * [key_set][google.spanner.v1.PartitionReadRequest.key_set] and sorting + * result rows. See [key_set][google.spanner.v1.PartitionReadRequest.key_set] + * for further information. + * + * Generated from protobuf field string index = 4; + * @param string $var + * @return $this + */ + public function setIndex($var) + { + GPBUtil::checkString($var, True); + $this->index = $var; + + return $this; + } + + /** + * The columns of [table][google.spanner.v1.PartitionReadRequest.table] to be + * returned for each row matching this request. + * + * Generated from protobuf field repeated string columns = 5; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getColumns() + { + return $this->columns; + } + + /** + * The columns of [table][google.spanner.v1.PartitionReadRequest.table] to be + * returned for each row matching this request. + * + * Generated from protobuf field repeated string columns = 5; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setColumns($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->columns = $arr; + + return $this; + } + + /** + * Required. `key_set` identifies the rows to be yielded. `key_set` names the + * primary keys of the rows in + * [table][google.spanner.v1.PartitionReadRequest.table] to be yielded, unless + * [index][google.spanner.v1.PartitionReadRequest.index] is present. If + * [index][google.spanner.v1.PartitionReadRequest.index] is present, then + * [key_set][google.spanner.v1.PartitionReadRequest.key_set] instead names + * index keys in [index][google.spanner.v1.PartitionReadRequest.index]. + * It is not an error for the `key_set` to name rows that do not + * exist in the database. Read yields nothing for nonexistent rows. + * + * Generated from protobuf field .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\V1\KeySet|null + */ + public function getKeySet() + { + return $this->key_set; + } + + public function hasKeySet() + { + return isset($this->key_set); + } + + public function clearKeySet() + { + unset($this->key_set); + } + + /** + * Required. `key_set` identifies the rows to be yielded. `key_set` names the + * primary keys of the rows in + * [table][google.spanner.v1.PartitionReadRequest.table] to be yielded, unless + * [index][google.spanner.v1.PartitionReadRequest.index] is present. If + * [index][google.spanner.v1.PartitionReadRequest.index] is present, then + * [key_set][google.spanner.v1.PartitionReadRequest.key_set] instead names + * index keys in [index][google.spanner.v1.PartitionReadRequest.index]. + * It is not an error for the `key_set` to name rows that do not + * exist in the database. Read yields nothing for nonexistent rows. + * + * Generated from protobuf field .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\V1\KeySet $var + * @return $this + */ + public function setKeySet($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\KeySet::class); + $this->key_set = $var; + + return $this; + } + + /** + * Additional options that affect how many partitions are created. + * + * Generated from protobuf field .google.spanner.v1.PartitionOptions partition_options = 9; + * @return \Google\Cloud\Spanner\V1\PartitionOptions|null + */ + public function getPartitionOptions() + { + return $this->partition_options; + } + + public function hasPartitionOptions() + { + return isset($this->partition_options); + } + + public function clearPartitionOptions() + { + unset($this->partition_options); + } + + /** + * Additional options that affect how many partitions are created. + * + * Generated from protobuf field .google.spanner.v1.PartitionOptions partition_options = 9; + * @param \Google\Cloud\Spanner\V1\PartitionOptions $var + * @return $this + */ + public function setPartitionOptions($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\PartitionOptions::class); + $this->partition_options = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PartitionResponse.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PartitionResponse.php new file mode 100644 index 000000000000..f73e1179d2df --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PartitionResponse.php @@ -0,0 +1,112 @@ +google.spanner.v1.PartitionResponse + */ +class PartitionResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Partitions created by this request. + * + * Generated from protobuf field repeated .google.spanner.v1.Partition partitions = 1; + */ + private $partitions; + /** + * Transaction created by this request. + * + * Generated from protobuf field .google.spanner.v1.Transaction transaction = 2; + */ + protected $transaction = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Spanner\V1\Partition>|\Google\Protobuf\Internal\RepeatedField $partitions + * Partitions created by this request. + * @type \Google\Cloud\Spanner\V1\Transaction $transaction + * Transaction created by this request. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Partitions created by this request. + * + * Generated from protobuf field repeated .google.spanner.v1.Partition partitions = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPartitions() + { + return $this->partitions; + } + + /** + * Partitions created by this request. + * + * Generated from protobuf field repeated .google.spanner.v1.Partition partitions = 1; + * @param array<\Google\Cloud\Spanner\V1\Partition>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPartitions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\Partition::class); + $this->partitions = $arr; + + return $this; + } + + /** + * Transaction created by this request. + * + * Generated from protobuf field .google.spanner.v1.Transaction transaction = 2; + * @return \Google\Cloud\Spanner\V1\Transaction|null + */ + public function getTransaction() + { + return $this->transaction; + } + + public function hasTransaction() + { + return isset($this->transaction); + } + + public function clearTransaction() + { + unset($this->transaction); + } + + /** + * Transaction created by this request. + * + * Generated from protobuf field .google.spanner.v1.Transaction transaction = 2; + * @param \Google\Cloud\Spanner\V1\Transaction $var + * @return $this + */ + public function setTransaction($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\Transaction::class); + $this->transaction = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PlanNode.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PlanNode.php new file mode 100644 index 000000000000..9137384574bb --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PlanNode.php @@ -0,0 +1,353 @@ +google.spanner.v1.PlanNode + */ +class PlanNode extends \Google\Protobuf\Internal\Message +{ + /** + * The `PlanNode`'s index in [node list][google.spanner.v1.QueryPlan.plan_nodes]. + * + * Generated from protobuf field int32 index = 1; + */ + protected $index = 0; + /** + * Used to determine the type of node. May be needed for visualizing + * different kinds of nodes differently. For example, If the node is a + * [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] node, it will have a condensed representation + * which can be used to directly embed a description of the node in its + * parent. + * + * Generated from protobuf field .google.spanner.v1.PlanNode.Kind kind = 2; + */ + protected $kind = 0; + /** + * The display name for the node. + * + * Generated from protobuf field string display_name = 3; + */ + protected $display_name = ''; + /** + * List of child node `index`es and their relationship to this parent. + * + * Generated from protobuf field repeated .google.spanner.v1.PlanNode.ChildLink child_links = 4; + */ + private $child_links; + /** + * Condensed representation for [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] nodes. + * + * Generated from protobuf field .google.spanner.v1.PlanNode.ShortRepresentation short_representation = 5; + */ + protected $short_representation = null; + /** + * Attributes relevant to the node contained in a group of key-value pairs. + * For example, a Parameter Reference node could have the following + * information in its metadata: + * { + * "parameter_reference": "param1", + * "parameter_type": "array" + * } + * + * Generated from protobuf field .google.protobuf.Struct metadata = 6; + */ + protected $metadata = null; + /** + * The execution statistics associated with the node, contained in a group of + * key-value pairs. Only present if the plan was returned as a result of a + * profile query. For example, number of executions, number of rows/time per + * execution etc. + * + * Generated from protobuf field .google.protobuf.Struct execution_stats = 7; + */ + protected $execution_stats = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $index + * The `PlanNode`'s index in [node list][google.spanner.v1.QueryPlan.plan_nodes]. + * @type int $kind + * Used to determine the type of node. May be needed for visualizing + * different kinds of nodes differently. For example, If the node is a + * [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] node, it will have a condensed representation + * which can be used to directly embed a description of the node in its + * parent. + * @type string $display_name + * The display name for the node. + * @type array<\Google\Cloud\Spanner\V1\PlanNode\ChildLink>|\Google\Protobuf\Internal\RepeatedField $child_links + * List of child node `index`es and their relationship to this parent. + * @type \Google\Cloud\Spanner\V1\PlanNode\ShortRepresentation $short_representation + * Condensed representation for [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] nodes. + * @type \Google\Protobuf\Struct $metadata + * Attributes relevant to the node contained in a group of key-value pairs. + * For example, a Parameter Reference node could have the following + * information in its metadata: + * { + * "parameter_reference": "param1", + * "parameter_type": "array" + * } + * @type \Google\Protobuf\Struct $execution_stats + * The execution statistics associated with the node, contained in a group of + * key-value pairs. Only present if the plan was returned as a result of a + * profile query. For example, number of executions, number of rows/time per + * execution etc. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\QueryPlan::initOnce(); + parent::__construct($data); + } + + /** + * The `PlanNode`'s index in [node list][google.spanner.v1.QueryPlan.plan_nodes]. + * + * Generated from protobuf field int32 index = 1; + * @return int + */ + public function getIndex() + { + return $this->index; + } + + /** + * The `PlanNode`'s index in [node list][google.spanner.v1.QueryPlan.plan_nodes]. + * + * Generated from protobuf field int32 index = 1; + * @param int $var + * @return $this + */ + public function setIndex($var) + { + GPBUtil::checkInt32($var); + $this->index = $var; + + return $this; + } + + /** + * Used to determine the type of node. May be needed for visualizing + * different kinds of nodes differently. For example, If the node is a + * [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] node, it will have a condensed representation + * which can be used to directly embed a description of the node in its + * parent. + * + * Generated from protobuf field .google.spanner.v1.PlanNode.Kind kind = 2; + * @return int + */ + public function getKind() + { + return $this->kind; + } + + /** + * Used to determine the type of node. May be needed for visualizing + * different kinds of nodes differently. For example, If the node is a + * [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] node, it will have a condensed representation + * which can be used to directly embed a description of the node in its + * parent. + * + * Generated from protobuf field .google.spanner.v1.PlanNode.Kind kind = 2; + * @param int $var + * @return $this + */ + public function setKind($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\V1\PlanNode\Kind::class); + $this->kind = $var; + + return $this; + } + + /** + * The display name for the node. + * + * Generated from protobuf field string display_name = 3; + * @return string + */ + public function getDisplayName() + { + return $this->display_name; + } + + /** + * The display name for the node. + * + * Generated from protobuf field string display_name = 3; + * @param string $var + * @return $this + */ + public function setDisplayName($var) + { + GPBUtil::checkString($var, True); + $this->display_name = $var; + + return $this; + } + + /** + * List of child node `index`es and their relationship to this parent. + * + * Generated from protobuf field repeated .google.spanner.v1.PlanNode.ChildLink child_links = 4; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getChildLinks() + { + return $this->child_links; + } + + /** + * List of child node `index`es and their relationship to this parent. + * + * Generated from protobuf field repeated .google.spanner.v1.PlanNode.ChildLink child_links = 4; + * @param array<\Google\Cloud\Spanner\V1\PlanNode\ChildLink>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setChildLinks($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\PlanNode\ChildLink::class); + $this->child_links = $arr; + + return $this; + } + + /** + * Condensed representation for [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] nodes. + * + * Generated from protobuf field .google.spanner.v1.PlanNode.ShortRepresentation short_representation = 5; + * @return \Google\Cloud\Spanner\V1\PlanNode\ShortRepresentation|null + */ + public function getShortRepresentation() + { + return $this->short_representation; + } + + public function hasShortRepresentation() + { + return isset($this->short_representation); + } + + public function clearShortRepresentation() + { + unset($this->short_representation); + } + + /** + * Condensed representation for [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] nodes. + * + * Generated from protobuf field .google.spanner.v1.PlanNode.ShortRepresentation short_representation = 5; + * @param \Google\Cloud\Spanner\V1\PlanNode\ShortRepresentation $var + * @return $this + */ + public function setShortRepresentation($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\PlanNode\ShortRepresentation::class); + $this->short_representation = $var; + + return $this; + } + + /** + * Attributes relevant to the node contained in a group of key-value pairs. + * For example, a Parameter Reference node could have the following + * information in its metadata: + * { + * "parameter_reference": "param1", + * "parameter_type": "array" + * } + * + * Generated from protobuf field .google.protobuf.Struct metadata = 6; + * @return \Google\Protobuf\Struct|null + */ + public function getMetadata() + { + return $this->metadata; + } + + public function hasMetadata() + { + return isset($this->metadata); + } + + public function clearMetadata() + { + unset($this->metadata); + } + + /** + * Attributes relevant to the node contained in a group of key-value pairs. + * For example, a Parameter Reference node could have the following + * information in its metadata: + * { + * "parameter_reference": "param1", + * "parameter_type": "array" + * } + * + * Generated from protobuf field .google.protobuf.Struct metadata = 6; + * @param \Google\Protobuf\Struct $var + * @return $this + */ + public function setMetadata($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Struct::class); + $this->metadata = $var; + + return $this; + } + + /** + * The execution statistics associated with the node, contained in a group of + * key-value pairs. Only present if the plan was returned as a result of a + * profile query. For example, number of executions, number of rows/time per + * execution etc. + * + * Generated from protobuf field .google.protobuf.Struct execution_stats = 7; + * @return \Google\Protobuf\Struct|null + */ + public function getExecutionStats() + { + return $this->execution_stats; + } + + public function hasExecutionStats() + { + return isset($this->execution_stats); + } + + public function clearExecutionStats() + { + unset($this->execution_stats); + } + + /** + * The execution statistics associated with the node, contained in a group of + * key-value pairs. Only present if the plan was returned as a result of a + * profile query. For example, number of executions, number of rows/time per + * execution etc. + * + * Generated from protobuf field .google.protobuf.Struct execution_stats = 7; + * @param \Google\Protobuf\Struct $var + * @return $this + */ + public function setExecutionStats($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Struct::class); + $this->execution_stats = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PlanNode/ChildLink.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PlanNode/ChildLink.php new file mode 100644 index 000000000000..1afd40ab8fdb --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PlanNode/ChildLink.php @@ -0,0 +1,179 @@ +google.spanner.v1.PlanNode.ChildLink + */ +class ChildLink extends \Google\Protobuf\Internal\Message +{ + /** + * The node to which the link points. + * + * Generated from protobuf field int32 child_index = 1; + */ + protected $child_index = 0; + /** + * The type of the link. For example, in Hash Joins this could be used to + * distinguish between the build child and the probe child, or in the case + * of the child being an output variable, to represent the tag associated + * with the output variable. + * + * Generated from protobuf field string type = 2; + */ + protected $type = ''; + /** + * Only present if the child node is [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] and corresponds + * to an output variable of the parent node. The field carries the name of + * the output variable. + * For example, a `TableScan` operator that reads rows from a table will + * have child links to the `SCALAR` nodes representing the output variables + * created for each column that is read by the operator. The corresponding + * `variable` fields will be set to the variable names assigned to the + * columns. + * + * Generated from protobuf field string variable = 3; + */ + protected $variable = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $child_index + * The node to which the link points. + * @type string $type + * The type of the link. For example, in Hash Joins this could be used to + * distinguish between the build child and the probe child, or in the case + * of the child being an output variable, to represent the tag associated + * with the output variable. + * @type string $variable + * Only present if the child node is [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] and corresponds + * to an output variable of the parent node. The field carries the name of + * the output variable. + * For example, a `TableScan` operator that reads rows from a table will + * have child links to the `SCALAR` nodes representing the output variables + * created for each column that is read by the operator. The corresponding + * `variable` fields will be set to the variable names assigned to the + * columns. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\QueryPlan::initOnce(); + parent::__construct($data); + } + + /** + * The node to which the link points. + * + * Generated from protobuf field int32 child_index = 1; + * @return int + */ + public function getChildIndex() + { + return $this->child_index; + } + + /** + * The node to which the link points. + * + * Generated from protobuf field int32 child_index = 1; + * @param int $var + * @return $this + */ + public function setChildIndex($var) + { + GPBUtil::checkInt32($var); + $this->child_index = $var; + + return $this; + } + + /** + * The type of the link. For example, in Hash Joins this could be used to + * distinguish between the build child and the probe child, or in the case + * of the child being an output variable, to represent the tag associated + * with the output variable. + * + * Generated from protobuf field string type = 2; + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * The type of the link. For example, in Hash Joins this could be used to + * distinguish between the build child and the probe child, or in the case + * of the child being an output variable, to represent the tag associated + * with the output variable. + * + * Generated from protobuf field string type = 2; + * @param string $var + * @return $this + */ + public function setType($var) + { + GPBUtil::checkString($var, True); + $this->type = $var; + + return $this; + } + + /** + * Only present if the child node is [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] and corresponds + * to an output variable of the parent node. The field carries the name of + * the output variable. + * For example, a `TableScan` operator that reads rows from a table will + * have child links to the `SCALAR` nodes representing the output variables + * created for each column that is read by the operator. The corresponding + * `variable` fields will be set to the variable names assigned to the + * columns. + * + * Generated from protobuf field string variable = 3; + * @return string + */ + public function getVariable() + { + return $this->variable; + } + + /** + * Only present if the child node is [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] and corresponds + * to an output variable of the parent node. The field carries the name of + * the output variable. + * For example, a `TableScan` operator that reads rows from a table will + * have child links to the `SCALAR` nodes representing the output variables + * created for each column that is read by the operator. The corresponding + * `variable` fields will be set to the variable names assigned to the + * columns. + * + * Generated from protobuf field string variable = 3; + * @param string $var + * @return $this + */ + public function setVariable($var) + { + GPBUtil::checkString($var, True); + $this->variable = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(ChildLink::class, \Google\Cloud\Spanner\V1\PlanNode_ChildLink::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PlanNode/Kind.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PlanNode/Kind.php new file mode 100644 index 000000000000..78081c797e03 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PlanNode/Kind.php @@ -0,0 +1,70 @@ +google.spanner.v1.PlanNode.Kind + */ +class Kind +{ + /** + * Not specified. + * + * Generated from protobuf enum KIND_UNSPECIFIED = 0; + */ + const KIND_UNSPECIFIED = 0; + /** + * Denotes a Relational operator node in the expression tree. Relational + * operators represent iterative processing of rows during query execution. + * For example, a `TableScan` operation that reads rows from a table. + * + * Generated from protobuf enum RELATIONAL = 1; + */ + const RELATIONAL = 1; + /** + * Denotes a Scalar node in the expression tree. Scalar nodes represent + * non-iterable entities in the query plan. For example, constants or + * arithmetic operators appearing inside predicate expressions or references + * to column names. + * + * Generated from protobuf enum SCALAR = 2; + */ + const SCALAR = 2; + + private static $valueToName = [ + self::KIND_UNSPECIFIED => 'KIND_UNSPECIFIED', + self::RELATIONAL => 'RELATIONAL', + self::SCALAR => 'SCALAR', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Kind::class, \Google\Cloud\Spanner\V1\PlanNode_Kind::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PlanNode/ShortRepresentation.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PlanNode/ShortRepresentation.php new file mode 100644 index 000000000000..4de00c304229 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/PlanNode/ShortRepresentation.php @@ -0,0 +1,121 @@ +google.spanner.v1.PlanNode.ShortRepresentation + */ +class ShortRepresentation extends \Google\Protobuf\Internal\Message +{ + /** + * A string representation of the expression subtree rooted at this node. + * + * Generated from protobuf field string description = 1; + */ + protected $description = ''; + /** + * A mapping of (subquery variable name) -> (subquery node id) for cases + * where the `description` string of this node references a `SCALAR` + * subquery contained in the expression subtree rooted at this node. The + * referenced `SCALAR` subquery may not necessarily be a direct child of + * this node. + * + * Generated from protobuf field map subqueries = 2; + */ + private $subqueries; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $description + * A string representation of the expression subtree rooted at this node. + * @type array|\Google\Protobuf\Internal\MapField $subqueries + * A mapping of (subquery variable name) -> (subquery node id) for cases + * where the `description` string of this node references a `SCALAR` + * subquery contained in the expression subtree rooted at this node. The + * referenced `SCALAR` subquery may not necessarily be a direct child of + * this node. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\QueryPlan::initOnce(); + parent::__construct($data); + } + + /** + * A string representation of the expression subtree rooted at this node. + * + * Generated from protobuf field string description = 1; + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * A string representation of the expression subtree rooted at this node. + * + * Generated from protobuf field string description = 1; + * @param string $var + * @return $this + */ + public function setDescription($var) + { + GPBUtil::checkString($var, True); + $this->description = $var; + + return $this; + } + + /** + * A mapping of (subquery variable name) -> (subquery node id) for cases + * where the `description` string of this node references a `SCALAR` + * subquery contained in the expression subtree rooted at this node. The + * referenced `SCALAR` subquery may not necessarily be a direct child of + * this node. + * + * Generated from protobuf field map subqueries = 2; + * @return \Google\Protobuf\Internal\MapField + */ + public function getSubqueries() + { + return $this->subqueries; + } + + /** + * A mapping of (subquery variable name) -> (subquery node id) for cases + * where the `description` string of this node references a `SCALAR` + * subquery contained in the expression subtree rooted at this node. The + * referenced `SCALAR` subquery may not necessarily be a direct child of + * this node. + * + * Generated from protobuf field map subqueries = 2; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setSubqueries($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::INT32); + $this->subqueries = $arr; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(ShortRepresentation::class, \Google\Cloud\Spanner\V1\PlanNode_ShortRepresentation::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/QueryPlan.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/QueryPlan.php new file mode 100644 index 000000000000..b09ddcab41ba --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/QueryPlan.php @@ -0,0 +1,75 @@ +google.spanner.v1.QueryPlan + */ +class QueryPlan extends \Google\Protobuf\Internal\Message +{ + /** + * The nodes in the query plan. Plan nodes are returned in pre-order starting + * with the plan root. Each [PlanNode][google.spanner.v1.PlanNode]'s `id` corresponds to its index in + * `plan_nodes`. + * + * Generated from protobuf field repeated .google.spanner.v1.PlanNode plan_nodes = 1; + */ + private $plan_nodes; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Spanner\V1\PlanNode>|\Google\Protobuf\Internal\RepeatedField $plan_nodes + * The nodes in the query plan. Plan nodes are returned in pre-order starting + * with the plan root. Each [PlanNode][google.spanner.v1.PlanNode]'s `id` corresponds to its index in + * `plan_nodes`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\QueryPlan::initOnce(); + parent::__construct($data); + } + + /** + * The nodes in the query plan. Plan nodes are returned in pre-order starting + * with the plan root. Each [PlanNode][google.spanner.v1.PlanNode]'s `id` corresponds to its index in + * `plan_nodes`. + * + * Generated from protobuf field repeated .google.spanner.v1.PlanNode plan_nodes = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPlanNodes() + { + return $this->plan_nodes; + } + + /** + * The nodes in the query plan. Plan nodes are returned in pre-order starting + * with the plan root. Each [PlanNode][google.spanner.v1.PlanNode]'s `id` corresponds to its index in + * `plan_nodes`. + * + * Generated from protobuf field repeated .google.spanner.v1.PlanNode plan_nodes = 1; + * @param array<\Google\Cloud\Spanner\V1\PlanNode>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPlanNodes($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\PlanNode::class); + $this->plan_nodes = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ReadRequest.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ReadRequest.php new file mode 100644 index 000000000000..6f97b44a5e6f --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ReadRequest.php @@ -0,0 +1,706 @@ +google.spanner.v1.ReadRequest + */ +class ReadRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The session in which the read should be performed. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $session = ''; + /** + * The transaction to use. If none is provided, the default is a + * temporary read-only transaction with strong concurrency. + * + * Generated from protobuf field .google.spanner.v1.TransactionSelector transaction = 2; + */ + protected $transaction = null; + /** + * Required. The name of the table in the database to be read. + * + * Generated from protobuf field string table = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $table = ''; + /** + * If non-empty, the name of an index on + * [table][google.spanner.v1.ReadRequest.table]. This index is used instead of + * the table primary key when interpreting + * [key_set][google.spanner.v1.ReadRequest.key_set] and sorting result rows. + * See [key_set][google.spanner.v1.ReadRequest.key_set] for further + * information. + * + * Generated from protobuf field string index = 4; + */ + protected $index = ''; + /** + * Required. The columns of [table][google.spanner.v1.ReadRequest.table] to be + * returned for each row matching this request. + * + * Generated from protobuf field repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + */ + private $columns; + /** + * Required. `key_set` identifies the rows to be yielded. `key_set` names the + * primary keys of the rows in [table][google.spanner.v1.ReadRequest.table] to + * be yielded, unless [index][google.spanner.v1.ReadRequest.index] is present. + * If [index][google.spanner.v1.ReadRequest.index] is present, then + * [key_set][google.spanner.v1.ReadRequest.key_set] instead names index keys + * in [index][google.spanner.v1.ReadRequest.index]. + * If the [partition_token][google.spanner.v1.ReadRequest.partition_token] + * field is empty, rows are yielded in table primary key order (if + * [index][google.spanner.v1.ReadRequest.index] is empty) or index key order + * (if [index][google.spanner.v1.ReadRequest.index] is non-empty). If the + * [partition_token][google.spanner.v1.ReadRequest.partition_token] field is + * not empty, rows will be yielded in an unspecified order. + * It is not an error for the `key_set` to name rows that do not + * exist in the database. Read yields nothing for nonexistent rows. + * + * Generated from protobuf field .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $key_set = null; + /** + * If greater than zero, only the first `limit` rows are yielded. If `limit` + * is zero, the default is no limit. A limit cannot be specified if + * `partition_token` is set. + * + * Generated from protobuf field int64 limit = 8; + */ + protected $limit = 0; + /** + * If this request is resuming a previously interrupted read, + * `resume_token` should be copied from the last + * [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the + * interruption. Doing this enables the new read to resume where the last read + * left off. The rest of the request parameters must exactly match the request + * that yielded this token. + * + * Generated from protobuf field bytes resume_token = 9; + */ + protected $resume_token = ''; + /** + * If present, results will be restricted to the specified partition + * previously created using PartitionRead(). There must be an exact + * match for the values of fields common to this message and the + * PartitionReadRequest message used to create this partition_token. + * + * Generated from protobuf field bytes partition_token = 10; + */ + protected $partition_token = ''; + /** + * Common options for this request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 11; + */ + protected $request_options = null; + /** + * Directed read options for this request. + * + * Generated from protobuf field .google.spanner.v1.DirectedReadOptions directed_read_options = 14; + */ + protected $directed_read_options = null; + /** + * If this is for a partitioned read and this field is set to `true`, the + * request is executed with Spanner Data Boost independent compute resources. + * If the field is set to `true` but the request does not set + * `partition_token`, the API returns an `INVALID_ARGUMENT` error. + * + * Generated from protobuf field bool data_boost_enabled = 15; + */ + protected $data_boost_enabled = false; + /** + * Optional. Order for the returned rows. + * By default, Spanner will return result rows in primary key order except for + * PartitionRead requests. For applications that do not require rows to be + * returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting + * `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval, + * resulting in lower latencies in certain cases (e.g. bulk point lookups). + * + * Generated from protobuf field .google.spanner.v1.ReadRequest.OrderBy order_by = 16 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $order_by = 0; + /** + * Optional. Lock Hint for the request, it can only be used with read-write + * transactions. + * + * Generated from protobuf field .google.spanner.v1.ReadRequest.LockHint lock_hint = 17 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $lock_hint = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $session + * Required. The session in which the read should be performed. + * @type \Google\Cloud\Spanner\V1\TransactionSelector $transaction + * The transaction to use. If none is provided, the default is a + * temporary read-only transaction with strong concurrency. + * @type string $table + * Required. The name of the table in the database to be read. + * @type string $index + * If non-empty, the name of an index on + * [table][google.spanner.v1.ReadRequest.table]. This index is used instead of + * the table primary key when interpreting + * [key_set][google.spanner.v1.ReadRequest.key_set] and sorting result rows. + * See [key_set][google.spanner.v1.ReadRequest.key_set] for further + * information. + * @type array|\Google\Protobuf\Internal\RepeatedField $columns + * Required. The columns of [table][google.spanner.v1.ReadRequest.table] to be + * returned for each row matching this request. + * @type \Google\Cloud\Spanner\V1\KeySet $key_set + * Required. `key_set` identifies the rows to be yielded. `key_set` names the + * primary keys of the rows in [table][google.spanner.v1.ReadRequest.table] to + * be yielded, unless [index][google.spanner.v1.ReadRequest.index] is present. + * If [index][google.spanner.v1.ReadRequest.index] is present, then + * [key_set][google.spanner.v1.ReadRequest.key_set] instead names index keys + * in [index][google.spanner.v1.ReadRequest.index]. + * If the [partition_token][google.spanner.v1.ReadRequest.partition_token] + * field is empty, rows are yielded in table primary key order (if + * [index][google.spanner.v1.ReadRequest.index] is empty) or index key order + * (if [index][google.spanner.v1.ReadRequest.index] is non-empty). If the + * [partition_token][google.spanner.v1.ReadRequest.partition_token] field is + * not empty, rows will be yielded in an unspecified order. + * It is not an error for the `key_set` to name rows that do not + * exist in the database. Read yields nothing for nonexistent rows. + * @type int|string $limit + * If greater than zero, only the first `limit` rows are yielded. If `limit` + * is zero, the default is no limit. A limit cannot be specified if + * `partition_token` is set. + * @type string $resume_token + * If this request is resuming a previously interrupted read, + * `resume_token` should be copied from the last + * [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the + * interruption. Doing this enables the new read to resume where the last read + * left off. The rest of the request parameters must exactly match the request + * that yielded this token. + * @type string $partition_token + * If present, results will be restricted to the specified partition + * previously created using PartitionRead(). There must be an exact + * match for the values of fields common to this message and the + * PartitionReadRequest message used to create this partition_token. + * @type \Google\Cloud\Spanner\V1\RequestOptions $request_options + * Common options for this request. + * @type \Google\Cloud\Spanner\V1\DirectedReadOptions $directed_read_options + * Directed read options for this request. + * @type bool $data_boost_enabled + * If this is for a partitioned read and this field is set to `true`, the + * request is executed with Spanner Data Boost independent compute resources. + * If the field is set to `true` but the request does not set + * `partition_token`, the API returns an `INVALID_ARGUMENT` error. + * @type int $order_by + * Optional. Order for the returned rows. + * By default, Spanner will return result rows in primary key order except for + * PartitionRead requests. For applications that do not require rows to be + * returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting + * `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval, + * resulting in lower latencies in certain cases (e.g. bulk point lookups). + * @type int $lock_hint + * Optional. Lock Hint for the request, it can only be used with read-write + * transactions. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Required. The session in which the read should be performed. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getSession() + { + return $this->session; + } + + /** + * Required. The session in which the read should be performed. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setSession($var) + { + GPBUtil::checkString($var, True); + $this->session = $var; + + return $this; + } + + /** + * The transaction to use. If none is provided, the default is a + * temporary read-only transaction with strong concurrency. + * + * Generated from protobuf field .google.spanner.v1.TransactionSelector transaction = 2; + * @return \Google\Cloud\Spanner\V1\TransactionSelector|null + */ + public function getTransaction() + { + return $this->transaction; + } + + public function hasTransaction() + { + return isset($this->transaction); + } + + public function clearTransaction() + { + unset($this->transaction); + } + + /** + * The transaction to use. If none is provided, the default is a + * temporary read-only transaction with strong concurrency. + * + * Generated from protobuf field .google.spanner.v1.TransactionSelector transaction = 2; + * @param \Google\Cloud\Spanner\V1\TransactionSelector $var + * @return $this + */ + public function setTransaction($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\TransactionSelector::class); + $this->transaction = $var; + + return $this; + } + + /** + * Required. The name of the table in the database to be read. + * + * Generated from protobuf field string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getTable() + { + return $this->table; + } + + /** + * Required. The name of the table in the database to be read. + * + * Generated from protobuf field string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setTable($var) + { + GPBUtil::checkString($var, True); + $this->table = $var; + + return $this; + } + + /** + * If non-empty, the name of an index on + * [table][google.spanner.v1.ReadRequest.table]. This index is used instead of + * the table primary key when interpreting + * [key_set][google.spanner.v1.ReadRequest.key_set] and sorting result rows. + * See [key_set][google.spanner.v1.ReadRequest.key_set] for further + * information. + * + * Generated from protobuf field string index = 4; + * @return string + */ + public function getIndex() + { + return $this->index; + } + + /** + * If non-empty, the name of an index on + * [table][google.spanner.v1.ReadRequest.table]. This index is used instead of + * the table primary key when interpreting + * [key_set][google.spanner.v1.ReadRequest.key_set] and sorting result rows. + * See [key_set][google.spanner.v1.ReadRequest.key_set] for further + * information. + * + * Generated from protobuf field string index = 4; + * @param string $var + * @return $this + */ + public function setIndex($var) + { + GPBUtil::checkString($var, True); + $this->index = $var; + + return $this; + } + + /** + * Required. The columns of [table][google.spanner.v1.ReadRequest.table] to be + * returned for each row matching this request. + * + * Generated from protobuf field repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getColumns() + { + return $this->columns; + } + + /** + * Required. The columns of [table][google.spanner.v1.ReadRequest.table] to be + * returned for each row matching this request. + * + * Generated from protobuf field repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setColumns($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->columns = $arr; + + return $this; + } + + /** + * Required. `key_set` identifies the rows to be yielded. `key_set` names the + * primary keys of the rows in [table][google.spanner.v1.ReadRequest.table] to + * be yielded, unless [index][google.spanner.v1.ReadRequest.index] is present. + * If [index][google.spanner.v1.ReadRequest.index] is present, then + * [key_set][google.spanner.v1.ReadRequest.key_set] instead names index keys + * in [index][google.spanner.v1.ReadRequest.index]. + * If the [partition_token][google.spanner.v1.ReadRequest.partition_token] + * field is empty, rows are yielded in table primary key order (if + * [index][google.spanner.v1.ReadRequest.index] is empty) or index key order + * (if [index][google.spanner.v1.ReadRequest.index] is non-empty). If the + * [partition_token][google.spanner.v1.ReadRequest.partition_token] field is + * not empty, rows will be yielded in an unspecified order. + * It is not an error for the `key_set` to name rows that do not + * exist in the database. Read yields nothing for nonexistent rows. + * + * Generated from protobuf field .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\V1\KeySet|null + */ + public function getKeySet() + { + return $this->key_set; + } + + public function hasKeySet() + { + return isset($this->key_set); + } + + public function clearKeySet() + { + unset($this->key_set); + } + + /** + * Required. `key_set` identifies the rows to be yielded. `key_set` names the + * primary keys of the rows in [table][google.spanner.v1.ReadRequest.table] to + * be yielded, unless [index][google.spanner.v1.ReadRequest.index] is present. + * If [index][google.spanner.v1.ReadRequest.index] is present, then + * [key_set][google.spanner.v1.ReadRequest.key_set] instead names index keys + * in [index][google.spanner.v1.ReadRequest.index]. + * If the [partition_token][google.spanner.v1.ReadRequest.partition_token] + * field is empty, rows are yielded in table primary key order (if + * [index][google.spanner.v1.ReadRequest.index] is empty) or index key order + * (if [index][google.spanner.v1.ReadRequest.index] is non-empty). If the + * [partition_token][google.spanner.v1.ReadRequest.partition_token] field is + * not empty, rows will be yielded in an unspecified order. + * It is not an error for the `key_set` to name rows that do not + * exist in the database. Read yields nothing for nonexistent rows. + * + * Generated from protobuf field .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\V1\KeySet $var + * @return $this + */ + public function setKeySet($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\KeySet::class); + $this->key_set = $var; + + return $this; + } + + /** + * If greater than zero, only the first `limit` rows are yielded. If `limit` + * is zero, the default is no limit. A limit cannot be specified if + * `partition_token` is set. + * + * Generated from protobuf field int64 limit = 8; + * @return int|string + */ + public function getLimit() + { + return $this->limit; + } + + /** + * If greater than zero, only the first `limit` rows are yielded. If `limit` + * is zero, the default is no limit. A limit cannot be specified if + * `partition_token` is set. + * + * Generated from protobuf field int64 limit = 8; + * @param int|string $var + * @return $this + */ + public function setLimit($var) + { + GPBUtil::checkInt64($var); + $this->limit = $var; + + return $this; + } + + /** + * If this request is resuming a previously interrupted read, + * `resume_token` should be copied from the last + * [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the + * interruption. Doing this enables the new read to resume where the last read + * left off. The rest of the request parameters must exactly match the request + * that yielded this token. + * + * Generated from protobuf field bytes resume_token = 9; + * @return string + */ + public function getResumeToken() + { + return $this->resume_token; + } + + /** + * If this request is resuming a previously interrupted read, + * `resume_token` should be copied from the last + * [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the + * interruption. Doing this enables the new read to resume where the last read + * left off. The rest of the request parameters must exactly match the request + * that yielded this token. + * + * Generated from protobuf field bytes resume_token = 9; + * @param string $var + * @return $this + */ + public function setResumeToken($var) + { + GPBUtil::checkString($var, False); + $this->resume_token = $var; + + return $this; + } + + /** + * If present, results will be restricted to the specified partition + * previously created using PartitionRead(). There must be an exact + * match for the values of fields common to this message and the + * PartitionReadRequest message used to create this partition_token. + * + * Generated from protobuf field bytes partition_token = 10; + * @return string + */ + public function getPartitionToken() + { + return $this->partition_token; + } + + /** + * If present, results will be restricted to the specified partition + * previously created using PartitionRead(). There must be an exact + * match for the values of fields common to this message and the + * PartitionReadRequest message used to create this partition_token. + * + * Generated from protobuf field bytes partition_token = 10; + * @param string $var + * @return $this + */ + public function setPartitionToken($var) + { + GPBUtil::checkString($var, False); + $this->partition_token = $var; + + return $this; + } + + /** + * Common options for this request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 11; + * @return \Google\Cloud\Spanner\V1\RequestOptions|null + */ + public function getRequestOptions() + { + return $this->request_options; + } + + public function hasRequestOptions() + { + return isset($this->request_options); + } + + public function clearRequestOptions() + { + unset($this->request_options); + } + + /** + * Common options for this request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions request_options = 11; + * @param \Google\Cloud\Spanner\V1\RequestOptions $var + * @return $this + */ + public function setRequestOptions($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\RequestOptions::class); + $this->request_options = $var; + + return $this; + } + + /** + * Directed read options for this request. + * + * Generated from protobuf field .google.spanner.v1.DirectedReadOptions directed_read_options = 14; + * @return \Google\Cloud\Spanner\V1\DirectedReadOptions|null + */ + public function getDirectedReadOptions() + { + return $this->directed_read_options; + } + + public function hasDirectedReadOptions() + { + return isset($this->directed_read_options); + } + + public function clearDirectedReadOptions() + { + unset($this->directed_read_options); + } + + /** + * Directed read options for this request. + * + * Generated from protobuf field .google.spanner.v1.DirectedReadOptions directed_read_options = 14; + * @param \Google\Cloud\Spanner\V1\DirectedReadOptions $var + * @return $this + */ + public function setDirectedReadOptions($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\DirectedReadOptions::class); + $this->directed_read_options = $var; + + return $this; + } + + /** + * If this is for a partitioned read and this field is set to `true`, the + * request is executed with Spanner Data Boost independent compute resources. + * If the field is set to `true` but the request does not set + * `partition_token`, the API returns an `INVALID_ARGUMENT` error. + * + * Generated from protobuf field bool data_boost_enabled = 15; + * @return bool + */ + public function getDataBoostEnabled() + { + return $this->data_boost_enabled; + } + + /** + * If this is for a partitioned read and this field is set to `true`, the + * request is executed with Spanner Data Boost independent compute resources. + * If the field is set to `true` but the request does not set + * `partition_token`, the API returns an `INVALID_ARGUMENT` error. + * + * Generated from protobuf field bool data_boost_enabled = 15; + * @param bool $var + * @return $this + */ + public function setDataBoostEnabled($var) + { + GPBUtil::checkBool($var); + $this->data_boost_enabled = $var; + + return $this; + } + + /** + * Optional. Order for the returned rows. + * By default, Spanner will return result rows in primary key order except for + * PartitionRead requests. For applications that do not require rows to be + * returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting + * `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval, + * resulting in lower latencies in certain cases (e.g. bulk point lookups). + * + * Generated from protobuf field .google.spanner.v1.ReadRequest.OrderBy order_by = 16 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getOrderBy() + { + return $this->order_by; + } + + /** + * Optional. Order for the returned rows. + * By default, Spanner will return result rows in primary key order except for + * PartitionRead requests. For applications that do not require rows to be + * returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting + * `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval, + * resulting in lower latencies in certain cases (e.g. bulk point lookups). + * + * Generated from protobuf field .google.spanner.v1.ReadRequest.OrderBy order_by = 16 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setOrderBy($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\V1\ReadRequest\OrderBy::class); + $this->order_by = $var; + + return $this; + } + + /** + * Optional. Lock Hint for the request, it can only be used with read-write + * transactions. + * + * Generated from protobuf field .google.spanner.v1.ReadRequest.LockHint lock_hint = 17 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getLockHint() + { + return $this->lock_hint; + } + + /** + * Optional. Lock Hint for the request, it can only be used with read-write + * transactions. + * + * Generated from protobuf field .google.spanner.v1.ReadRequest.LockHint lock_hint = 17 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setLockHint($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\V1\ReadRequest\LockHint::class); + $this->lock_hint = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ReadRequest/LockHint.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ReadRequest/LockHint.php new file mode 100644 index 000000000000..c0e38b196dbf --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ReadRequest/LockHint.php @@ -0,0 +1,95 @@ +google.spanner.v1.ReadRequest.LockHint + */ +class LockHint +{ + /** + * Default value. + * LOCK_HINT_UNSPECIFIED is equivalent to LOCK_HINT_SHARED. + * + * Generated from protobuf enum LOCK_HINT_UNSPECIFIED = 0; + */ + const LOCK_HINT_UNSPECIFIED = 0; + /** + * Acquire shared locks. + * By default when you perform a read as part of a read-write transaction, + * Spanner acquires shared read locks, which allows other reads to still + * access the data until your transaction is ready to commit. When your + * transaction is committing and writes are being applied, the transaction + * attempts to upgrade to an exclusive lock for any data you are writing. + * For more information about locks, see [Lock + * modes](https://cloud.google.com/spanner/docs/introspection/lock-statistics#explain-lock-modes). + * + * Generated from protobuf enum LOCK_HINT_SHARED = 1; + */ + const LOCK_HINT_SHARED = 1; + /** + * Acquire exclusive locks. + * Requesting exclusive locks is beneficial if you observe high write + * contention, which means you notice that multiple transactions are + * concurrently trying to read and write to the same data, resulting in a + * large number of aborts. This problem occurs when two transactions + * initially acquire shared locks and then both try to upgrade to exclusive + * locks at the same time. In this situation both transactions are waiting + * for the other to give up their lock, resulting in a deadlocked situation. + * Spanner is able to detect this occurring and force one of the + * transactions to abort. However, this is a slow and expensive operation + * and results in lower performance. In this case it makes sense to acquire + * exclusive locks at the start of the transaction because then when + * multiple transactions try to act on the same data, they automatically get + * serialized. Each transaction waits its turn to acquire the lock and + * avoids getting into deadlock situations. + * Because the exclusive lock hint is just a hint, it should not be + * considered equivalent to a mutex. In other words, you should not use + * Spanner exclusive locks as a mutual exclusion mechanism for the execution + * of code outside of Spanner. + * **Note:** Request exclusive locks judiciously because they block others + * from reading that data for the entire transaction, rather than just when + * the writes are being performed. Unless you observe high write contention, + * you should use the default of shared read locks so you don't prematurely + * block other clients from reading the data that you're writing to. + * + * Generated from protobuf enum LOCK_HINT_EXCLUSIVE = 2; + */ + const LOCK_HINT_EXCLUSIVE = 2; + + private static $valueToName = [ + self::LOCK_HINT_UNSPECIFIED => 'LOCK_HINT_UNSPECIFIED', + self::LOCK_HINT_SHARED => 'LOCK_HINT_SHARED', + self::LOCK_HINT_EXCLUSIVE => 'LOCK_HINT_EXCLUSIVE', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(LockHint::class, \Google\Cloud\Spanner\V1\ReadRequest_LockHint::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ReadRequest/OrderBy.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ReadRequest/OrderBy.php new file mode 100644 index 000000000000..4a229a9738f2 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ReadRequest/OrderBy.php @@ -0,0 +1,67 @@ +google.spanner.v1.ReadRequest.OrderBy + */ +class OrderBy +{ + /** + * Default value. + * ORDER_BY_UNSPECIFIED is equivalent to ORDER_BY_PRIMARY_KEY. + * + * Generated from protobuf enum ORDER_BY_UNSPECIFIED = 0; + */ + const ORDER_BY_UNSPECIFIED = 0; + /** + * Read rows are returned in primary key order. + * In the event that this option is used in conjunction with the + * `partition_token` field, the API will return an `INVALID_ARGUMENT` error. + * + * Generated from protobuf enum ORDER_BY_PRIMARY_KEY = 1; + */ + const ORDER_BY_PRIMARY_KEY = 1; + /** + * Read rows are returned in any order. + * + * Generated from protobuf enum ORDER_BY_NO_ORDER = 2; + */ + const ORDER_BY_NO_ORDER = 2; + + private static $valueToName = [ + self::ORDER_BY_UNSPECIFIED => 'ORDER_BY_UNSPECIFIED', + self::ORDER_BY_PRIMARY_KEY => 'ORDER_BY_PRIMARY_KEY', + self::ORDER_BY_NO_ORDER => 'ORDER_BY_NO_ORDER', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(OrderBy::class, \Google\Cloud\Spanner\V1\ReadRequest_OrderBy::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/RequestOptions.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/RequestOptions.php new file mode 100644 index 000000000000..1b2cd281d004 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/RequestOptions.php @@ -0,0 +1,211 @@ +google.spanner.v1.RequestOptions + */ +class RequestOptions extends \Google\Protobuf\Internal\Message +{ + /** + * Priority for the request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions.Priority priority = 1; + */ + protected $priority = 0; + /** + * A per-request tag which can be applied to queries or reads, used for + * statistics collection. + * Both request_tag and transaction_tag can be specified for a read or query + * that belongs to a transaction. + * This field is ignored for requests where it's not applicable (e.g. + * CommitRequest). + * Legal characters for `request_tag` values are all printable characters + * (ASCII 32 - 126) and the length of a request_tag is limited to 50 + * characters. Values that exceed this limit are truncated. + * Any leading underscore (_) characters will be removed from the string. + * + * Generated from protobuf field string request_tag = 2; + */ + protected $request_tag = ''; + /** + * A tag used for statistics collection about this transaction. + * Both request_tag and transaction_tag can be specified for a read or query + * that belongs to a transaction. + * The value of transaction_tag should be the same for all requests belonging + * to the same transaction. + * If this request doesn't belong to any transaction, transaction_tag will be + * ignored. + * Legal characters for `transaction_tag` values are all printable characters + * (ASCII 32 - 126) and the length of a transaction_tag is limited to 50 + * characters. Values that exceed this limit are truncated. + * Any leading underscore (_) characters will be removed from the string. + * + * Generated from protobuf field string transaction_tag = 3; + */ + protected $transaction_tag = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $priority + * Priority for the request. + * @type string $request_tag + * A per-request tag which can be applied to queries or reads, used for + * statistics collection. + * Both request_tag and transaction_tag can be specified for a read or query + * that belongs to a transaction. + * This field is ignored for requests where it's not applicable (e.g. + * CommitRequest). + * Legal characters for `request_tag` values are all printable characters + * (ASCII 32 - 126) and the length of a request_tag is limited to 50 + * characters. Values that exceed this limit are truncated. + * Any leading underscore (_) characters will be removed from the string. + * @type string $transaction_tag + * A tag used for statistics collection about this transaction. + * Both request_tag and transaction_tag can be specified for a read or query + * that belongs to a transaction. + * The value of transaction_tag should be the same for all requests belonging + * to the same transaction. + * If this request doesn't belong to any transaction, transaction_tag will be + * ignored. + * Legal characters for `transaction_tag` values are all printable characters + * (ASCII 32 - 126) and the length of a transaction_tag is limited to 50 + * characters. Values that exceed this limit are truncated. + * Any leading underscore (_) characters will be removed from the string. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Priority for the request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions.Priority priority = 1; + * @return int + */ + public function getPriority() + { + return $this->priority; + } + + /** + * Priority for the request. + * + * Generated from protobuf field .google.spanner.v1.RequestOptions.Priority priority = 1; + * @param int $var + * @return $this + */ + public function setPriority($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\V1\RequestOptions\Priority::class); + $this->priority = $var; + + return $this; + } + + /** + * A per-request tag which can be applied to queries or reads, used for + * statistics collection. + * Both request_tag and transaction_tag can be specified for a read or query + * that belongs to a transaction. + * This field is ignored for requests where it's not applicable (e.g. + * CommitRequest). + * Legal characters for `request_tag` values are all printable characters + * (ASCII 32 - 126) and the length of a request_tag is limited to 50 + * characters. Values that exceed this limit are truncated. + * Any leading underscore (_) characters will be removed from the string. + * + * Generated from protobuf field string request_tag = 2; + * @return string + */ + public function getRequestTag() + { + return $this->request_tag; + } + + /** + * A per-request tag which can be applied to queries or reads, used for + * statistics collection. + * Both request_tag and transaction_tag can be specified for a read or query + * that belongs to a transaction. + * This field is ignored for requests where it's not applicable (e.g. + * CommitRequest). + * Legal characters for `request_tag` values are all printable characters + * (ASCII 32 - 126) and the length of a request_tag is limited to 50 + * characters. Values that exceed this limit are truncated. + * Any leading underscore (_) characters will be removed from the string. + * + * Generated from protobuf field string request_tag = 2; + * @param string $var + * @return $this + */ + public function setRequestTag($var) + { + GPBUtil::checkString($var, True); + $this->request_tag = $var; + + return $this; + } + + /** + * A tag used for statistics collection about this transaction. + * Both request_tag and transaction_tag can be specified for a read or query + * that belongs to a transaction. + * The value of transaction_tag should be the same for all requests belonging + * to the same transaction. + * If this request doesn't belong to any transaction, transaction_tag will be + * ignored. + * Legal characters for `transaction_tag` values are all printable characters + * (ASCII 32 - 126) and the length of a transaction_tag is limited to 50 + * characters. Values that exceed this limit are truncated. + * Any leading underscore (_) characters will be removed from the string. + * + * Generated from protobuf field string transaction_tag = 3; + * @return string + */ + public function getTransactionTag() + { + return $this->transaction_tag; + } + + /** + * A tag used for statistics collection about this transaction. + * Both request_tag and transaction_tag can be specified for a read or query + * that belongs to a transaction. + * The value of transaction_tag should be the same for all requests belonging + * to the same transaction. + * If this request doesn't belong to any transaction, transaction_tag will be + * ignored. + * Legal characters for `transaction_tag` values are all printable characters + * (ASCII 32 - 126) and the length of a transaction_tag is limited to 50 + * characters. Values that exceed this limit are truncated. + * Any leading underscore (_) characters will be removed from the string. + * + * Generated from protobuf field string transaction_tag = 3; + * @param string $var + * @return $this + */ + public function setTransactionTag($var) + { + GPBUtil::checkString($var, True); + $this->transaction_tag = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/RequestOptions/Priority.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/RequestOptions/Priority.php new file mode 100644 index 000000000000..b8d614f98da5 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/RequestOptions/Priority.php @@ -0,0 +1,84 @@ +google.spanner.v1.RequestOptions.Priority + */ +class Priority +{ + /** + * `PRIORITY_UNSPECIFIED` is equivalent to `PRIORITY_HIGH`. + * + * Generated from protobuf enum PRIORITY_UNSPECIFIED = 0; + */ + const PRIORITY_UNSPECIFIED = 0; + /** + * This specifies that the request is low priority. + * + * Generated from protobuf enum PRIORITY_LOW = 1; + */ + const PRIORITY_LOW = 1; + /** + * This specifies that the request is medium priority. + * + * Generated from protobuf enum PRIORITY_MEDIUM = 2; + */ + const PRIORITY_MEDIUM = 2; + /** + * This specifies that the request is high priority. + * + * Generated from protobuf enum PRIORITY_HIGH = 3; + */ + const PRIORITY_HIGH = 3; + + private static $valueToName = [ + self::PRIORITY_UNSPECIFIED => 'PRIORITY_UNSPECIFIED', + self::PRIORITY_LOW => 'PRIORITY_LOW', + self::PRIORITY_MEDIUM => 'PRIORITY_MEDIUM', + self::PRIORITY_HIGH => 'PRIORITY_HIGH', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Priority::class, \Google\Cloud\Spanner\V1\RequestOptions_Priority::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ResultSet.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ResultSet.php new file mode 100644 index 000000000000..af4bbe1996f0 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ResultSet.php @@ -0,0 +1,272 @@ +google.spanner.v1.ResultSet + */ +class ResultSet extends \Google\Protobuf\Internal\Message +{ + /** + * Metadata about the result set, such as row type information. + * + * Generated from protobuf field .google.spanner.v1.ResultSetMetadata metadata = 1; + */ + protected $metadata = null; + /** + * Each element in `rows` is a row whose format is defined by + * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith element + * in each row matches the ith field in + * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements are + * encoded based on type as described + * [here][google.spanner.v1.TypeCode]. + * + * Generated from protobuf field repeated .google.protobuf.ListValue rows = 2; + */ + private $rows; + /** + * Query plan and execution statistics for the SQL statement that + * produced this result set. These can be requested by setting + * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. + * DML statements always produce stats containing the number of rows + * modified, unless executed using the + * [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN] [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. + * Other fields may or may not be populated, based on the + * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. + * + * Generated from protobuf field .google.spanner.v1.ResultSetStats stats = 3; + */ + protected $stats = null; + /** + * Optional. A precommit token will be included if the read-write transaction + * is on a multiplexed session. + * The precommit token with the highest sequence number from this transaction + * attempt should be passed to the + * [Commit][google.spanner.v1.Spanner.Commit] request for this transaction. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.MultiplexedSessionPrecommitToken precommit_token = 5 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $precommit_token = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\V1\ResultSetMetadata $metadata + * Metadata about the result set, such as row type information. + * @type array<\Google\Protobuf\ListValue>|\Google\Protobuf\Internal\RepeatedField $rows + * Each element in `rows` is a row whose format is defined by + * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith element + * in each row matches the ith field in + * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements are + * encoded based on type as described + * [here][google.spanner.v1.TypeCode]. + * @type \Google\Cloud\Spanner\V1\ResultSetStats $stats + * Query plan and execution statistics for the SQL statement that + * produced this result set. These can be requested by setting + * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. + * DML statements always produce stats containing the number of rows + * modified, unless executed using the + * [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN] [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. + * Other fields may or may not be populated, based on the + * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. + * @type \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken $precommit_token + * Optional. A precommit token will be included if the read-write transaction + * is on a multiplexed session. + * The precommit token with the highest sequence number from this transaction + * attempt should be passed to the + * [Commit][google.spanner.v1.Spanner.Commit] request for this transaction. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\ResultSet::initOnce(); + parent::__construct($data); + } + + /** + * Metadata about the result set, such as row type information. + * + * Generated from protobuf field .google.spanner.v1.ResultSetMetadata metadata = 1; + * @return \Google\Cloud\Spanner\V1\ResultSetMetadata|null + */ + public function getMetadata() + { + return $this->metadata; + } + + public function hasMetadata() + { + return isset($this->metadata); + } + + public function clearMetadata() + { + unset($this->metadata); + } + + /** + * Metadata about the result set, such as row type information. + * + * Generated from protobuf field .google.spanner.v1.ResultSetMetadata metadata = 1; + * @param \Google\Cloud\Spanner\V1\ResultSetMetadata $var + * @return $this + */ + public function setMetadata($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\ResultSetMetadata::class); + $this->metadata = $var; + + return $this; + } + + /** + * Each element in `rows` is a row whose format is defined by + * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith element + * in each row matches the ith field in + * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements are + * encoded based on type as described + * [here][google.spanner.v1.TypeCode]. + * + * Generated from protobuf field repeated .google.protobuf.ListValue rows = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getRows() + { + return $this->rows; + } + + /** + * Each element in `rows` is a row whose format is defined by + * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith element + * in each row matches the ith field in + * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements are + * encoded based on type as described + * [here][google.spanner.v1.TypeCode]. + * + * Generated from protobuf field repeated .google.protobuf.ListValue rows = 2; + * @param array<\Google\Protobuf\ListValue>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setRows($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\ListValue::class); + $this->rows = $arr; + + return $this; + } + + /** + * Query plan and execution statistics for the SQL statement that + * produced this result set. These can be requested by setting + * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. + * DML statements always produce stats containing the number of rows + * modified, unless executed using the + * [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN] [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. + * Other fields may or may not be populated, based on the + * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. + * + * Generated from protobuf field .google.spanner.v1.ResultSetStats stats = 3; + * @return \Google\Cloud\Spanner\V1\ResultSetStats|null + */ + public function getStats() + { + return $this->stats; + } + + public function hasStats() + { + return isset($this->stats); + } + + public function clearStats() + { + unset($this->stats); + } + + /** + * Query plan and execution statistics for the SQL statement that + * produced this result set. These can be requested by setting + * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. + * DML statements always produce stats containing the number of rows + * modified, unless executed using the + * [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN] [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. + * Other fields may or may not be populated, based on the + * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. + * + * Generated from protobuf field .google.spanner.v1.ResultSetStats stats = 3; + * @param \Google\Cloud\Spanner\V1\ResultSetStats $var + * @return $this + */ + public function setStats($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\ResultSetStats::class); + $this->stats = $var; + + return $this; + } + + /** + * Optional. A precommit token will be included if the read-write transaction + * is on a multiplexed session. + * The precommit token with the highest sequence number from this transaction + * attempt should be passed to the + * [Commit][google.spanner.v1.Spanner.Commit] request for this transaction. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.MultiplexedSessionPrecommitToken precommit_token = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken|null + */ + public function getPrecommitToken() + { + return $this->precommit_token; + } + + public function hasPrecommitToken() + { + return isset($this->precommit_token); + } + + public function clearPrecommitToken() + { + unset($this->precommit_token); + } + + /** + * Optional. A precommit token will be included if the read-write transaction + * is on a multiplexed session. + * The precommit token with the highest sequence number from this transaction + * attempt should be passed to the + * [Commit][google.spanner.v1.Spanner.Commit] request for this transaction. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.MultiplexedSessionPrecommitToken precommit_token = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken $var + * @return $this + */ + public function setPrecommitToken($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken::class); + $this->precommit_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ResultSetMetadata.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ResultSetMetadata.php new file mode 100644 index 000000000000..fac10e18e680 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ResultSetMetadata.php @@ -0,0 +1,225 @@ +google.spanner.v1.ResultSetMetadata + */ +class ResultSetMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * Indicates the field names and types for the rows in the result + * set. For example, a SQL query like `"SELECT UserId, UserName FROM + * Users"` could return a `row_type` value like: + * "fields": [ + * { "name": "UserId", "type": { "code": "INT64" } }, + * { "name": "UserName", "type": { "code": "STRING" } }, + * ] + * + * Generated from protobuf field .google.spanner.v1.StructType row_type = 1; + */ + protected $row_type = null; + /** + * If the read or SQL query began a transaction as a side-effect, the + * information about the new transaction is yielded here. + * + * Generated from protobuf field .google.spanner.v1.Transaction transaction = 2; + */ + protected $transaction = null; + /** + * A SQL query can be parameterized. In PLAN mode, these parameters can be + * undeclared. This indicates the field names and types for those undeclared + * parameters in the SQL query. For example, a SQL query like `"SELECT * FROM + * Users where UserId = @userId and UserName = @userName "` could return a + * `undeclared_parameters` value like: + * "fields": [ + * { "name": "UserId", "type": { "code": "INT64" } }, + * { "name": "UserName", "type": { "code": "STRING" } }, + * ] + * + * Generated from protobuf field .google.spanner.v1.StructType undeclared_parameters = 3; + */ + protected $undeclared_parameters = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\V1\StructType $row_type + * Indicates the field names and types for the rows in the result + * set. For example, a SQL query like `"SELECT UserId, UserName FROM + * Users"` could return a `row_type` value like: + * "fields": [ + * { "name": "UserId", "type": { "code": "INT64" } }, + * { "name": "UserName", "type": { "code": "STRING" } }, + * ] + * @type \Google\Cloud\Spanner\V1\Transaction $transaction + * If the read or SQL query began a transaction as a side-effect, the + * information about the new transaction is yielded here. + * @type \Google\Cloud\Spanner\V1\StructType $undeclared_parameters + * A SQL query can be parameterized. In PLAN mode, these parameters can be + * undeclared. This indicates the field names and types for those undeclared + * parameters in the SQL query. For example, a SQL query like `"SELECT * FROM + * Users where UserId = @userId and UserName = @userName "` could return a + * `undeclared_parameters` value like: + * "fields": [ + * { "name": "UserId", "type": { "code": "INT64" } }, + * { "name": "UserName", "type": { "code": "STRING" } }, + * ] + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\ResultSet::initOnce(); + parent::__construct($data); + } + + /** + * Indicates the field names and types for the rows in the result + * set. For example, a SQL query like `"SELECT UserId, UserName FROM + * Users"` could return a `row_type` value like: + * "fields": [ + * { "name": "UserId", "type": { "code": "INT64" } }, + * { "name": "UserName", "type": { "code": "STRING" } }, + * ] + * + * Generated from protobuf field .google.spanner.v1.StructType row_type = 1; + * @return \Google\Cloud\Spanner\V1\StructType|null + */ + public function getRowType() + { + return $this->row_type; + } + + public function hasRowType() + { + return isset($this->row_type); + } + + public function clearRowType() + { + unset($this->row_type); + } + + /** + * Indicates the field names and types for the rows in the result + * set. For example, a SQL query like `"SELECT UserId, UserName FROM + * Users"` could return a `row_type` value like: + * "fields": [ + * { "name": "UserId", "type": { "code": "INT64" } }, + * { "name": "UserName", "type": { "code": "STRING" } }, + * ] + * + * Generated from protobuf field .google.spanner.v1.StructType row_type = 1; + * @param \Google\Cloud\Spanner\V1\StructType $var + * @return $this + */ + public function setRowType($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\StructType::class); + $this->row_type = $var; + + return $this; + } + + /** + * If the read or SQL query began a transaction as a side-effect, the + * information about the new transaction is yielded here. + * + * Generated from protobuf field .google.spanner.v1.Transaction transaction = 2; + * @return \Google\Cloud\Spanner\V1\Transaction|null + */ + public function getTransaction() + { + return $this->transaction; + } + + public function hasTransaction() + { + return isset($this->transaction); + } + + public function clearTransaction() + { + unset($this->transaction); + } + + /** + * If the read or SQL query began a transaction as a side-effect, the + * information about the new transaction is yielded here. + * + * Generated from protobuf field .google.spanner.v1.Transaction transaction = 2; + * @param \Google\Cloud\Spanner\V1\Transaction $var + * @return $this + */ + public function setTransaction($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\Transaction::class); + $this->transaction = $var; + + return $this; + } + + /** + * A SQL query can be parameterized. In PLAN mode, these parameters can be + * undeclared. This indicates the field names and types for those undeclared + * parameters in the SQL query. For example, a SQL query like `"SELECT * FROM + * Users where UserId = @userId and UserName = @userName "` could return a + * `undeclared_parameters` value like: + * "fields": [ + * { "name": "UserId", "type": { "code": "INT64" } }, + * { "name": "UserName", "type": { "code": "STRING" } }, + * ] + * + * Generated from protobuf field .google.spanner.v1.StructType undeclared_parameters = 3; + * @return \Google\Cloud\Spanner\V1\StructType|null + */ + public function getUndeclaredParameters() + { + return $this->undeclared_parameters; + } + + public function hasUndeclaredParameters() + { + return isset($this->undeclared_parameters); + } + + public function clearUndeclaredParameters() + { + unset($this->undeclared_parameters); + } + + /** + * A SQL query can be parameterized. In PLAN mode, these parameters can be + * undeclared. This indicates the field names and types for those undeclared + * parameters in the SQL query. For example, a SQL query like `"SELECT * FROM + * Users where UserId = @userId and UserName = @userName "` could return a + * `undeclared_parameters` value like: + * "fields": [ + * { "name": "UserId", "type": { "code": "INT64" } }, + * { "name": "UserName", "type": { "code": "STRING" } }, + * ] + * + * Generated from protobuf field .google.spanner.v1.StructType undeclared_parameters = 3; + * @param \Google\Cloud\Spanner\V1\StructType $var + * @return $this + */ + public function setUndeclaredParameters($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\StructType::class); + $this->undeclared_parameters = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ResultSetStats.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ResultSetStats.php new file mode 100644 index 000000000000..e39cc1952951 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/ResultSetStats.php @@ -0,0 +1,227 @@ +google.spanner.v1.ResultSetStats + */ +class ResultSetStats extends \Google\Protobuf\Internal\Message +{ + /** + * [QueryPlan][google.spanner.v1.QueryPlan] for the query associated with this result. + * + * Generated from protobuf field .google.spanner.v1.QueryPlan query_plan = 1; + */ + protected $query_plan = null; + /** + * Aggregated statistics from the execution of the query. Only present when + * the query is profiled. For example, a query could return the statistics as + * follows: + * { + * "rows_returned": "3", + * "elapsed_time": "1.22 secs", + * "cpu_time": "1.19 secs" + * } + * + * Generated from protobuf field .google.protobuf.Struct query_stats = 2; + */ + protected $query_stats = null; + protected $row_count; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\V1\QueryPlan $query_plan + * [QueryPlan][google.spanner.v1.QueryPlan] for the query associated with this result. + * @type \Google\Protobuf\Struct $query_stats + * Aggregated statistics from the execution of the query. Only present when + * the query is profiled. For example, a query could return the statistics as + * follows: + * { + * "rows_returned": "3", + * "elapsed_time": "1.22 secs", + * "cpu_time": "1.19 secs" + * } + * @type int|string $row_count_exact + * Standard DML returns an exact count of rows that were modified. + * @type int|string $row_count_lower_bound + * Partitioned DML does not offer exactly-once semantics, so it + * returns a lower bound of the rows modified. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\ResultSet::initOnce(); + parent::__construct($data); + } + + /** + * [QueryPlan][google.spanner.v1.QueryPlan] for the query associated with this result. + * + * Generated from protobuf field .google.spanner.v1.QueryPlan query_plan = 1; + * @return \Google\Cloud\Spanner\V1\QueryPlan|null + */ + public function getQueryPlan() + { + return $this->query_plan; + } + + public function hasQueryPlan() + { + return isset($this->query_plan); + } + + public function clearQueryPlan() + { + unset($this->query_plan); + } + + /** + * [QueryPlan][google.spanner.v1.QueryPlan] for the query associated with this result. + * + * Generated from protobuf field .google.spanner.v1.QueryPlan query_plan = 1; + * @param \Google\Cloud\Spanner\V1\QueryPlan $var + * @return $this + */ + public function setQueryPlan($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\QueryPlan::class); + $this->query_plan = $var; + + return $this; + } + + /** + * Aggregated statistics from the execution of the query. Only present when + * the query is profiled. For example, a query could return the statistics as + * follows: + * { + * "rows_returned": "3", + * "elapsed_time": "1.22 secs", + * "cpu_time": "1.19 secs" + * } + * + * Generated from protobuf field .google.protobuf.Struct query_stats = 2; + * @return \Google\Protobuf\Struct|null + */ + public function getQueryStats() + { + return $this->query_stats; + } + + public function hasQueryStats() + { + return isset($this->query_stats); + } + + public function clearQueryStats() + { + unset($this->query_stats); + } + + /** + * Aggregated statistics from the execution of the query. Only present when + * the query is profiled. For example, a query could return the statistics as + * follows: + * { + * "rows_returned": "3", + * "elapsed_time": "1.22 secs", + * "cpu_time": "1.19 secs" + * } + * + * Generated from protobuf field .google.protobuf.Struct query_stats = 2; + * @param \Google\Protobuf\Struct $var + * @return $this + */ + public function setQueryStats($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Struct::class); + $this->query_stats = $var; + + return $this; + } + + /** + * Standard DML returns an exact count of rows that were modified. + * + * Generated from protobuf field int64 row_count_exact = 3; + * @return int|string + */ + public function getRowCountExact() + { + return $this->readOneof(3); + } + + public function hasRowCountExact() + { + return $this->hasOneof(3); + } + + /** + * Standard DML returns an exact count of rows that were modified. + * + * Generated from protobuf field int64 row_count_exact = 3; + * @param int|string $var + * @return $this + */ + public function setRowCountExact($var) + { + GPBUtil::checkInt64($var); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * Partitioned DML does not offer exactly-once semantics, so it + * returns a lower bound of the rows modified. + * + * Generated from protobuf field int64 row_count_lower_bound = 4; + * @return int|string + */ + public function getRowCountLowerBound() + { + return $this->readOneof(4); + } + + public function hasRowCountLowerBound() + { + return $this->hasOneof(4); + } + + /** + * Partitioned DML does not offer exactly-once semantics, so it + * returns a lower bound of the rows modified. + * + * Generated from protobuf field int64 row_count_lower_bound = 4; + * @param int|string $var + * @return $this + */ + public function setRowCountLowerBound($var) + { + GPBUtil::checkInt64($var); + $this->writeOneof(4, $var); + + return $this; + } + + /** + * @return string + */ + public function getRowCount() + { + return $this->whichOneof("row_count"); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/RollbackRequest.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/RollbackRequest.php new file mode 100644 index 000000000000..23129ad2e295 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/RollbackRequest.php @@ -0,0 +1,117 @@ +google.spanner.v1.RollbackRequest + */ +class RollbackRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The session in which the transaction to roll back is running. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $session = ''; + /** + * Required. The transaction to roll back. + * + * Generated from protobuf field bytes transaction_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $transaction_id = ''; + + /** + * @param string $session Required. The session in which the transaction to roll back is running. Please see + * {@see SpannerClient::sessionName()} for help formatting this field. + * @param string $transactionId Required. The transaction to roll back. + * + * @return \Google\Cloud\Spanner\V1\RollbackRequest + * + * @experimental + */ + public static function build(string $session, string $transactionId): self + { + return (new self()) + ->setSession($session) + ->setTransactionId($transactionId); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $session + * Required. The session in which the transaction to roll back is running. + * @type string $transaction_id + * Required. The transaction to roll back. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Required. The session in which the transaction to roll back is running. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getSession() + { + return $this->session; + } + + /** + * Required. The session in which the transaction to roll back is running. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setSession($var) + { + GPBUtil::checkString($var, True); + $this->session = $var; + + return $this; + } + + /** + * Required. The transaction to roll back. + * + * Generated from protobuf field bytes transaction_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getTransactionId() + { + return $this->transaction_id; + } + + /** + * Required. The transaction to roll back. + * + * Generated from protobuf field bytes transaction_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setTransactionId($var) + { + GPBUtil::checkString($var, False); + $this->transaction_id = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Session.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Session.php new file mode 100644 index 000000000000..772272bb851a --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Session.php @@ -0,0 +1,309 @@ +google.spanner.v1.Session + */ +class Session extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. The name of the session. This is always system-assigned. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $name = ''; + /** + * The labels for the session. + * * Label keys must be between 1 and 63 characters long and must conform to + * the following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`. + * * Label values must be between 0 and 63 characters long and must conform + * to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`. + * * No more than 64 labels can be associated with a given session. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * + * Generated from protobuf field map labels = 2; + */ + private $labels; + /** + * Output only. The timestamp when the session is created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $create_time = null; + /** + * Output only. The approximate timestamp when the session is last used. It is + * typically earlier than the actual last use time. + * + * Generated from protobuf field .google.protobuf.Timestamp approximate_last_use_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $approximate_last_use_time = null; + /** + * The database role which created this session. + * + * Generated from protobuf field string creator_role = 5; + */ + protected $creator_role = ''; + /** + * Optional. If true, specifies a multiplexed session. A multiplexed session + * may be used for multiple, concurrent read-only operations but can not be + * used for read-write transactions, partitioned reads, or partitioned + * queries. Multiplexed sessions can be created via + * [CreateSession][google.spanner.v1.Spanner.CreateSession] but not via + * [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions]. + * Multiplexed sessions may not be deleted nor listed. + * + * Generated from protobuf field bool multiplexed = 6 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $multiplexed = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Output only. The name of the session. This is always system-assigned. + * @type array|\Google\Protobuf\Internal\MapField $labels + * The labels for the session. + * * Label keys must be between 1 and 63 characters long and must conform to + * the following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`. + * * Label values must be between 0 and 63 characters long and must conform + * to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`. + * * No more than 64 labels can be associated with a given session. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. The timestamp when the session is created. + * @type \Google\Protobuf\Timestamp $approximate_last_use_time + * Output only. The approximate timestamp when the session is last used. It is + * typically earlier than the actual last use time. + * @type string $creator_role + * The database role which created this session. + * @type bool $multiplexed + * Optional. If true, specifies a multiplexed session. A multiplexed session + * may be used for multiple, concurrent read-only operations but can not be + * used for read-write transactions, partitioned reads, or partitioned + * queries. Multiplexed sessions can be created via + * [CreateSession][google.spanner.v1.Spanner.CreateSession] but not via + * [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions]. + * Multiplexed sessions may not be deleted nor listed. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Spanner::initOnce(); + parent::__construct($data); + } + + /** + * Output only. The name of the session. This is always system-assigned. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Output only. The name of the session. This is always system-assigned. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * The labels for the session. + * * Label keys must be between 1 and 63 characters long and must conform to + * the following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`. + * * Label values must be between 0 and 63 characters long and must conform + * to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`. + * * No more than 64 labels can be associated with a given session. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * + * Generated from protobuf field map labels = 2; + * @return \Google\Protobuf\Internal\MapField + */ + public function getLabels() + { + return $this->labels; + } + + /** + * The labels for the session. + * * Label keys must be between 1 and 63 characters long and must conform to + * the following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`. + * * Label values must be between 0 and 63 characters long and must conform + * to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`. + * * No more than 64 labels can be associated with a given session. + * See https://goo.gl/xmQnxf for more information on and examples of labels. + * + * Generated from protobuf field map labels = 2; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setLabels($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->labels = $arr; + + return $this; + } + + /** + * Output only. The timestamp when the session is created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + + /** + * Output only. The timestamp when the session is created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Output only. The approximate timestamp when the session is last used. It is + * typically earlier than the actual last use time. + * + * Generated from protobuf field .google.protobuf.Timestamp approximate_last_use_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getApproximateLastUseTime() + { + return $this->approximate_last_use_time; + } + + public function hasApproximateLastUseTime() + { + return isset($this->approximate_last_use_time); + } + + public function clearApproximateLastUseTime() + { + unset($this->approximate_last_use_time); + } + + /** + * Output only. The approximate timestamp when the session is last used. It is + * typically earlier than the actual last use time. + * + * Generated from protobuf field .google.protobuf.Timestamp approximate_last_use_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setApproximateLastUseTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->approximate_last_use_time = $var; + + return $this; + } + + /** + * The database role which created this session. + * + * Generated from protobuf field string creator_role = 5; + * @return string + */ + public function getCreatorRole() + { + return $this->creator_role; + } + + /** + * The database role which created this session. + * + * Generated from protobuf field string creator_role = 5; + * @param string $var + * @return $this + */ + public function setCreatorRole($var) + { + GPBUtil::checkString($var, True); + $this->creator_role = $var; + + return $this; + } + + /** + * Optional. If true, specifies a multiplexed session. A multiplexed session + * may be used for multiple, concurrent read-only operations but can not be + * used for read-write transactions, partitioned reads, or partitioned + * queries. Multiplexed sessions can be created via + * [CreateSession][google.spanner.v1.Spanner.CreateSession] but not via + * [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions]. + * Multiplexed sessions may not be deleted nor listed. + * + * Generated from protobuf field bool multiplexed = 6 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getMultiplexed() + { + return $this->multiplexed; + } + + /** + * Optional. If true, specifies a multiplexed session. A multiplexed session + * may be used for multiple, concurrent read-only operations but can not be + * used for read-write transactions, partitioned reads, or partitioned + * queries. Multiplexed sessions can be created via + * [CreateSession][google.spanner.v1.Spanner.CreateSession] but not via + * [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions]. + * Multiplexed sessions may not be deleted nor listed. + * + * Generated from protobuf field bool multiplexed = 6 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setMultiplexed($var) + { + GPBUtil::checkBool($var); + $this->multiplexed = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/StructType.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/StructType.php new file mode 100644 index 000000000000..a67da0c0d598 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/StructType.php @@ -0,0 +1,88 @@ +google.spanner.v1.StructType + */ +class StructType extends \Google\Protobuf\Internal\Message +{ + /** + * The list of fields that make up this struct. Order is + * significant, because values of this struct type are represented as + * lists, where the order of field values matches the order of + * fields in the [StructType][google.spanner.v1.StructType]. In turn, the + * order of fields matches the order of columns in a read request, or the + * order of fields in the `SELECT` clause of a query. + * + * Generated from protobuf field repeated .google.spanner.v1.StructType.Field fields = 1; + */ + private $fields; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Spanner\V1\StructType\Field>|\Google\Protobuf\Internal\RepeatedField $fields + * The list of fields that make up this struct. Order is + * significant, because values of this struct type are represented as + * lists, where the order of field values matches the order of + * fields in the [StructType][google.spanner.v1.StructType]. In turn, the + * order of fields matches the order of columns in a read request, or the + * order of fields in the `SELECT` clause of a query. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Type::initOnce(); + parent::__construct($data); + } + + /** + * The list of fields that make up this struct. Order is + * significant, because values of this struct type are represented as + * lists, where the order of field values matches the order of + * fields in the [StructType][google.spanner.v1.StructType]. In turn, the + * order of fields matches the order of columns in a read request, or the + * order of fields in the `SELECT` clause of a query. + * + * Generated from protobuf field repeated .google.spanner.v1.StructType.Field fields = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getFields() + { + return $this->fields; + } + + /** + * The list of fields that make up this struct. Order is + * significant, because values of this struct type are represented as + * lists, where the order of field values matches the order of + * fields in the [StructType][google.spanner.v1.StructType]. In turn, the + * order of fields matches the order of columns in a read request, or the + * order of fields in the `SELECT` clause of a query. + * + * Generated from protobuf field repeated .google.spanner.v1.StructType.Field fields = 1; + * @param array<\Google\Cloud\Spanner\V1\StructType\Field>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setFields($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\StructType\Field::class); + $this->fields = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/StructType/Field.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/StructType/Field.php new file mode 100644 index 000000000000..d14de6cea1b3 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/StructType/Field.php @@ -0,0 +1,138 @@ +google.spanner.v1.StructType.Field + */ +class Field extends \Google\Protobuf\Internal\Message +{ + /** + * The name of the field. For reads, this is the column name. For + * SQL queries, it is the column alias (e.g., `"Word"` in the + * query `"SELECT 'hello' AS Word"`), or the column name (e.g., + * `"ColName"` in the query `"SELECT ColName FROM Table"`). Some + * columns might have an empty name (e.g., `"SELECT + * UPPER(ColName)"`). Note that a query result can contain + * multiple fields with the same name. + * + * Generated from protobuf field string name = 1; + */ + protected $name = ''; + /** + * The type of the field. + * + * Generated from protobuf field .google.spanner.v1.Type type = 2; + */ + protected $type = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * The name of the field. For reads, this is the column name. For + * SQL queries, it is the column alias (e.g., `"Word"` in the + * query `"SELECT 'hello' AS Word"`), or the column name (e.g., + * `"ColName"` in the query `"SELECT ColName FROM Table"`). Some + * columns might have an empty name (e.g., `"SELECT + * UPPER(ColName)"`). Note that a query result can contain + * multiple fields with the same name. + * @type \Google\Cloud\Spanner\V1\Type $type + * The type of the field. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Type::initOnce(); + parent::__construct($data); + } + + /** + * The name of the field. For reads, this is the column name. For + * SQL queries, it is the column alias (e.g., `"Word"` in the + * query `"SELECT 'hello' AS Word"`), or the column name (e.g., + * `"ColName"` in the query `"SELECT ColName FROM Table"`). Some + * columns might have an empty name (e.g., `"SELECT + * UPPER(ColName)"`). Note that a query result can contain + * multiple fields with the same name. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The name of the field. For reads, this is the column name. For + * SQL queries, it is the column alias (e.g., `"Word"` in the + * query `"SELECT 'hello' AS Word"`), or the column name (e.g., + * `"ColName"` in the query `"SELECT ColName FROM Table"`). Some + * columns might have an empty name (e.g., `"SELECT + * UPPER(ColName)"`). Note that a query result can contain + * multiple fields with the same name. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * The type of the field. + * + * Generated from protobuf field .google.spanner.v1.Type type = 2; + * @return \Google\Cloud\Spanner\V1\Type|null + */ + public function getType() + { + return $this->type; + } + + public function hasType() + { + return isset($this->type); + } + + public function clearType() + { + unset($this->type); + } + + /** + * The type of the field. + * + * Generated from protobuf field .google.spanner.v1.Type type = 2; + * @param \Google\Cloud\Spanner\V1\Type $var + * @return $this + */ + public function setType($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\Type::class); + $this->type = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Field::class, \Google\Cloud\Spanner\V1\StructType_Field::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Transaction.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Transaction.php new file mode 100644 index 000000000000..6bed7fe90d30 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Transaction.php @@ -0,0 +1,227 @@ +google.spanner.v1.Transaction + */ +class Transaction extends \Google\Protobuf\Internal\Message +{ + /** + * `id` may be used to identify the transaction in subsequent + * [Read][google.spanner.v1.Spanner.Read], + * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], + * [Commit][google.spanner.v1.Spanner.Commit], or + * [Rollback][google.spanner.v1.Spanner.Rollback] calls. + * Single-use read-only transactions do not have IDs, because + * single-use transactions do not support multiple requests. + * + * Generated from protobuf field bytes id = 1; + */ + protected $id = ''; + /** + * For snapshot read-only transactions, the read timestamp chosen + * for the transaction. Not returned by default: see + * [TransactionOptions.ReadOnly.return_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.return_read_timestamp]. + * A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. + * Example: `"2014-10-02T15:01:23.045123456Z"`. + * + * Generated from protobuf field .google.protobuf.Timestamp read_timestamp = 2; + */ + protected $read_timestamp = null; + /** + * A precommit token will be included in the response of a BeginTransaction + * request if the read-write transaction is on a multiplexed session and + * a mutation_key was specified in the + * [BeginTransaction][google.spanner.v1.BeginTransactionRequest]. + * The precommit token with the highest sequence number from this transaction + * attempt should be passed to the [Commit][google.spanner.v1.Spanner.Commit] + * request for this transaction. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.MultiplexedSessionPrecommitToken precommit_token = 3; + */ + protected $precommit_token = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $id + * `id` may be used to identify the transaction in subsequent + * [Read][google.spanner.v1.Spanner.Read], + * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], + * [Commit][google.spanner.v1.Spanner.Commit], or + * [Rollback][google.spanner.v1.Spanner.Rollback] calls. + * Single-use read-only transactions do not have IDs, because + * single-use transactions do not support multiple requests. + * @type \Google\Protobuf\Timestamp $read_timestamp + * For snapshot read-only transactions, the read timestamp chosen + * for the transaction. Not returned by default: see + * [TransactionOptions.ReadOnly.return_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.return_read_timestamp]. + * A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. + * Example: `"2014-10-02T15:01:23.045123456Z"`. + * @type \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken $precommit_token + * A precommit token will be included in the response of a BeginTransaction + * request if the read-write transaction is on a multiplexed session and + * a mutation_key was specified in the + * [BeginTransaction][google.spanner.v1.BeginTransactionRequest]. + * The precommit token with the highest sequence number from this transaction + * attempt should be passed to the [Commit][google.spanner.v1.Spanner.Commit] + * request for this transaction. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Transaction::initOnce(); + parent::__construct($data); + } + + /** + * `id` may be used to identify the transaction in subsequent + * [Read][google.spanner.v1.Spanner.Read], + * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], + * [Commit][google.spanner.v1.Spanner.Commit], or + * [Rollback][google.spanner.v1.Spanner.Rollback] calls. + * Single-use read-only transactions do not have IDs, because + * single-use transactions do not support multiple requests. + * + * Generated from protobuf field bytes id = 1; + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * `id` may be used to identify the transaction in subsequent + * [Read][google.spanner.v1.Spanner.Read], + * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], + * [Commit][google.spanner.v1.Spanner.Commit], or + * [Rollback][google.spanner.v1.Spanner.Rollback] calls. + * Single-use read-only transactions do not have IDs, because + * single-use transactions do not support multiple requests. + * + * Generated from protobuf field bytes id = 1; + * @param string $var + * @return $this + */ + public function setId($var) + { + GPBUtil::checkString($var, False); + $this->id = $var; + + return $this; + } + + /** + * For snapshot read-only transactions, the read timestamp chosen + * for the transaction. Not returned by default: see + * [TransactionOptions.ReadOnly.return_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.return_read_timestamp]. + * A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. + * Example: `"2014-10-02T15:01:23.045123456Z"`. + * + * Generated from protobuf field .google.protobuf.Timestamp read_timestamp = 2; + * @return \Google\Protobuf\Timestamp|null + */ + public function getReadTimestamp() + { + return $this->read_timestamp; + } + + public function hasReadTimestamp() + { + return isset($this->read_timestamp); + } + + public function clearReadTimestamp() + { + unset($this->read_timestamp); + } + + /** + * For snapshot read-only transactions, the read timestamp chosen + * for the transaction. Not returned by default: see + * [TransactionOptions.ReadOnly.return_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.return_read_timestamp]. + * A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. + * Example: `"2014-10-02T15:01:23.045123456Z"`. + * + * Generated from protobuf field .google.protobuf.Timestamp read_timestamp = 2; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setReadTimestamp($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->read_timestamp = $var; + + return $this; + } + + /** + * A precommit token will be included in the response of a BeginTransaction + * request if the read-write transaction is on a multiplexed session and + * a mutation_key was specified in the + * [BeginTransaction][google.spanner.v1.BeginTransactionRequest]. + * The precommit token with the highest sequence number from this transaction + * attempt should be passed to the [Commit][google.spanner.v1.Spanner.Commit] + * request for this transaction. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.MultiplexedSessionPrecommitToken precommit_token = 3; + * @return \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken|null + */ + public function getPrecommitToken() + { + return $this->precommit_token; + } + + public function hasPrecommitToken() + { + return isset($this->precommit_token); + } + + public function clearPrecommitToken() + { + unset($this->precommit_token); + } + + /** + * A precommit token will be included in the response of a BeginTransaction + * request if the read-write transaction is on a multiplexed session and + * a mutation_key was specified in the + * [BeginTransaction][google.spanner.v1.BeginTransactionRequest]. + * The precommit token with the highest sequence number from this transaction + * attempt should be passed to the [Commit][google.spanner.v1.Spanner.Commit] + * request for this transaction. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field .google.spanner.v1.MultiplexedSessionPrecommitToken precommit_token = 3; + * @param \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken $var + * @return $this + */ + public function setPrecommitToken($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\MultiplexedSessionPrecommitToken::class); + $this->precommit_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionOptions.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionOptions.php new file mode 100644 index 000000000000..d72a12452c2e --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionOptions.php @@ -0,0 +1,504 @@ +. + * All queries on change stream TVFs must be executed using the + * ExecuteStreamingSql API with a single-use read-only transaction with a + * strong read-only timestamp_bound. The change stream TVF allows users to + * specify the start_timestamp and end_timestamp for the time range of + * interest. All change records within the retention period is accessible + * using the strong read-only timestamp_bound. All other TransactionOptions + * are invalid for change stream queries. + * In addition, if TransactionOptions.read_only.return_read_timestamp is set + * to true, a special value of 2^63 - 2 will be returned in the + * [Transaction][google.spanner.v1.Transaction] message that describes the + * transaction, instead of a valid read timestamp. This special value should be + * discarded and not used for any subsequent queries. + * Please see https://cloud.google.com/spanner/docs/change-streams + * for more details on how to query the change stream TVFs. + * Partitioned DML transactions: + * Partitioned DML transactions are used to execute DML statements with a + * different execution strategy that provides different, and often better, + * scalability properties for large, table-wide operations than DML in a + * ReadWrite transaction. Smaller scoped statements, such as an OLTP workload, + * should prefer using ReadWrite transactions. + * Partitioned DML partitions the keyspace and runs the DML statement on each + * partition in separate, internal transactions. These transactions commit + * automatically when complete, and run independently from one another. + * To reduce lock contention, this execution strategy only acquires read locks + * on rows that match the WHERE clause of the statement. Additionally, the + * smaller per-partition transactions hold locks for less time. + * That said, Partitioned DML is not a drop-in replacement for standard DML used + * in ReadWrite transactions. + * - The DML statement must be fully-partitionable. Specifically, the statement + * must be expressible as the union of many statements which each access only + * a single row of the table. + * - The statement is not applied atomically to all rows of the table. Rather, + * the statement is applied atomically to partitions of the table, in + * independent transactions. Secondary index rows are updated atomically + * with the base table rows. + * - Partitioned DML does not guarantee exactly-once execution semantics + * against a partition. The statement will be applied at least once to each + * partition. It is strongly recommended that the DML statement should be + * idempotent to avoid unexpected results. For instance, it is potentially + * dangerous to run a statement such as + * `UPDATE table SET column = column + 1` as it could be run multiple times + * against some rows. + * - The partitions are committed automatically - there is no support for + * Commit or Rollback. If the call returns an error, or if the client issuing + * the ExecuteSql call dies, it is possible that some rows had the statement + * executed on them successfully. It is also possible that statement was + * never executed against other rows. + * - Partitioned DML transactions may only contain the execution of a single + * DML statement via ExecuteSql or ExecuteStreamingSql. + * - If any error is encountered during the execution of the partitioned DML + * operation (for instance, a UNIQUE INDEX violation, division by zero, or a + * value that cannot be stored due to schema constraints), then the + * operation is stopped at that point and an error is returned. It is + * possible that at this point, some partitions have been committed (or even + * committed multiple times), and other partitions have not been run at all. + * Given the above, Partitioned DML is good fit for large, database-wide, + * operations that are idempotent, such as deleting old rows from a very large + * table. + * + * Generated from protobuf message google.spanner.v1.TransactionOptions + */ +class TransactionOptions extends \Google\Protobuf\Internal\Message +{ + /** + * When `exclude_txn_from_change_streams` is set to `true`: + * * Mutations from this transaction will not be recorded in change streams + * with DDL option `allow_txn_exclusion=true` that are tracking columns + * modified by these transactions. + * * Mutations from this transaction will be recorded in change streams with + * DDL option `allow_txn_exclusion=false or not set` that are tracking + * columns modified by these transactions. + * When `exclude_txn_from_change_streams` is set to `false` or not set, + * mutations from this transaction will be recorded in all change streams that + * are tracking columns modified by these transactions. + * `exclude_txn_from_change_streams` may only be specified for read-write or + * partitioned-dml transactions, otherwise the API will return an + * `INVALID_ARGUMENT` error. + * + * Generated from protobuf field bool exclude_txn_from_change_streams = 5; + */ + protected $exclude_txn_from_change_streams = false; + protected $mode; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\V1\TransactionOptions\ReadWrite $read_write + * Transaction may write. + * Authorization to begin a read-write transaction requires + * `spanner.databases.beginOrRollbackReadWriteTransaction` permission + * on the `session` resource. + * @type \Google\Cloud\Spanner\V1\TransactionOptions\PartitionedDml $partitioned_dml + * Partitioned DML transaction. + * Authorization to begin a Partitioned DML transaction requires + * `spanner.databases.beginPartitionedDmlTransaction` permission + * on the `session` resource. + * @type \Google\Cloud\Spanner\V1\TransactionOptions\PBReadOnly $read_only + * Transaction will not write. + * Authorization to begin a read-only transaction requires + * `spanner.databases.beginReadOnlyTransaction` permission + * on the `session` resource. + * @type bool $exclude_txn_from_change_streams + * When `exclude_txn_from_change_streams` is set to `true`: + * * Mutations from this transaction will not be recorded in change streams + * with DDL option `allow_txn_exclusion=true` that are tracking columns + * modified by these transactions. + * * Mutations from this transaction will be recorded in change streams with + * DDL option `allow_txn_exclusion=false or not set` that are tracking + * columns modified by these transactions. + * When `exclude_txn_from_change_streams` is set to `false` or not set, + * mutations from this transaction will be recorded in all change streams that + * are tracking columns modified by these transactions. + * `exclude_txn_from_change_streams` may only be specified for read-write or + * partitioned-dml transactions, otherwise the API will return an + * `INVALID_ARGUMENT` error. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Transaction::initOnce(); + parent::__construct($data); + } + + /** + * Transaction may write. + * Authorization to begin a read-write transaction requires + * `spanner.databases.beginOrRollbackReadWriteTransaction` permission + * on the `session` resource. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions.ReadWrite read_write = 1; + * @return \Google\Cloud\Spanner\V1\TransactionOptions\ReadWrite|null + */ + public function getReadWrite() + { + return $this->readOneof(1); + } + + public function hasReadWrite() + { + return $this->hasOneof(1); + } + + /** + * Transaction may write. + * Authorization to begin a read-write transaction requires + * `spanner.databases.beginOrRollbackReadWriteTransaction` permission + * on the `session` resource. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions.ReadWrite read_write = 1; + * @param \Google\Cloud\Spanner\V1\TransactionOptions\ReadWrite $var + * @return $this + */ + public function setReadWrite($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\TransactionOptions\ReadWrite::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * Partitioned DML transaction. + * Authorization to begin a Partitioned DML transaction requires + * `spanner.databases.beginPartitionedDmlTransaction` permission + * on the `session` resource. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions.PartitionedDml partitioned_dml = 3; + * @return \Google\Cloud\Spanner\V1\TransactionOptions\PartitionedDml|null + */ + public function getPartitionedDml() + { + return $this->readOneof(3); + } + + public function hasPartitionedDml() + { + return $this->hasOneof(3); + } + + /** + * Partitioned DML transaction. + * Authorization to begin a Partitioned DML transaction requires + * `spanner.databases.beginPartitionedDmlTransaction` permission + * on the `session` resource. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions.PartitionedDml partitioned_dml = 3; + * @param \Google\Cloud\Spanner\V1\TransactionOptions\PartitionedDml $var + * @return $this + */ + public function setPartitionedDml($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\TransactionOptions\PartitionedDml::class); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * Transaction will not write. + * Authorization to begin a read-only transaction requires + * `spanner.databases.beginReadOnlyTransaction` permission + * on the `session` resource. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions.ReadOnly read_only = 2; + * @return \Google\Cloud\Spanner\V1\TransactionOptions\PBReadOnly|null + */ + public function getReadOnly() + { + return $this->readOneof(2); + } + + public function hasReadOnly() + { + return $this->hasOneof(2); + } + + /** + * Transaction will not write. + * Authorization to begin a read-only transaction requires + * `spanner.databases.beginReadOnlyTransaction` permission + * on the `session` resource. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions.ReadOnly read_only = 2; + * @param \Google\Cloud\Spanner\V1\TransactionOptions\PBReadOnly $var + * @return $this + */ + public function setReadOnly($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\TransactionOptions\PBReadOnly::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * When `exclude_txn_from_change_streams` is set to `true`: + * * Mutations from this transaction will not be recorded in change streams + * with DDL option `allow_txn_exclusion=true` that are tracking columns + * modified by these transactions. + * * Mutations from this transaction will be recorded in change streams with + * DDL option `allow_txn_exclusion=false or not set` that are tracking + * columns modified by these transactions. + * When `exclude_txn_from_change_streams` is set to `false` or not set, + * mutations from this transaction will be recorded in all change streams that + * are tracking columns modified by these transactions. + * `exclude_txn_from_change_streams` may only be specified for read-write or + * partitioned-dml transactions, otherwise the API will return an + * `INVALID_ARGUMENT` error. + * + * Generated from protobuf field bool exclude_txn_from_change_streams = 5; + * @return bool + */ + public function getExcludeTxnFromChangeStreams() + { + return $this->exclude_txn_from_change_streams; + } + + /** + * When `exclude_txn_from_change_streams` is set to `true`: + * * Mutations from this transaction will not be recorded in change streams + * with DDL option `allow_txn_exclusion=true` that are tracking columns + * modified by these transactions. + * * Mutations from this transaction will be recorded in change streams with + * DDL option `allow_txn_exclusion=false or not set` that are tracking + * columns modified by these transactions. + * When `exclude_txn_from_change_streams` is set to `false` or not set, + * mutations from this transaction will be recorded in all change streams that + * are tracking columns modified by these transactions. + * `exclude_txn_from_change_streams` may only be specified for read-write or + * partitioned-dml transactions, otherwise the API will return an + * `INVALID_ARGUMENT` error. + * + * Generated from protobuf field bool exclude_txn_from_change_streams = 5; + * @param bool $var + * @return $this + */ + public function setExcludeTxnFromChangeStreams($var) + { + GPBUtil::checkBool($var); + $this->exclude_txn_from_change_streams = $var; + + return $this; + } + + /** + * @return string + */ + public function getMode() + { + return $this->whichOneof("mode"); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionOptions/PBReadOnly.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionOptions/PBReadOnly.php new file mode 100644 index 000000000000..114fed83d6e2 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionOptions/PBReadOnly.php @@ -0,0 +1,357 @@ +google.spanner.v1.TransactionOptions.ReadOnly + */ +class PBReadOnly extends \Google\Protobuf\Internal\Message +{ + /** + * If true, the Cloud Spanner-selected read timestamp is included in + * the [Transaction][google.spanner.v1.Transaction] message that describes + * the transaction. + * + * Generated from protobuf field bool return_read_timestamp = 6; + */ + protected $return_read_timestamp = false; + protected $timestamp_bound; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type bool $strong + * Read at a timestamp where all previously committed transactions + * are visible. + * @type \Google\Protobuf\Timestamp $min_read_timestamp + * Executes all reads at a timestamp >= `min_read_timestamp`. + * This is useful for requesting fresher data than some previous + * read, or data that is fresh enough to observe the effects of some + * previously committed transaction whose timestamp is known. + * Note that this option can only be used in single-use transactions. + * A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. + * Example: `"2014-10-02T15:01:23.045123456Z"`. + * @type \Google\Protobuf\Duration $max_staleness + * Read data at a timestamp >= `NOW - max_staleness` + * seconds. Guarantees that all writes that have committed more + * than the specified number of seconds ago are visible. Because + * Cloud Spanner chooses the exact timestamp, this mode works even if + * the client's local clock is substantially skewed from Cloud Spanner + * commit timestamps. + * Useful for reading the freshest data available at a nearby + * replica, while bounding the possible staleness if the local + * replica has fallen behind. + * Note that this option can only be used in single-use + * transactions. + * @type \Google\Protobuf\Timestamp $read_timestamp + * Executes all reads at the given timestamp. Unlike other modes, + * reads at a specific timestamp are repeatable; the same read at + * the same timestamp always returns the same data. If the + * timestamp is in the future, the read will block until the + * specified timestamp, modulo the read's deadline. + * Useful for large scale consistent reads such as mapreduces, or + * for coordinating many reads against a consistent snapshot of the + * data. + * A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. + * Example: `"2014-10-02T15:01:23.045123456Z"`. + * @type \Google\Protobuf\Duration $exact_staleness + * Executes all reads at a timestamp that is `exact_staleness` + * old. The timestamp is chosen soon after the read is started. + * Guarantees that all writes that have committed more than the + * specified number of seconds ago are visible. Because Cloud Spanner + * chooses the exact timestamp, this mode works even if the client's + * local clock is substantially skewed from Cloud Spanner commit + * timestamps. + * Useful for reading at nearby replicas without the distributed + * timestamp negotiation overhead of `max_staleness`. + * @type bool $return_read_timestamp + * If true, the Cloud Spanner-selected read timestamp is included in + * the [Transaction][google.spanner.v1.Transaction] message that describes + * the transaction. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Transaction::initOnce(); + parent::__construct($data); + } + + /** + * Read at a timestamp where all previously committed transactions + * are visible. + * + * Generated from protobuf field bool strong = 1; + * @return bool + */ + public function getStrong() + { + return $this->readOneof(1); + } + + public function hasStrong() + { + return $this->hasOneof(1); + } + + /** + * Read at a timestamp where all previously committed transactions + * are visible. + * + * Generated from protobuf field bool strong = 1; + * @param bool $var + * @return $this + */ + public function setStrong($var) + { + GPBUtil::checkBool($var); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * Executes all reads at a timestamp >= `min_read_timestamp`. + * This is useful for requesting fresher data than some previous + * read, or data that is fresh enough to observe the effects of some + * previously committed transaction whose timestamp is known. + * Note that this option can only be used in single-use transactions. + * A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. + * Example: `"2014-10-02T15:01:23.045123456Z"`. + * + * Generated from protobuf field .google.protobuf.Timestamp min_read_timestamp = 2; + * @return \Google\Protobuf\Timestamp|null + */ + public function getMinReadTimestamp() + { + return $this->readOneof(2); + } + + public function hasMinReadTimestamp() + { + return $this->hasOneof(2); + } + + /** + * Executes all reads at a timestamp >= `min_read_timestamp`. + * This is useful for requesting fresher data than some previous + * read, or data that is fresh enough to observe the effects of some + * previously committed transaction whose timestamp is known. + * Note that this option can only be used in single-use transactions. + * A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. + * Example: `"2014-10-02T15:01:23.045123456Z"`. + * + * Generated from protobuf field .google.protobuf.Timestamp min_read_timestamp = 2; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setMinReadTimestamp($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * Read data at a timestamp >= `NOW - max_staleness` + * seconds. Guarantees that all writes that have committed more + * than the specified number of seconds ago are visible. Because + * Cloud Spanner chooses the exact timestamp, this mode works even if + * the client's local clock is substantially skewed from Cloud Spanner + * commit timestamps. + * Useful for reading the freshest data available at a nearby + * replica, while bounding the possible staleness if the local + * replica has fallen behind. + * Note that this option can only be used in single-use + * transactions. + * + * Generated from protobuf field .google.protobuf.Duration max_staleness = 3; + * @return \Google\Protobuf\Duration|null + */ + public function getMaxStaleness() + { + return $this->readOneof(3); + } + + public function hasMaxStaleness() + { + return $this->hasOneof(3); + } + + /** + * Read data at a timestamp >= `NOW - max_staleness` + * seconds. Guarantees that all writes that have committed more + * than the specified number of seconds ago are visible. Because + * Cloud Spanner chooses the exact timestamp, this mode works even if + * the client's local clock is substantially skewed from Cloud Spanner + * commit timestamps. + * Useful for reading the freshest data available at a nearby + * replica, while bounding the possible staleness if the local + * replica has fallen behind. + * Note that this option can only be used in single-use + * transactions. + * + * Generated from protobuf field .google.protobuf.Duration max_staleness = 3; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setMaxStaleness($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * Executes all reads at the given timestamp. Unlike other modes, + * reads at a specific timestamp are repeatable; the same read at + * the same timestamp always returns the same data. If the + * timestamp is in the future, the read will block until the + * specified timestamp, modulo the read's deadline. + * Useful for large scale consistent reads such as mapreduces, or + * for coordinating many reads against a consistent snapshot of the + * data. + * A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. + * Example: `"2014-10-02T15:01:23.045123456Z"`. + * + * Generated from protobuf field .google.protobuf.Timestamp read_timestamp = 4; + * @return \Google\Protobuf\Timestamp|null + */ + public function getReadTimestamp() + { + return $this->readOneof(4); + } + + public function hasReadTimestamp() + { + return $this->hasOneof(4); + } + + /** + * Executes all reads at the given timestamp. Unlike other modes, + * reads at a specific timestamp are repeatable; the same read at + * the same timestamp always returns the same data. If the + * timestamp is in the future, the read will block until the + * specified timestamp, modulo the read's deadline. + * Useful for large scale consistent reads such as mapreduces, or + * for coordinating many reads against a consistent snapshot of the + * data. + * A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. + * Example: `"2014-10-02T15:01:23.045123456Z"`. + * + * Generated from protobuf field .google.protobuf.Timestamp read_timestamp = 4; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setReadTimestamp($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->writeOneof(4, $var); + + return $this; + } + + /** + * Executes all reads at a timestamp that is `exact_staleness` + * old. The timestamp is chosen soon after the read is started. + * Guarantees that all writes that have committed more than the + * specified number of seconds ago are visible. Because Cloud Spanner + * chooses the exact timestamp, this mode works even if the client's + * local clock is substantially skewed from Cloud Spanner commit + * timestamps. + * Useful for reading at nearby replicas without the distributed + * timestamp negotiation overhead of `max_staleness`. + * + * Generated from protobuf field .google.protobuf.Duration exact_staleness = 5; + * @return \Google\Protobuf\Duration|null + */ + public function getExactStaleness() + { + return $this->readOneof(5); + } + + public function hasExactStaleness() + { + return $this->hasOneof(5); + } + + /** + * Executes all reads at a timestamp that is `exact_staleness` + * old. The timestamp is chosen soon after the read is started. + * Guarantees that all writes that have committed more than the + * specified number of seconds ago are visible. Because Cloud Spanner + * chooses the exact timestamp, this mode works even if the client's + * local clock is substantially skewed from Cloud Spanner commit + * timestamps. + * Useful for reading at nearby replicas without the distributed + * timestamp negotiation overhead of `max_staleness`. + * + * Generated from protobuf field .google.protobuf.Duration exact_staleness = 5; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setExactStaleness($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->writeOneof(5, $var); + + return $this; + } + + /** + * If true, the Cloud Spanner-selected read timestamp is included in + * the [Transaction][google.spanner.v1.Transaction] message that describes + * the transaction. + * + * Generated from protobuf field bool return_read_timestamp = 6; + * @return bool + */ + public function getReturnReadTimestamp() + { + return $this->return_read_timestamp; + } + + /** + * If true, the Cloud Spanner-selected read timestamp is included in + * the [Transaction][google.spanner.v1.Transaction] message that describes + * the transaction. + * + * Generated from protobuf field bool return_read_timestamp = 6; + * @param bool $var + * @return $this + */ + public function setReturnReadTimestamp($var) + { + GPBUtil::checkBool($var); + $this->return_read_timestamp = $var; + + return $this; + } + + /** + * @return string + */ + public function getTimestampBound() + { + return $this->whichOneof("timestamp_bound"); + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(PBReadOnly::class, \Google\Cloud\Spanner\V1\TransactionOptions_ReadOnly::class); + +// Adding a class alias for backwards compatibility with the "readonly" keyword. +class_alias(PBReadOnly::class, __NAMESPACE__ . '\ReadOnly'); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionOptions/PartitionedDml.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionOptions/PartitionedDml.php new file mode 100644 index 000000000000..06d0e4b25c62 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionOptions/PartitionedDml.php @@ -0,0 +1,36 @@ +google.spanner.v1.TransactionOptions.PartitionedDml + */ +class PartitionedDml extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Transaction::initOnce(); + parent::__construct($data); + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(PartitionedDml::class, \Google\Cloud\Spanner\V1\TransactionOptions_PartitionedDml::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionOptions/ReadOnly.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionOptions/ReadOnly.php new file mode 100644 index 000000000000..d9f5f7d4789f --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionOptions/ReadOnly.php @@ -0,0 +1,9 @@ +google.spanner.v1.TransactionOptions.ReadWrite + */ +class ReadWrite extends \Google\Protobuf\Internal\Message +{ + /** + * Read lock mode for the transaction. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode read_lock_mode = 1; + */ + protected $read_lock_mode = 0; + /** + * Optional. Clients should pass the transaction ID of the previous + * transaction attempt that was aborted if this transaction is being + * executed on a multiplexed session. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field bytes multiplexed_session_previous_transaction_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $multiplexed_session_previous_transaction_id = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $read_lock_mode + * Read lock mode for the transaction. + * @type string $multiplexed_session_previous_transaction_id + * Optional. Clients should pass the transaction ID of the previous + * transaction attempt that was aborted if this transaction is being + * executed on a multiplexed session. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Transaction::initOnce(); + parent::__construct($data); + } + + /** + * Read lock mode for the transaction. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode read_lock_mode = 1; + * @return int + */ + public function getReadLockMode() + { + return $this->read_lock_mode; + } + + /** + * Read lock mode for the transaction. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode read_lock_mode = 1; + * @param int $var + * @return $this + */ + public function setReadLockMode($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\V1\TransactionOptions\ReadWrite\ReadLockMode::class); + $this->read_lock_mode = $var; + + return $this; + } + + /** + * Optional. Clients should pass the transaction ID of the previous + * transaction attempt that was aborted if this transaction is being + * executed on a multiplexed session. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field bytes multiplexed_session_previous_transaction_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getMultiplexedSessionPreviousTransactionId() + { + return $this->multiplexed_session_previous_transaction_id; + } + + /** + * Optional. Clients should pass the transaction ID of the previous + * transaction attempt that was aborted if this transaction is being + * executed on a multiplexed session. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * + * Generated from protobuf field bytes multiplexed_session_previous_transaction_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setMultiplexedSessionPreviousTransactionId($var) + { + GPBUtil::checkString($var, False); + $this->multiplexed_session_previous_transaction_id = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(ReadWrite::class, \Google\Cloud\Spanner\V1\TransactionOptions_ReadWrite::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionOptions/ReadWrite/ReadLockMode.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionOptions/ReadWrite/ReadLockMode.php new file mode 100644 index 000000000000..75b8922f96cb --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionOptions/ReadWrite/ReadLockMode.php @@ -0,0 +1,70 @@ +google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode + */ +class ReadLockMode +{ + /** + * Default value. + * If the value is not specified, the pessimistic read lock is used. + * + * Generated from protobuf enum READ_LOCK_MODE_UNSPECIFIED = 0; + */ + const READ_LOCK_MODE_UNSPECIFIED = 0; + /** + * Pessimistic lock mode. + * Read locks are acquired immediately on read. + * + * Generated from protobuf enum PESSIMISTIC = 1; + */ + const PESSIMISTIC = 1; + /** + * Optimistic lock mode. + * Locks for reads within the transaction are not acquired on read. + * Instead the locks are acquired on a commit to validate that + * read/queried data has not changed since the transaction started. + * + * Generated from protobuf enum OPTIMISTIC = 2; + */ + const OPTIMISTIC = 2; + + private static $valueToName = [ + self::READ_LOCK_MODE_UNSPECIFIED => 'READ_LOCK_MODE_UNSPECIFIED', + self::PESSIMISTIC => 'PESSIMISTIC', + self::OPTIMISTIC => 'OPTIMISTIC', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(ReadLockMode::class, \Google\Cloud\Spanner\V1\TransactionOptions_ReadWrite_ReadLockMode::class); + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionSelector.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionSelector.php new file mode 100644 index 000000000000..f955f410ee81 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TransactionSelector.php @@ -0,0 +1,160 @@ +google.spanner.v1.TransactionSelector + */ +class TransactionSelector extends \Google\Protobuf\Internal\Message +{ + protected $selector; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\V1\TransactionOptions $single_use + * Execute the read or SQL query in a temporary transaction. + * This is the most efficient way to execute a transaction that + * consists of a single SQL query. + * @type string $id + * Execute the read or SQL query in a previously-started transaction. + * @type \Google\Cloud\Spanner\V1\TransactionOptions $begin + * Begin a new transaction and execute this read or SQL query in + * it. The transaction ID of the new transaction is returned in + * [ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction], + * which is a [Transaction][google.spanner.v1.Transaction]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Transaction::initOnce(); + parent::__construct($data); + } + + /** + * Execute the read or SQL query in a temporary transaction. + * This is the most efficient way to execute a transaction that + * consists of a single SQL query. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions single_use = 1; + * @return \Google\Cloud\Spanner\V1\TransactionOptions|null + */ + public function getSingleUse() + { + return $this->readOneof(1); + } + + public function hasSingleUse() + { + return $this->hasOneof(1); + } + + /** + * Execute the read or SQL query in a temporary transaction. + * This is the most efficient way to execute a transaction that + * consists of a single SQL query. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions single_use = 1; + * @param \Google\Cloud\Spanner\V1\TransactionOptions $var + * @return $this + */ + public function setSingleUse($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\TransactionOptions::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * Execute the read or SQL query in a previously-started transaction. + * + * Generated from protobuf field bytes id = 2; + * @return string + */ + public function getId() + { + return $this->readOneof(2); + } + + public function hasId() + { + return $this->hasOneof(2); + } + + /** + * Execute the read or SQL query in a previously-started transaction. + * + * Generated from protobuf field bytes id = 2; + * @param string $var + * @return $this + */ + public function setId($var) + { + GPBUtil::checkString($var, False); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * Begin a new transaction and execute this read or SQL query in + * it. The transaction ID of the new transaction is returned in + * [ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction], + * which is a [Transaction][google.spanner.v1.Transaction]. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions begin = 3; + * @return \Google\Cloud\Spanner\V1\TransactionOptions|null + */ + public function getBegin() + { + return $this->readOneof(3); + } + + public function hasBegin() + { + return $this->hasOneof(3); + } + + /** + * Begin a new transaction and execute this read or SQL query in + * it. The transaction ID of the new transaction is returned in + * [ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction], + * which is a [Transaction][google.spanner.v1.Transaction]. + * + * Generated from protobuf field .google.spanner.v1.TransactionOptions begin = 3; + * @param \Google\Cloud\Spanner\V1\TransactionOptions $var + * @return $this + */ + public function setBegin($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\TransactionOptions::class); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * @return string + */ + public function getSelector() + { + return $this->whichOneof("selector"); + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Type.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Type.php new file mode 100644 index 000000000000..6527eae3f162 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/Type.php @@ -0,0 +1,284 @@ +google.spanner.v1.Type + */ +class Type extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The [TypeCode][google.spanner.v1.TypeCode] for this type. + * + * Generated from protobuf field .google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $code = 0; + /** + * If [code][google.spanner.v1.Type.code] == + * [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type` is the + * type of the array elements. + * + * Generated from protobuf field .google.spanner.v1.Type array_element_type = 2; + */ + protected $array_element_type = null; + /** + * If [code][google.spanner.v1.Type.code] == + * [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type` provides + * type information for the struct's fields. + * + * Generated from protobuf field .google.spanner.v1.StructType struct_type = 3; + */ + protected $struct_type = null; + /** + * The [TypeAnnotationCode][google.spanner.v1.TypeAnnotationCode] that + * disambiguates SQL type that Spanner will use to represent values of this + * type during query processing. This is necessary for some type codes because + * a single [TypeCode][google.spanner.v1.TypeCode] can be mapped to different + * SQL types depending on the SQL dialect. + * [type_annotation][google.spanner.v1.Type.type_annotation] typically is not + * needed to process the content of a value (it doesn't affect serialization) + * and clients can ignore it on the read path. + * + * Generated from protobuf field .google.spanner.v1.TypeAnnotationCode type_annotation = 4; + */ + protected $type_annotation = 0; + /** + * If [code][google.spanner.v1.Type.code] == + * [PROTO][google.spanner.v1.TypeCode.PROTO] or + * [code][google.spanner.v1.Type.code] == + * [ENUM][google.spanner.v1.TypeCode.ENUM], then `proto_type_fqn` is the fully + * qualified name of the proto type representing the proto/enum definition. + * + * Generated from protobuf field string proto_type_fqn = 5; + */ + protected $proto_type_fqn = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $code + * Required. The [TypeCode][google.spanner.v1.TypeCode] for this type. + * @type \Google\Cloud\Spanner\V1\Type $array_element_type + * If [code][google.spanner.v1.Type.code] == + * [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type` is the + * type of the array elements. + * @type \Google\Cloud\Spanner\V1\StructType $struct_type + * If [code][google.spanner.v1.Type.code] == + * [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type` provides + * type information for the struct's fields. + * @type int $type_annotation + * The [TypeAnnotationCode][google.spanner.v1.TypeAnnotationCode] that + * disambiguates SQL type that Spanner will use to represent values of this + * type during query processing. This is necessary for some type codes because + * a single [TypeCode][google.spanner.v1.TypeCode] can be mapped to different + * SQL types depending on the SQL dialect. + * [type_annotation][google.spanner.v1.Type.type_annotation] typically is not + * needed to process the content of a value (it doesn't affect serialization) + * and clients can ignore it on the read path. + * @type string $proto_type_fqn + * If [code][google.spanner.v1.Type.code] == + * [PROTO][google.spanner.v1.TypeCode.PROTO] or + * [code][google.spanner.v1.Type.code] == + * [ENUM][google.spanner.v1.TypeCode.ENUM], then `proto_type_fqn` is the fully + * qualified name of the proto type representing the proto/enum definition. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\V1\Type::initOnce(); + parent::__construct($data); + } + + /** + * Required. The [TypeCode][google.spanner.v1.TypeCode] for this type. + * + * Generated from protobuf field .google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return int + */ + public function getCode() + { + return $this->code; + } + + /** + * Required. The [TypeCode][google.spanner.v1.TypeCode] for this type. + * + * Generated from protobuf field .google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param int $var + * @return $this + */ + public function setCode($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\V1\TypeCode::class); + $this->code = $var; + + return $this; + } + + /** + * If [code][google.spanner.v1.Type.code] == + * [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type` is the + * type of the array elements. + * + * Generated from protobuf field .google.spanner.v1.Type array_element_type = 2; + * @return \Google\Cloud\Spanner\V1\Type|null + */ + public function getArrayElementType() + { + return $this->array_element_type; + } + + public function hasArrayElementType() + { + return isset($this->array_element_type); + } + + public function clearArrayElementType() + { + unset($this->array_element_type); + } + + /** + * If [code][google.spanner.v1.Type.code] == + * [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type` is the + * type of the array elements. + * + * Generated from protobuf field .google.spanner.v1.Type array_element_type = 2; + * @param \Google\Cloud\Spanner\V1\Type $var + * @return $this + */ + public function setArrayElementType($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\Type::class); + $this->array_element_type = $var; + + return $this; + } + + /** + * If [code][google.spanner.v1.Type.code] == + * [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type` provides + * type information for the struct's fields. + * + * Generated from protobuf field .google.spanner.v1.StructType struct_type = 3; + * @return \Google\Cloud\Spanner\V1\StructType|null + */ + public function getStructType() + { + return $this->struct_type; + } + + public function hasStructType() + { + return isset($this->struct_type); + } + + public function clearStructType() + { + unset($this->struct_type); + } + + /** + * If [code][google.spanner.v1.Type.code] == + * [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type` provides + * type information for the struct's fields. + * + * Generated from protobuf field .google.spanner.v1.StructType struct_type = 3; + * @param \Google\Cloud\Spanner\V1\StructType $var + * @return $this + */ + public function setStructType($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\StructType::class); + $this->struct_type = $var; + + return $this; + } + + /** + * The [TypeAnnotationCode][google.spanner.v1.TypeAnnotationCode] that + * disambiguates SQL type that Spanner will use to represent values of this + * type during query processing. This is necessary for some type codes because + * a single [TypeCode][google.spanner.v1.TypeCode] can be mapped to different + * SQL types depending on the SQL dialect. + * [type_annotation][google.spanner.v1.Type.type_annotation] typically is not + * needed to process the content of a value (it doesn't affect serialization) + * and clients can ignore it on the read path. + * + * Generated from protobuf field .google.spanner.v1.TypeAnnotationCode type_annotation = 4; + * @return int + */ + public function getTypeAnnotation() + { + return $this->type_annotation; + } + + /** + * The [TypeAnnotationCode][google.spanner.v1.TypeAnnotationCode] that + * disambiguates SQL type that Spanner will use to represent values of this + * type during query processing. This is necessary for some type codes because + * a single [TypeCode][google.spanner.v1.TypeCode] can be mapped to different + * SQL types depending on the SQL dialect. + * [type_annotation][google.spanner.v1.Type.type_annotation] typically is not + * needed to process the content of a value (it doesn't affect serialization) + * and clients can ignore it on the read path. + * + * Generated from protobuf field .google.spanner.v1.TypeAnnotationCode type_annotation = 4; + * @param int $var + * @return $this + */ + public function setTypeAnnotation($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Spanner\V1\TypeAnnotationCode::class); + $this->type_annotation = $var; + + return $this; + } + + /** + * If [code][google.spanner.v1.Type.code] == + * [PROTO][google.spanner.v1.TypeCode.PROTO] or + * [code][google.spanner.v1.Type.code] == + * [ENUM][google.spanner.v1.TypeCode.ENUM], then `proto_type_fqn` is the fully + * qualified name of the proto type representing the proto/enum definition. + * + * Generated from protobuf field string proto_type_fqn = 5; + * @return string + */ + public function getProtoTypeFqn() + { + return $this->proto_type_fqn; + } + + /** + * If [code][google.spanner.v1.Type.code] == + * [PROTO][google.spanner.v1.TypeCode.PROTO] or + * [code][google.spanner.v1.Type.code] == + * [ENUM][google.spanner.v1.TypeCode.ENUM], then `proto_type_fqn` is the fully + * qualified name of the proto type representing the proto/enum definition. + * + * Generated from protobuf field string proto_type_fqn = 5; + * @param string $var + * @return $this + */ + public function setProtoTypeFqn($var) + { + GPBUtil::checkString($var, True); + $this->proto_type_fqn = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TypeAnnotationCode.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TypeAnnotationCode.php new file mode 100644 index 000000000000..5aa003011f3d --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TypeAnnotationCode.php @@ -0,0 +1,85 @@ +google.spanner.v1.TypeAnnotationCode + */ +class TypeAnnotationCode +{ + /** + * Not specified. + * + * Generated from protobuf enum TYPE_ANNOTATION_CODE_UNSPECIFIED = 0; + */ + const TYPE_ANNOTATION_CODE_UNSPECIFIED = 0; + /** + * PostgreSQL compatible NUMERIC type. This annotation needs to be applied to + * [Type][google.spanner.v1.Type] instances having + * [NUMERIC][google.spanner.v1.TypeCode.NUMERIC] type code to specify that + * values of this type should be treated as PostgreSQL NUMERIC values. + * Currently this annotation is always needed for + * [NUMERIC][google.spanner.v1.TypeCode.NUMERIC] when a client interacts with + * PostgreSQL-enabled Spanner databases. + * + * Generated from protobuf enum PG_NUMERIC = 2; + */ + const PG_NUMERIC = 2; + /** + * PostgreSQL compatible JSONB type. This annotation needs to be applied to + * [Type][google.spanner.v1.Type] instances having + * [JSON][google.spanner.v1.TypeCode.JSON] type code to specify that values of + * this type should be treated as PostgreSQL JSONB values. Currently this + * annotation is always needed for [JSON][google.spanner.v1.TypeCode.JSON] + * when a client interacts with PostgreSQL-enabled Spanner databases. + * + * Generated from protobuf enum PG_JSONB = 3; + */ + const PG_JSONB = 3; + /** + * PostgreSQL compatible OID type. This annotation can be used by a client + * interacting with PostgreSQL-enabled Spanner database to specify that a + * value should be treated using the semantics of the OID type. + * + * Generated from protobuf enum PG_OID = 4; + */ + const PG_OID = 4; + + private static $valueToName = [ + self::TYPE_ANNOTATION_CODE_UNSPECIFIED => 'TYPE_ANNOTATION_CODE_UNSPECIFIED', + self::PG_NUMERIC => 'PG_NUMERIC', + self::PG_JSONB => 'PG_JSONB', + self::PG_OID => 'PG_OID', + ]; + + 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/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TypeCode.php b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TypeCode.php new file mode 100644 index 000000000000..19ca4f38e502 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/proto/src/Google/Cloud/Spanner/V1/TypeCode.php @@ -0,0 +1,199 @@ +google.spanner.v1.TypeCode + */ +class TypeCode +{ + /** + * Not specified. + * + * Generated from protobuf enum TYPE_CODE_UNSPECIFIED = 0; + */ + const TYPE_CODE_UNSPECIFIED = 0; + /** + * Encoded as JSON `true` or `false`. + * + * Generated from protobuf enum BOOL = 1; + */ + const BOOL = 1; + /** + * Encoded as `string`, in decimal format. + * + * Generated from protobuf enum INT64 = 2; + */ + const INT64 = 2; + /** + * Encoded as `number`, or the strings `"NaN"`, `"Infinity"`, or + * `"-Infinity"`. + * + * Generated from protobuf enum FLOAT64 = 3; + */ + const FLOAT64 = 3; + /** + * Encoded as `number`, or the strings `"NaN"`, `"Infinity"`, or + * `"-Infinity"`. + * + * Generated from protobuf enum FLOAT32 = 15; + */ + const FLOAT32 = 15; + /** + * Encoded as `string` in RFC 3339 timestamp format. The time zone + * must be present, and must be `"Z"`. + * If the schema has the column option + * `allow_commit_timestamp=true`, the placeholder string + * `"spanner.commit_timestamp()"` can be used to instruct the system + * to insert the commit timestamp associated with the transaction + * commit. + * + * Generated from protobuf enum TIMESTAMP = 4; + */ + const TIMESTAMP = 4; + /** + * Encoded as `string` in RFC 3339 date format. + * + * Generated from protobuf enum DATE = 5; + */ + const DATE = 5; + /** + * Encoded as `string`. + * + * Generated from protobuf enum STRING = 6; + */ + const STRING = 6; + /** + * Encoded as a base64-encoded `string`, as described in RFC 4648, + * section 4. + * + * Generated from protobuf enum BYTES = 7; + */ + const BYTES = 7; + /** + * Encoded as `list`, where the list elements are represented + * according to + * [array_element_type][google.spanner.v1.Type.array_element_type]. + * + * Generated from protobuf enum ARRAY = 8; + */ + const PBARRAY = 8; + /** + * Encoded as `list`, where list element `i` is represented according + * to [struct_type.fields[i]][google.spanner.v1.StructType.fields]. + * + * Generated from protobuf enum STRUCT = 9; + */ + const STRUCT = 9; + /** + * Encoded as `string`, in decimal format or scientific notation format. + * Decimal format: + * `[+-]Digits[.[Digits]]` or + * `[+-][Digits].Digits` + * Scientific notation: + * `[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits]` or + * `[+-][Digits].Digits[ExponentIndicator[+-]Digits]` + * (ExponentIndicator is `"e"` or `"E"`) + * + * Generated from protobuf enum NUMERIC = 10; + */ + const NUMERIC = 10; + /** + * Encoded as a JSON-formatted `string` as described in RFC 7159. The + * following rules are applied when parsing JSON input: + * - Whitespace characters are not preserved. + * - If a JSON object has duplicate keys, only the first key is preserved. + * - Members of a JSON object are not guaranteed to have their order + * preserved. + * - JSON array elements will have their order preserved. + * + * Generated from protobuf enum JSON = 11; + */ + const JSON = 11; + /** + * Encoded as a base64-encoded `string`, as described in RFC 4648, + * section 4. + * + * Generated from protobuf enum PROTO = 13; + */ + const PROTO = 13; + /** + * Encoded as `string`, in decimal format. + * + * Generated from protobuf enum ENUM = 14; + */ + const ENUM = 14; + /** + * Encoded as `string`, in `ISO8601` duration format - + * `P[n]Y[n]M[n]DT[n]H[n]M[n[.fraction]]S` + * where `n` is an integer. + * For example, `P1Y2M3DT4H5M6.5S` represents time duration of 1 year, 2 + * months, 3 days, 4 hours, 5 minutes, and 6.5 seconds. + * + * Generated from protobuf enum INTERVAL = 16; + */ + const INTERVAL = 16; + /** + * Encoded as `string`, in lower-case hexa-decimal format, as described + * in RFC 9562, section 4. + * + * Generated from protobuf enum UUID = 17; + */ + const UUID = 17; + + private static $valueToName = [ + self::TYPE_CODE_UNSPECIFIED => 'TYPE_CODE_UNSPECIFIED', + self::BOOL => 'BOOL', + self::INT64 => 'INT64', + self::FLOAT64 => 'FLOAT64', + self::FLOAT32 => 'FLOAT32', + self::TIMESTAMP => 'TIMESTAMP', + self::DATE => 'DATE', + self::STRING => 'STRING', + self::BYTES => 'BYTES', + self::PBARRAY => 'ARRAY', + self::STRUCT => 'STRUCT', + self::NUMERIC => 'NUMERIC', + self::JSON => 'JSON', + self::PROTO => 'PROTO', + self::ENUM => 'ENUM', + self::INTERVAL => 'INTERVAL', + self::UUID => 'UUID', + ]; + + 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)) { + $pbconst = __CLASS__. '::PB' . strtoupper($name); + if (!defined($pbconst)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($pbconst); + } + return constant($const); + } +} + diff --git a/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/batch_create_sessions.php b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/batch_create_sessions.php new file mode 100644 index 000000000000..40be97dbffc6 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/batch_create_sessions.php @@ -0,0 +1,82 @@ +setDatabase($formattedDatabase) + ->setSessionCount($sessionCount); + + // Call the API and handle any network failures. + try { + /** @var BatchCreateSessionsResponse $response */ + $response = $spannerClient->batchCreateSessions($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 +{ + $formattedDatabase = SpannerClient::databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $sessionCount = 0; + + batch_create_sessions_sample($formattedDatabase, $sessionCount); +} +// [END spanner_v1_generated_Spanner_BatchCreateSessions_sync] diff --git a/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/batch_write.php b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/batch_write.php new file mode 100644 index 000000000000..7d3aa26e340e --- /dev/null +++ b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/batch_write.php @@ -0,0 +1,102 @@ +setMutations($mutationGroupsMutations); + $mutationGroups = [$mutationGroup,]; + $request = (new BatchWriteRequest()) + ->setSession($formattedSession) + ->setMutationGroups($mutationGroups); + + // Call the API and handle any network failures. + try { + /** @var ServerStream $stream */ + $stream = $spannerClient->batchWrite($request); + + /** @var BatchWriteResponse $element */ + foreach ($stream->readAll() as $element) { + printf('Element data: %s' . PHP_EOL, $element->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 +{ + $formattedSession = SpannerClient::sessionName( + '[PROJECT]', + '[INSTANCE]', + '[DATABASE]', + '[SESSION]' + ); + + batch_write_sample($formattedSession); +} +// [END spanner_v1_generated_Spanner_BatchWrite_sync] diff --git a/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/begin_transaction.php b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/begin_transaction.php new file mode 100644 index 000000000000..f1bd435dc644 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/begin_transaction.php @@ -0,0 +1,83 @@ +setSession($formattedSession) + ->setOptions($options); + + // Call the API and handle any network failures. + try { + /** @var Transaction $response */ + $response = $spannerClient->beginTransaction($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 +{ + $formattedSession = SpannerClient::sessionName( + '[PROJECT]', + '[INSTANCE]', + '[DATABASE]', + '[SESSION]' + ); + + begin_transaction_sample($formattedSession); +} +// [END spanner_v1_generated_Spanner_BeginTransaction_sync] diff --git a/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/commit.php b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/commit.php new file mode 100644 index 000000000000..abd85545fc62 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/commit.php @@ -0,0 +1,92 @@ +setSession($formattedSession) + ->setMutations($mutations); + + // Call the API and handle any network failures. + try { + /** @var CommitResponse $response */ + $response = $spannerClient->commit($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 +{ + $formattedSession = SpannerClient::sessionName( + '[PROJECT]', + '[INSTANCE]', + '[DATABASE]', + '[SESSION]' + ); + + commit_sample($formattedSession); +} +// [END spanner_v1_generated_Spanner_Commit_sync] diff --git a/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/create_session.php b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/create_session.php new file mode 100644 index 000000000000..e16f02cbd08e --- /dev/null +++ b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/create_session.php @@ -0,0 +1,89 @@ +setDatabase($formattedDatabase); + + // Call the API and handle any network failures. + try { + /** @var Session $response */ + $response = $spannerClient->createSession($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 +{ + $formattedDatabase = SpannerClient::databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + + create_session_sample($formattedDatabase); +} +// [END spanner_v1_generated_Spanner_CreateSession_sync] diff --git a/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/delete_session.php b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/delete_session.php new file mode 100644 index 000000000000..73c3e3c4da9f --- /dev/null +++ b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/delete_session.php @@ -0,0 +1,71 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + $spannerClient->deleteSession($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 = SpannerClient::sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + + delete_session_sample($formattedName); +} +// [END spanner_v1_generated_Spanner_DeleteSession_sync] diff --git a/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/execute_batch_dml.php b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/execute_batch_dml.php new file mode 100644 index 000000000000..1c40318ba4d2 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/execute_batch_dml.php @@ -0,0 +1,110 @@ +setSql($statementsSql); + $statements = [$statement,]; + $request = (new ExecuteBatchDmlRequest()) + ->setSession($formattedSession) + ->setTransaction($transaction) + ->setStatements($statements) + ->setSeqno($seqno); + + // Call the API and handle any network failures. + try { + /** @var ExecuteBatchDmlResponse $response */ + $response = $spannerClient->executeBatchDml($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 +{ + $formattedSession = SpannerClient::sessionName( + '[PROJECT]', + '[INSTANCE]', + '[DATABASE]', + '[SESSION]' + ); + $statementsSql = '[SQL]'; + $seqno = 0; + + execute_batch_dml_sample($formattedSession, $statementsSql, $seqno); +} +// [END spanner_v1_generated_Spanner_ExecuteBatchDml_sync] diff --git a/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/execute_sql.php b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/execute_sql.php new file mode 100644 index 000000000000..5e27212686bb --- /dev/null +++ b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/execute_sql.php @@ -0,0 +1,91 @@ +setSession($formattedSession) + ->setSql($sql); + + // Call the API and handle any network failures. + try { + /** @var ResultSet $response */ + $response = $spannerClient->executeSql($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 +{ + $formattedSession = SpannerClient::sessionName( + '[PROJECT]', + '[INSTANCE]', + '[DATABASE]', + '[SESSION]' + ); + $sql = '[SQL]'; + + execute_sql_sample($formattedSession, $sql); +} +// [END spanner_v1_generated_Spanner_ExecuteSql_sync] diff --git a/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/execute_streaming_sql.php b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/execute_streaming_sql.php new file mode 100644 index 000000000000..330bd96b65ca --- /dev/null +++ b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/execute_streaming_sql.php @@ -0,0 +1,88 @@ +setSession($formattedSession) + ->setSql($sql); + + // Call the API and handle any network failures. + try { + /** @var ServerStream $stream */ + $stream = $spannerClient->executeStreamingSql($request); + + /** @var PartialResultSet $element */ + foreach ($stream->readAll() as $element) { + printf('Element data: %s' . PHP_EOL, $element->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 +{ + $formattedSession = SpannerClient::sessionName( + '[PROJECT]', + '[INSTANCE]', + '[DATABASE]', + '[SESSION]' + ); + $sql = '[SQL]'; + + execute_streaming_sql_sample($formattedSession, $sql); +} +// [END spanner_v1_generated_Spanner_ExecuteStreamingSql_sync] diff --git a/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/get_session.php b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/get_session.php new file mode 100644 index 000000000000..02478a3ef603 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/get_session.php @@ -0,0 +1,73 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var Session $response */ + $response = $spannerClient->getSession($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 = SpannerClient::sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + + get_session_sample($formattedName); +} +// [END spanner_v1_generated_Spanner_GetSession_sync] diff --git a/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/list_sessions.php b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/list_sessions.php new file mode 100644 index 000000000000..1f91d9202b21 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/list_sessions.php @@ -0,0 +1,76 @@ +setDatabase($formattedDatabase); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $spannerClient->listSessions($request); + + /** @var Session $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()); + } +} + +/** + * 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 +{ + $formattedDatabase = SpannerClient::databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + + list_sessions_sample($formattedDatabase); +} +// [END spanner_v1_generated_Spanner_ListSessions_sync] diff --git a/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/partition_query.php b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/partition_query.php new file mode 100644 index 000000000000..9af6f93afe0b --- /dev/null +++ b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/partition_query.php @@ -0,0 +1,101 @@ +setSession($formattedSession) + ->setSql($sql); + + // Call the API and handle any network failures. + try { + /** @var PartitionResponse $response */ + $response = $spannerClient->partitionQuery($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 +{ + $formattedSession = SpannerClient::sessionName( + '[PROJECT]', + '[INSTANCE]', + '[DATABASE]', + '[SESSION]' + ); + $sql = '[SQL]'; + + partition_query_sample($formattedSession, $sql); +} +// [END spanner_v1_generated_Spanner_PartitionQuery_sync] diff --git a/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/partition_read.php b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/partition_read.php new file mode 100644 index 000000000000..4db50f8a4371 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/partition_read.php @@ -0,0 +1,95 @@ +setSession($formattedSession) + ->setTable($table) + ->setKeySet($keySet); + + // Call the API and handle any network failures. + try { + /** @var PartitionResponse $response */ + $response = $spannerClient->partitionRead($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 +{ + $formattedSession = SpannerClient::sessionName( + '[PROJECT]', + '[INSTANCE]', + '[DATABASE]', + '[SESSION]' + ); + $table = '[TABLE]'; + + partition_read_sample($formattedSession, $table); +} +// [END spanner_v1_generated_Spanner_PartitionRead_sync] diff --git a/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/read.php b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/read.php new file mode 100644 index 000000000000..0efe5830717f --- /dev/null +++ b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/read.php @@ -0,0 +1,100 @@ +setSession($formattedSession) + ->setTable($table) + ->setColumns($columns) + ->setKeySet($keySet); + + // Call the API and handle any network failures. + try { + /** @var ResultSet $response */ + $response = $spannerClient->read($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 +{ + $formattedSession = SpannerClient::sessionName( + '[PROJECT]', + '[INSTANCE]', + '[DATABASE]', + '[SESSION]' + ); + $table = '[TABLE]'; + $columnsElement = '[COLUMNS]'; + + read_sample($formattedSession, $table, $columnsElement); +} +// [END spanner_v1_generated_Spanner_Read_sync] diff --git a/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/rollback.php b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/rollback.php new file mode 100644 index 000000000000..1eb7e9a22772 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/rollback.php @@ -0,0 +1,85 @@ +setSession($formattedSession) + ->setTransactionId($transactionId); + + // Call the API and handle any network failures. + try { + $spannerClient->rollback($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 +{ + $formattedSession = SpannerClient::sessionName( + '[PROJECT]', + '[INSTANCE]', + '[DATABASE]', + '[SESSION]' + ); + $transactionId = '...'; + + rollback_sample($formattedSession, $transactionId); +} +// [END spanner_v1_generated_Spanner_Rollback_sync] diff --git a/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/streaming_read.php b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/streaming_read.php new file mode 100644 index 000000000000..48ee32a9a094 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/samples/V1/SpannerClient/streaming_read.php @@ -0,0 +1,99 @@ +setSession($formattedSession) + ->setTable($table) + ->setColumns($columns) + ->setKeySet($keySet); + + // Call the API and handle any network failures. + try { + /** @var ServerStream $stream */ + $stream = $spannerClient->streamingRead($request); + + /** @var PartialResultSet $element */ + foreach ($stream->readAll() as $element) { + printf('Element data: %s' . PHP_EOL, $element->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 +{ + $formattedSession = SpannerClient::sessionName( + '[PROJECT]', + '[INSTANCE]', + '[DATABASE]', + '[SESSION]' + ); + $table = '[TABLE]'; + $columnsElement = '[COLUMNS]'; + + streaming_read_sample($formattedSession, $table, $columnsElement); +} +// [END spanner_v1_generated_Spanner_StreamingRead_sync] diff --git a/owl-bot-staging/Spanner/v1/src/V1/Client/SpannerClient.php b/owl-bot-staging/Spanner/v1/src/V1/Client/SpannerClient.php new file mode 100644 index 000000000000..e794a10d3d54 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/src/V1/Client/SpannerClient.php @@ -0,0 +1,836 @@ + batchCreateSessionsAsync(BatchCreateSessionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface beginTransactionAsync(BeginTransactionRequest $request, array $optionalArgs = []) + * @method PromiseInterface commitAsync(CommitRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSessionAsync(CreateSessionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSessionAsync(DeleteSessionRequest $request, array $optionalArgs = []) + * @method PromiseInterface executeBatchDmlAsync(ExecuteBatchDmlRequest $request, array $optionalArgs = []) + * @method PromiseInterface executeSqlAsync(ExecuteSqlRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSessionAsync(GetSessionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSessionsAsync(ListSessionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface partitionQueryAsync(PartitionQueryRequest $request, array $optionalArgs = []) + * @method PromiseInterface partitionReadAsync(PartitionReadRequest $request, array $optionalArgs = []) + * @method PromiseInterface readAsync(ReadRequest $request, array $optionalArgs = []) + * @method PromiseInterface rollbackAsync(RollbackRequest $request, array $optionalArgs = []) + */ +final class SpannerClient +{ + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.spanner.v1.Spanner'; + + /** + * The default address of the service. + * + * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. + */ + private const SERVICE_ADDRESS = 'spanner.googleapis.com'; + + /** The address template of the service. */ + private const SERVICE_ADDRESS_TEMPLATE = 'spanner.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', + 'https://www.googleapis.com/auth/spanner.data', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/spanner_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/spanner_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/spanner_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/spanner_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a database + * resource. + * + * @param string $project + * @param string $instance + * @param string $database + * + * @return string The formatted database resource. + */ + public static function databaseName(string $project, string $instance, string $database): string + { + return self::getPathTemplate('database')->render([ + 'project' => $project, + 'instance' => $instance, + 'database' => $database, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a session + * resource. + * + * @param string $project + * @param string $instance + * @param string $database + * @param string $session + * + * @return string The formatted session resource. + */ + public static function sessionName(string $project, string $instance, string $database, string $session): string + { + return self::getPathTemplate('session')->render([ + 'project' => $project, + 'instance' => $instance, + 'database' => $database, + 'session' => $session, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - database: projects/{project}/instances/{instance}/databases/{database} + * - session: projects/{project}/instances/{instance}/databases/{database}/sessions/{session} + * + * 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. + * + * Setting the "SPANNER_EMULATOR_HOST" environment variable will automatically set + * the API Endpoint to the value specified in the variable, as well as ensure that + * empty credentials are used in the transport layer. + * + * @param array $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 'spanner.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * 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 + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @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 + * } + * + * @throws ValidationException + */ + public function __construct(array $options = []) + { + $options = $this->setDefaultEmulatorConfig($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); + } + + /** + * Creates multiple new sessions. + * + * This API can be used to initialize a session cache on the clients. + * See https://goo.gl/TgSFN2 for best practices on session cache management. + * + * The async variant is {@see SpannerClient::batchCreateSessionsAsync()} . + * + * @example samples/V1/SpannerClient/batch_create_sessions.php + * + * @param BatchCreateSessionsRequest $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 BatchCreateSessionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchCreateSessions(BatchCreateSessionsRequest $request, array $callOptions = []): BatchCreateSessionsResponse + { + return $this->startApiCall('BatchCreateSessions', $request, $callOptions)->wait(); + } + + /** + * Batches the supplied mutation groups in a collection of efficient + * transactions. All mutations in a group are committed atomically. However, + * mutations across groups can be committed non-atomically in an unspecified + * order and thus, they must be independent of each other. Partial failure is + * possible, i.e., some groups may have been committed successfully, while + * some may have failed. The results of individual batches are streamed into + * the response as the batches are applied. + * + * BatchWrite requests are not replay protected, meaning that each mutation + * group may be applied more than once. Replays of non-idempotent mutations + * may have undesirable effects. For example, replays of an insert mutation + * may produce an already exists error or if you use generated or commit + * timestamp-based keys, it may result in additional rows being added to the + * mutation's table. We recommend structuring your mutation groups to be + * idempotent to avoid this issue. + * + * @example samples/V1/SpannerClient/batch_write.php + * + * @param BatchWriteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchWrite(BatchWriteRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('BatchWrite', $request, $callOptions); + } + + /** + * Begins a new transaction. This step can often be skipped: + * [Read][google.spanner.v1.Spanner.Read], + * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and + * [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a + * side-effect. + * + * The async variant is {@see SpannerClient::beginTransactionAsync()} . + * + * @example samples/V1/SpannerClient/begin_transaction.php + * + * @param BeginTransactionRequest $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 Transaction + * + * @throws ApiException Thrown if the API call fails. + */ + public function beginTransaction(BeginTransactionRequest $request, array $callOptions = []): Transaction + { + return $this->startApiCall('BeginTransaction', $request, $callOptions)->wait(); + } + + /** + * Commits a transaction. The request includes the mutations to be + * applied to rows in the database. + * + * `Commit` might return an `ABORTED` error. This can occur at any time; + * commonly, the cause is conflicts with concurrent + * transactions. However, it can also happen for a variety of other + * reasons. If `Commit` returns `ABORTED`, the caller should re-attempt + * the transaction from the beginning, re-using the same session. + * + * On very rare occasions, `Commit` might return `UNKNOWN`. This can happen, + * for example, if the client job experiences a 1+ hour networking failure. + * At that point, Cloud Spanner has lost track of the transaction outcome and + * we recommend that you perform another read from the database to see the + * state of things as they are now. + * + * The async variant is {@see SpannerClient::commitAsync()} . + * + * @example samples/V1/SpannerClient/commit.php + * + * @param CommitRequest $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 CommitResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function commit(CommitRequest $request, array $callOptions = []): CommitResponse + { + return $this->startApiCall('Commit', $request, $callOptions)->wait(); + } + + /** + * Creates a new session. A session can be used to perform + * transactions that read and/or modify data in a Cloud Spanner database. + * Sessions are meant to be reused for many consecutive + * transactions. + * + * Sessions can only execute one transaction at a time. To execute + * multiple concurrent read-write/write-only transactions, create + * multiple sessions. Note that standalone reads and queries use a + * transaction internally, and count toward the one transaction + * limit. + * + * Active sessions use additional server resources, so it is a good idea to + * delete idle and unneeded sessions. + * Aside from explicit deletes, Cloud Spanner may delete sessions for which no + * operations are sent for more than an hour. If a session is deleted, + * requests to it return `NOT_FOUND`. + * + * Idle sessions can be kept alive by sending a trivial SQL query + * periodically, e.g., `"SELECT 1"`. + * + * The async variant is {@see SpannerClient::createSessionAsync()} . + * + * @example samples/V1/SpannerClient/create_session.php + * + * @param CreateSessionRequest $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 Session + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSession(CreateSessionRequest $request, array $callOptions = []): Session + { + return $this->startApiCall('CreateSession', $request, $callOptions)->wait(); + } + + /** + * Ends a session, releasing server resources associated with it. This will + * asynchronously trigger cancellation of any operations that are running with + * this session. + * + * The async variant is {@see SpannerClient::deleteSessionAsync()} . + * + * @example samples/V1/SpannerClient/delete_session.php + * + * @param DeleteSessionRequest $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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSession(DeleteSessionRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteSession', $request, $callOptions)->wait(); + } + + /** + * Executes a batch of SQL DML statements. This method allows many statements + * to be run with lower latency than submitting them sequentially with + * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. + * + * Statements are executed in sequential order. A request can succeed even if + * a statement fails. The + * [ExecuteBatchDmlResponse.status][google.spanner.v1.ExecuteBatchDmlResponse.status] + * field in the response provides information about the statement that failed. + * Clients must inspect this field to determine whether an error occurred. + * + * Execution stops after the first failed statement; the remaining statements + * are not executed. + * + * The async variant is {@see SpannerClient::executeBatchDmlAsync()} . + * + * @example samples/V1/SpannerClient/execute_batch_dml.php + * + * @param ExecuteBatchDmlRequest $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 ExecuteBatchDmlResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function executeBatchDml(ExecuteBatchDmlRequest $request, array $callOptions = []): ExecuteBatchDmlResponse + { + return $this->startApiCall('ExecuteBatchDml', $request, $callOptions)->wait(); + } + + /** + * Executes an SQL statement, returning all results in a single reply. This + * method cannot be used to return a result set larger than 10 MiB; + * if the query yields more data than that, the query fails with + * a `FAILED_PRECONDITION` error. + * + * Operations inside read-write transactions might return `ABORTED`. If + * this occurs, the application should restart the transaction from + * the beginning. See [Transaction][google.spanner.v1.Transaction] for more + * details. + * + * Larger result sets can be fetched in streaming fashion by calling + * [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] + * instead. + * + * The async variant is {@see SpannerClient::executeSqlAsync()} . + * + * @example samples/V1/SpannerClient/execute_sql.php + * + * @param ExecuteSqlRequest $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 ResultSet + * + * @throws ApiException Thrown if the API call fails. + */ + public function executeSql(ExecuteSqlRequest $request, array $callOptions = []): ResultSet + { + return $this->startApiCall('ExecuteSql', $request, $callOptions)->wait(); + } + + /** + * Like [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], except returns the + * result set as a stream. Unlike + * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], there is no limit on + * the size of the returned result set. However, no individual row in the + * result set can exceed 100 MiB, and no column value can exceed 10 MiB. + * + * @example samples/V1/SpannerClient/execute_streaming_sql.php + * + * @param ExecuteSqlRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function executeStreamingSql(ExecuteSqlRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('ExecuteStreamingSql', $request, $callOptions); + } + + /** + * Gets a session. Returns `NOT_FOUND` if the session does not exist. + * This is mainly useful for determining whether a session is still + * alive. + * + * The async variant is {@see SpannerClient::getSessionAsync()} . + * + * @example samples/V1/SpannerClient/get_session.php + * + * @param GetSessionRequest $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 Session + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSession(GetSessionRequest $request, array $callOptions = []): Session + { + return $this->startApiCall('GetSession', $request, $callOptions)->wait(); + } + + /** + * Lists all sessions in a given database. + * + * The async variant is {@see SpannerClient::listSessionsAsync()} . + * + * @example samples/V1/SpannerClient/list_sessions.php + * + * @param ListSessionsRequest $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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSessions(ListSessionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSessions', $request, $callOptions); + } + + /** + * Creates a set of partition tokens that can be used to execute a query + * operation in parallel. Each of the returned partition tokens can be used + * by [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] to + * specify a subset of the query result to read. The same session and + * read-only transaction must be used by the PartitionQueryRequest used to + * create the partition tokens and the ExecuteSqlRequests that use the + * partition tokens. + * + * Partition tokens become invalid when the session used to create them + * is deleted, is idle for too long, begins a new transaction, or becomes too + * old. When any of these happen, it is not possible to resume the query, and + * the whole operation must be restarted from the beginning. + * + * The async variant is {@see SpannerClient::partitionQueryAsync()} . + * + * @example samples/V1/SpannerClient/partition_query.php + * + * @param PartitionQueryRequest $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 PartitionResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function partitionQuery(PartitionQueryRequest $request, array $callOptions = []): PartitionResponse + { + return $this->startApiCall('PartitionQuery', $request, $callOptions)->wait(); + } + + /** + * Creates a set of partition tokens that can be used to execute a read + * operation in parallel. Each of the returned partition tokens can be used + * by [StreamingRead][google.spanner.v1.Spanner.StreamingRead] to specify a + * subset of the read result to read. The same session and read-only + * transaction must be used by the PartitionReadRequest used to create the + * partition tokens and the ReadRequests that use the partition tokens. There + * are no ordering guarantees on rows returned among the returned partition + * tokens, or even within each individual StreamingRead call issued with a + * partition_token. + * + * Partition tokens become invalid when the session used to create them + * is deleted, is idle for too long, begins a new transaction, or becomes too + * old. When any of these happen, it is not possible to resume the read, and + * the whole operation must be restarted from the beginning. + * + * The async variant is {@see SpannerClient::partitionReadAsync()} . + * + * @example samples/V1/SpannerClient/partition_read.php + * + * @param PartitionReadRequest $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 PartitionResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function partitionRead(PartitionReadRequest $request, array $callOptions = []): PartitionResponse + { + return $this->startApiCall('PartitionRead', $request, $callOptions)->wait(); + } + + /** + * Reads rows from the database using key lookups and scans, as a + * simple key/value style alternative to + * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. This method cannot be + * used to return a result set larger than 10 MiB; if the read matches more + * data than that, the read fails with a `FAILED_PRECONDITION` + * error. + * + * Reads inside read-write transactions might return `ABORTED`. If + * this occurs, the application should restart the transaction from + * the beginning. See [Transaction][google.spanner.v1.Transaction] for more + * details. + * + * Larger result sets can be yielded in streaming fashion by calling + * [StreamingRead][google.spanner.v1.Spanner.StreamingRead] instead. + * + * The async variant is {@see SpannerClient::readAsync()} . + * + * @example samples/V1/SpannerClient/read.php + * + * @param ReadRequest $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 ResultSet + * + * @throws ApiException Thrown if the API call fails. + */ + public function read(ReadRequest $request, array $callOptions = []): ResultSet + { + return $this->startApiCall('Read', $request, $callOptions)->wait(); + } + + /** + * Rolls back a transaction, releasing any locks it holds. It is a good + * idea to call this for any transaction that includes one or more + * [Read][google.spanner.v1.Spanner.Read] or + * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] requests and ultimately + * decides not to commit. + * + * `Rollback` returns `OK` if it successfully aborts the transaction, the + * transaction was already aborted, or the transaction is not + * found. `Rollback` never returns `ABORTED`. + * + * The async variant is {@see SpannerClient::rollbackAsync()} . + * + * @example samples/V1/SpannerClient/rollback.php + * + * @param RollbackRequest $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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function rollback(RollbackRequest $request, array $callOptions = []): void + { + $this->startApiCall('Rollback', $request, $callOptions)->wait(); + } + + /** + * Like [Read][google.spanner.v1.Spanner.Read], except returns the result set + * as a stream. Unlike [Read][google.spanner.v1.Spanner.Read], there is no + * limit on the size of the returned result set. However, no individual row in + * the result set can exceed 100 MiB, and no column value can exceed + * 10 MiB. + * + * @example samples/V1/SpannerClient/streaming_read.php + * + * @param ReadRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function streamingRead(ReadRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('StreamingRead', $request, $callOptions); + } + + /** Configure the gapic configuration to use a service emulator. */ + private function setDefaultEmulatorConfig(array $options): array + { + $emulatorHost = getenv('SPANNER_EMULATOR_HOST'); + if (empty($emulatorHost)) { + return $options; + } + + if ($scheme = parse_url($emulatorHost, PHP_URL_SCHEME)) { + $search = $scheme . '://'; + $emulatorHost = str_replace($search, '', $emulatorHost); + } + + $options['apiEndpoint'] ??= $emulatorHost; + $options['transportConfig']['grpc']['stubOpts']['credentials'] ??= ChannelCredentials::createInsecure(); + $options['credentials'] ??= new InsecureCredentialsWrapper(); + return $options; + } +} diff --git a/owl-bot-staging/Spanner/v1/src/V1/Gapic/SpannerGapicClient.php b/owl-bot-staging/Spanner/v1/src/V1/Gapic/SpannerGapicClient.php new file mode 100644 index 000000000000..836e5478470b --- /dev/null +++ b/owl-bot-staging/Spanner/v1/src/V1/Gapic/SpannerGapicClient.php @@ -0,0 +1,1919 @@ +databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + * $sessionCount = 0; + * $response = $spannerClient->batchCreateSessions($formattedDatabase, $sessionCount); + * } finally { + * $spannerClient->close(); + * } + * ``` + * + * 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. + * + * @deprecated Please use the new service client {@see \Google\Cloud\Spanner\V1\Client\SpannerClient}. + */ +class SpannerGapicClient +{ + use GapicClientTrait; + + /** The name of the service. */ + const SERVICE_NAME = 'google.spanner.v1.Spanner'; + + /** + * The default address of the service. + * + * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. + */ + const SERVICE_ADDRESS = 'spanner.googleapis.com'; + + /** The address template of the service. */ + private const SERVICE_ADDRESS_TEMPLATE = 'spanner.UNIVERSE_DOMAIN'; + + /** The default port of the service. */ + const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/spanner.data', + ]; + + private static $databaseNameTemplate; + + private static $sessionNameTemplate; + + private static $pathTemplateMap; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/spanner_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/spanner_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/spanner_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/spanner_rest_client_config.php', + ], + ], + ]; + } + + private static function getDatabaseNameTemplate() + { + if (self::$databaseNameTemplate == null) { + self::$databaseNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/databases/{database}'); + } + + return self::$databaseNameTemplate; + } + + private static function getSessionNameTemplate() + { + if (self::$sessionNameTemplate == null) { + self::$sessionNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/databases/{database}/sessions/{session}'); + } + + return self::$sessionNameTemplate; + } + + private static function getPathTemplateMap() + { + if (self::$pathTemplateMap == null) { + self::$pathTemplateMap = [ + 'database' => self::getDatabaseNameTemplate(), + 'session' => self::getSessionNameTemplate(), + ]; + } + + return self::$pathTemplateMap; + } + + /** + * Formats a string containing the fully-qualified path to represent a database + * resource. + * + * @param string $project + * @param string $instance + * @param string $database + * + * @return string The formatted database resource. + */ + public static function databaseName($project, $instance, $database) + { + return self::getDatabaseNameTemplate()->render([ + 'project' => $project, + 'instance' => $instance, + 'database' => $database, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a session + * resource. + * + * @param string $project + * @param string $instance + * @param string $database + * @param string $session + * + * @return string The formatted session resource. + */ + public static function sessionName($project, $instance, $database, $session) + { + return self::getSessionNameTemplate()->render([ + 'project' => $project, + 'instance' => $instance, + 'database' => $database, + 'session' => $session, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - database: projects/{project}/instances/{instance}/databases/{database} + * - session: projects/{project}/instances/{instance}/databases/{database}/sessions/{session} + * + * 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($formattedName, $template = null) + { + $templateMap = self::getPathTemplateMap(); + if ($template) { + if (!isset($templateMap[$template])) { + throw new ValidationException("Template name $template does not exist"); + } + + return $templateMap[$template]->match($formattedName); + } + + foreach ($templateMap as $templateName => $pathTemplate) { + try { + return $pathTemplate->match($formattedName); + } catch (ValidationException $ex) { + // Swallow the exception to continue trying other path templates + } + } + + throw new ValidationException("Input did not match any known format. Input: $formattedName"); + } + + /** + * Constructor. + * + * @param array $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 'spanner.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * 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 + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @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. + * } + * + * @throws ValidationException + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** + * Creates multiple new sessions. + * + * This API can be used to initialize a session cache on the clients. + * See https://goo.gl/TgSFN2 for best practices on session cache management. + * + * Sample code: + * ``` + * $spannerClient = new SpannerClient(); + * try { + * $formattedDatabase = $spannerClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + * $sessionCount = 0; + * $response = $spannerClient->batchCreateSessions($formattedDatabase, $sessionCount); + * } finally { + * $spannerClient->close(); + * } + * ``` + * + * @param string $database Required. The database in which the new sessions are created. + * @param int $sessionCount Required. The number of sessions to be created in this batch call. + * The API may return fewer than the requested number of sessions. If a + * specific number of sessions are desired, the client can make additional + * calls to BatchCreateSessions (adjusting + * [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] + * as necessary). + * @param array $optionalArgs { + * Optional. + * + * @type Session $sessionTemplate + * Parameters to be applied to each created session. + * @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 \Google\Cloud\Spanner\V1\BatchCreateSessionsResponse + * + * @throws ApiException if the remote call fails + */ + public function batchCreateSessions($database, $sessionCount, array $optionalArgs = []) + { + $request = new BatchCreateSessionsRequest(); + $requestParamHeaders = []; + $request->setDatabase($database); + $request->setSessionCount($sessionCount); + $requestParamHeaders['database'] = $database; + if (isset($optionalArgs['sessionTemplate'])) { + $request->setSessionTemplate($optionalArgs['sessionTemplate']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('BatchCreateSessions', BatchCreateSessionsResponse::class, $optionalArgs, $request)->wait(); + } + + /** + * Batches the supplied mutation groups in a collection of efficient + * transactions. All mutations in a group are committed atomically. However, + * mutations across groups can be committed non-atomically in an unspecified + * order and thus, they must be independent of each other. Partial failure is + * possible, i.e., some groups may have been committed successfully, while + * some may have failed. The results of individual batches are streamed into + * the response as the batches are applied. + * + * BatchWrite requests are not replay protected, meaning that each mutation + * group may be applied more than once. Replays of non-idempotent mutations + * may have undesirable effects. For example, replays of an insert mutation + * may produce an already exists error or if you use generated or commit + * timestamp-based keys, it may result in additional rows being added to the + * mutation's table. We recommend structuring your mutation groups to be + * idempotent to avoid this issue. + * + * Sample code: + * ``` + * $spannerClient = new SpannerClient(); + * try { + * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + * $mutationGroups = []; + * // Read all responses until the stream is complete + * $stream = $spannerClient->batchWrite($formattedSession, $mutationGroups); + * foreach ($stream->readAll() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $spannerClient->close(); + * } + * ``` + * + * @param string $session Required. The session in which the batch request is to be run. + * @param MutationGroup[] $mutationGroups Required. The groups of mutations to be applied. + * @param array $optionalArgs { + * Optional. + * + * @type RequestOptions $requestOptions + * Common options for this request. + * @type bool $excludeTxnFromChangeStreams + * Optional. When `exclude_txn_from_change_streams` is set to `true`: + * * Mutations from all transactions in this batch write operation will not + * be recorded in change streams with DDL option `allow_txn_exclusion=true` + * that are tracking columns modified by these transactions. + * * Mutations from all transactions in this batch write operation will be + * recorded in change streams with DDL option `allow_txn_exclusion=false or + * not set` that are tracking columns modified by these transactions. + * + * When `exclude_txn_from_change_streams` is set to `false` or not set, + * mutations from all transactions in this batch write operation will be + * recorded in all change streams that are tracking columns modified by these + * transactions. + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return \Google\ApiCore\ServerStream + * + * @throws ApiException if the remote call fails + */ + public function batchWrite($session, $mutationGroups, array $optionalArgs = []) + { + $request = new BatchWriteRequest(); + $requestParamHeaders = []; + $request->setSession($session); + $request->setMutationGroups($mutationGroups); + $requestParamHeaders['session'] = $session; + if (isset($optionalArgs['requestOptions'])) { + $request->setRequestOptions($optionalArgs['requestOptions']); + } + + if (isset($optionalArgs['excludeTxnFromChangeStreams'])) { + $request->setExcludeTxnFromChangeStreams($optionalArgs['excludeTxnFromChangeStreams']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('BatchWrite', BatchWriteResponse::class, $optionalArgs, $request, Call::SERVER_STREAMING_CALL); + } + + /** + * Begins a new transaction. This step can often be skipped: + * [Read][google.spanner.v1.Spanner.Read], + * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and + * [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a + * side-effect. + * + * Sample code: + * ``` + * $spannerClient = new SpannerClient(); + * try { + * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + * $options = new TransactionOptions(); + * $response = $spannerClient->beginTransaction($formattedSession, $options); + * } finally { + * $spannerClient->close(); + * } + * ``` + * + * @param string $session Required. The session in which the transaction runs. + * @param TransactionOptions $options Required. Options for the new transaction. + * @param array $optionalArgs { + * Optional. + * + * @type RequestOptions $requestOptions + * Common options for this request. + * Priority is ignored for this request. Setting the priority in this + * request_options struct will not do anything. To set the priority for a + * transaction, set it on the reads and writes that are part of this + * transaction instead. + * @type Mutation $mutationKey + * Optional. Required for read-write transactions on a multiplexed session + * that commit mutations but do not perform any reads or queries. Clients + * should randomly select one of the mutations from the mutation set and send + * it as a part of this request. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * @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 \Google\Cloud\Spanner\V1\Transaction + * + * @throws ApiException if the remote call fails + */ + public function beginTransaction($session, $options, array $optionalArgs = []) + { + $request = new BeginTransactionRequest(); + $requestParamHeaders = []; + $request->setSession($session); + $request->setOptions($options); + $requestParamHeaders['session'] = $session; + if (isset($optionalArgs['requestOptions'])) { + $request->setRequestOptions($optionalArgs['requestOptions']); + } + + if (isset($optionalArgs['mutationKey'])) { + $request->setMutationKey($optionalArgs['mutationKey']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('BeginTransaction', Transaction::class, $optionalArgs, $request)->wait(); + } + + /** + * Commits a transaction. The request includes the mutations to be + * applied to rows in the database. + * + * `Commit` might return an `ABORTED` error. This can occur at any time; + * commonly, the cause is conflicts with concurrent + * transactions. However, it can also happen for a variety of other + * reasons. If `Commit` returns `ABORTED`, the caller should re-attempt + * the transaction from the beginning, re-using the same session. + * + * On very rare occasions, `Commit` might return `UNKNOWN`. This can happen, + * for example, if the client job experiences a 1+ hour networking failure. + * At that point, Cloud Spanner has lost track of the transaction outcome and + * we recommend that you perform another read from the database to see the + * state of things as they are now. + * + * Sample code: + * ``` + * $spannerClient = new SpannerClient(); + * try { + * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + * $mutations = []; + * $response = $spannerClient->commit($formattedSession, $mutations); + * } finally { + * $spannerClient->close(); + * } + * ``` + * + * @param string $session Required. The session in which the transaction to be committed is running. + * @param Mutation[] $mutations The mutations to be executed when this transaction commits. All + * mutations are applied atomically, in the order they appear in + * this list. + * @param array $optionalArgs { + * Optional. + * + * @type string $transactionId + * Commit a previously-started transaction. + * @type TransactionOptions $singleUseTransaction + * Execute mutations in a temporary transaction. Note that unlike + * commit of a previously-started transaction, commit with a + * temporary transaction is non-idempotent. That is, if the + * `CommitRequest` is sent to Cloud Spanner more than once (for + * instance, due to retries in the application, or in the + * transport library), it is possible that the mutations are + * executed more than once. If this is undesirable, use + * [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and + * [Commit][google.spanner.v1.Spanner.Commit] instead. + * @type bool $returnCommitStats + * If `true`, then statistics related to the transaction will be included in + * the [CommitResponse][google.spanner.v1.CommitResponse.commit_stats]. + * Default value is `false`. + * @type Duration $maxCommitDelay + * Optional. The amount of latency this request is willing to incur in order + * to improve throughput. If this field is not set, Spanner assumes requests + * are relatively latency sensitive and automatically determines an + * appropriate delay time. You can specify a batching delay value between 0 + * and 500 ms. + * @type RequestOptions $requestOptions + * Common options for this request. + * @type MultiplexedSessionPrecommitToken $precommitToken + * Optional. If the read-write transaction was executed on a multiplexed + * session, the precommit token with the highest sequence number received in + * this transaction attempt, should be included here. Failing to do so will + * result in a FailedPrecondition error. + * This feature is not yet supported and will result in an UNIMPLEMENTED + * error. + * @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 \Google\Cloud\Spanner\V1\CommitResponse + * + * @throws ApiException if the remote call fails + */ + public function commit($session, $mutations, array $optionalArgs = []) + { + $request = new CommitRequest(); + $requestParamHeaders = []; + $request->setSession($session); + $request->setMutations($mutations); + $requestParamHeaders['session'] = $session; + if (isset($optionalArgs['transactionId'])) { + $request->setTransactionId($optionalArgs['transactionId']); + } + + if (isset($optionalArgs['singleUseTransaction'])) { + $request->setSingleUseTransaction($optionalArgs['singleUseTransaction']); + } + + if (isset($optionalArgs['returnCommitStats'])) { + $request->setReturnCommitStats($optionalArgs['returnCommitStats']); + } + + if (isset($optionalArgs['maxCommitDelay'])) { + $request->setMaxCommitDelay($optionalArgs['maxCommitDelay']); + } + + if (isset($optionalArgs['requestOptions'])) { + $request->setRequestOptions($optionalArgs['requestOptions']); + } + + if (isset($optionalArgs['precommitToken'])) { + $request->setPrecommitToken($optionalArgs['precommitToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('Commit', CommitResponse::class, $optionalArgs, $request)->wait(); + } + + /** + * Creates a new session. A session can be used to perform + * transactions that read and/or modify data in a Cloud Spanner database. + * Sessions are meant to be reused for many consecutive + * transactions. + * + * Sessions can only execute one transaction at a time. To execute + * multiple concurrent read-write/write-only transactions, create + * multiple sessions. Note that standalone reads and queries use a + * transaction internally, and count toward the one transaction + * limit. + * + * Active sessions use additional server resources, so it is a good idea to + * delete idle and unneeded sessions. + * Aside from explicit deletes, Cloud Spanner may delete sessions for which no + * operations are sent for more than an hour. If a session is deleted, + * requests to it return `NOT_FOUND`. + * + * Idle sessions can be kept alive by sending a trivial SQL query + * periodically, e.g., `"SELECT 1"`. + * + * Sample code: + * ``` + * $spannerClient = new SpannerClient(); + * try { + * $formattedDatabase = $spannerClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + * $response = $spannerClient->createSession($formattedDatabase); + * } finally { + * $spannerClient->close(); + * } + * ``` + * + * @param string $database Required. The database in which the new session is created. + * @param array $optionalArgs { + * Optional. + * + * @type Session $session + * Required. The session to create. + * @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 \Google\Cloud\Spanner\V1\Session + * + * @throws ApiException if the remote call fails + */ + public function createSession($database, array $optionalArgs = []) + { + $request = new CreateSessionRequest(); + $requestParamHeaders = []; + $request->setDatabase($database); + $requestParamHeaders['database'] = $database; + if (isset($optionalArgs['session'])) { + $request->setSession($optionalArgs['session']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateSession', Session::class, $optionalArgs, $request)->wait(); + } + + /** + * Ends a session, releasing server resources associated with it. This will + * asynchronously trigger cancellation of any operations that are running with + * this session. + * + * Sample code: + * ``` + * $spannerClient = new SpannerClient(); + * try { + * $formattedName = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + * $spannerClient->deleteSession($formattedName); + * } finally { + * $spannerClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the session to delete. + * @param array $optionalArgs { + * 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. + * } + * + * @throws ApiException if the remote call fails + */ + public function deleteSession($name, array $optionalArgs = []) + { + $request = new DeleteSessionRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteSession', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Executes a batch of SQL DML statements. This method allows many statements + * to be run with lower latency than submitting them sequentially with + * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. + * + * Statements are executed in sequential order. A request can succeed even if + * a statement fails. The + * [ExecuteBatchDmlResponse.status][google.spanner.v1.ExecuteBatchDmlResponse.status] + * field in the response provides information about the statement that failed. + * Clients must inspect this field to determine whether an error occurred. + * + * Execution stops after the first failed statement; the remaining statements + * are not executed. + * + * Sample code: + * ``` + * $spannerClient = new SpannerClient(); + * try { + * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + * $transaction = new TransactionSelector(); + * $statements = []; + * $seqno = 0; + * $response = $spannerClient->executeBatchDml($formattedSession, $transaction, $statements, $seqno); + * } finally { + * $spannerClient->close(); + * } + * ``` + * + * @param string $session Required. The session in which the DML statements should be performed. + * @param TransactionSelector $transaction Required. The transaction to use. Must be a read-write transaction. + * + * To protect against replays, single-use transactions are not supported. The + * caller must either supply an existing transaction ID or begin a new + * transaction. + * @param Statement[] $statements Required. The list of statements to execute in this batch. Statements are + * executed serially, such that the effects of statement `i` are visible to + * statement `i+1`. Each statement must be a DML statement. Execution stops at + * the first failed statement; the remaining statements are not executed. + * + * Callers must provide at least one statement. + * @param int $seqno Required. A per-transaction sequence number used to identify this request. + * This field makes each request idempotent such that if the request is + * received multiple times, at most one will succeed. + * + * The sequence number must be monotonically increasing within the + * transaction. If a request arrives for the first time with an out-of-order + * sequence number, the transaction may be aborted. Replays of previously + * handled requests will yield the same response as the first execution. + * @param array $optionalArgs { + * Optional. + * + * @type RequestOptions $requestOptions + * Common options for this request. + * @type bool $lastStatements + * Optional. If set to true, this request marks the end of the transaction. + * The transaction should be committed or aborted after these statements + * execute, and attempts to execute any other requests against this + * transaction (including reads and queries) will be rejected. + * + * Setting this option may cause some error reporting to be deferred until + * commit time (e.g. validation of unique constraints). Given this, successful + * execution of statements should not be assumed until a subsequent Commit + * call completes successfully. + * @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 \Google\Cloud\Spanner\V1\ExecuteBatchDmlResponse + * + * @throws ApiException if the remote call fails + */ + public function executeBatchDml($session, $transaction, $statements, $seqno, array $optionalArgs = []) + { + $request = new ExecuteBatchDmlRequest(); + $requestParamHeaders = []; + $request->setSession($session); + $request->setTransaction($transaction); + $request->setStatements($statements); + $request->setSeqno($seqno); + $requestParamHeaders['session'] = $session; + if (isset($optionalArgs['requestOptions'])) { + $request->setRequestOptions($optionalArgs['requestOptions']); + } + + if (isset($optionalArgs['lastStatements'])) { + $request->setLastStatements($optionalArgs['lastStatements']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('ExecuteBatchDml', ExecuteBatchDmlResponse::class, $optionalArgs, $request)->wait(); + } + + /** + * Executes an SQL statement, returning all results in a single reply. This + * method cannot be used to return a result set larger than 10 MiB; + * if the query yields more data than that, the query fails with + * a `FAILED_PRECONDITION` error. + * + * Operations inside read-write transactions might return `ABORTED`. If + * this occurs, the application should restart the transaction from + * the beginning. See [Transaction][google.spanner.v1.Transaction] for more + * details. + * + * Larger result sets can be fetched in streaming fashion by calling + * [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] + * instead. + * + * Sample code: + * ``` + * $spannerClient = new SpannerClient(); + * try { + * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + * $sql = 'sql'; + * $response = $spannerClient->executeSql($formattedSession, $sql); + * } finally { + * $spannerClient->close(); + * } + * ``` + * + * @param string $session Required. The session in which the SQL query should be performed. + * @param string $sql Required. The SQL string. + * @param array $optionalArgs { + * Optional. + * + * @type TransactionSelector $transaction + * The transaction to use. + * + * For queries, if none is provided, the default is a temporary read-only + * transaction with strong concurrency. + * + * Standard DML statements require a read-write transaction. To protect + * against replays, single-use transactions are not supported. The caller + * must either supply an existing transaction ID or begin a new transaction. + * + * Partitioned DML requires an existing Partitioned DML transaction ID. + * @type Struct $params + * Parameter names and values that bind to placeholders in the SQL string. + * + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names must conform + * to the naming requirements of identifiers as specified at + * https://cloud.google.com/spanner/docs/lexical#identifiers. + * + * Parameters can appear anywhere that a literal value is expected. The same + * parameter name can be used more than once, for example: + * + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * + * It is an error to execute a SQL statement with unbound parameters. + * @type array $paramTypes + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in + * [params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings. + * + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL statement parameters. See the + * definition of [Type][google.spanner.v1.Type] for more information + * about SQL types. + * @type string $resumeToken + * If this request is resuming a previously interrupted SQL statement + * execution, `resume_token` should be copied from the last + * [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the + * interruption. Doing this enables the new SQL statement execution to resume + * where the last one left off. The rest of the request parameters must + * exactly match the request that yielded this token. + * @type int $queryMode + * Used to control the amount of debugging information returned in + * [ResultSetStats][google.spanner.v1.ResultSetStats]. If + * [partition_token][google.spanner.v1.ExecuteSqlRequest.partition_token] is + * set, [query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] can only + * be set to + * [QueryMode.NORMAL][google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL]. + * For allowed values, use constants defined on {@see \Google\Cloud\Spanner\V1\ExecuteSqlRequest\QueryMode} + * @type string $partitionToken + * If present, results will be restricted to the specified partition + * previously created using PartitionQuery(). There must be an exact + * match for the values of fields common to this message and the + * PartitionQueryRequest message used to create this partition_token. + * @type int $seqno + * A per-transaction sequence number used to identify this request. This field + * makes each request idempotent such that if the request is received multiple + * times, at most one will succeed. + * + * The sequence number must be monotonically increasing within the + * transaction. If a request arrives for the first time with an out-of-order + * sequence number, the transaction may be aborted. Replays of previously + * handled requests will yield the same response as the first execution. + * + * Required for DML statements. Ignored for queries. + * @type QueryOptions $queryOptions + * Query optimizer configuration to use for the given query. + * @type RequestOptions $requestOptions + * Common options for this request. + * @type DirectedReadOptions $directedReadOptions + * Directed read options for this request. + * @type bool $dataBoostEnabled + * If this is for a partitioned query and this field is set to `true`, the + * request is executed with Spanner Data Boost independent compute resources. + * + * If the field is set to `true` but the request does not set + * `partition_token`, the API returns an `INVALID_ARGUMENT` error. + * @type bool $lastStatement + * Optional. If set to true, this statement marks the end of the transaction. + * The transaction should be committed or aborted after this statement + * executes, and attempts to execute any other requests against this + * transaction (including reads and queries) will be rejected. + * + * For DML statements, setting this option may cause some error reporting to + * be deferred until commit time (e.g. validation of unique constraints). + * Given this, successful execution of a DML statement should not be assumed + * until a subsequent Commit call completes successfully. + * @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 \Google\Cloud\Spanner\V1\ResultSet + * + * @throws ApiException if the remote call fails + */ + public function executeSql($session, $sql, array $optionalArgs = []) + { + $request = new ExecuteSqlRequest(); + $requestParamHeaders = []; + $request->setSession($session); + $request->setSql($sql); + $requestParamHeaders['session'] = $session; + if (isset($optionalArgs['transaction'])) { + $request->setTransaction($optionalArgs['transaction']); + } + + if (isset($optionalArgs['params'])) { + $request->setParams($optionalArgs['params']); + } + + if (isset($optionalArgs['paramTypes'])) { + $request->setParamTypes($optionalArgs['paramTypes']); + } + + if (isset($optionalArgs['resumeToken'])) { + $request->setResumeToken($optionalArgs['resumeToken']); + } + + if (isset($optionalArgs['queryMode'])) { + $request->setQueryMode($optionalArgs['queryMode']); + } + + if (isset($optionalArgs['partitionToken'])) { + $request->setPartitionToken($optionalArgs['partitionToken']); + } + + if (isset($optionalArgs['seqno'])) { + $request->setSeqno($optionalArgs['seqno']); + } + + if (isset($optionalArgs['queryOptions'])) { + $request->setQueryOptions($optionalArgs['queryOptions']); + } + + if (isset($optionalArgs['requestOptions'])) { + $request->setRequestOptions($optionalArgs['requestOptions']); + } + + if (isset($optionalArgs['directedReadOptions'])) { + $request->setDirectedReadOptions($optionalArgs['directedReadOptions']); + } + + if (isset($optionalArgs['dataBoostEnabled'])) { + $request->setDataBoostEnabled($optionalArgs['dataBoostEnabled']); + } + + if (isset($optionalArgs['lastStatement'])) { + $request->setLastStatement($optionalArgs['lastStatement']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('ExecuteSql', ResultSet::class, $optionalArgs, $request)->wait(); + } + + /** + * Like [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], except returns the + * result set as a stream. Unlike + * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], there is no limit on + * the size of the returned result set. However, no individual row in the + * result set can exceed 100 MiB, and no column value can exceed 10 MiB. + * + * Sample code: + * ``` + * $spannerClient = new SpannerClient(); + * try { + * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + * $sql = 'sql'; + * // Read all responses until the stream is complete + * $stream = $spannerClient->executeStreamingSql($formattedSession, $sql); + * foreach ($stream->readAll() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $spannerClient->close(); + * } + * ``` + * + * @param string $session Required. The session in which the SQL query should be performed. + * @param string $sql Required. The SQL string. + * @param array $optionalArgs { + * Optional. + * + * @type TransactionSelector $transaction + * The transaction to use. + * + * For queries, if none is provided, the default is a temporary read-only + * transaction with strong concurrency. + * + * Standard DML statements require a read-write transaction. To protect + * against replays, single-use transactions are not supported. The caller + * must either supply an existing transaction ID or begin a new transaction. + * + * Partitioned DML requires an existing Partitioned DML transaction ID. + * @type Struct $params + * Parameter names and values that bind to placeholders in the SQL string. + * + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names must conform + * to the naming requirements of identifiers as specified at + * https://cloud.google.com/spanner/docs/lexical#identifiers. + * + * Parameters can appear anywhere that a literal value is expected. The same + * parameter name can be used more than once, for example: + * + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * + * It is an error to execute a SQL statement with unbound parameters. + * @type array $paramTypes + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in + * [params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings. + * + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL statement parameters. See the + * definition of [Type][google.spanner.v1.Type] for more information + * about SQL types. + * @type string $resumeToken + * If this request is resuming a previously interrupted SQL statement + * execution, `resume_token` should be copied from the last + * [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the + * interruption. Doing this enables the new SQL statement execution to resume + * where the last one left off. The rest of the request parameters must + * exactly match the request that yielded this token. + * @type int $queryMode + * Used to control the amount of debugging information returned in + * [ResultSetStats][google.spanner.v1.ResultSetStats]. If + * [partition_token][google.spanner.v1.ExecuteSqlRequest.partition_token] is + * set, [query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] can only + * be set to + * [QueryMode.NORMAL][google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL]. + * For allowed values, use constants defined on {@see \Google\Cloud\Spanner\V1\ExecuteSqlRequest\QueryMode} + * @type string $partitionToken + * If present, results will be restricted to the specified partition + * previously created using PartitionQuery(). There must be an exact + * match for the values of fields common to this message and the + * PartitionQueryRequest message used to create this partition_token. + * @type int $seqno + * A per-transaction sequence number used to identify this request. This field + * makes each request idempotent such that if the request is received multiple + * times, at most one will succeed. + * + * The sequence number must be monotonically increasing within the + * transaction. If a request arrives for the first time with an out-of-order + * sequence number, the transaction may be aborted. Replays of previously + * handled requests will yield the same response as the first execution. + * + * Required for DML statements. Ignored for queries. + * @type QueryOptions $queryOptions + * Query optimizer configuration to use for the given query. + * @type RequestOptions $requestOptions + * Common options for this request. + * @type DirectedReadOptions $directedReadOptions + * Directed read options for this request. + * @type bool $dataBoostEnabled + * If this is for a partitioned query and this field is set to `true`, the + * request is executed with Spanner Data Boost independent compute resources. + * + * If the field is set to `true` but the request does not set + * `partition_token`, the API returns an `INVALID_ARGUMENT` error. + * @type bool $lastStatement + * Optional. If set to true, this statement marks the end of the transaction. + * The transaction should be committed or aborted after this statement + * executes, and attempts to execute any other requests against this + * transaction (including reads and queries) will be rejected. + * + * For DML statements, setting this option may cause some error reporting to + * be deferred until commit time (e.g. validation of unique constraints). + * Given this, successful execution of a DML statement should not be assumed + * until a subsequent Commit call completes successfully. + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return \Google\ApiCore\ServerStream + * + * @throws ApiException if the remote call fails + */ + public function executeStreamingSql($session, $sql, array $optionalArgs = []) + { + $request = new ExecuteSqlRequest(); + $requestParamHeaders = []; + $request->setSession($session); + $request->setSql($sql); + $requestParamHeaders['session'] = $session; + if (isset($optionalArgs['transaction'])) { + $request->setTransaction($optionalArgs['transaction']); + } + + if (isset($optionalArgs['params'])) { + $request->setParams($optionalArgs['params']); + } + + if (isset($optionalArgs['paramTypes'])) { + $request->setParamTypes($optionalArgs['paramTypes']); + } + + if (isset($optionalArgs['resumeToken'])) { + $request->setResumeToken($optionalArgs['resumeToken']); + } + + if (isset($optionalArgs['queryMode'])) { + $request->setQueryMode($optionalArgs['queryMode']); + } + + if (isset($optionalArgs['partitionToken'])) { + $request->setPartitionToken($optionalArgs['partitionToken']); + } + + if (isset($optionalArgs['seqno'])) { + $request->setSeqno($optionalArgs['seqno']); + } + + if (isset($optionalArgs['queryOptions'])) { + $request->setQueryOptions($optionalArgs['queryOptions']); + } + + if (isset($optionalArgs['requestOptions'])) { + $request->setRequestOptions($optionalArgs['requestOptions']); + } + + if (isset($optionalArgs['directedReadOptions'])) { + $request->setDirectedReadOptions($optionalArgs['directedReadOptions']); + } + + if (isset($optionalArgs['dataBoostEnabled'])) { + $request->setDataBoostEnabled($optionalArgs['dataBoostEnabled']); + } + + if (isset($optionalArgs['lastStatement'])) { + $request->setLastStatement($optionalArgs['lastStatement']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('ExecuteStreamingSql', PartialResultSet::class, $optionalArgs, $request, Call::SERVER_STREAMING_CALL); + } + + /** + * Gets a session. Returns `NOT_FOUND` if the session does not exist. + * This is mainly useful for determining whether a session is still + * alive. + * + * Sample code: + * ``` + * $spannerClient = new SpannerClient(); + * try { + * $formattedName = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + * $response = $spannerClient->getSession($formattedName); + * } finally { + * $spannerClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the session to retrieve. + * @param array $optionalArgs { + * 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 \Google\Cloud\Spanner\V1\Session + * + * @throws ApiException if the remote call fails + */ + public function getSession($name, array $optionalArgs = []) + { + $request = new GetSessionRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetSession', Session::class, $optionalArgs, $request)->wait(); + } + + /** + * Lists all sessions in a given database. + * + * Sample code: + * ``` + * $spannerClient = new SpannerClient(); + * try { + * $formattedDatabase = $spannerClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + * // Iterate over pages of elements + * $pagedResponse = $spannerClient->listSessions($formattedDatabase); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $spannerClient->listSessions($formattedDatabase); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $spannerClient->close(); + * } + * ``` + * + * @param string $database Required. The database in which to list sessions. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type string $filter + * An expression for filtering the results of the request. Filter rules are + * case insensitive. The fields eligible for filtering are: + * + * * `labels.key` where key is the name of a label + * + * Some examples of using filters are: + * + * * `labels.env:*` --> The session has the label "env". + * * `labels.env:dev` --> The session has the label "env" and the value of + * the label contains the string "dev". + * @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 \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listSessions($database, array $optionalArgs = []) + { + $request = new ListSessionsRequest(); + $requestParamHeaders = []; + $request->setDatabase($database); + $requestParamHeaders['database'] = $database; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListSessions', $optionalArgs, ListSessionsResponse::class, $request); + } + + /** + * Creates a set of partition tokens that can be used to execute a query + * operation in parallel. Each of the returned partition tokens can be used + * by [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] to + * specify a subset of the query result to read. The same session and + * read-only transaction must be used by the PartitionQueryRequest used to + * create the partition tokens and the ExecuteSqlRequests that use the + * partition tokens. + * + * Partition tokens become invalid when the session used to create them + * is deleted, is idle for too long, begins a new transaction, or becomes too + * old. When any of these happen, it is not possible to resume the query, and + * the whole operation must be restarted from the beginning. + * + * Sample code: + * ``` + * $spannerClient = new SpannerClient(); + * try { + * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + * $sql = 'sql'; + * $response = $spannerClient->partitionQuery($formattedSession, $sql); + * } finally { + * $spannerClient->close(); + * } + * ``` + * + * @param string $session Required. The session used to create the partitions. + * @param string $sql Required. The query request to generate partitions for. The request will + * fail if the query is not root partitionable. For a query to be root + * partitionable, it needs to satisfy a few conditions. For example, if the + * query execution plan contains a distributed union operator, then it must be + * the first operator in the plan. For more information about other + * conditions, see [Read data in + * parallel](https://cloud.google.com/spanner/docs/reads#read_data_in_parallel). + * + * The query request must not contain DML commands, such as INSERT, UPDATE, or + * DELETE. Use + * [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] with a + * PartitionedDml transaction for large, partition-friendly DML operations. + * @param array $optionalArgs { + * Optional. + * + * @type TransactionSelector $transaction + * Read only snapshot transactions are supported, read/write and single use + * transactions are not. + * @type Struct $params + * Parameter names and values that bind to placeholders in the SQL string. + * + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names can contain + * letters, numbers, and underscores. + * + * Parameters can appear anywhere that a literal value is expected. The same + * parameter name can be used more than once, for example: + * + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * + * It is an error to execute a SQL statement with unbound parameters. + * @type array $paramTypes + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in + * [params][google.spanner.v1.PartitionQueryRequest.params] as JSON strings. + * + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL query parameters. See the + * definition of [Type][google.spanner.v1.Type] for more information + * about SQL types. + * @type PartitionOptions $partitionOptions + * Additional options that affect how many partitions are created. + * @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 \Google\Cloud\Spanner\V1\PartitionResponse + * + * @throws ApiException if the remote call fails + */ + public function partitionQuery($session, $sql, array $optionalArgs = []) + { + $request = new PartitionQueryRequest(); + $requestParamHeaders = []; + $request->setSession($session); + $request->setSql($sql); + $requestParamHeaders['session'] = $session; + if (isset($optionalArgs['transaction'])) { + $request->setTransaction($optionalArgs['transaction']); + } + + if (isset($optionalArgs['params'])) { + $request->setParams($optionalArgs['params']); + } + + if (isset($optionalArgs['paramTypes'])) { + $request->setParamTypes($optionalArgs['paramTypes']); + } + + if (isset($optionalArgs['partitionOptions'])) { + $request->setPartitionOptions($optionalArgs['partitionOptions']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('PartitionQuery', PartitionResponse::class, $optionalArgs, $request)->wait(); + } + + /** + * Creates a set of partition tokens that can be used to execute a read + * operation in parallel. Each of the returned partition tokens can be used + * by [StreamingRead][google.spanner.v1.Spanner.StreamingRead] to specify a + * subset of the read result to read. The same session and read-only + * transaction must be used by the PartitionReadRequest used to create the + * partition tokens and the ReadRequests that use the partition tokens. There + * are no ordering guarantees on rows returned among the returned partition + * tokens, or even within each individual StreamingRead call issued with a + * partition_token. + * + * Partition tokens become invalid when the session used to create them + * is deleted, is idle for too long, begins a new transaction, or becomes too + * old. When any of these happen, it is not possible to resume the read, and + * the whole operation must be restarted from the beginning. + * + * Sample code: + * ``` + * $spannerClient = new SpannerClient(); + * try { + * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + * $table = 'table'; + * $keySet = new KeySet(); + * $response = $spannerClient->partitionRead($formattedSession, $table, $keySet); + * } finally { + * $spannerClient->close(); + * } + * ``` + * + * @param string $session Required. The session used to create the partitions. + * @param string $table Required. The name of the table in the database to be read. + * @param KeySet $keySet Required. `key_set` identifies the rows to be yielded. `key_set` names the + * primary keys of the rows in + * [table][google.spanner.v1.PartitionReadRequest.table] to be yielded, unless + * [index][google.spanner.v1.PartitionReadRequest.index] is present. If + * [index][google.spanner.v1.PartitionReadRequest.index] is present, then + * [key_set][google.spanner.v1.PartitionReadRequest.key_set] instead names + * index keys in [index][google.spanner.v1.PartitionReadRequest.index]. + * + * It is not an error for the `key_set` to name rows that do not + * exist in the database. Read yields nothing for nonexistent rows. + * @param array $optionalArgs { + * Optional. + * + * @type TransactionSelector $transaction + * Read only snapshot transactions are supported, read/write and single use + * transactions are not. + * @type string $index + * If non-empty, the name of an index on + * [table][google.spanner.v1.PartitionReadRequest.table]. This index is used + * instead of the table primary key when interpreting + * [key_set][google.spanner.v1.PartitionReadRequest.key_set] and sorting + * result rows. See [key_set][google.spanner.v1.PartitionReadRequest.key_set] + * for further information. + * @type string[] $columns + * The columns of [table][google.spanner.v1.PartitionReadRequest.table] to be + * returned for each row matching this request. + * @type PartitionOptions $partitionOptions + * Additional options that affect how many partitions are created. + * @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 \Google\Cloud\Spanner\V1\PartitionResponse + * + * @throws ApiException if the remote call fails + */ + public function partitionRead($session, $table, $keySet, array $optionalArgs = []) + { + $request = new PartitionReadRequest(); + $requestParamHeaders = []; + $request->setSession($session); + $request->setTable($table); + $request->setKeySet($keySet); + $requestParamHeaders['session'] = $session; + if (isset($optionalArgs['transaction'])) { + $request->setTransaction($optionalArgs['transaction']); + } + + if (isset($optionalArgs['index'])) { + $request->setIndex($optionalArgs['index']); + } + + if (isset($optionalArgs['columns'])) { + $request->setColumns($optionalArgs['columns']); + } + + if (isset($optionalArgs['partitionOptions'])) { + $request->setPartitionOptions($optionalArgs['partitionOptions']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('PartitionRead', PartitionResponse::class, $optionalArgs, $request)->wait(); + } + + /** + * Reads rows from the database using key lookups and scans, as a + * simple key/value style alternative to + * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. This method cannot be + * used to return a result set larger than 10 MiB; if the read matches more + * data than that, the read fails with a `FAILED_PRECONDITION` + * error. + * + * Reads inside read-write transactions might return `ABORTED`. If + * this occurs, the application should restart the transaction from + * the beginning. See [Transaction][google.spanner.v1.Transaction] for more + * details. + * + * Larger result sets can be yielded in streaming fashion by calling + * [StreamingRead][google.spanner.v1.Spanner.StreamingRead] instead. + * + * Sample code: + * ``` + * $spannerClient = new SpannerClient(); + * try { + * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + * $table = 'table'; + * $columns = []; + * $keySet = new KeySet(); + * $response = $spannerClient->read($formattedSession, $table, $columns, $keySet); + * } finally { + * $spannerClient->close(); + * } + * ``` + * + * @param string $session Required. The session in which the read should be performed. + * @param string $table Required. The name of the table in the database to be read. + * @param string[] $columns Required. The columns of [table][google.spanner.v1.ReadRequest.table] to be + * returned for each row matching this request. + * @param KeySet $keySet Required. `key_set` identifies the rows to be yielded. `key_set` names the + * primary keys of the rows in [table][google.spanner.v1.ReadRequest.table] to + * be yielded, unless [index][google.spanner.v1.ReadRequest.index] is present. + * If [index][google.spanner.v1.ReadRequest.index] is present, then + * [key_set][google.spanner.v1.ReadRequest.key_set] instead names index keys + * in [index][google.spanner.v1.ReadRequest.index]. + * + * If the [partition_token][google.spanner.v1.ReadRequest.partition_token] + * field is empty, rows are yielded in table primary key order (if + * [index][google.spanner.v1.ReadRequest.index] is empty) or index key order + * (if [index][google.spanner.v1.ReadRequest.index] is non-empty). If the + * [partition_token][google.spanner.v1.ReadRequest.partition_token] field is + * not empty, rows will be yielded in an unspecified order. + * + * It is not an error for the `key_set` to name rows that do not + * exist in the database. Read yields nothing for nonexistent rows. + * @param array $optionalArgs { + * Optional. + * + * @type TransactionSelector $transaction + * The transaction to use. If none is provided, the default is a + * temporary read-only transaction with strong concurrency. + * @type string $index + * If non-empty, the name of an index on + * [table][google.spanner.v1.ReadRequest.table]. This index is used instead of + * the table primary key when interpreting + * [key_set][google.spanner.v1.ReadRequest.key_set] and sorting result rows. + * See [key_set][google.spanner.v1.ReadRequest.key_set] for further + * information. + * @type int $limit + * If greater than zero, only the first `limit` rows are yielded. If `limit` + * is zero, the default is no limit. A limit cannot be specified if + * `partition_token` is set. + * @type string $resumeToken + * If this request is resuming a previously interrupted read, + * `resume_token` should be copied from the last + * [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the + * interruption. Doing this enables the new read to resume where the last read + * left off. The rest of the request parameters must exactly match the request + * that yielded this token. + * @type string $partitionToken + * If present, results will be restricted to the specified partition + * previously created using PartitionRead(). There must be an exact + * match for the values of fields common to this message and the + * PartitionReadRequest message used to create this partition_token. + * @type RequestOptions $requestOptions + * Common options for this request. + * @type DirectedReadOptions $directedReadOptions + * Directed read options for this request. + * @type bool $dataBoostEnabled + * If this is for a partitioned read and this field is set to `true`, the + * request is executed with Spanner Data Boost independent compute resources. + * + * If the field is set to `true` but the request does not set + * `partition_token`, the API returns an `INVALID_ARGUMENT` error. + * @type int $orderBy + * Optional. Order for the returned rows. + * + * By default, Spanner will return result rows in primary key order except for + * PartitionRead requests. For applications that do not require rows to be + * returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting + * `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval, + * resulting in lower latencies in certain cases (e.g. bulk point lookups). + * For allowed values, use constants defined on {@see \Google\Cloud\Spanner\V1\ReadRequest\OrderBy} + * @type int $lockHint + * Optional. Lock Hint for the request, it can only be used with read-write + * transactions. + * For allowed values, use constants defined on {@see \Google\Cloud\Spanner\V1\ReadRequest\LockHint} + * @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 \Google\Cloud\Spanner\V1\ResultSet + * + * @throws ApiException if the remote call fails + */ + public function read($session, $table, $columns, $keySet, array $optionalArgs = []) + { + $request = new ReadRequest(); + $requestParamHeaders = []; + $request->setSession($session); + $request->setTable($table); + $request->setColumns($columns); + $request->setKeySet($keySet); + $requestParamHeaders['session'] = $session; + if (isset($optionalArgs['transaction'])) { + $request->setTransaction($optionalArgs['transaction']); + } + + if (isset($optionalArgs['index'])) { + $request->setIndex($optionalArgs['index']); + } + + if (isset($optionalArgs['limit'])) { + $request->setLimit($optionalArgs['limit']); + } + + if (isset($optionalArgs['resumeToken'])) { + $request->setResumeToken($optionalArgs['resumeToken']); + } + + if (isset($optionalArgs['partitionToken'])) { + $request->setPartitionToken($optionalArgs['partitionToken']); + } + + if (isset($optionalArgs['requestOptions'])) { + $request->setRequestOptions($optionalArgs['requestOptions']); + } + + if (isset($optionalArgs['directedReadOptions'])) { + $request->setDirectedReadOptions($optionalArgs['directedReadOptions']); + } + + if (isset($optionalArgs['dataBoostEnabled'])) { + $request->setDataBoostEnabled($optionalArgs['dataBoostEnabled']); + } + + if (isset($optionalArgs['orderBy'])) { + $request->setOrderBy($optionalArgs['orderBy']); + } + + if (isset($optionalArgs['lockHint'])) { + $request->setLockHint($optionalArgs['lockHint']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('Read', ResultSet::class, $optionalArgs, $request)->wait(); + } + + /** + * Rolls back a transaction, releasing any locks it holds. It is a good + * idea to call this for any transaction that includes one or more + * [Read][google.spanner.v1.Spanner.Read] or + * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] requests and ultimately + * decides not to commit. + * + * `Rollback` returns `OK` if it successfully aborts the transaction, the + * transaction was already aborted, or the transaction is not + * found. `Rollback` never returns `ABORTED`. + * + * Sample code: + * ``` + * $spannerClient = new SpannerClient(); + * try { + * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + * $transactionId = '...'; + * $spannerClient->rollback($formattedSession, $transactionId); + * } finally { + * $spannerClient->close(); + * } + * ``` + * + * @param string $session Required. The session in which the transaction to roll back is running. + * @param string $transactionId Required. The transaction to roll back. + * @param array $optionalArgs { + * 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. + * } + * + * @throws ApiException if the remote call fails + */ + public function rollback($session, $transactionId, array $optionalArgs = []) + { + $request = new RollbackRequest(); + $requestParamHeaders = []; + $request->setSession($session); + $request->setTransactionId($transactionId); + $requestParamHeaders['session'] = $session; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('Rollback', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Like [Read][google.spanner.v1.Spanner.Read], except returns the result set + * as a stream. Unlike [Read][google.spanner.v1.Spanner.Read], there is no + * limit on the size of the returned result set. However, no individual row in + * the result set can exceed 100 MiB, and no column value can exceed + * 10 MiB. + * + * Sample code: + * ``` + * $spannerClient = new SpannerClient(); + * try { + * $formattedSession = $spannerClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + * $table = 'table'; + * $columns = []; + * $keySet = new KeySet(); + * // Read all responses until the stream is complete + * $stream = $spannerClient->streamingRead($formattedSession, $table, $columns, $keySet); + * foreach ($stream->readAll() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $spannerClient->close(); + * } + * ``` + * + * @param string $session Required. The session in which the read should be performed. + * @param string $table Required. The name of the table in the database to be read. + * @param string[] $columns Required. The columns of [table][google.spanner.v1.ReadRequest.table] to be + * returned for each row matching this request. + * @param KeySet $keySet Required. `key_set` identifies the rows to be yielded. `key_set` names the + * primary keys of the rows in [table][google.spanner.v1.ReadRequest.table] to + * be yielded, unless [index][google.spanner.v1.ReadRequest.index] is present. + * If [index][google.spanner.v1.ReadRequest.index] is present, then + * [key_set][google.spanner.v1.ReadRequest.key_set] instead names index keys + * in [index][google.spanner.v1.ReadRequest.index]. + * + * If the [partition_token][google.spanner.v1.ReadRequest.partition_token] + * field is empty, rows are yielded in table primary key order (if + * [index][google.spanner.v1.ReadRequest.index] is empty) or index key order + * (if [index][google.spanner.v1.ReadRequest.index] is non-empty). If the + * [partition_token][google.spanner.v1.ReadRequest.partition_token] field is + * not empty, rows will be yielded in an unspecified order. + * + * It is not an error for the `key_set` to name rows that do not + * exist in the database. Read yields nothing for nonexistent rows. + * @param array $optionalArgs { + * Optional. + * + * @type TransactionSelector $transaction + * The transaction to use. If none is provided, the default is a + * temporary read-only transaction with strong concurrency. + * @type string $index + * If non-empty, the name of an index on + * [table][google.spanner.v1.ReadRequest.table]. This index is used instead of + * the table primary key when interpreting + * [key_set][google.spanner.v1.ReadRequest.key_set] and sorting result rows. + * See [key_set][google.spanner.v1.ReadRequest.key_set] for further + * information. + * @type int $limit + * If greater than zero, only the first `limit` rows are yielded. If `limit` + * is zero, the default is no limit. A limit cannot be specified if + * `partition_token` is set. + * @type string $resumeToken + * If this request is resuming a previously interrupted read, + * `resume_token` should be copied from the last + * [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the + * interruption. Doing this enables the new read to resume where the last read + * left off. The rest of the request parameters must exactly match the request + * that yielded this token. + * @type string $partitionToken + * If present, results will be restricted to the specified partition + * previously created using PartitionRead(). There must be an exact + * match for the values of fields common to this message and the + * PartitionReadRequest message used to create this partition_token. + * @type RequestOptions $requestOptions + * Common options for this request. + * @type DirectedReadOptions $directedReadOptions + * Directed read options for this request. + * @type bool $dataBoostEnabled + * If this is for a partitioned read and this field is set to `true`, the + * request is executed with Spanner Data Boost independent compute resources. + * + * If the field is set to `true` but the request does not set + * `partition_token`, the API returns an `INVALID_ARGUMENT` error. + * @type int $orderBy + * Optional. Order for the returned rows. + * + * By default, Spanner will return result rows in primary key order except for + * PartitionRead requests. For applications that do not require rows to be + * returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting + * `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval, + * resulting in lower latencies in certain cases (e.g. bulk point lookups). + * For allowed values, use constants defined on {@see \Google\Cloud\Spanner\V1\ReadRequest\OrderBy} + * @type int $lockHint + * Optional. Lock Hint for the request, it can only be used with read-write + * transactions. + * For allowed values, use constants defined on {@see \Google\Cloud\Spanner\V1\ReadRequest\LockHint} + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return \Google\ApiCore\ServerStream + * + * @throws ApiException if the remote call fails + */ + public function streamingRead($session, $table, $columns, $keySet, array $optionalArgs = []) + { + $request = new ReadRequest(); + $requestParamHeaders = []; + $request->setSession($session); + $request->setTable($table); + $request->setColumns($columns); + $request->setKeySet($keySet); + $requestParamHeaders['session'] = $session; + if (isset($optionalArgs['transaction'])) { + $request->setTransaction($optionalArgs['transaction']); + } + + if (isset($optionalArgs['index'])) { + $request->setIndex($optionalArgs['index']); + } + + if (isset($optionalArgs['limit'])) { + $request->setLimit($optionalArgs['limit']); + } + + if (isset($optionalArgs['resumeToken'])) { + $request->setResumeToken($optionalArgs['resumeToken']); + } + + if (isset($optionalArgs['partitionToken'])) { + $request->setPartitionToken($optionalArgs['partitionToken']); + } + + if (isset($optionalArgs['requestOptions'])) { + $request->setRequestOptions($optionalArgs['requestOptions']); + } + + if (isset($optionalArgs['directedReadOptions'])) { + $request->setDirectedReadOptions($optionalArgs['directedReadOptions']); + } + + if (isset($optionalArgs['dataBoostEnabled'])) { + $request->setDataBoostEnabled($optionalArgs['dataBoostEnabled']); + } + + if (isset($optionalArgs['orderBy'])) { + $request->setOrderBy($optionalArgs['orderBy']); + } + + if (isset($optionalArgs['lockHint'])) { + $request->setLockHint($optionalArgs['lockHint']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('StreamingRead', PartialResultSet::class, $optionalArgs, $request, Call::SERVER_STREAMING_CALL); + } +} diff --git a/owl-bot-staging/Spanner/v1/src/V1/SpannerClient.php b/owl-bot-staging/Spanner/v1/src/V1/SpannerClient.php new file mode 100644 index 000000000000..d4d3a0e783b3 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/src/V1/SpannerClient.php @@ -0,0 +1,34 @@ + [ + 'google.spanner.v1.Spanner' => [ + 'BatchCreateSessions' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\V1\BatchCreateSessionsResponse', + 'headerParams' => [ + [ + 'keyName' => 'database', + 'fieldAccessors' => [ + 'getDatabase', + ], + ], + ], + ], + 'BatchWrite' => [ + 'grpcStreaming' => [ + 'grpcStreamingType' => 'ServerStreaming', + ], + 'callType' => \Google\ApiCore\Call::SERVER_STREAMING_CALL, + 'responseType' => 'Google\Cloud\Spanner\V1\BatchWriteResponse', + 'headerParams' => [ + [ + 'keyName' => 'session', + 'fieldAccessors' => [ + 'getSession', + ], + ], + ], + ], + 'BeginTransaction' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\V1\Transaction', + 'headerParams' => [ + [ + 'keyName' => 'session', + 'fieldAccessors' => [ + 'getSession', + ], + ], + ], + ], + 'Commit' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\V1\CommitResponse', + 'headerParams' => [ + [ + 'keyName' => 'session', + 'fieldAccessors' => [ + 'getSession', + ], + ], + ], + ], + 'CreateSession' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\V1\Session', + 'headerParams' => [ + [ + 'keyName' => 'database', + 'fieldAccessors' => [ + 'getDatabase', + ], + ], + ], + ], + 'DeleteSession' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'ExecuteBatchDml' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\V1\ExecuteBatchDmlResponse', + 'headerParams' => [ + [ + 'keyName' => 'session', + 'fieldAccessors' => [ + 'getSession', + ], + ], + ], + ], + 'ExecuteSql' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\V1\ResultSet', + 'headerParams' => [ + [ + 'keyName' => 'session', + 'fieldAccessors' => [ + 'getSession', + ], + ], + ], + ], + 'ExecuteStreamingSql' => [ + 'grpcStreaming' => [ + 'grpcStreamingType' => 'ServerStreaming', + ], + 'callType' => \Google\ApiCore\Call::SERVER_STREAMING_CALL, + 'responseType' => 'Google\Cloud\Spanner\V1\PartialResultSet', + 'headerParams' => [ + [ + 'keyName' => 'session', + 'fieldAccessors' => [ + 'getSession', + ], + ], + ], + ], + 'GetSession' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\V1\Session', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'ListSessions' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getSessions', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Spanner\V1\ListSessionsResponse', + 'headerParams' => [ + [ + 'keyName' => 'database', + 'fieldAccessors' => [ + 'getDatabase', + ], + ], + ], + ], + 'PartitionQuery' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\V1\PartitionResponse', + 'headerParams' => [ + [ + 'keyName' => 'session', + 'fieldAccessors' => [ + 'getSession', + ], + ], + ], + ], + 'PartitionRead' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\V1\PartitionResponse', + 'headerParams' => [ + [ + 'keyName' => 'session', + 'fieldAccessors' => [ + 'getSession', + ], + ], + ], + ], + 'Read' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Spanner\V1\ResultSet', + 'headerParams' => [ + [ + 'keyName' => 'session', + 'fieldAccessors' => [ + 'getSession', + ], + ], + ], + ], + 'Rollback' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'session', + 'fieldAccessors' => [ + 'getSession', + ], + ], + ], + ], + 'StreamingRead' => [ + 'grpcStreaming' => [ + 'grpcStreamingType' => 'ServerStreaming', + ], + 'callType' => \Google\ApiCore\Call::SERVER_STREAMING_CALL, + 'responseType' => 'Google\Cloud\Spanner\V1\PartialResultSet', + 'headerParams' => [ + [ + 'keyName' => 'session', + 'fieldAccessors' => [ + 'getSession', + ], + ], + ], + ], + 'templateMap' => [ + 'database' => 'projects/{project}/instances/{instance}/databases/{database}', + 'session' => 'projects/{project}/instances/{instance}/databases/{database}/sessions/{session}', + ], + ], + ], +]; diff --git a/owl-bot-staging/Spanner/v1/src/V1/resources/spanner_rest_client_config.php b/owl-bot-staging/Spanner/v1/src/V1/resources/spanner_rest_client_config.php new file mode 100644 index 000000000000..e661da669861 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/src/V1/resources/spanner_rest_client_config.php @@ -0,0 +1,320 @@ + [ + 'google.longrunning.Operations' => [ + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}:cancel', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}:cancel', + ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/backups/*/operations/*}:cancel', + ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/instanceConfigs/*/operations/*}:cancel', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}', + ], + [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/backups/*/operations/*}', + ], + [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instanceConfigs/*/operations/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/backups/*/operations/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instanceConfigs/*/operations/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/operations}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/operations}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/backups/*/operations}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instanceConfigs/*/operations}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + 'google.spanner.v1.Spanner' => [ + 'BatchCreateSessions' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{database=projects/*/instances/*/databases/*}/sessions:batchCreate', + 'body' => '*', + 'placeholders' => [ + 'database' => [ + 'getters' => [ + 'getDatabase', + ], + ], + ], + ], + 'BatchWrite' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:batchWrite', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getters' => [ + 'getSession', + ], + ], + ], + ], + 'BeginTransaction' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:beginTransaction', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getters' => [ + 'getSession', + ], + ], + ], + ], + 'Commit' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:commit', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getters' => [ + 'getSession', + ], + ], + ], + ], + 'CreateSession' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{database=projects/*/instances/*/databases/*}/sessions', + 'body' => '*', + 'placeholders' => [ + 'database' => [ + 'getters' => [ + 'getDatabase', + ], + ], + ], + ], + 'DeleteSession' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/sessions/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ExecuteBatchDml' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeBatchDml', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getters' => [ + 'getSession', + ], + ], + ], + ], + 'ExecuteSql' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeSql', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getters' => [ + 'getSession', + ], + ], + ], + ], + 'ExecuteStreamingSql' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeStreamingSql', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getters' => [ + 'getSession', + ], + ], + ], + ], + 'GetSession' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/instances/*/databases/*/sessions/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListSessions' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{database=projects/*/instances/*/databases/*}/sessions', + 'placeholders' => [ + 'database' => [ + 'getters' => [ + 'getDatabase', + ], + ], + ], + ], + 'PartitionQuery' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionQuery', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getters' => [ + 'getSession', + ], + ], + ], + ], + 'PartitionRead' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionRead', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getters' => [ + 'getSession', + ], + ], + ], + ], + 'Read' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:read', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getters' => [ + 'getSession', + ], + ], + ], + ], + 'Rollback' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:rollback', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getters' => [ + 'getSession', + ], + ], + ], + ], + 'StreamingRead' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{session=projects/*/instances/*/databases/*/sessions/*}:streamingRead', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getters' => [ + 'getSession', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/owl-bot-staging/Spanner/v1/tests/Unit/V1/Client/SpannerClientTest.php b/owl-bot-staging/Spanner/v1/tests/Unit/V1/Client/SpannerClientTest.php new file mode 100644 index 000000000000..1a1021bad381 --- /dev/null +++ b/owl-bot-staging/Spanner/v1/tests/Unit/V1/Client/SpannerClientTest.php @@ -0,0 +1,1308 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return SpannerClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new SpannerClient($options); + } + + /** @test */ + public function batchCreateSessionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new BatchCreateSessionsResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $sessionCount = 185691686; + $request = (new BatchCreateSessionsRequest()) + ->setDatabase($formattedDatabase) + ->setSessionCount($sessionCount); + $response = $gapicClient->batchCreateSessions($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/BatchCreateSessions', $actualFuncCall); + $actualValue = $actualRequestObject->getDatabase(); + $this->assertProtobufEquals($formattedDatabase, $actualValue); + $actualValue = $actualRequestObject->getSessionCount(); + $this->assertProtobufEquals($sessionCount, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function batchCreateSessionsExceptionTest() + { + $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 + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $sessionCount = 185691686; + $request = (new BatchCreateSessionsRequest()) + ->setDatabase($formattedDatabase) + ->setSessionCount($sessionCount); + try { + $gapicClient->batchCreateSessions($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 batchWriteTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new BatchWriteResponse(); + $transport->addResponse($expectedResponse); + $expectedResponse2 = new BatchWriteResponse(); + $transport->addResponse($expectedResponse2); + $expectedResponse3 = new BatchWriteResponse(); + $transport->addResponse($expectedResponse3); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $mutationGroups = []; + $request = (new BatchWriteRequest()) + ->setSession($formattedSession) + ->setMutationGroups($mutationGroups); + $serverStream = $gapicClient->batchWrite($request); + $this->assertInstanceOf(ServerStream::class, $serverStream); + $responses = iterator_to_array($serverStream->readAll()); + $expectedResponses = []; + $expectedResponses[] = $expectedResponse; + $expectedResponses[] = $expectedResponse2; + $expectedResponses[] = $expectedResponse3; + $this->assertEquals($expectedResponses, $responses); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/BatchWrite', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getMutationGroups(); + $this->assertProtobufEquals($mutationGroups, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function batchWriteExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $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->setStreamingStatus($status); + $this->assertTrue($transport->isExhausted()); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $mutationGroups = []; + $request = (new BatchWriteRequest()) + ->setSession($formattedSession) + ->setMutationGroups($mutationGroups); + $serverStream = $gapicClient->batchWrite($request); + $results = $serverStream->readAll(); + try { + iterator_to_array($results); + // If the close stream 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 beginTransactionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $id = '27'; + $expectedResponse = new Transaction(); + $expectedResponse->setId($id); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $options = new TransactionOptions(); + $request = (new BeginTransactionRequest()) + ->setSession($formattedSession) + ->setOptions($options); + $response = $gapicClient->beginTransaction($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/BeginTransaction', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getOptions(); + $this->assertProtobufEquals($options, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function beginTransactionExceptionTest() + { + $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 + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $options = new TransactionOptions(); + $request = (new BeginTransactionRequest()) + ->setSession($formattedSession) + ->setOptions($options); + try { + $gapicClient->beginTransaction($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 commitTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new CommitResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $mutations = []; + $request = (new CommitRequest()) + ->setSession($formattedSession) + ->setMutations($mutations); + $response = $gapicClient->commit($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/Commit', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getMutations(); + $this->assertProtobufEquals($mutations, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function commitExceptionTest() + { + $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 + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $mutations = []; + $request = (new CommitRequest()) + ->setSession($formattedSession) + ->setMutations($mutations); + try { + $gapicClient->commit($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 createSessionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $creatorRole = 'creatorRole-1605962583'; + $multiplexed = false; + $expectedResponse = new Session(); + $expectedResponse->setName($name); + $expectedResponse->setCreatorRole($creatorRole); + $expectedResponse->setMultiplexed($multiplexed); + $transport->addResponse($expectedResponse); + // Mock request + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $request = (new CreateSessionRequest()) + ->setDatabase($formattedDatabase); + $response = $gapicClient->createSession($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/CreateSession', $actualFuncCall); + $actualValue = $actualRequestObject->getDatabase(); + $this->assertProtobufEquals($formattedDatabase, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createSessionExceptionTest() + { + $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 + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $request = (new CreateSessionRequest()) + ->setDatabase($formattedDatabase); + try { + $gapicClient->createSession($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 deleteSessionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $request = (new DeleteSessionRequest()) + ->setName($formattedName); + $gapicClient->deleteSession($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/DeleteSession', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteSessionExceptionTest() + { + $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->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $request = (new DeleteSessionRequest()) + ->setName($formattedName); + try { + $gapicClient->deleteSession($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 executeBatchDmlTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new ExecuteBatchDmlResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $transaction = new TransactionSelector(); + $statements = []; + $seqno = 109325920; + $request = (new ExecuteBatchDmlRequest()) + ->setSession($formattedSession) + ->setTransaction($transaction) + ->setStatements($statements) + ->setSeqno($seqno); + $response = $gapicClient->executeBatchDml($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/ExecuteBatchDml', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getTransaction(); + $this->assertProtobufEquals($transaction, $actualValue); + $actualValue = $actualRequestObject->getStatements(); + $this->assertProtobufEquals($statements, $actualValue); + $actualValue = $actualRequestObject->getSeqno(); + $this->assertProtobufEquals($seqno, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function executeBatchDmlExceptionTest() + { + $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 + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $transaction = new TransactionSelector(); + $statements = []; + $seqno = 109325920; + $request = (new ExecuteBatchDmlRequest()) + ->setSession($formattedSession) + ->setTransaction($transaction) + ->setStatements($statements) + ->setSeqno($seqno); + try { + $gapicClient->executeBatchDml($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 executeSqlTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new ResultSet(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $sql = 'sql114126'; + $request = (new ExecuteSqlRequest()) + ->setSession($formattedSession) + ->setSql($sql); + $response = $gapicClient->executeSql($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/ExecuteSql', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getSql(); + $this->assertProtobufEquals($sql, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function executeSqlExceptionTest() + { + $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 + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $sql = 'sql114126'; + $request = (new ExecuteSqlRequest()) + ->setSession($formattedSession) + ->setSql($sql); + try { + $gapicClient->executeSql($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 executeStreamingSqlTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $chunkedValue = true; + $resumeToken2 = '90'; + $expectedResponse = new PartialResultSet(); + $expectedResponse->setChunkedValue($chunkedValue); + $expectedResponse->setResumeToken($resumeToken2); + $transport->addResponse($expectedResponse); + $chunkedValue2 = false; + $resumeToken3 = '91'; + $expectedResponse2 = new PartialResultSet(); + $expectedResponse2->setChunkedValue($chunkedValue2); + $expectedResponse2->setResumeToken($resumeToken3); + $transport->addResponse($expectedResponse2); + $chunkedValue3 = true; + $resumeToken4 = '92'; + $expectedResponse3 = new PartialResultSet(); + $expectedResponse3->setChunkedValue($chunkedValue3); + $expectedResponse3->setResumeToken($resumeToken4); + $transport->addResponse($expectedResponse3); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $sql = 'sql114126'; + $request = (new ExecuteSqlRequest()) + ->setSession($formattedSession) + ->setSql($sql); + $serverStream = $gapicClient->executeStreamingSql($request); + $this->assertInstanceOf(ServerStream::class, $serverStream); + $responses = iterator_to_array($serverStream->readAll()); + $expectedResponses = []; + $expectedResponses[] = $expectedResponse; + $expectedResponses[] = $expectedResponse2; + $expectedResponses[] = $expectedResponse3; + $this->assertEquals($expectedResponses, $responses); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/ExecuteStreamingSql', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getSql(); + $this->assertProtobufEquals($sql, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function executeStreamingSqlExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $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->setStreamingStatus($status); + $this->assertTrue($transport->isExhausted()); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $sql = 'sql114126'; + $request = (new ExecuteSqlRequest()) + ->setSession($formattedSession) + ->setSql($sql); + $serverStream = $gapicClient->executeStreamingSql($request); + $results = $serverStream->readAll(); + try { + iterator_to_array($results); + // If the close stream 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 getSessionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $creatorRole = 'creatorRole-1605962583'; + $multiplexed = false; + $expectedResponse = new Session(); + $expectedResponse->setName($name2); + $expectedResponse->setCreatorRole($creatorRole); + $expectedResponse->setMultiplexed($multiplexed); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $request = (new GetSessionRequest()) + ->setName($formattedName); + $response = $gapicClient->getSession($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/GetSession', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getSessionExceptionTest() + { + $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->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $request = (new GetSessionRequest()) + ->setName($formattedName); + try { + $gapicClient->getSession($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 listSessionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $sessionsElement = new Session(); + $sessions = [ + $sessionsElement, + ]; + $expectedResponse = new ListSessionsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setSessions($sessions); + $transport->addResponse($expectedResponse); + // Mock request + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $request = (new ListSessionsRequest()) + ->setDatabase($formattedDatabase); + $response = $gapicClient->listSessions($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getSessions()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/ListSessions', $actualFuncCall); + $actualValue = $actualRequestObject->getDatabase(); + $this->assertProtobufEquals($formattedDatabase, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listSessionsExceptionTest() + { + $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 + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $request = (new ListSessionsRequest()) + ->setDatabase($formattedDatabase); + try { + $gapicClient->listSessions($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 partitionQueryTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new PartitionResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $sql = 'sql114126'; + $request = (new PartitionQueryRequest()) + ->setSession($formattedSession) + ->setSql($sql); + $response = $gapicClient->partitionQuery($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/PartitionQuery', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getSql(); + $this->assertProtobufEquals($sql, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function partitionQueryExceptionTest() + { + $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 + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $sql = 'sql114126'; + $request = (new PartitionQueryRequest()) + ->setSession($formattedSession) + ->setSql($sql); + try { + $gapicClient->partitionQuery($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 partitionReadTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new PartitionResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $table = 'table110115790'; + $keySet = new KeySet(); + $request = (new PartitionReadRequest()) + ->setSession($formattedSession) + ->setTable($table) + ->setKeySet($keySet); + $response = $gapicClient->partitionRead($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/PartitionRead', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getTable(); + $this->assertProtobufEquals($table, $actualValue); + $actualValue = $actualRequestObject->getKeySet(); + $this->assertProtobufEquals($keySet, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function partitionReadExceptionTest() + { + $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 + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $table = 'table110115790'; + $keySet = new KeySet(); + $request = (new PartitionReadRequest()) + ->setSession($formattedSession) + ->setTable($table) + ->setKeySet($keySet); + try { + $gapicClient->partitionRead($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 readTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new ResultSet(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $table = 'table110115790'; + $columns = []; + $keySet = new KeySet(); + $request = (new ReadRequest()) + ->setSession($formattedSession) + ->setTable($table) + ->setColumns($columns) + ->setKeySet($keySet); + $response = $gapicClient->read($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/Read', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getTable(); + $this->assertProtobufEquals($table, $actualValue); + $actualValue = $actualRequestObject->getColumns(); + $this->assertProtobufEquals($columns, $actualValue); + $actualValue = $actualRequestObject->getKeySet(); + $this->assertProtobufEquals($keySet, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function readExceptionTest() + { + $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 + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $table = 'table110115790'; + $columns = []; + $keySet = new KeySet(); + $request = (new ReadRequest()) + ->setSession($formattedSession) + ->setTable($table) + ->setColumns($columns) + ->setKeySet($keySet); + try { + $gapicClient->read($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 rollbackTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $transactionId = '28'; + $request = (new RollbackRequest()) + ->setSession($formattedSession) + ->setTransactionId($transactionId); + $gapicClient->rollback($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/Rollback', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getTransactionId(); + $this->assertProtobufEquals($transactionId, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function rollbackExceptionTest() + { + $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 + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $transactionId = '28'; + $request = (new RollbackRequest()) + ->setSession($formattedSession) + ->setTransactionId($transactionId); + try { + $gapicClient->rollback($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 streamingReadTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $chunkedValue = true; + $resumeToken2 = '90'; + $expectedResponse = new PartialResultSet(); + $expectedResponse->setChunkedValue($chunkedValue); + $expectedResponse->setResumeToken($resumeToken2); + $transport->addResponse($expectedResponse); + $chunkedValue2 = false; + $resumeToken3 = '91'; + $expectedResponse2 = new PartialResultSet(); + $expectedResponse2->setChunkedValue($chunkedValue2); + $expectedResponse2->setResumeToken($resumeToken3); + $transport->addResponse($expectedResponse2); + $chunkedValue3 = true; + $resumeToken4 = '92'; + $expectedResponse3 = new PartialResultSet(); + $expectedResponse3->setChunkedValue($chunkedValue3); + $expectedResponse3->setResumeToken($resumeToken4); + $transport->addResponse($expectedResponse3); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $table = 'table110115790'; + $columns = []; + $keySet = new KeySet(); + $request = (new ReadRequest()) + ->setSession($formattedSession) + ->setTable($table) + ->setColumns($columns) + ->setKeySet($keySet); + $serverStream = $gapicClient->streamingRead($request); + $this->assertInstanceOf(ServerStream::class, $serverStream); + $responses = iterator_to_array($serverStream->readAll()); + $expectedResponses = []; + $expectedResponses[] = $expectedResponse; + $expectedResponses[] = $expectedResponse2; + $expectedResponses[] = $expectedResponse3; + $this->assertEquals($expectedResponses, $responses); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/StreamingRead', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getTable(); + $this->assertProtobufEquals($table, $actualValue); + $actualValue = $actualRequestObject->getColumns(); + $this->assertProtobufEquals($columns, $actualValue); + $actualValue = $actualRequestObject->getKeySet(); + $this->assertProtobufEquals($keySet, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function streamingReadExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $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->setStreamingStatus($status); + $this->assertTrue($transport->isExhausted()); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $table = 'table110115790'; + $columns = []; + $keySet = new KeySet(); + $request = (new ReadRequest()) + ->setSession($formattedSession) + ->setTable($table) + ->setColumns($columns) + ->setKeySet($keySet); + $serverStream = $gapicClient->streamingRead($request); + $results = $serverStream->readAll(); + try { + iterator_to_array($results); + // If the close stream 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 batchCreateSessionsAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new BatchCreateSessionsResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $sessionCount = 185691686; + $request = (new BatchCreateSessionsRequest()) + ->setDatabase($formattedDatabase) + ->setSessionCount($sessionCount); + $response = $gapicClient->batchCreateSessionsAsync($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.spanner.v1.Spanner/BatchCreateSessions', $actualFuncCall); + $actualValue = $actualRequestObject->getDatabase(); + $this->assertProtobufEquals($formattedDatabase, $actualValue); + $actualValue = $actualRequestObject->getSessionCount(); + $this->assertProtobufEquals($sessionCount, $actualValue); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/owl-bot-staging/Spanner/v1/tests/Unit/V1/SpannerClientTest.php b/owl-bot-staging/Spanner/v1/tests/Unit/V1/SpannerClientTest.php new file mode 100644 index 000000000000..adf20f12570b --- /dev/null +++ b/owl-bot-staging/Spanner/v1/tests/Unit/V1/SpannerClientTest.php @@ -0,0 +1,1161 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return SpannerClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new SpannerClient($options); + } + + /** @test */ + public function batchCreateSessionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new BatchCreateSessionsResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $sessionCount = 185691686; + $response = $gapicClient->batchCreateSessions($formattedDatabase, $sessionCount); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/BatchCreateSessions', $actualFuncCall); + $actualValue = $actualRequestObject->getDatabase(); + $this->assertProtobufEquals($formattedDatabase, $actualValue); + $actualValue = $actualRequestObject->getSessionCount(); + $this->assertProtobufEquals($sessionCount, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function batchCreateSessionsExceptionTest() + { + $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 + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $sessionCount = 185691686; + try { + $gapicClient->batchCreateSessions($formattedDatabase, $sessionCount); + // 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 batchWriteTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new BatchWriteResponse(); + $transport->addResponse($expectedResponse); + $expectedResponse2 = new BatchWriteResponse(); + $transport->addResponse($expectedResponse2); + $expectedResponse3 = new BatchWriteResponse(); + $transport->addResponse($expectedResponse3); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $mutationGroups = []; + $serverStream = $gapicClient->batchWrite($formattedSession, $mutationGroups); + $this->assertInstanceOf(ServerStream::class, $serverStream); + $responses = iterator_to_array($serverStream->readAll()); + $expectedResponses = []; + $expectedResponses[] = $expectedResponse; + $expectedResponses[] = $expectedResponse2; + $expectedResponses[] = $expectedResponse3; + $this->assertEquals($expectedResponses, $responses); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/BatchWrite', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getMutationGroups(); + $this->assertProtobufEquals($mutationGroups, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function batchWriteExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $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->setStreamingStatus($status); + $this->assertTrue($transport->isExhausted()); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $mutationGroups = []; + $serverStream = $gapicClient->batchWrite($formattedSession, $mutationGroups); + $results = $serverStream->readAll(); + try { + iterator_to_array($results); + // If the close stream 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 beginTransactionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $id = '27'; + $expectedResponse = new Transaction(); + $expectedResponse->setId($id); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $options = new TransactionOptions(); + $response = $gapicClient->beginTransaction($formattedSession, $options); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/BeginTransaction', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getOptions(); + $this->assertProtobufEquals($options, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function beginTransactionExceptionTest() + { + $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 + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $options = new TransactionOptions(); + try { + $gapicClient->beginTransaction($formattedSession, $options); + // 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 commitTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new CommitResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $mutations = []; + $response = $gapicClient->commit($formattedSession, $mutations); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/Commit', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getMutations(); + $this->assertProtobufEquals($mutations, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function commitExceptionTest() + { + $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 + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $mutations = []; + try { + $gapicClient->commit($formattedSession, $mutations); + // 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 createSessionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $creatorRole = 'creatorRole-1605962583'; + $multiplexed = false; + $expectedResponse = new Session(); + $expectedResponse->setName($name); + $expectedResponse->setCreatorRole($creatorRole); + $expectedResponse->setMultiplexed($multiplexed); + $transport->addResponse($expectedResponse); + // Mock request + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $response = $gapicClient->createSession($formattedDatabase); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/CreateSession', $actualFuncCall); + $actualValue = $actualRequestObject->getDatabase(); + $this->assertProtobufEquals($formattedDatabase, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createSessionExceptionTest() + { + $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 + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + try { + $gapicClient->createSession($formattedDatabase); + // 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 deleteSessionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $gapicClient->deleteSession($formattedName); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/DeleteSession', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteSessionExceptionTest() + { + $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->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + try { + $gapicClient->deleteSession($formattedName); + // 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 executeBatchDmlTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new ExecuteBatchDmlResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $transaction = new TransactionSelector(); + $statements = []; + $seqno = 109325920; + $response = $gapicClient->executeBatchDml($formattedSession, $transaction, $statements, $seqno); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/ExecuteBatchDml', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getTransaction(); + $this->assertProtobufEquals($transaction, $actualValue); + $actualValue = $actualRequestObject->getStatements(); + $this->assertProtobufEquals($statements, $actualValue); + $actualValue = $actualRequestObject->getSeqno(); + $this->assertProtobufEquals($seqno, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function executeBatchDmlExceptionTest() + { + $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 + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $transaction = new TransactionSelector(); + $statements = []; + $seqno = 109325920; + try { + $gapicClient->executeBatchDml($formattedSession, $transaction, $statements, $seqno); + // 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 executeSqlTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new ResultSet(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $sql = 'sql114126'; + $response = $gapicClient->executeSql($formattedSession, $sql); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/ExecuteSql', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getSql(); + $this->assertProtobufEquals($sql, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function executeSqlExceptionTest() + { + $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 + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $sql = 'sql114126'; + try { + $gapicClient->executeSql($formattedSession, $sql); + // 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 executeStreamingSqlTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $chunkedValue = true; + $resumeToken2 = '90'; + $expectedResponse = new PartialResultSet(); + $expectedResponse->setChunkedValue($chunkedValue); + $expectedResponse->setResumeToken($resumeToken2); + $transport->addResponse($expectedResponse); + $chunkedValue2 = false; + $resumeToken3 = '91'; + $expectedResponse2 = new PartialResultSet(); + $expectedResponse2->setChunkedValue($chunkedValue2); + $expectedResponse2->setResumeToken($resumeToken3); + $transport->addResponse($expectedResponse2); + $chunkedValue3 = true; + $resumeToken4 = '92'; + $expectedResponse3 = new PartialResultSet(); + $expectedResponse3->setChunkedValue($chunkedValue3); + $expectedResponse3->setResumeToken($resumeToken4); + $transport->addResponse($expectedResponse3); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $sql = 'sql114126'; + $serverStream = $gapicClient->executeStreamingSql($formattedSession, $sql); + $this->assertInstanceOf(ServerStream::class, $serverStream); + $responses = iterator_to_array($serverStream->readAll()); + $expectedResponses = []; + $expectedResponses[] = $expectedResponse; + $expectedResponses[] = $expectedResponse2; + $expectedResponses[] = $expectedResponse3; + $this->assertEquals($expectedResponses, $responses); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/ExecuteStreamingSql', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getSql(); + $this->assertProtobufEquals($sql, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function executeStreamingSqlExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $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->setStreamingStatus($status); + $this->assertTrue($transport->isExhausted()); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $sql = 'sql114126'; + $serverStream = $gapicClient->executeStreamingSql($formattedSession, $sql); + $results = $serverStream->readAll(); + try { + iterator_to_array($results); + // If the close stream 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 getSessionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $creatorRole = 'creatorRole-1605962583'; + $multiplexed = false; + $expectedResponse = new Session(); + $expectedResponse->setName($name2); + $expectedResponse->setCreatorRole($creatorRole); + $expectedResponse->setMultiplexed($multiplexed); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $response = $gapicClient->getSession($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/GetSession', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getSessionExceptionTest() + { + $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->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + try { + $gapicClient->getSession($formattedName); + // 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 listSessionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $sessionsElement = new Session(); + $sessions = [ + $sessionsElement, + ]; + $expectedResponse = new ListSessionsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setSessions($sessions); + $transport->addResponse($expectedResponse); + // Mock request + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + $response = $gapicClient->listSessions($formattedDatabase); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getSessions()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/ListSessions', $actualFuncCall); + $actualValue = $actualRequestObject->getDatabase(); + $this->assertProtobufEquals($formattedDatabase, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listSessionsExceptionTest() + { + $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 + $formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]'); + try { + $gapicClient->listSessions($formattedDatabase); + // 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 partitionQueryTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new PartitionResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $sql = 'sql114126'; + $response = $gapicClient->partitionQuery($formattedSession, $sql); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/PartitionQuery', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getSql(); + $this->assertProtobufEquals($sql, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function partitionQueryExceptionTest() + { + $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 + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $sql = 'sql114126'; + try { + $gapicClient->partitionQuery($formattedSession, $sql); + // 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 partitionReadTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new PartitionResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $table = 'table110115790'; + $keySet = new KeySet(); + $response = $gapicClient->partitionRead($formattedSession, $table, $keySet); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/PartitionRead', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getTable(); + $this->assertProtobufEquals($table, $actualValue); + $actualValue = $actualRequestObject->getKeySet(); + $this->assertProtobufEquals($keySet, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function partitionReadExceptionTest() + { + $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 + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $table = 'table110115790'; + $keySet = new KeySet(); + try { + $gapicClient->partitionRead($formattedSession, $table, $keySet); + // 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 readTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new ResultSet(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $table = 'table110115790'; + $columns = []; + $keySet = new KeySet(); + $response = $gapicClient->read($formattedSession, $table, $columns, $keySet); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/Read', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getTable(); + $this->assertProtobufEquals($table, $actualValue); + $actualValue = $actualRequestObject->getColumns(); + $this->assertProtobufEquals($columns, $actualValue); + $actualValue = $actualRequestObject->getKeySet(); + $this->assertProtobufEquals($keySet, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function readExceptionTest() + { + $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 + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $table = 'table110115790'; + $columns = []; + $keySet = new KeySet(); + try { + $gapicClient->read($formattedSession, $table, $columns, $keySet); + // 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 rollbackTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $transactionId = '28'; + $gapicClient->rollback($formattedSession, $transactionId); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/Rollback', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getTransactionId(); + $this->assertProtobufEquals($transactionId, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function rollbackExceptionTest() + { + $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 + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $transactionId = '28'; + try { + $gapicClient->rollback($formattedSession, $transactionId); + // 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 streamingReadTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $chunkedValue = true; + $resumeToken2 = '90'; + $expectedResponse = new PartialResultSet(); + $expectedResponse->setChunkedValue($chunkedValue); + $expectedResponse->setResumeToken($resumeToken2); + $transport->addResponse($expectedResponse); + $chunkedValue2 = false; + $resumeToken3 = '91'; + $expectedResponse2 = new PartialResultSet(); + $expectedResponse2->setChunkedValue($chunkedValue2); + $expectedResponse2->setResumeToken($resumeToken3); + $transport->addResponse($expectedResponse2); + $chunkedValue3 = true; + $resumeToken4 = '92'; + $expectedResponse3 = new PartialResultSet(); + $expectedResponse3->setChunkedValue($chunkedValue3); + $expectedResponse3->setResumeToken($resumeToken4); + $transport->addResponse($expectedResponse3); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $table = 'table110115790'; + $columns = []; + $keySet = new KeySet(); + $serverStream = $gapicClient->streamingRead($formattedSession, $table, $columns, $keySet); + $this->assertInstanceOf(ServerStream::class, $serverStream); + $responses = iterator_to_array($serverStream->readAll()); + $expectedResponses = []; + $expectedResponses[] = $expectedResponse; + $expectedResponses[] = $expectedResponse2; + $expectedResponses[] = $expectedResponse3; + $this->assertEquals($expectedResponses, $responses); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.spanner.v1.Spanner/StreamingRead', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getTable(); + $this->assertProtobufEquals($table, $actualValue); + $actualValue = $actualRequestObject->getColumns(); + $this->assertProtobufEquals($columns, $actualValue); + $actualValue = $actualRequestObject->getKeySet(); + $this->assertProtobufEquals($keySet, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function streamingReadExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $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->setStreamingStatus($status); + $this->assertTrue($transport->isExhausted()); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]'); + $table = 'table110115790'; + $columns = []; + $keySet = new KeySet(); + $serverStream = $gapicClient->streamingRead($formattedSession, $table, $columns, $keySet); + $results = $serverStream->readAll(); + try { + iterator_to_array($results); + // If the close stream 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()); + } +}