diff --git a/owl-bot-staging/OsLogin/v1/proto/src/GPBMetadata/Google/Cloud/Oslogin/Common/Common.php b/owl-bot-staging/OsLogin/v1/proto/src/GPBMetadata/Google/Cloud/Oslogin/Common/Common.php new file mode 100644 index 000000000000..58e5d425988e Binary files /dev/null and b/owl-bot-staging/OsLogin/v1/proto/src/GPBMetadata/Google/Cloud/Oslogin/Common/Common.php differ diff --git a/owl-bot-staging/OsLogin/v1/proto/src/GPBMetadata/Google/Cloud/Oslogin/V1/Oslogin.php b/owl-bot-staging/OsLogin/v1/proto/src/GPBMetadata/Google/Cloud/Oslogin/V1/Oslogin.php new file mode 100644 index 000000000000..95d90b3390be --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/proto/src/GPBMetadata/Google/Cloud/Oslogin/V1/Oslogin.php @@ -0,0 +1,80 @@ +internalAddGeneratedFile( + ' +’ +%google/cloud/oslogin/v1/oslogin.protogoogle.cloud.oslogin.v1google/api/client.protogoogle/api/field_behavior.protogoogle/api/resource.proto(google/cloud/oslogin/common/common.protogoogle/protobuf/empty.proto google/protobuf/field_mask.proto"˜ + LoginProfile +name ( BàAA +posix_accounts ( 2).google.cloud.oslogin.common.PosixAccountQ +ssh_public_keys ( 28.google.cloud.oslogin.v1.LoginProfile.SshPublicKeysEntry_ +SshPublicKeysEntry +key ( 8 +value ( 2).google.cloud.oslogin.common.SshPublicKey:8"  +CreateSshPublicKeyRequest; +parent ( B+àAúA%#oslogin.googleapis.com/SshPublicKeyF +ssh_public_key ( 2).google.cloud.oslogin.common.SshPublicKeyBàA"V +DeletePosixAccountRequest9 +name ( B+àAúA% +#oslogin.googleapis.com/PosixAccount"V +DeleteSshPublicKeyRequest9 +name ( B+àAúA% +#oslogin.googleapis.com/SshPublicKey"z +GetLoginProfileRequest9 +name ( B+àAúA%#oslogin.googleapis.com/PosixAccount + +project_id (  + system_id ( "S +GetSshPublicKeyRequest9 +name ( B+àAúA% +#oslogin.googleapis.com/SshPublicKey"Ê +ImportSshPublicKeyRequest; +parent ( B+àAúA%#oslogin.googleapis.com/SshPublicKeyF +ssh_public_key ( 2).google.cloud.oslogin.common.SshPublicKeyBàA + +project_id (  +regions ( BàA"k +ImportSshPublicKeyResponse< + login_profile ( 2%.google.cloud.oslogin.v1.LoginProfile +details ( "Ï +UpdateSshPublicKeyRequest9 +name ( B+àAúA% +#oslogin.googleapis.com/SshPublicKeyF +ssh_public_key ( 2).google.cloud.oslogin.common.SshPublicKeyBàA/ + update_mask ( 2.google.protobuf.FieldMask2† +OsLoginServiceÇ +CreateSshPublicKey2.google.cloud.oslogin.v1.CreateSshPublicKeyRequest).google.cloud.oslogin.common.SshPublicKey"R‚Óä“4""/v1/{parent=users/*}/sshPublicKeys:ssh_public_keyÚAparent,ssh_public_keyŽ +DeletePosixAccount2.google.cloud.oslogin.v1.DeletePosixAccountRequest.google.protobuf.Empty",‚Óä“*/v1/{name=users/*/projects/*}ÚAname“ +DeleteSshPublicKey2.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest.google.protobuf.Empty"1‚Óä“$*"/v1/{name=users/*/sshPublicKeys/*}ÚAname™ +GetLoginProfile/.google.cloud.oslogin.v1.GetLoginProfileRequest%.google.cloud.oslogin.v1.LoginProfile".‚Óä“!/v1/{name=users/*}/loginProfileÚAname  +GetSshPublicKey/.google.cloud.oslogin.v1.GetSshPublicKeyRequest).google.cloud.oslogin.common.SshPublicKey"1‚Óä“$"/v1/{name=users/*/sshPublicKeys/*}ÚAnameù +ImportSshPublicKey2.google.cloud.oslogin.v1.ImportSshPublicKeyRequest3.google.cloud.oslogin.v1.ImportSshPublicKeyResponse"z‚Óä“9"\'/v1/{parent=users/*}:importSshPublicKey:ssh_public_keyÚAparent,ssh_public_keyÚA parent,ssh_public_key,project_idç +UpdateSshPublicKey2.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest).google.cloud.oslogin.common.SshPublicKey"r‚Óä“42"/v1/{name=users/*/sshPublicKeys/*}:ssh_public_keyÚAname,ssh_public_keyÚAname,ssh_public_key,update_maskÝÊAoslogin.googleapis.comÒAÀhttps://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/cloud-platform.read-only,https://www.googleapis.com/auth/compute,https://www.googleapis.com/auth/compute.readonlyBµ +com.google.cloud.oslogin.v1B OsLoginProtoPZ5cloud.google.com/go/oslogin/apiv1/osloginpb;osloginpbªGoogle.Cloud.OsLogin.V1ÊGoogle\\Cloud\\OsLogin\\V1êGoogle::Cloud::OsLogin::V1bproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/Common/OperatingSystemType.php b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/Common/OperatingSystemType.php new file mode 100644 index 000000000000..dea57253ea7e --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/Common/OperatingSystemType.php @@ -0,0 +1,62 @@ +google.cloud.oslogin.common.OperatingSystemType + */ +class OperatingSystemType +{ + /** + * The operating system type associated with the user account information is + * unspecified. + * + * Generated from protobuf enum OPERATING_SYSTEM_TYPE_UNSPECIFIED = 0; + */ + const OPERATING_SYSTEM_TYPE_UNSPECIFIED = 0; + /** + * Linux user account information. + * + * Generated from protobuf enum LINUX = 1; + */ + const LINUX = 1; + /** + * Windows user account information. + * + * Generated from protobuf enum WINDOWS = 2; + */ + const WINDOWS = 2; + + private static $valueToName = [ + self::OPERATING_SYSTEM_TYPE_UNSPECIFIED => 'OPERATING_SYSTEM_TYPE_UNSPECIFIED', + self::LINUX => 'LINUX', + self::WINDOWS => 'WINDOWS', + ]; + + 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/OsLogin/v1/proto/src/Google/Cloud/OsLogin/Common/PosixAccount.php b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/Common/PosixAccount.php new file mode 100644 index 000000000000..99d5713285c0 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/Common/PosixAccount.php @@ -0,0 +1,411 @@ +google.cloud.oslogin.common.PosixAccount + */ +class PosixAccount extends \Google\Protobuf\Internal\Message +{ + /** + * Only one POSIX account can be marked as primary. + * + * Generated from protobuf field bool primary = 1; + */ + protected $primary = false; + /** + * The username of the POSIX account. + * + * Generated from protobuf field string username = 2; + */ + protected $username = ''; + /** + * The user ID. + * + * Generated from protobuf field int64 uid = 3; + */ + protected $uid = 0; + /** + * The default group ID. + * + * Generated from protobuf field int64 gid = 4; + */ + protected $gid = 0; + /** + * The path to the home directory for this account. + * + * Generated from protobuf field string home_directory = 5; + */ + protected $home_directory = ''; + /** + * The path to the logic shell for this account. + * + * Generated from protobuf field string shell = 6; + */ + protected $shell = ''; + /** + * The GECOS (user information) entry for this account. + * + * Generated from protobuf field string gecos = 7; + */ + protected $gecos = ''; + /** + * System identifier for which account the username or uid applies to. + * By default, the empty value is used. + * + * Generated from protobuf field string system_id = 8; + */ + protected $system_id = ''; + /** + * Output only. A POSIX account identifier. + * + * Generated from protobuf field string account_id = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $account_id = ''; + /** + * The operating system type where this account applies. + * + * Generated from protobuf field .google.cloud.oslogin.common.OperatingSystemType operating_system_type = 10; + */ + protected $operating_system_type = 0; + /** + * Output only. The canonical resource name. + * + * Generated from protobuf field string name = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type bool $primary + * Only one POSIX account can be marked as primary. + * @type string $username + * The username of the POSIX account. + * @type int|string $uid + * The user ID. + * @type int|string $gid + * The default group ID. + * @type string $home_directory + * The path to the home directory for this account. + * @type string $shell + * The path to the logic shell for this account. + * @type string $gecos + * The GECOS (user information) entry for this account. + * @type string $system_id + * System identifier for which account the username or uid applies to. + * By default, the empty value is used. + * @type string $account_id + * Output only. A POSIX account identifier. + * @type int $operating_system_type + * The operating system type where this account applies. + * @type string $name + * Output only. The canonical resource name. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\Common\Common::initOnce(); + parent::__construct($data); + } + + /** + * Only one POSIX account can be marked as primary. + * + * Generated from protobuf field bool primary = 1; + * @return bool + */ + public function getPrimary() + { + return $this->primary; + } + + /** + * Only one POSIX account can be marked as primary. + * + * Generated from protobuf field bool primary = 1; + * @param bool $var + * @return $this + */ + public function setPrimary($var) + { + GPBUtil::checkBool($var); + $this->primary = $var; + + return $this; + } + + /** + * The username of the POSIX account. + * + * Generated from protobuf field string username = 2; + * @return string + */ + public function getUsername() + { + return $this->username; + } + + /** + * The username of the POSIX account. + * + * Generated from protobuf field string username = 2; + * @param string $var + * @return $this + */ + public function setUsername($var) + { + GPBUtil::checkString($var, True); + $this->username = $var; + + return $this; + } + + /** + * The user ID. + * + * Generated from protobuf field int64 uid = 3; + * @return int|string + */ + public function getUid() + { + return $this->uid; + } + + /** + * The user ID. + * + * Generated from protobuf field int64 uid = 3; + * @param int|string $var + * @return $this + */ + public function setUid($var) + { + GPBUtil::checkInt64($var); + $this->uid = $var; + + return $this; + } + + /** + * The default group ID. + * + * Generated from protobuf field int64 gid = 4; + * @return int|string + */ + public function getGid() + { + return $this->gid; + } + + /** + * The default group ID. + * + * Generated from protobuf field int64 gid = 4; + * @param int|string $var + * @return $this + */ + public function setGid($var) + { + GPBUtil::checkInt64($var); + $this->gid = $var; + + return $this; + } + + /** + * The path to the home directory for this account. + * + * Generated from protobuf field string home_directory = 5; + * @return string + */ + public function getHomeDirectory() + { + return $this->home_directory; + } + + /** + * The path to the home directory for this account. + * + * Generated from protobuf field string home_directory = 5; + * @param string $var + * @return $this + */ + public function setHomeDirectory($var) + { + GPBUtil::checkString($var, True); + $this->home_directory = $var; + + return $this; + } + + /** + * The path to the logic shell for this account. + * + * Generated from protobuf field string shell = 6; + * @return string + */ + public function getShell() + { + return $this->shell; + } + + /** + * The path to the logic shell for this account. + * + * Generated from protobuf field string shell = 6; + * @param string $var + * @return $this + */ + public function setShell($var) + { + GPBUtil::checkString($var, True); + $this->shell = $var; + + return $this; + } + + /** + * The GECOS (user information) entry for this account. + * + * Generated from protobuf field string gecos = 7; + * @return string + */ + public function getGecos() + { + return $this->gecos; + } + + /** + * The GECOS (user information) entry for this account. + * + * Generated from protobuf field string gecos = 7; + * @param string $var + * @return $this + */ + public function setGecos($var) + { + GPBUtil::checkString($var, True); + $this->gecos = $var; + + return $this; + } + + /** + * System identifier for which account the username or uid applies to. + * By default, the empty value is used. + * + * Generated from protobuf field string system_id = 8; + * @return string + */ + public function getSystemId() + { + return $this->system_id; + } + + /** + * System identifier for which account the username or uid applies to. + * By default, the empty value is used. + * + * Generated from protobuf field string system_id = 8; + * @param string $var + * @return $this + */ + public function setSystemId($var) + { + GPBUtil::checkString($var, True); + $this->system_id = $var; + + return $this; + } + + /** + * Output only. A POSIX account identifier. + * + * Generated from protobuf field string account_id = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getAccountId() + { + return $this->account_id; + } + + /** + * Output only. A POSIX account identifier. + * + * Generated from protobuf field string account_id = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setAccountId($var) + { + GPBUtil::checkString($var, True); + $this->account_id = $var; + + return $this; + } + + /** + * The operating system type where this account applies. + * + * Generated from protobuf field .google.cloud.oslogin.common.OperatingSystemType operating_system_type = 10; + * @return int + */ + public function getOperatingSystemType() + { + return $this->operating_system_type; + } + + /** + * The operating system type where this account applies. + * + * Generated from protobuf field .google.cloud.oslogin.common.OperatingSystemType operating_system_type = 10; + * @param int $var + * @return $this + */ + public function setOperatingSystemType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\OsLogin\Common\OperatingSystemType::class); + $this->operating_system_type = $var; + + return $this; + } + + /** + * Output only. The canonical resource name. + * + * Generated from protobuf field string name = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Output only. The canonical resource name. + * + * Generated from protobuf field string name = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/Common/SshPublicKey.php b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/Common/SshPublicKey.php new file mode 100644 index 000000000000..185588081e3e --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/Common/SshPublicKey.php @@ -0,0 +1,177 @@ +google.cloud.oslogin.common.SshPublicKey + */ +class SshPublicKey extends \Google\Protobuf\Internal\Message +{ + /** + * Public key text in SSH format, defined by + * RFC4253 + * section 6.6. + * + * Generated from protobuf field string key = 1; + */ + protected $key = ''; + /** + * An expiration time in microseconds since epoch. + * + * Generated from protobuf field int64 expiration_time_usec = 2; + */ + protected $expiration_time_usec = 0; + /** + * Output only. The SHA-256 fingerprint of the SSH public key. + * + * Generated from protobuf field string fingerprint = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $fingerprint = ''; + /** + * Output only. The canonical resource name. + * + * Generated from protobuf field string name = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $key + * Public key text in SSH format, defined by + * RFC4253 + * section 6.6. + * @type int|string $expiration_time_usec + * An expiration time in microseconds since epoch. + * @type string $fingerprint + * Output only. The SHA-256 fingerprint of the SSH public key. + * @type string $name + * Output only. The canonical resource name. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\Common\Common::initOnce(); + parent::__construct($data); + } + + /** + * Public key text in SSH format, defined by + * RFC4253 + * section 6.6. + * + * Generated from protobuf field string key = 1; + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * Public key text in SSH format, defined by + * RFC4253 + * section 6.6. + * + * Generated from protobuf field string key = 1; + * @param string $var + * @return $this + */ + public function setKey($var) + { + GPBUtil::checkString($var, True); + $this->key = $var; + + return $this; + } + + /** + * An expiration time in microseconds since epoch. + * + * Generated from protobuf field int64 expiration_time_usec = 2; + * @return int|string + */ + public function getExpirationTimeUsec() + { + return $this->expiration_time_usec; + } + + /** + * An expiration time in microseconds since epoch. + * + * Generated from protobuf field int64 expiration_time_usec = 2; + * @param int|string $var + * @return $this + */ + public function setExpirationTimeUsec($var) + { + GPBUtil::checkInt64($var); + $this->expiration_time_usec = $var; + + return $this; + } + + /** + * Output only. The SHA-256 fingerprint of the SSH public key. + * + * Generated from protobuf field string fingerprint = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getFingerprint() + { + return $this->fingerprint; + } + + /** + * Output only. The SHA-256 fingerprint of the SSH public key. + * + * Generated from protobuf field string fingerprint = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setFingerprint($var) + { + GPBUtil::checkString($var, True); + $this->fingerprint = $var; + + return $this; + } + + /** + * Output only. The canonical resource name. + * + * Generated from protobuf field string name = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Output only. The canonical resource name. + * + * Generated from protobuf field string name = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/CreateSshPublicKeyRequest.php b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/CreateSshPublicKeyRequest.php new file mode 100644 index 000000000000..76728c29f5e7 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/CreateSshPublicKeyRequest.php @@ -0,0 +1,127 @@ +google.cloud.oslogin.v1.CreateSshPublicKeyRequest + */ +class CreateSshPublicKeyRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The unique ID for the user in format `users/{user}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. The SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $ssh_public_key = null; + + /** + * @param string $parent Required. The unique ID for the user in format `users/{user}`. Please see + * {@see OsLoginServiceClient::userName()} for help formatting this field. + * @param \Google\Cloud\OsLogin\Common\SshPublicKey $sshPublicKey Required. The SSH public key and expiration time. + * + * @return \Google\Cloud\OsLogin\V1\CreateSshPublicKeyRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\OsLogin\Common\SshPublicKey $sshPublicKey): self + { + return (new self()) + ->setParent($parent) + ->setSshPublicKey($sshPublicKey); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The unique ID for the user in format `users/{user}`. + * @type \Google\Cloud\OsLogin\Common\SshPublicKey $ssh_public_key + * Required. The SSH public key and expiration time. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The unique ID for the user in format `users/{user}`. + * + * 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 unique ID for the user in format `users/{user}`. + * + * 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 SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\OsLogin\Common\SshPublicKey|null + */ + public function getSshPublicKey() + { + return $this->ssh_public_key; + } + + public function hasSshPublicKey() + { + return isset($this->ssh_public_key); + } + + public function clearSshPublicKey() + { + unset($this->ssh_public_key); + } + + /** + * Required. The SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\OsLogin\Common\SshPublicKey $var + * @return $this + */ + public function setSshPublicKey($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\Common\SshPublicKey::class); + $this->ssh_public_key = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/DeletePosixAccountRequest.php b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/DeletePosixAccountRequest.php new file mode 100644 index 000000000000..965160ab977f --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/DeletePosixAccountRequest.php @@ -0,0 +1,91 @@ +google.cloud.oslogin.v1.DeletePosixAccountRequest + */ +class DeletePosixAccountRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. A reference to the POSIX account to update. POSIX accounts are + * identified by the project ID they are associated with. A reference to the + * POSIX account is in format `users/{user}/projects/{project}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. A reference to the POSIX account to update. POSIX accounts are + * identified by the project ID they are associated with. A reference to the + * POSIX account is in format `users/{user}/projects/{project}`. Please see + * {@see OsLoginServiceClient::posixAccountName()} for help formatting this field. + * + * @return \Google\Cloud\OsLogin\V1\DeletePosixAccountRequest + * + * @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. A reference to the POSIX account to update. POSIX accounts are + * identified by the project ID they are associated with. A reference to the + * POSIX account is in format `users/{user}/projects/{project}`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Required. A reference to the POSIX account to update. POSIX accounts are + * identified by the project ID they are associated with. A reference to the + * POSIX account is in format `users/{user}/projects/{project}`. + * + * 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. A reference to the POSIX account to update. POSIX accounts are + * identified by the project ID they are associated with. A reference to the + * POSIX account is in format `users/{user}/projects/{project}`. + * + * 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/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/DeleteSshPublicKeyRequest.php b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/DeleteSshPublicKeyRequest.php new file mode 100644 index 000000000000..11383a19392f --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/DeleteSshPublicKeyRequest.php @@ -0,0 +1,91 @@ +google.cloud.oslogin.v1.DeleteSshPublicKeyRequest + */ +class DeleteSshPublicKeyRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. Please see + * {@see OsLoginServiceClient::sshPublicKeyName()} for help formatting this field. + * + * @return \Google\Cloud\OsLogin\V1\DeleteSshPublicKeyRequest + * + * @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 fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * 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 fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * 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/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/GetLoginProfileRequest.php b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/GetLoginProfileRequest.php new file mode 100644 index 000000000000..85992364fab9 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/GetLoginProfileRequest.php @@ -0,0 +1,149 @@ +google.cloud.oslogin.v1.GetLoginProfileRequest + */ +class GetLoginProfileRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The unique ID for the user in format `users/{user}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + /** + * The project ID of the Google Cloud Platform project. + * + * Generated from protobuf field string project_id = 2; + */ + protected $project_id = ''; + /** + * A system ID for filtering the results of the request. + * + * Generated from protobuf field string system_id = 3; + */ + protected $system_id = ''; + + /** + * @param string $name Required. The unique ID for the user in format `users/{user}`. Please see + * {@see OsLoginServiceClient::userName()} for help formatting this field. + * + * @return \Google\Cloud\OsLogin\V1\GetLoginProfileRequest + * + * @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 unique ID for the user in format `users/{user}`. + * @type string $project_id + * The project ID of the Google Cloud Platform project. + * @type string $system_id + * A system ID for filtering the results of the request. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The unique ID for the user in format `users/{user}`. + * + * 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 unique ID for the user in format `users/{user}`. + * + * 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; + } + + /** + * The project ID of the Google Cloud Platform project. + * + * Generated from protobuf field string project_id = 2; + * @return string + */ + public function getProjectId() + { + return $this->project_id; + } + + /** + * The project ID of the Google Cloud Platform project. + * + * Generated from protobuf field string project_id = 2; + * @param string $var + * @return $this + */ + public function setProjectId($var) + { + GPBUtil::checkString($var, True); + $this->project_id = $var; + + return $this; + } + + /** + * A system ID for filtering the results of the request. + * + * Generated from protobuf field string system_id = 3; + * @return string + */ + public function getSystemId() + { + return $this->system_id; + } + + /** + * A system ID for filtering the results of the request. + * + * Generated from protobuf field string system_id = 3; + * @param string $var + * @return $this + */ + public function setSystemId($var) + { + GPBUtil::checkString($var, True); + $this->system_id = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/GetSshPublicKeyRequest.php b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/GetSshPublicKeyRequest.php new file mode 100644 index 000000000000..6e6de1d0ec84 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/GetSshPublicKeyRequest.php @@ -0,0 +1,91 @@ +google.cloud.oslogin.v1.GetSshPublicKeyRequest + */ +class GetSshPublicKeyRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The fingerprint of the public key to retrieve. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. The fingerprint of the public key to retrieve. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. Please see + * {@see OsLoginServiceClient::sshPublicKeyName()} for help formatting this field. + * + * @return \Google\Cloud\OsLogin\V1\GetSshPublicKeyRequest + * + * @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 fingerprint of the public key to retrieve. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The fingerprint of the public key to retrieve. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * 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 fingerprint of the public key to retrieve. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * 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/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/ImportSshPublicKeyRequest.php b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/ImportSshPublicKeyRequest.php new file mode 100644 index 000000000000..122ed6f2f131 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/ImportSshPublicKeyRequest.php @@ -0,0 +1,221 @@ +google.cloud.oslogin.v1.ImportSshPublicKeyRequest + */ +class ImportSshPublicKeyRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The unique ID for the user in format `users/{user}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Optional. The SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $ssh_public_key = null; + /** + * The project ID of the Google Cloud Platform project. + * + * Generated from protobuf field string project_id = 3; + */ + protected $project_id = ''; + /** + * Optional. The regions to which to assert that the key was written. + * If unspecified, defaults to all regions. + * Regions are listed at https://cloud.google.com/about/locations#region. + * + * Generated from protobuf field repeated string regions = 5 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $regions; + + /** + * @param string $parent Required. The unique ID for the user in format `users/{user}`. Please see + * {@see OsLoginServiceClient::userName()} for help formatting this field. + * @param \Google\Cloud\OsLogin\Common\SshPublicKey $sshPublicKey Optional. The SSH public key and expiration time. + * + * @return \Google\Cloud\OsLogin\V1\ImportSshPublicKeyRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\OsLogin\Common\SshPublicKey $sshPublicKey): self + { + return (new self()) + ->setParent($parent) + ->setSshPublicKey($sshPublicKey); + } + + /** + * @param string $parent Required. The unique ID for the user in format `users/{user}`. Please see + * {@see OsLoginServiceClient::userName()} for help formatting this field. + * @param \Google\Cloud\OsLogin\Common\SshPublicKey $sshPublicKey Optional. The SSH public key and expiration time. + * @param string $projectId The project ID of the Google Cloud Platform project. + * + * @return \Google\Cloud\OsLogin\V1\ImportSshPublicKeyRequest + * + * @experimental + */ + public static function buildFromParentSshPublicKeyProjectId(string $parent, \Google\Cloud\OsLogin\Common\SshPublicKey $sshPublicKey, string $projectId): self + { + return (new self()) + ->setParent($parent) + ->setSshPublicKey($sshPublicKey) + ->setProjectId($projectId); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The unique ID for the user in format `users/{user}`. + * @type \Google\Cloud\OsLogin\Common\SshPublicKey $ssh_public_key + * Optional. The SSH public key and expiration time. + * @type string $project_id + * The project ID of the Google Cloud Platform project. + * @type array|\Google\Protobuf\Internal\RepeatedField $regions + * Optional. The regions to which to assert that the key was written. + * If unspecified, defaults to all regions. + * Regions are listed at https://cloud.google.com/about/locations#region. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The unique ID for the user in format `users/{user}`. + * + * 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 unique ID for the user in format `users/{user}`. + * + * 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. The SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\OsLogin\Common\SshPublicKey|null + */ + public function getSshPublicKey() + { + return $this->ssh_public_key; + } + + public function hasSshPublicKey() + { + return isset($this->ssh_public_key); + } + + public function clearSshPublicKey() + { + unset($this->ssh_public_key); + } + + /** + * Optional. The SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\OsLogin\Common\SshPublicKey $var + * @return $this + */ + public function setSshPublicKey($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\Common\SshPublicKey::class); + $this->ssh_public_key = $var; + + return $this; + } + + /** + * The project ID of the Google Cloud Platform project. + * + * Generated from protobuf field string project_id = 3; + * @return string + */ + public function getProjectId() + { + return $this->project_id; + } + + /** + * The project ID of the Google Cloud Platform project. + * + * Generated from protobuf field string project_id = 3; + * @param string $var + * @return $this + */ + public function setProjectId($var) + { + GPBUtil::checkString($var, True); + $this->project_id = $var; + + return $this; + } + + /** + * Optional. The regions to which to assert that the key was written. + * If unspecified, defaults to all regions. + * Regions are listed at https://cloud.google.com/about/locations#region. + * + * Generated from protobuf field repeated string regions = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getRegions() + { + return $this->regions; + } + + /** + * Optional. The regions to which to assert that the key was written. + * If unspecified, defaults to all regions. + * Regions are listed at https://cloud.google.com/about/locations#region. + * + * Generated from protobuf field repeated string regions = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setRegions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->regions = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/ImportSshPublicKeyResponse.php b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/ImportSshPublicKeyResponse.php new file mode 100644 index 000000000000..c9c749a53bee --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/ImportSshPublicKeyResponse.php @@ -0,0 +1,111 @@ +google.cloud.oslogin.v1.ImportSshPublicKeyResponse + */ +class ImportSshPublicKeyResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The login profile information for the user. + * + * Generated from protobuf field .google.cloud.oslogin.v1.LoginProfile login_profile = 1; + */ + protected $login_profile = null; + /** + * Detailed information about import results. + * + * Generated from protobuf field string details = 2; + */ + protected $details = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\OsLogin\V1\LoginProfile $login_profile + * The login profile information for the user. + * @type string $details + * Detailed information about import results. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * The login profile information for the user. + * + * Generated from protobuf field .google.cloud.oslogin.v1.LoginProfile login_profile = 1; + * @return \Google\Cloud\OsLogin\V1\LoginProfile|null + */ + public function getLoginProfile() + { + return $this->login_profile; + } + + public function hasLoginProfile() + { + return isset($this->login_profile); + } + + public function clearLoginProfile() + { + unset($this->login_profile); + } + + /** + * The login profile information for the user. + * + * Generated from protobuf field .google.cloud.oslogin.v1.LoginProfile login_profile = 1; + * @param \Google\Cloud\OsLogin\V1\LoginProfile $var + * @return $this + */ + public function setLoginProfile($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\V1\LoginProfile::class); + $this->login_profile = $var; + + return $this; + } + + /** + * Detailed information about import results. + * + * Generated from protobuf field string details = 2; + * @return string + */ + public function getDetails() + { + return $this->details; + } + + /** + * Detailed information about import results. + * + * Generated from protobuf field string details = 2; + * @param string $var + * @return $this + */ + public function setDetails($var) + { + GPBUtil::checkString($var, True); + $this->details = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/LoginProfile.php b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/LoginProfile.php new file mode 100644 index 000000000000..6abe567377c1 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/LoginProfile.php @@ -0,0 +1,136 @@ +google.cloud.oslogin.v1.LoginProfile + */ +class LoginProfile extends \Google\Protobuf\Internal\Message +{ + /** + * Required. A unique user ID. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $name = ''; + /** + * The list of POSIX accounts associated with the user. + * + * Generated from protobuf field repeated .google.cloud.oslogin.common.PosixAccount posix_accounts = 2; + */ + private $posix_accounts; + /** + * A map from SSH public key fingerprint to the associated key object. + * + * Generated from protobuf field map ssh_public_keys = 3; + */ + private $ssh_public_keys; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. A unique user ID. + * @type array<\Google\Cloud\OsLogin\Common\PosixAccount>|\Google\Protobuf\Internal\RepeatedField $posix_accounts + * The list of POSIX accounts associated with the user. + * @type array|\Google\Protobuf\Internal\MapField $ssh_public_keys + * A map from SSH public key fingerprint to the associated key object. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Required. A unique user ID. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. A unique user ID. + * + * 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; + } + + /** + * The list of POSIX accounts associated with the user. + * + * Generated from protobuf field repeated .google.cloud.oslogin.common.PosixAccount posix_accounts = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPosixAccounts() + { + return $this->posix_accounts; + } + + /** + * The list of POSIX accounts associated with the user. + * + * Generated from protobuf field repeated .google.cloud.oslogin.common.PosixAccount posix_accounts = 2; + * @param array<\Google\Cloud\OsLogin\Common\PosixAccount>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPosixAccounts($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\OsLogin\Common\PosixAccount::class); + $this->posix_accounts = $arr; + + return $this; + } + + /** + * A map from SSH public key fingerprint to the associated key object. + * + * Generated from protobuf field map ssh_public_keys = 3; + * @return \Google\Protobuf\Internal\MapField + */ + public function getSshPublicKeys() + { + return $this->ssh_public_keys; + } + + /** + * A map from SSH public key fingerprint to the associated key object. + * + * Generated from protobuf field map ssh_public_keys = 3; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setSshPublicKeys($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\OsLogin\Common\SshPublicKey::class); + $this->ssh_public_keys = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/UpdateSshPublicKeyRequest.php b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/UpdateSshPublicKeyRequest.php new file mode 100644 index 000000000000..421c2a2586c5 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/proto/src/Google/Cloud/OsLogin/V1/UpdateSshPublicKeyRequest.php @@ -0,0 +1,201 @@ +google.cloud.oslogin.v1.UpdateSshPublicKeyRequest + */ +class UpdateSshPublicKeyRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + /** + * Required. The SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $ssh_public_key = null; + /** + * Mask to control which fields get updated. Updates all if not present. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3; + */ + protected $update_mask = null; + + /** + * @param string $name Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. Please see + * {@see OsLoginServiceClient::sshPublicKeyName()} for help formatting this field. + * @param \Google\Cloud\OsLogin\Common\SshPublicKey $sshPublicKey Required. The SSH public key and expiration time. + * + * @return \Google\Cloud\OsLogin\V1\UpdateSshPublicKeyRequest + * + * @experimental + */ + public static function build(string $name, \Google\Cloud\OsLogin\Common\SshPublicKey $sshPublicKey): self + { + return (new self()) + ->setName($name) + ->setSshPublicKey($sshPublicKey); + } + + /** + * @param string $name Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. Please see + * {@see OsLoginServiceClient::sshPublicKeyName()} for help formatting this field. + * @param \Google\Cloud\OsLogin\Common\SshPublicKey $sshPublicKey Required. The SSH public key and expiration time. + * @param \Google\Protobuf\FieldMask $updateMask Mask to control which fields get updated. Updates all if not present. + * + * @return \Google\Cloud\OsLogin\V1\UpdateSshPublicKeyRequest + * + * @experimental + */ + public static function buildFromNameSshPublicKeyUpdateMask(string $name, \Google\Cloud\OsLogin\Common\SshPublicKey $sshPublicKey, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setName($name) + ->setSshPublicKey($sshPublicKey) + ->setUpdateMask($updateMask); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * @type \Google\Cloud\OsLogin\Common\SshPublicKey $ssh_public_key + * Required. The SSH public key and expiration time. + * @type \Google\Protobuf\FieldMask $update_mask + * Mask to control which fields get updated. Updates all if not present. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * 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 fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * 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 SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\OsLogin\Common\SshPublicKey|null + */ + public function getSshPublicKey() + { + return $this->ssh_public_key; + } + + public function hasSshPublicKey() + { + return isset($this->ssh_public_key); + } + + public function clearSshPublicKey() + { + unset($this->ssh_public_key); + } + + /** + * Required. The SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\OsLogin\Common\SshPublicKey $var + * @return $this + */ + public function setSshPublicKey($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\Common\SshPublicKey::class); + $this->ssh_public_key = $var; + + return $this; + } + + /** + * Mask to control which fields get updated. Updates all if not present. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3; + * @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); + } + + /** + * Mask to control which fields get updated. Updates all if not present. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3; + * @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/OsLogin/v1/samples/V1/OsLoginServiceClient/create_ssh_public_key.php b/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/create_ssh_public_key.php new file mode 100644 index 000000000000..648a5ea7645f --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/create_ssh_public_key.php @@ -0,0 +1,73 @@ +setParent($formattedParent) + ->setSshPublicKey($sshPublicKey); + + // Call the API and handle any network failures. + try { + /** @var SshPublicKey $response */ + $response = $osLoginServiceClient->createSshPublicKey($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 = OsLoginServiceClient::userName('[USER]'); + + create_ssh_public_key_sample($formattedParent); +} +// [END oslogin_v1_generated_OsLoginService_CreateSshPublicKey_sync] diff --git a/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/delete_posix_account.php b/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/delete_posix_account.php new file mode 100644 index 000000000000..cec102d70eed --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/delete_posix_account.php @@ -0,0 +1,71 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + $osLoginServiceClient->deletePosixAccount($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 = OsLoginServiceClient::posixAccountName('[USER]', '[PROJECT]'); + + delete_posix_account_sample($formattedName); +} +// [END oslogin_v1_generated_OsLoginService_DeletePosixAccount_sync] diff --git a/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/delete_ssh_public_key.php b/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/delete_ssh_public_key.php new file mode 100644 index 000000000000..e7398c7d3fc4 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/delete_ssh_public_key.php @@ -0,0 +1,71 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + $osLoginServiceClient->deleteSshPublicKey($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 = OsLoginServiceClient::sshPublicKeyName('[USER]', '[FINGERPRINT]'); + + delete_ssh_public_key_sample($formattedName); +} +// [END oslogin_v1_generated_OsLoginService_DeleteSshPublicKey_sync] diff --git a/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/get_login_profile.php b/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/get_login_profile.php new file mode 100644 index 000000000000..6b97dcf8279b --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/get_login_profile.php @@ -0,0 +1,72 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var LoginProfile $response */ + $response = $osLoginServiceClient->getLoginProfile($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 = OsLoginServiceClient::userName('[USER]'); + + get_login_profile_sample($formattedName); +} +// [END oslogin_v1_generated_OsLoginService_GetLoginProfile_sync] diff --git a/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/get_ssh_public_key.php b/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/get_ssh_public_key.php new file mode 100644 index 000000000000..a7570bc0d15d --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/get_ssh_public_key.php @@ -0,0 +1,73 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var SshPublicKey $response */ + $response = $osLoginServiceClient->getSshPublicKey($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 = OsLoginServiceClient::sshPublicKeyName('[USER]', '[FINGERPRINT]'); + + get_ssh_public_key_sample($formattedName); +} +// [END oslogin_v1_generated_OsLoginService_GetSshPublicKey_sync] diff --git a/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/import_ssh_public_key.php b/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/import_ssh_public_key.php new file mode 100644 index 000000000000..a631d81efa91 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/import_ssh_public_key.php @@ -0,0 +1,73 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var ImportSshPublicKeyResponse $response */ + $response = $osLoginServiceClient->importSshPublicKey($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 = OsLoginServiceClient::userName('[USER]'); + + import_ssh_public_key_sample($formattedParent); +} +// [END oslogin_v1_generated_OsLoginService_ImportSshPublicKey_sync] diff --git a/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/update_ssh_public_key.php b/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/update_ssh_public_key.php new file mode 100644 index 000000000000..a742735ea2a3 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/samples/V1/OsLoginServiceClient/update_ssh_public_key.php @@ -0,0 +1,76 @@ +setName($formattedName) + ->setSshPublicKey($sshPublicKey); + + // Call the API and handle any network failures. + try { + /** @var SshPublicKey $response */ + $response = $osLoginServiceClient->updateSshPublicKey($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 = OsLoginServiceClient::sshPublicKeyName('[USER]', '[FINGERPRINT]'); + + update_ssh_public_key_sample($formattedName); +} +// [END oslogin_v1_generated_OsLoginService_UpdateSshPublicKey_sync] diff --git a/owl-bot-staging/OsLogin/v1/src/V1/Client/OsLoginServiceClient.php b/owl-bot-staging/OsLogin/v1/src/V1/Client/OsLoginServiceClient.php new file mode 100644 index 000000000000..39daa47e1ae5 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/src/V1/Client/OsLoginServiceClient.php @@ -0,0 +1,447 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/os_login_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/os_login_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/os_login_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/os_login_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * posix_account resource. + * + * @param string $user + * @param string $project + * + * @return string The formatted posix_account resource. + */ + public static function posixAccountName(string $user, string $project): string + { + return self::getPathTemplate('posixAccount')->render([ + 'user' => $user, + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * ssh_public_key resource. + * + * @param string $user + * @param string $fingerprint + * + * @return string The formatted ssh_public_key resource. + */ + public static function sshPublicKeyName(string $user, string $fingerprint): string + { + return self::getPathTemplate('sshPublicKey')->render([ + 'user' => $user, + 'fingerprint' => $fingerprint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a user + * resource. + * + * @param string $user + * + * @return string The formatted user resource. + */ + public static function userName(string $user): string + { + return self::getPathTemplate('user')->render([ + 'user' => $user, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - posixAccount: users/{user}/projects/{project} + * - sshPublicKey: users/{user}/sshPublicKeys/{fingerprint} + * - user: users/{user} + * + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * Constructor. + * + * @param array $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 'oslogin.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); + } + + /** 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); + } + + /** + * Create an SSH public key + * + * The async variant is {@see OsLoginServiceClient::createSshPublicKeyAsync()} . + * + * @example samples/V1/OsLoginServiceClient/create_ssh_public_key.php + * + * @param CreateSshPublicKeyRequest $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 SshPublicKey + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSshPublicKey(CreateSshPublicKeyRequest $request, array $callOptions = []): SshPublicKey + { + return $this->startApiCall('CreateSshPublicKey', $request, $callOptions)->wait(); + } + + /** + * Deletes a POSIX account. + * + * The async variant is {@see OsLoginServiceClient::deletePosixAccountAsync()} . + * + * @example samples/V1/OsLoginServiceClient/delete_posix_account.php + * + * @param DeletePosixAccountRequest $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 deletePosixAccount(DeletePosixAccountRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeletePosixAccount', $request, $callOptions)->wait(); + } + + /** + * Deletes an SSH public key. + * + * The async variant is {@see OsLoginServiceClient::deleteSshPublicKeyAsync()} . + * + * @example samples/V1/OsLoginServiceClient/delete_ssh_public_key.php + * + * @param DeleteSshPublicKeyRequest $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 deleteSshPublicKey(DeleteSshPublicKeyRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteSshPublicKey', $request, $callOptions)->wait(); + } + + /** + * Retrieves the profile information used for logging in to a virtual machine + * on Google Compute Engine. + * + * The async variant is {@see OsLoginServiceClient::getLoginProfileAsync()} . + * + * @example samples/V1/OsLoginServiceClient/get_login_profile.php + * + * @param GetLoginProfileRequest $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 LoginProfile + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLoginProfile(GetLoginProfileRequest $request, array $callOptions = []): LoginProfile + { + return $this->startApiCall('GetLoginProfile', $request, $callOptions)->wait(); + } + + /** + * Retrieves an SSH public key. + * + * The async variant is {@see OsLoginServiceClient::getSshPublicKeyAsync()} . + * + * @example samples/V1/OsLoginServiceClient/get_ssh_public_key.php + * + * @param GetSshPublicKeyRequest $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 SshPublicKey + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSshPublicKey(GetSshPublicKeyRequest $request, array $callOptions = []): SshPublicKey + { + return $this->startApiCall('GetSshPublicKey', $request, $callOptions)->wait(); + } + + /** + * Adds an SSH public key and returns the profile information. Default POSIX + * account information is set when no username and UID exist as part of the + * login profile. + * + * The async variant is {@see OsLoginServiceClient::importSshPublicKeyAsync()} . + * + * @example samples/V1/OsLoginServiceClient/import_ssh_public_key.php + * + * @param ImportSshPublicKeyRequest $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 ImportSshPublicKeyResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importSshPublicKey(ImportSshPublicKeyRequest $request, array $callOptions = []): ImportSshPublicKeyResponse + { + return $this->startApiCall('ImportSshPublicKey', $request, $callOptions)->wait(); + } + + /** + * Updates an SSH public key and returns the profile information. This method + * supports patch semantics. + * + * The async variant is {@see OsLoginServiceClient::updateSshPublicKeyAsync()} . + * + * @example samples/V1/OsLoginServiceClient/update_ssh_public_key.php + * + * @param UpdateSshPublicKeyRequest $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 SshPublicKey + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSshPublicKey(UpdateSshPublicKeyRequest $request, array $callOptions = []): SshPublicKey + { + return $this->startApiCall('UpdateSshPublicKey', $request, $callOptions)->wait(); + } +} diff --git a/owl-bot-staging/OsLogin/v1/src/V1/Gapic/OsLoginServiceGapicClient.php b/owl-bot-staging/OsLogin/v1/src/V1/Gapic/OsLoginServiceGapicClient.php new file mode 100644 index 000000000000..b4e73514f422 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/src/V1/Gapic/OsLoginServiceGapicClient.php @@ -0,0 +1,650 @@ +userName('[USER]'); + * $sshPublicKey = new SshPublicKey(); + * $response = $osLoginServiceClient->createSshPublicKey($formattedParent, $sshPublicKey); + * } finally { + * $osLoginServiceClient->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\OsLogin\V1\Client\OsLoginServiceClient}. + */ +class OsLoginServiceGapicClient +{ + use GapicClientTrait; + + /** The name of the service. */ + const SERVICE_NAME = 'google.cloud.oslogin.v1.OsLoginService'; + + /** + * The default address of the service. + * + * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. + */ + const SERVICE_ADDRESS = 'oslogin.googleapis.com'; + + /** The address template of the service. */ + private const SERVICE_ADDRESS_TEMPLATE = 'oslogin.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/cloud-platform.read-only', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/compute.readonly', + ]; + + private static $posixAccountNameTemplate; + + private static $sshPublicKeyNameTemplate; + + private static $userNameTemplate; + + private static $pathTemplateMap; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/os_login_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/os_login_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/os_login_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/os_login_service_rest_client_config.php', + ], + ], + ]; + } + + private static function getPosixAccountNameTemplate() + { + if (self::$posixAccountNameTemplate == null) { + self::$posixAccountNameTemplate = new PathTemplate('users/{user}/projects/{project}'); + } + + return self::$posixAccountNameTemplate; + } + + private static function getSshPublicKeyNameTemplate() + { + if (self::$sshPublicKeyNameTemplate == null) { + self::$sshPublicKeyNameTemplate = new PathTemplate('users/{user}/sshPublicKeys/{fingerprint}'); + } + + return self::$sshPublicKeyNameTemplate; + } + + private static function getUserNameTemplate() + { + if (self::$userNameTemplate == null) { + self::$userNameTemplate = new PathTemplate('users/{user}'); + } + + return self::$userNameTemplate; + } + + private static function getPathTemplateMap() + { + if (self::$pathTemplateMap == null) { + self::$pathTemplateMap = [ + 'posixAccount' => self::getPosixAccountNameTemplate(), + 'sshPublicKey' => self::getSshPublicKeyNameTemplate(), + 'user' => self::getUserNameTemplate(), + ]; + } + + return self::$pathTemplateMap; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * posix_account resource. + * + * @param string $user + * @param string $project + * + * @return string The formatted posix_account resource. + */ + public static function posixAccountName($user, $project) + { + return self::getPosixAccountNameTemplate()->render([ + 'user' => $user, + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * ssh_public_key resource. + * + * @param string $user + * @param string $fingerprint + * + * @return string The formatted ssh_public_key resource. + */ + public static function sshPublicKeyName($user, $fingerprint) + { + return self::getSshPublicKeyNameTemplate()->render([ + 'user' => $user, + 'fingerprint' => $fingerprint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a user + * resource. + * + * @param string $user + * + * @return string The formatted user resource. + */ + public static function userName($user) + { + return self::getUserNameTemplate()->render([ + 'user' => $user, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - posixAccount: users/{user}/projects/{project} + * - sshPublicKey: users/{user}/sshPublicKeys/{fingerprint} + * - user: users/{user} + * + * 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 'oslogin.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); + } + + /** + * Create an SSH public key + * + * Sample code: + * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); + * try { + * $formattedParent = $osLoginServiceClient->userName('[USER]'); + * $sshPublicKey = new SshPublicKey(); + * $response = $osLoginServiceClient->createSshPublicKey($formattedParent, $sshPublicKey); + * } finally { + * $osLoginServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. The unique ID for the user in format `users/{user}`. + * @param SshPublicKey $sshPublicKey Required. The SSH public key and expiration time. + * @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\OsLogin\Common\SshPublicKey + * + * @throws ApiException if the remote call fails + */ + public function createSshPublicKey($parent, $sshPublicKey, array $optionalArgs = []) + { + $request = new CreateSshPublicKeyRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setSshPublicKey($sshPublicKey); + $requestParamHeaders['parent'] = $parent; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateSshPublicKey', SshPublicKey::class, $optionalArgs, $request)->wait(); + } + + /** + * Deletes a POSIX account. + * + * Sample code: + * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); + * try { + * $formattedName = $osLoginServiceClient->posixAccountName('[USER]', '[PROJECT]'); + * $osLoginServiceClient->deletePosixAccount($formattedName); + * } finally { + * $osLoginServiceClient->close(); + * } + * ``` + * + * @param string $name Required. A reference to the POSIX account to update. POSIX accounts are + * identified by the project ID they are associated with. A reference to the + * POSIX account is in format `users/{user}/projects/{project}`. + * @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 deletePosixAccount($name, array $optionalArgs = []) + { + $request = new DeletePosixAccountRequest(); + $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('DeletePosixAccount', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Deletes an SSH public key. + * + * Sample code: + * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); + * try { + * $formattedName = $osLoginServiceClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + * $osLoginServiceClient->deleteSshPublicKey($formattedName); + * } finally { + * $osLoginServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * @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 deleteSshPublicKey($name, array $optionalArgs = []) + { + $request = new DeleteSshPublicKeyRequest(); + $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('DeleteSshPublicKey', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Retrieves the profile information used for logging in to a virtual machine + * on Google Compute Engine. + * + * Sample code: + * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); + * try { + * $formattedName = $osLoginServiceClient->userName('[USER]'); + * $response = $osLoginServiceClient->getLoginProfile($formattedName); + * } finally { + * $osLoginServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The unique ID for the user in format `users/{user}`. + * @param array $optionalArgs { + * Optional. + * + * @type string $projectId + * The project ID of the Google Cloud Platform project. + * @type string $systemId + * A system ID for filtering the results of the request. + * @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\OsLogin\V1\LoginProfile + * + * @throws ApiException if the remote call fails + */ + public function getLoginProfile($name, array $optionalArgs = []) + { + $request = new GetLoginProfileRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['projectId'])) { + $request->setProjectId($optionalArgs['projectId']); + } + + if (isset($optionalArgs['systemId'])) { + $request->setSystemId($optionalArgs['systemId']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetLoginProfile', LoginProfile::class, $optionalArgs, $request)->wait(); + } + + /** + * Retrieves an SSH public key. + * + * Sample code: + * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); + * try { + * $formattedName = $osLoginServiceClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + * $response = $osLoginServiceClient->getSshPublicKey($formattedName); + * } finally { + * $osLoginServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The fingerprint of the public key to retrieve. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * @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\OsLogin\Common\SshPublicKey + * + * @throws ApiException if the remote call fails + */ + public function getSshPublicKey($name, array $optionalArgs = []) + { + $request = new GetSshPublicKeyRequest(); + $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('GetSshPublicKey', SshPublicKey::class, $optionalArgs, $request)->wait(); + } + + /** + * Adds an SSH public key and returns the profile information. Default POSIX + * account information is set when no username and UID exist as part of the + * login profile. + * + * Sample code: + * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); + * try { + * $formattedParent = $osLoginServiceClient->userName('[USER]'); + * $response = $osLoginServiceClient->importSshPublicKey($formattedParent); + * } finally { + * $osLoginServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. The unique ID for the user in format `users/{user}`. + * @param array $optionalArgs { + * Optional. + * + * @type SshPublicKey $sshPublicKey + * Optional. The SSH public key and expiration time. + * @type string $projectId + * The project ID of the Google Cloud Platform project. + * @type string[] $regions + * Optional. The regions to which to assert that the key was written. + * If unspecified, defaults to all regions. + * Regions are listed at https://cloud.google.com/about/locations#region. + * @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\OsLogin\V1\ImportSshPublicKeyResponse + * + * @throws ApiException if the remote call fails + */ + public function importSshPublicKey($parent, array $optionalArgs = []) + { + $request = new ImportSshPublicKeyRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['sshPublicKey'])) { + $request->setSshPublicKey($optionalArgs['sshPublicKey']); + } + + if (isset($optionalArgs['projectId'])) { + $request->setProjectId($optionalArgs['projectId']); + } + + if (isset($optionalArgs['regions'])) { + $request->setRegions($optionalArgs['regions']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('ImportSshPublicKey', ImportSshPublicKeyResponse::class, $optionalArgs, $request)->wait(); + } + + /** + * Updates an SSH public key and returns the profile information. This method + * supports patch semantics. + * + * Sample code: + * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); + * try { + * $formattedName = $osLoginServiceClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + * $sshPublicKey = new SshPublicKey(); + * $response = $osLoginServiceClient->updateSshPublicKey($formattedName, $sshPublicKey); + * } finally { + * $osLoginServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * @param SshPublicKey $sshPublicKey Required. The SSH public key and expiration time. + * @param array $optionalArgs { + * Optional. + * + * @type FieldMask $updateMask + * Mask to control which fields get updated. Updates all if not present. + * @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\OsLogin\Common\SshPublicKey + * + * @throws ApiException if the remote call fails + */ + public function updateSshPublicKey($name, $sshPublicKey, array $optionalArgs = []) + { + $request = new UpdateSshPublicKeyRequest(); + $requestParamHeaders = []; + $request->setName($name); + $request->setSshPublicKey($sshPublicKey); + $requestParamHeaders['name'] = $name; + 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('UpdateSshPublicKey', SshPublicKey::class, $optionalArgs, $request)->wait(); + } +} diff --git a/owl-bot-staging/OsLogin/v1/src/V1/OsLoginServiceClient.php b/owl-bot-staging/OsLogin/v1/src/V1/OsLoginServiceClient.php new file mode 100644 index 000000000000..9c63096b9c6b --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/src/V1/OsLoginServiceClient.php @@ -0,0 +1,34 @@ + [ + 'google.cloud.oslogin.v1.OsLoginService' => [ + 'CreateSshPublicKey' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\OsLogin\Common\SshPublicKey', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'DeletePosixAccount' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'DeleteSshPublicKey' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetLoginProfile' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\OsLogin\V1\LoginProfile', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetSshPublicKey' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\OsLogin\Common\SshPublicKey', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'ImportSshPublicKey' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\OsLogin\V1\ImportSshPublicKeyResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateSshPublicKey' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\OsLogin\Common\SshPublicKey', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'templateMap' => [ + 'posixAccount' => 'users/{user}/projects/{project}', + 'sshPublicKey' => 'users/{user}/sshPublicKeys/{fingerprint}', + 'user' => 'users/{user}', + ], + ], + ], +]; diff --git a/owl-bot-staging/OsLogin/v1/src/V1/resources/os_login_service_rest_client_config.php b/owl-bot-staging/OsLogin/v1/src/V1/resources/os_login_service_rest_client_config.php new file mode 100644 index 000000000000..37ff351a8d33 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/src/V1/resources/os_login_service_rest_client_config.php @@ -0,0 +1,89 @@ + [ + 'google.cloud.oslogin.v1.OsLoginService' => [ + 'CreateSshPublicKey' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=users/*}/sshPublicKeys', + 'body' => 'ssh_public_key', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'DeletePosixAccount' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=users/*/projects/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteSshPublicKey' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=users/*/sshPublicKeys/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetLoginProfile' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=users/*}/loginProfile', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetSshPublicKey' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=users/*/sshPublicKeys/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ImportSshPublicKey' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=users/*}:importSshPublicKey', + 'body' => 'ssh_public_key', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateSshPublicKey' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{name=users/*/sshPublicKeys/*}', + 'body' => 'ssh_public_key', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/owl-bot-staging/OsLogin/v1/tests/Unit/V1/Client/OsLoginServiceClientTest.php b/owl-bot-staging/OsLogin/v1/tests/Unit/V1/Client/OsLoginServiceClientTest.php new file mode 100644 index 000000000000..ec2cc9b6eb64 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/tests/Unit/V1/Client/OsLoginServiceClientTest.php @@ -0,0 +1,582 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return OsLoginServiceClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new OsLoginServiceClient($options); + } + + /** @test */ + public function createSshPublicKeyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $key = 'key106079'; + $expirationTimeUsec = 2058878882; + $fingerprint = 'fingerprint-1375934236'; + $name = 'name3373707'; + $expectedResponse = new SshPublicKey(); + $expectedResponse->setKey($key); + $expectedResponse->setExpirationTimeUsec($expirationTimeUsec); + $expectedResponse->setFingerprint($fingerprint); + $expectedResponse->setName($name); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->userName('[USER]'); + $sshPublicKey = new SshPublicKey(); + $request = (new CreateSshPublicKeyRequest()) + ->setParent($formattedParent) + ->setSshPublicKey($sshPublicKey); + $response = $gapicClient->createSshPublicKey($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/CreateSshPublicKey', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getSshPublicKey(); + $this->assertProtobufEquals($sshPublicKey, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createSshPublicKeyExceptionTest() + { + $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->userName('[USER]'); + $sshPublicKey = new SshPublicKey(); + $request = (new CreateSshPublicKeyRequest()) + ->setParent($formattedParent) + ->setSshPublicKey($sshPublicKey); + try { + $gapicClient->createSshPublicKey($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 deletePosixAccountTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->posixAccountName('[USER]', '[PROJECT]'); + $request = (new DeletePosixAccountRequest()) + ->setName($formattedName); + $gapicClient->deletePosixAccount($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/DeletePosixAccount', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deletePosixAccountExceptionTest() + { + $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->posixAccountName('[USER]', '[PROJECT]'); + $request = (new DeletePosixAccountRequest()) + ->setName($formattedName); + try { + $gapicClient->deletePosixAccount($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 deleteSshPublicKeyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + $request = (new DeleteSshPublicKeyRequest()) + ->setName($formattedName); + $gapicClient->deleteSshPublicKey($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/DeleteSshPublicKey', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteSshPublicKeyExceptionTest() + { + $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + $request = (new DeleteSshPublicKeyRequest()) + ->setName($formattedName); + try { + $gapicClient->deleteSshPublicKey($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 getLoginProfileTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $expectedResponse = new LoginProfile(); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->userName('[USER]'); + $request = (new GetLoginProfileRequest()) + ->setName($formattedName); + $response = $gapicClient->getLoginProfile($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/GetLoginProfile', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getLoginProfileExceptionTest() + { + $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->userName('[USER]'); + $request = (new GetLoginProfileRequest()) + ->setName($formattedName); + try { + $gapicClient->getLoginProfile($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 getSshPublicKeyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $key = 'key106079'; + $expirationTimeUsec = 2058878882; + $fingerprint = 'fingerprint-1375934236'; + $name2 = 'name2-1052831874'; + $expectedResponse = new SshPublicKey(); + $expectedResponse->setKey($key); + $expectedResponse->setExpirationTimeUsec($expirationTimeUsec); + $expectedResponse->setFingerprint($fingerprint); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + $request = (new GetSshPublicKeyRequest()) + ->setName($formattedName); + $response = $gapicClient->getSshPublicKey($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/GetSshPublicKey', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getSshPublicKeyExceptionTest() + { + $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + $request = (new GetSshPublicKeyRequest()) + ->setName($formattedName); + try { + $gapicClient->getSshPublicKey($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 importSshPublicKeyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $details = 'details1557721666'; + $expectedResponse = new ImportSshPublicKeyResponse(); + $expectedResponse->setDetails($details); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->userName('[USER]'); + $request = (new ImportSshPublicKeyRequest()) + ->setParent($formattedParent); + $response = $gapicClient->importSshPublicKey($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/ImportSshPublicKey', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function importSshPublicKeyExceptionTest() + { + $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->userName('[USER]'); + $request = (new ImportSshPublicKeyRequest()) + ->setParent($formattedParent); + try { + $gapicClient->importSshPublicKey($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 updateSshPublicKeyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $key = 'key106079'; + $expirationTimeUsec = 2058878882; + $fingerprint = 'fingerprint-1375934236'; + $name2 = 'name2-1052831874'; + $expectedResponse = new SshPublicKey(); + $expectedResponse->setKey($key); + $expectedResponse->setExpirationTimeUsec($expirationTimeUsec); + $expectedResponse->setFingerprint($fingerprint); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + $sshPublicKey = new SshPublicKey(); + $request = (new UpdateSshPublicKeyRequest()) + ->setName($formattedName) + ->setSshPublicKey($sshPublicKey); + $response = $gapicClient->updateSshPublicKey($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/UpdateSshPublicKey', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $actualValue = $actualRequestObject->getSshPublicKey(); + $this->assertProtobufEquals($sshPublicKey, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateSshPublicKeyExceptionTest() + { + $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + $sshPublicKey = new SshPublicKey(); + $request = (new UpdateSshPublicKeyRequest()) + ->setName($formattedName) + ->setSshPublicKey($sshPublicKey); + try { + $gapicClient->updateSshPublicKey($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 createSshPublicKeyAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $key = 'key106079'; + $expirationTimeUsec = 2058878882; + $fingerprint = 'fingerprint-1375934236'; + $name = 'name3373707'; + $expectedResponse = new SshPublicKey(); + $expectedResponse->setKey($key); + $expectedResponse->setExpirationTimeUsec($expirationTimeUsec); + $expectedResponse->setFingerprint($fingerprint); + $expectedResponse->setName($name); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->userName('[USER]'); + $sshPublicKey = new SshPublicKey(); + $request = (new CreateSshPublicKeyRequest()) + ->setParent($formattedParent) + ->setSshPublicKey($sshPublicKey); + $response = $gapicClient->createSshPublicKeyAsync($request)->wait(); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/CreateSshPublicKey', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getSshPublicKey(); + $this->assertProtobufEquals($sshPublicKey, $actualValue); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/owl-bot-staging/OsLogin/v1/tests/Unit/V1/OsLoginServiceClientTest.php b/owl-bot-staging/OsLogin/v1/tests/Unit/V1/OsLoginServiceClientTest.php new file mode 100644 index 000000000000..2797a5cdef17 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1/tests/Unit/V1/OsLoginServiceClientTest.php @@ -0,0 +1,504 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return OsLoginServiceClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new OsLoginServiceClient($options); + } + + /** @test */ + public function createSshPublicKeyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $key = 'key106079'; + $expirationTimeUsec = 2058878882; + $fingerprint = 'fingerprint-1375934236'; + $name = 'name3373707'; + $expectedResponse = new SshPublicKey(); + $expectedResponse->setKey($key); + $expectedResponse->setExpirationTimeUsec($expirationTimeUsec); + $expectedResponse->setFingerprint($fingerprint); + $expectedResponse->setName($name); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->userName('[USER]'); + $sshPublicKey = new SshPublicKey(); + $response = $gapicClient->createSshPublicKey($formattedParent, $sshPublicKey); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/CreateSshPublicKey', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getSshPublicKey(); + $this->assertProtobufEquals($sshPublicKey, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createSshPublicKeyExceptionTest() + { + $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->userName('[USER]'); + $sshPublicKey = new SshPublicKey(); + try { + $gapicClient->createSshPublicKey($formattedParent, $sshPublicKey); + // 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 deletePosixAccountTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->posixAccountName('[USER]', '[PROJECT]'); + $gapicClient->deletePosixAccount($formattedName); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/DeletePosixAccount', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deletePosixAccountExceptionTest() + { + $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->posixAccountName('[USER]', '[PROJECT]'); + try { + $gapicClient->deletePosixAccount($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 deleteSshPublicKeyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + $gapicClient->deleteSshPublicKey($formattedName); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/DeleteSshPublicKey', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteSshPublicKeyExceptionTest() + { + $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + try { + $gapicClient->deleteSshPublicKey($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 getLoginProfileTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $expectedResponse = new LoginProfile(); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->userName('[USER]'); + $response = $gapicClient->getLoginProfile($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/GetLoginProfile', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getLoginProfileExceptionTest() + { + $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->userName('[USER]'); + try { + $gapicClient->getLoginProfile($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 getSshPublicKeyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $key = 'key106079'; + $expirationTimeUsec = 2058878882; + $fingerprint = 'fingerprint-1375934236'; + $name2 = 'name2-1052831874'; + $expectedResponse = new SshPublicKey(); + $expectedResponse->setKey($key); + $expectedResponse->setExpirationTimeUsec($expirationTimeUsec); + $expectedResponse->setFingerprint($fingerprint); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + $response = $gapicClient->getSshPublicKey($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/GetSshPublicKey', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getSshPublicKeyExceptionTest() + { + $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + try { + $gapicClient->getSshPublicKey($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 importSshPublicKeyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $details = 'details1557721666'; + $expectedResponse = new ImportSshPublicKeyResponse(); + $expectedResponse->setDetails($details); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->userName('[USER]'); + $response = $gapicClient->importSshPublicKey($formattedParent); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/ImportSshPublicKey', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function importSshPublicKeyExceptionTest() + { + $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->userName('[USER]'); + try { + $gapicClient->importSshPublicKey($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 updateSshPublicKeyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $key = 'key106079'; + $expirationTimeUsec = 2058878882; + $fingerprint = 'fingerprint-1375934236'; + $name2 = 'name2-1052831874'; + $expectedResponse = new SshPublicKey(); + $expectedResponse->setKey($key); + $expectedResponse->setExpirationTimeUsec($expirationTimeUsec); + $expectedResponse->setFingerprint($fingerprint); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + $sshPublicKey = new SshPublicKey(); + $response = $gapicClient->updateSshPublicKey($formattedName, $sshPublicKey); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/UpdateSshPublicKey', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $actualValue = $actualRequestObject->getSshPublicKey(); + $this->assertProtobufEquals($sshPublicKey, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateSshPublicKeyExceptionTest() + { + $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + $sshPublicKey = new SshPublicKey(); + try { + $gapicClient->updateSshPublicKey($formattedName, $sshPublicKey); + // 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()); + } +} diff --git a/owl-bot-staging/OsLogin/v1beta/proto/src/GPBMetadata/Google/Cloud/Oslogin/Common/Common.php b/owl-bot-staging/OsLogin/v1beta/proto/src/GPBMetadata/Google/Cloud/Oslogin/Common/Common.php new file mode 100644 index 000000000000..58e5d425988e Binary files /dev/null and b/owl-bot-staging/OsLogin/v1beta/proto/src/GPBMetadata/Google/Cloud/Oslogin/Common/Common.php differ diff --git a/owl-bot-staging/OsLogin/v1beta/proto/src/GPBMetadata/Google/Cloud/Oslogin/V1Beta/Oslogin.php b/owl-bot-staging/OsLogin/v1beta/proto/src/GPBMetadata/Google/Cloud/Oslogin/V1Beta/Oslogin.php new file mode 100644 index 000000000000..a1350a1528f6 Binary files /dev/null and b/owl-bot-staging/OsLogin/v1beta/proto/src/GPBMetadata/Google/Cloud/Oslogin/V1Beta/Oslogin.php differ diff --git a/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/Common/OperatingSystemType.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/Common/OperatingSystemType.php new file mode 100644 index 000000000000..dea57253ea7e --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/Common/OperatingSystemType.php @@ -0,0 +1,62 @@ +google.cloud.oslogin.common.OperatingSystemType + */ +class OperatingSystemType +{ + /** + * The operating system type associated with the user account information is + * unspecified. + * + * Generated from protobuf enum OPERATING_SYSTEM_TYPE_UNSPECIFIED = 0; + */ + const OPERATING_SYSTEM_TYPE_UNSPECIFIED = 0; + /** + * Linux user account information. + * + * Generated from protobuf enum LINUX = 1; + */ + const LINUX = 1; + /** + * Windows user account information. + * + * Generated from protobuf enum WINDOWS = 2; + */ + const WINDOWS = 2; + + private static $valueToName = [ + self::OPERATING_SYSTEM_TYPE_UNSPECIFIED => 'OPERATING_SYSTEM_TYPE_UNSPECIFIED', + self::LINUX => 'LINUX', + self::WINDOWS => 'WINDOWS', + ]; + + 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/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/Common/PosixAccount.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/Common/PosixAccount.php new file mode 100644 index 000000000000..99d5713285c0 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/Common/PosixAccount.php @@ -0,0 +1,411 @@ +google.cloud.oslogin.common.PosixAccount + */ +class PosixAccount extends \Google\Protobuf\Internal\Message +{ + /** + * Only one POSIX account can be marked as primary. + * + * Generated from protobuf field bool primary = 1; + */ + protected $primary = false; + /** + * The username of the POSIX account. + * + * Generated from protobuf field string username = 2; + */ + protected $username = ''; + /** + * The user ID. + * + * Generated from protobuf field int64 uid = 3; + */ + protected $uid = 0; + /** + * The default group ID. + * + * Generated from protobuf field int64 gid = 4; + */ + protected $gid = 0; + /** + * The path to the home directory for this account. + * + * Generated from protobuf field string home_directory = 5; + */ + protected $home_directory = ''; + /** + * The path to the logic shell for this account. + * + * Generated from protobuf field string shell = 6; + */ + protected $shell = ''; + /** + * The GECOS (user information) entry for this account. + * + * Generated from protobuf field string gecos = 7; + */ + protected $gecos = ''; + /** + * System identifier for which account the username or uid applies to. + * By default, the empty value is used. + * + * Generated from protobuf field string system_id = 8; + */ + protected $system_id = ''; + /** + * Output only. A POSIX account identifier. + * + * Generated from protobuf field string account_id = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $account_id = ''; + /** + * The operating system type where this account applies. + * + * Generated from protobuf field .google.cloud.oslogin.common.OperatingSystemType operating_system_type = 10; + */ + protected $operating_system_type = 0; + /** + * Output only. The canonical resource name. + * + * Generated from protobuf field string name = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type bool $primary + * Only one POSIX account can be marked as primary. + * @type string $username + * The username of the POSIX account. + * @type int|string $uid + * The user ID. + * @type int|string $gid + * The default group ID. + * @type string $home_directory + * The path to the home directory for this account. + * @type string $shell + * The path to the logic shell for this account. + * @type string $gecos + * The GECOS (user information) entry for this account. + * @type string $system_id + * System identifier for which account the username or uid applies to. + * By default, the empty value is used. + * @type string $account_id + * Output only. A POSIX account identifier. + * @type int $operating_system_type + * The operating system type where this account applies. + * @type string $name + * Output only. The canonical resource name. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\Common\Common::initOnce(); + parent::__construct($data); + } + + /** + * Only one POSIX account can be marked as primary. + * + * Generated from protobuf field bool primary = 1; + * @return bool + */ + public function getPrimary() + { + return $this->primary; + } + + /** + * Only one POSIX account can be marked as primary. + * + * Generated from protobuf field bool primary = 1; + * @param bool $var + * @return $this + */ + public function setPrimary($var) + { + GPBUtil::checkBool($var); + $this->primary = $var; + + return $this; + } + + /** + * The username of the POSIX account. + * + * Generated from protobuf field string username = 2; + * @return string + */ + public function getUsername() + { + return $this->username; + } + + /** + * The username of the POSIX account. + * + * Generated from protobuf field string username = 2; + * @param string $var + * @return $this + */ + public function setUsername($var) + { + GPBUtil::checkString($var, True); + $this->username = $var; + + return $this; + } + + /** + * The user ID. + * + * Generated from protobuf field int64 uid = 3; + * @return int|string + */ + public function getUid() + { + return $this->uid; + } + + /** + * The user ID. + * + * Generated from protobuf field int64 uid = 3; + * @param int|string $var + * @return $this + */ + public function setUid($var) + { + GPBUtil::checkInt64($var); + $this->uid = $var; + + return $this; + } + + /** + * The default group ID. + * + * Generated from protobuf field int64 gid = 4; + * @return int|string + */ + public function getGid() + { + return $this->gid; + } + + /** + * The default group ID. + * + * Generated from protobuf field int64 gid = 4; + * @param int|string $var + * @return $this + */ + public function setGid($var) + { + GPBUtil::checkInt64($var); + $this->gid = $var; + + return $this; + } + + /** + * The path to the home directory for this account. + * + * Generated from protobuf field string home_directory = 5; + * @return string + */ + public function getHomeDirectory() + { + return $this->home_directory; + } + + /** + * The path to the home directory for this account. + * + * Generated from protobuf field string home_directory = 5; + * @param string $var + * @return $this + */ + public function setHomeDirectory($var) + { + GPBUtil::checkString($var, True); + $this->home_directory = $var; + + return $this; + } + + /** + * The path to the logic shell for this account. + * + * Generated from protobuf field string shell = 6; + * @return string + */ + public function getShell() + { + return $this->shell; + } + + /** + * The path to the logic shell for this account. + * + * Generated from protobuf field string shell = 6; + * @param string $var + * @return $this + */ + public function setShell($var) + { + GPBUtil::checkString($var, True); + $this->shell = $var; + + return $this; + } + + /** + * The GECOS (user information) entry for this account. + * + * Generated from protobuf field string gecos = 7; + * @return string + */ + public function getGecos() + { + return $this->gecos; + } + + /** + * The GECOS (user information) entry for this account. + * + * Generated from protobuf field string gecos = 7; + * @param string $var + * @return $this + */ + public function setGecos($var) + { + GPBUtil::checkString($var, True); + $this->gecos = $var; + + return $this; + } + + /** + * System identifier for which account the username or uid applies to. + * By default, the empty value is used. + * + * Generated from protobuf field string system_id = 8; + * @return string + */ + public function getSystemId() + { + return $this->system_id; + } + + /** + * System identifier for which account the username or uid applies to. + * By default, the empty value is used. + * + * Generated from protobuf field string system_id = 8; + * @param string $var + * @return $this + */ + public function setSystemId($var) + { + GPBUtil::checkString($var, True); + $this->system_id = $var; + + return $this; + } + + /** + * Output only. A POSIX account identifier. + * + * Generated from protobuf field string account_id = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getAccountId() + { + return $this->account_id; + } + + /** + * Output only. A POSIX account identifier. + * + * Generated from protobuf field string account_id = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setAccountId($var) + { + GPBUtil::checkString($var, True); + $this->account_id = $var; + + return $this; + } + + /** + * The operating system type where this account applies. + * + * Generated from protobuf field .google.cloud.oslogin.common.OperatingSystemType operating_system_type = 10; + * @return int + */ + public function getOperatingSystemType() + { + return $this->operating_system_type; + } + + /** + * The operating system type where this account applies. + * + * Generated from protobuf field .google.cloud.oslogin.common.OperatingSystemType operating_system_type = 10; + * @param int $var + * @return $this + */ + public function setOperatingSystemType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\OsLogin\Common\OperatingSystemType::class); + $this->operating_system_type = $var; + + return $this; + } + + /** + * Output only. The canonical resource name. + * + * Generated from protobuf field string name = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Output only. The canonical resource name. + * + * Generated from protobuf field string name = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/Common/SshPublicKey.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/Common/SshPublicKey.php new file mode 100644 index 000000000000..185588081e3e --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/Common/SshPublicKey.php @@ -0,0 +1,177 @@ +google.cloud.oslogin.common.SshPublicKey + */ +class SshPublicKey extends \Google\Protobuf\Internal\Message +{ + /** + * Public key text in SSH format, defined by + * RFC4253 + * section 6.6. + * + * Generated from protobuf field string key = 1; + */ + protected $key = ''; + /** + * An expiration time in microseconds since epoch. + * + * Generated from protobuf field int64 expiration_time_usec = 2; + */ + protected $expiration_time_usec = 0; + /** + * Output only. The SHA-256 fingerprint of the SSH public key. + * + * Generated from protobuf field string fingerprint = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $fingerprint = ''; + /** + * Output only. The canonical resource name. + * + * Generated from protobuf field string name = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $key + * Public key text in SSH format, defined by + * RFC4253 + * section 6.6. + * @type int|string $expiration_time_usec + * An expiration time in microseconds since epoch. + * @type string $fingerprint + * Output only. The SHA-256 fingerprint of the SSH public key. + * @type string $name + * Output only. The canonical resource name. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\Common\Common::initOnce(); + parent::__construct($data); + } + + /** + * Public key text in SSH format, defined by + * RFC4253 + * section 6.6. + * + * Generated from protobuf field string key = 1; + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * Public key text in SSH format, defined by + * RFC4253 + * section 6.6. + * + * Generated from protobuf field string key = 1; + * @param string $var + * @return $this + */ + public function setKey($var) + { + GPBUtil::checkString($var, True); + $this->key = $var; + + return $this; + } + + /** + * An expiration time in microseconds since epoch. + * + * Generated from protobuf field int64 expiration_time_usec = 2; + * @return int|string + */ + public function getExpirationTimeUsec() + { + return $this->expiration_time_usec; + } + + /** + * An expiration time in microseconds since epoch. + * + * Generated from protobuf field int64 expiration_time_usec = 2; + * @param int|string $var + * @return $this + */ + public function setExpirationTimeUsec($var) + { + GPBUtil::checkInt64($var); + $this->expiration_time_usec = $var; + + return $this; + } + + /** + * Output only. The SHA-256 fingerprint of the SSH public key. + * + * Generated from protobuf field string fingerprint = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getFingerprint() + { + return $this->fingerprint; + } + + /** + * Output only. The SHA-256 fingerprint of the SSH public key. + * + * Generated from protobuf field string fingerprint = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setFingerprint($var) + { + GPBUtil::checkString($var, True); + $this->fingerprint = $var; + + return $this; + } + + /** + * Output only. The canonical resource name. + * + * Generated from protobuf field string name = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Output only. The canonical resource name. + * + * Generated from protobuf field string name = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/CreateSshPublicKeyRequest.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/CreateSshPublicKeyRequest.php new file mode 100644 index 000000000000..fe4dc074a4d7 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/CreateSshPublicKeyRequest.php @@ -0,0 +1,111 @@ +google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest + */ +class CreateSshPublicKeyRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The unique ID for the user in format `users/{user}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. The SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $ssh_public_key = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The unique ID for the user in format `users/{user}`. + * @type \Google\Cloud\OsLogin\Common\SshPublicKey $ssh_public_key + * Required. The SSH public key and expiration time. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The unique ID for the user in format `users/{user}`. + * + * 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 unique ID for the user in format `users/{user}`. + * + * 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 SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\OsLogin\Common\SshPublicKey|null + */ + public function getSshPublicKey() + { + return $this->ssh_public_key; + } + + public function hasSshPublicKey() + { + return isset($this->ssh_public_key); + } + + public function clearSshPublicKey() + { + unset($this->ssh_public_key); + } + + /** + * Required. The SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\OsLogin\Common\SshPublicKey $var + * @return $this + */ + public function setSshPublicKey($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\Common\SshPublicKey::class); + $this->ssh_public_key = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/DeletePosixAccountRequest.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/DeletePosixAccountRequest.php new file mode 100644 index 000000000000..a58e6210d0b9 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/DeletePosixAccountRequest.php @@ -0,0 +1,75 @@ +google.cloud.oslogin.v1beta.DeletePosixAccountRequest + */ +class DeletePosixAccountRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. A reference to the POSIX account to update. POSIX accounts are + * identified by the project ID they are associated with. A reference to the + * POSIX account is in format `users/{user}/projects/{project}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. A reference to the POSIX account to update. POSIX accounts are + * identified by the project ID they are associated with. A reference to the + * POSIX account is in format `users/{user}/projects/{project}`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Required. A reference to the POSIX account to update. POSIX accounts are + * identified by the project ID they are associated with. A reference to the + * POSIX account is in format `users/{user}/projects/{project}`. + * + * 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. A reference to the POSIX account to update. POSIX accounts are + * identified by the project ID they are associated with. A reference to the + * POSIX account is in format `users/{user}/projects/{project}`. + * + * 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/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/DeleteSshPublicKeyRequest.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/DeleteSshPublicKeyRequest.php new file mode 100644 index 000000000000..f394ba2c3243 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/DeleteSshPublicKeyRequest.php @@ -0,0 +1,75 @@ +google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest + */ +class DeleteSshPublicKeyRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * 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 fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * 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/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/GetLoginProfileRequest.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/GetLoginProfileRequest.php new file mode 100644 index 000000000000..8d4ea63b3bde --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/GetLoginProfileRequest.php @@ -0,0 +1,169 @@ +google.cloud.oslogin.v1beta.GetLoginProfileRequest + */ +class GetLoginProfileRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The unique ID for the user in format `users/{user}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + /** + * The project ID of the Google Cloud Platform project. + * + * Generated from protobuf field string project_id = 2; + */ + protected $project_id = ''; + /** + * A system ID for filtering the results of the request. + * + * Generated from protobuf field string system_id = 3; + */ + protected $system_id = ''; + /** + * The view configures whether to retrieve security keys information. + * + * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfileView view = 4; + */ + protected $view = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The unique ID for the user in format `users/{user}`. + * @type string $project_id + * The project ID of the Google Cloud Platform project. + * @type string $system_id + * A system ID for filtering the results of the request. + * @type int $view + * The view configures whether to retrieve security keys information. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The unique ID for the user in format `users/{user}`. + * + * 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 unique ID for the user in format `users/{user}`. + * + * 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; + } + + /** + * The project ID of the Google Cloud Platform project. + * + * Generated from protobuf field string project_id = 2; + * @return string + */ + public function getProjectId() + { + return $this->project_id; + } + + /** + * The project ID of the Google Cloud Platform project. + * + * Generated from protobuf field string project_id = 2; + * @param string $var + * @return $this + */ + public function setProjectId($var) + { + GPBUtil::checkString($var, True); + $this->project_id = $var; + + return $this; + } + + /** + * A system ID for filtering the results of the request. + * + * Generated from protobuf field string system_id = 3; + * @return string + */ + public function getSystemId() + { + return $this->system_id; + } + + /** + * A system ID for filtering the results of the request. + * + * Generated from protobuf field string system_id = 3; + * @param string $var + * @return $this + */ + public function setSystemId($var) + { + GPBUtil::checkString($var, True); + $this->system_id = $var; + + return $this; + } + + /** + * The view configures whether to retrieve security keys information. + * + * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfileView view = 4; + * @return int + */ + public function getView() + { + return $this->view; + } + + /** + * The view configures whether to retrieve security keys information. + * + * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfileView view = 4; + * @param int $var + * @return $this + */ + public function setView($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\OsLogin\V1beta\LoginProfileView::class); + $this->view = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/GetSshPublicKeyRequest.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/GetSshPublicKeyRequest.php new file mode 100644 index 000000000000..86ed57dc1f6b --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/GetSshPublicKeyRequest.php @@ -0,0 +1,75 @@ +google.cloud.oslogin.v1beta.GetSshPublicKeyRequest + */ +class GetSshPublicKeyRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The fingerprint of the public key to retrieve. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The fingerprint of the public key to retrieve. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The fingerprint of the public key to retrieve. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * 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 fingerprint of the public key to retrieve. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * 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/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/ImportSshPublicKeyRequest.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/ImportSshPublicKeyRequest.php new file mode 100644 index 000000000000..a13c4cc8d05d --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/ImportSshPublicKeyRequest.php @@ -0,0 +1,221 @@ +google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest + */ +class ImportSshPublicKeyRequest extends \Google\Protobuf\Internal\Message +{ + /** + * The unique ID for the user in format `users/{user}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. The SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $ssh_public_key = null; + /** + * The project ID of the Google Cloud Platform project. + * + * Generated from protobuf field string project_id = 3; + */ + protected $project_id = ''; + /** + * The view configures whether to retrieve security keys information. + * + * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfileView view = 4; + */ + protected $view = 0; + /** + * Optional. The regions to which to assert that the key was written. + * If unspecified, defaults to all regions. + * Regions are listed at https://cloud.google.com/about/locations#region. + * + * Generated from protobuf field repeated string regions = 5 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $regions; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * The unique ID for the user in format `users/{user}`. + * @type \Google\Cloud\OsLogin\Common\SshPublicKey $ssh_public_key + * Required. The SSH public key and expiration time. + * @type string $project_id + * The project ID of the Google Cloud Platform project. + * @type int $view + * The view configures whether to retrieve security keys information. + * @type array|\Google\Protobuf\Internal\RepeatedField $regions + * Optional. The regions to which to assert that the key was written. + * If unspecified, defaults to all regions. + * Regions are listed at https://cloud.google.com/about/locations#region. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * The unique ID for the user in format `users/{user}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * The unique ID for the user in format `users/{user}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Required. The SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\OsLogin\Common\SshPublicKey|null + */ + public function getSshPublicKey() + { + return $this->ssh_public_key; + } + + public function hasSshPublicKey() + { + return isset($this->ssh_public_key); + } + + public function clearSshPublicKey() + { + unset($this->ssh_public_key); + } + + /** + * Required. The SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\OsLogin\Common\SshPublicKey $var + * @return $this + */ + public function setSshPublicKey($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\Common\SshPublicKey::class); + $this->ssh_public_key = $var; + + return $this; + } + + /** + * The project ID of the Google Cloud Platform project. + * + * Generated from protobuf field string project_id = 3; + * @return string + */ + public function getProjectId() + { + return $this->project_id; + } + + /** + * The project ID of the Google Cloud Platform project. + * + * Generated from protobuf field string project_id = 3; + * @param string $var + * @return $this + */ + public function setProjectId($var) + { + GPBUtil::checkString($var, True); + $this->project_id = $var; + + return $this; + } + + /** + * The view configures whether to retrieve security keys information. + * + * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfileView view = 4; + * @return int + */ + public function getView() + { + return $this->view; + } + + /** + * The view configures whether to retrieve security keys information. + * + * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfileView view = 4; + * @param int $var + * @return $this + */ + public function setView($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\OsLogin\V1beta\LoginProfileView::class); + $this->view = $var; + + return $this; + } + + /** + * Optional. The regions to which to assert that the key was written. + * If unspecified, defaults to all regions. + * Regions are listed at https://cloud.google.com/about/locations#region. + * + * Generated from protobuf field repeated string regions = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getRegions() + { + return $this->regions; + } + + /** + * Optional. The regions to which to assert that the key was written. + * If unspecified, defaults to all regions. + * Regions are listed at https://cloud.google.com/about/locations#region. + * + * Generated from protobuf field repeated string regions = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setRegions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->regions = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/ImportSshPublicKeyResponse.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/ImportSshPublicKeyResponse.php new file mode 100644 index 000000000000..026586d27c37 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/ImportSshPublicKeyResponse.php @@ -0,0 +1,111 @@ +google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse + */ +class ImportSshPublicKeyResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The login profile information for the user. + * + * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfile login_profile = 1; + */ + protected $login_profile = null; + /** + * Detailed information about import results. + * + * Generated from protobuf field string details = 2; + */ + protected $details = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\OsLogin\V1beta\LoginProfile $login_profile + * The login profile information for the user. + * @type string $details + * Detailed information about import results. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * The login profile information for the user. + * + * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfile login_profile = 1; + * @return \Google\Cloud\OsLogin\V1beta\LoginProfile|null + */ + public function getLoginProfile() + { + return $this->login_profile; + } + + public function hasLoginProfile() + { + return isset($this->login_profile); + } + + public function clearLoginProfile() + { + unset($this->login_profile); + } + + /** + * The login profile information for the user. + * + * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfile login_profile = 1; + * @param \Google\Cloud\OsLogin\V1beta\LoginProfile $var + * @return $this + */ + public function setLoginProfile($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\V1beta\LoginProfile::class); + $this->login_profile = $var; + + return $this; + } + + /** + * Detailed information about import results. + * + * Generated from protobuf field string details = 2; + * @return string + */ + public function getDetails() + { + return $this->details; + } + + /** + * Detailed information about import results. + * + * Generated from protobuf field string details = 2; + * @param string $var + * @return $this + */ + public function setDetails($var) + { + GPBUtil::checkString($var, True); + $this->details = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/LoginProfile.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/LoginProfile.php new file mode 100644 index 000000000000..81477461ed62 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/LoginProfile.php @@ -0,0 +1,170 @@ +google.cloud.oslogin.v1beta.LoginProfile + */ +class LoginProfile extends \Google\Protobuf\Internal\Message +{ + /** + * Required. A unique user ID. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $name = ''; + /** + * The list of POSIX accounts associated with the user. + * + * Generated from protobuf field repeated .google.cloud.oslogin.common.PosixAccount posix_accounts = 2; + */ + private $posix_accounts; + /** + * A map from SSH public key fingerprint to the associated key object. + * + * Generated from protobuf field map ssh_public_keys = 3; + */ + private $ssh_public_keys; + /** + * The registered security key credentials for a user. + * + * Generated from protobuf field repeated .google.cloud.oslogin.v1beta.SecurityKey security_keys = 5; + */ + private $security_keys; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. A unique user ID. + * @type array<\Google\Cloud\OsLogin\Common\PosixAccount>|\Google\Protobuf\Internal\RepeatedField $posix_accounts + * The list of POSIX accounts associated with the user. + * @type array|\Google\Protobuf\Internal\MapField $ssh_public_keys + * A map from SSH public key fingerprint to the associated key object. + * @type array<\Google\Cloud\OsLogin\V1beta\SecurityKey>|\Google\Protobuf\Internal\RepeatedField $security_keys + * The registered security key credentials for a user. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Required. A unique user ID. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. A unique user ID. + * + * 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; + } + + /** + * The list of POSIX accounts associated with the user. + * + * Generated from protobuf field repeated .google.cloud.oslogin.common.PosixAccount posix_accounts = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPosixAccounts() + { + return $this->posix_accounts; + } + + /** + * The list of POSIX accounts associated with the user. + * + * Generated from protobuf field repeated .google.cloud.oslogin.common.PosixAccount posix_accounts = 2; + * @param array<\Google\Cloud\OsLogin\Common\PosixAccount>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPosixAccounts($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\OsLogin\Common\PosixAccount::class); + $this->posix_accounts = $arr; + + return $this; + } + + /** + * A map from SSH public key fingerprint to the associated key object. + * + * Generated from protobuf field map ssh_public_keys = 3; + * @return \Google\Protobuf\Internal\MapField + */ + public function getSshPublicKeys() + { + return $this->ssh_public_keys; + } + + /** + * A map from SSH public key fingerprint to the associated key object. + * + * Generated from protobuf field map ssh_public_keys = 3; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setSshPublicKeys($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\OsLogin\Common\SshPublicKey::class); + $this->ssh_public_keys = $arr; + + return $this; + } + + /** + * The registered security key credentials for a user. + * + * Generated from protobuf field repeated .google.cloud.oslogin.v1beta.SecurityKey security_keys = 5; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getSecurityKeys() + { + return $this->security_keys; + } + + /** + * The registered security key credentials for a user. + * + * Generated from protobuf field repeated .google.cloud.oslogin.v1beta.SecurityKey security_keys = 5; + * @param array<\Google\Cloud\OsLogin\V1beta\SecurityKey>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setSecurityKeys($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\OsLogin\V1beta\SecurityKey::class); + $this->security_keys = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/LoginProfileView.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/LoginProfileView.php new file mode 100644 index 000000000000..1de251f44127 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/LoginProfileView.php @@ -0,0 +1,61 @@ +google.cloud.oslogin.v1beta.LoginProfileView + */ +class LoginProfileView +{ + /** + * The default login profile view. The API defaults to the BASIC view. + * + * Generated from protobuf enum LOGIN_PROFILE_VIEW_UNSPECIFIED = 0; + */ + const LOGIN_PROFILE_VIEW_UNSPECIFIED = 0; + /** + * Includes POSIX and SSH key information. + * + * Generated from protobuf enum BASIC = 1; + */ + const BASIC = 1; + /** + * Include security key information for the user. + * + * Generated from protobuf enum SECURITY_KEY = 2; + */ + const SECURITY_KEY = 2; + + private static $valueToName = [ + self::LOGIN_PROFILE_VIEW_UNSPECIFIED => 'LOGIN_PROFILE_VIEW_UNSPECIFIED', + self::BASIC => 'BASIC', + self::SECURITY_KEY => 'SECURITY_KEY', + ]; + + 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/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/SecurityKey.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/SecurityKey.php new file mode 100644 index 000000000000..76da73920279 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/SecurityKey.php @@ -0,0 +1,224 @@ +google.cloud.oslogin.v1beta.SecurityKey + */ +class SecurityKey extends \Google\Protobuf\Internal\Message +{ + /** + * Public key text in SSH format, defined by + * [RFC4253]("https://www.ietf.org/rfc/rfc4253.txt") section 6.6. + * + * Generated from protobuf field string public_key = 1; + */ + protected $public_key = ''; + /** + * Hardware-backed private key text in SSH format. + * + * Generated from protobuf field string private_key = 2; + */ + protected $private_key = ''; + /** + * The security key nickname explicitly set by the user. + * + * Generated from protobuf field optional string device_nickname = 5; + */ + protected $device_nickname = null; + protected $protocol_type; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $public_key + * Public key text in SSH format, defined by + * [RFC4253]("https://www.ietf.org/rfc/rfc4253.txt") section 6.6. + * @type string $private_key + * Hardware-backed private key text in SSH format. + * @type \Google\Cloud\OsLogin\V1beta\UniversalTwoFactor $universal_two_factor + * The U2F protocol type. + * @type \Google\Cloud\OsLogin\V1beta\WebAuthn $web_authn + * The Web Authentication protocol type. + * @type string $device_nickname + * The security key nickname explicitly set by the user. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Public key text in SSH format, defined by + * [RFC4253]("https://www.ietf.org/rfc/rfc4253.txt") section 6.6. + * + * Generated from protobuf field string public_key = 1; + * @return string + */ + public function getPublicKey() + { + return $this->public_key; + } + + /** + * Public key text in SSH format, defined by + * [RFC4253]("https://www.ietf.org/rfc/rfc4253.txt") section 6.6. + * + * Generated from protobuf field string public_key = 1; + * @param string $var + * @return $this + */ + public function setPublicKey($var) + { + GPBUtil::checkString($var, True); + $this->public_key = $var; + + return $this; + } + + /** + * Hardware-backed private key text in SSH format. + * + * Generated from protobuf field string private_key = 2; + * @return string + */ + public function getPrivateKey() + { + return $this->private_key; + } + + /** + * Hardware-backed private key text in SSH format. + * + * Generated from protobuf field string private_key = 2; + * @param string $var + * @return $this + */ + public function setPrivateKey($var) + { + GPBUtil::checkString($var, True); + $this->private_key = $var; + + return $this; + } + + /** + * The U2F protocol type. + * + * Generated from protobuf field .google.cloud.oslogin.v1beta.UniversalTwoFactor universal_two_factor = 3; + * @return \Google\Cloud\OsLogin\V1beta\UniversalTwoFactor|null + */ + public function getUniversalTwoFactor() + { + return $this->readOneof(3); + } + + public function hasUniversalTwoFactor() + { + return $this->hasOneof(3); + } + + /** + * The U2F protocol type. + * + * Generated from protobuf field .google.cloud.oslogin.v1beta.UniversalTwoFactor universal_two_factor = 3; + * @param \Google\Cloud\OsLogin\V1beta\UniversalTwoFactor $var + * @return $this + */ + public function setUniversalTwoFactor($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\V1beta\UniversalTwoFactor::class); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * The Web Authentication protocol type. + * + * Generated from protobuf field .google.cloud.oslogin.v1beta.WebAuthn web_authn = 4; + * @return \Google\Cloud\OsLogin\V1beta\WebAuthn|null + */ + public function getWebAuthn() + { + return $this->readOneof(4); + } + + public function hasWebAuthn() + { + return $this->hasOneof(4); + } + + /** + * The Web Authentication protocol type. + * + * Generated from protobuf field .google.cloud.oslogin.v1beta.WebAuthn web_authn = 4; + * @param \Google\Cloud\OsLogin\V1beta\WebAuthn $var + * @return $this + */ + public function setWebAuthn($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\V1beta\WebAuthn::class); + $this->writeOneof(4, $var); + + return $this; + } + + /** + * The security key nickname explicitly set by the user. + * + * Generated from protobuf field optional string device_nickname = 5; + * @return string + */ + public function getDeviceNickname() + { + return isset($this->device_nickname) ? $this->device_nickname : ''; + } + + public function hasDeviceNickname() + { + return isset($this->device_nickname); + } + + public function clearDeviceNickname() + { + unset($this->device_nickname); + } + + /** + * The security key nickname explicitly set by the user. + * + * Generated from protobuf field optional string device_nickname = 5; + * @param string $var + * @return $this + */ + public function setDeviceNickname($var) + { + GPBUtil::checkString($var, True); + $this->device_nickname = $var; + + return $this; + } + + /** + * @return string + */ + public function getProtocolType() + { + return $this->whichOneof("protocol_type"); + } + +} + diff --git a/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/SignSshPublicKeyRequest.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/SignSshPublicKeyRequest.php new file mode 100644 index 000000000000..314b5694869f --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/SignSshPublicKeyRequest.php @@ -0,0 +1,111 @@ +google.cloud.oslogin.v1beta.SignSshPublicKeyRequest + */ +class SignSshPublicKeyRequest extends \Google\Protobuf\Internal\Message +{ + /** + * The SSH public key to sign. + * + * Generated from protobuf field string ssh_public_key = 1; + */ + protected $ssh_public_key = ''; + /** + * The parent project and zone for the signing request. This is needed to + * properly ensure per-organization ISS processing and potentially to provide + * for the possibility of zone-specific certificates used in the signing + * process. + * + * Generated from protobuf field string parent = 2; + */ + protected $parent = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $ssh_public_key + * The SSH public key to sign. + * @type string $parent + * The parent project and zone for the signing request. This is needed to + * properly ensure per-organization ISS processing and potentially to provide + * for the possibility of zone-specific certificates used in the signing + * process. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * The SSH public key to sign. + * + * Generated from protobuf field string ssh_public_key = 1; + * @return string + */ + public function getSshPublicKey() + { + return $this->ssh_public_key; + } + + /** + * The SSH public key to sign. + * + * Generated from protobuf field string ssh_public_key = 1; + * @param string $var + * @return $this + */ + public function setSshPublicKey($var) + { + GPBUtil::checkString($var, True); + $this->ssh_public_key = $var; + + return $this; + } + + /** + * The parent project and zone for the signing request. This is needed to + * properly ensure per-organization ISS processing and potentially to provide + * for the possibility of zone-specific certificates used in the signing + * process. + * + * Generated from protobuf field string parent = 2; + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * The parent project and zone for the signing request. This is needed to + * properly ensure per-organization ISS processing and potentially to provide + * for the possibility of zone-specific certificates used in the signing + * process. + * + * Generated from protobuf field string parent = 2; + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/SignSshPublicKeyResponse.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/SignSshPublicKeyResponse.php new file mode 100644 index 000000000000..9af354a4e9b6 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/SignSshPublicKeyResponse.php @@ -0,0 +1,65 @@ +google.cloud.oslogin.v1beta.SignSshPublicKeyResponse + */ +class SignSshPublicKeyResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The signed SSH public key to use in the SSH handshake. + * + * Generated from protobuf field string signed_ssh_public_key = 1; + */ + protected $signed_ssh_public_key = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $signed_ssh_public_key + * The signed SSH public key to use in the SSH handshake. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * The signed SSH public key to use in the SSH handshake. + * + * Generated from protobuf field string signed_ssh_public_key = 1; + * @return string + */ + public function getSignedSshPublicKey() + { + return $this->signed_ssh_public_key; + } + + /** + * The signed SSH public key to use in the SSH handshake. + * + * Generated from protobuf field string signed_ssh_public_key = 1; + * @param string $var + * @return $this + */ + public function setSignedSshPublicKey($var) + { + GPBUtil::checkString($var, True); + $this->signed_ssh_public_key = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/UniversalTwoFactor.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/UniversalTwoFactor.php new file mode 100644 index 000000000000..2f284a4f22c3 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/UniversalTwoFactor.php @@ -0,0 +1,67 @@ +google.cloud.oslogin.v1beta.UniversalTwoFactor + */ +class UniversalTwoFactor extends \Google\Protobuf\Internal\Message +{ + /** + * Application ID for the U2F protocol. + * + * Generated from protobuf field string app_id = 1; + */ + protected $app_id = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $app_id + * Application ID for the U2F protocol. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Application ID for the U2F protocol. + * + * Generated from protobuf field string app_id = 1; + * @return string + */ + public function getAppId() + { + return $this->app_id; + } + + /** + * Application ID for the U2F protocol. + * + * Generated from protobuf field string app_id = 1; + * @param string $var + * @return $this + */ + public function setAppId($var) + { + GPBUtil::checkString($var, True); + $this->app_id = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/UpdateSshPublicKeyRequest.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/UpdateSshPublicKeyRequest.php new file mode 100644 index 000000000000..736994072543 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/UpdateSshPublicKeyRequest.php @@ -0,0 +1,163 @@ +google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest + */ +class UpdateSshPublicKeyRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + /** + * Required. The SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $ssh_public_key = null; + /** + * Mask to control which fields get updated. Updates all if not present. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3; + */ + protected $update_mask = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * @type \Google\Cloud\OsLogin\Common\SshPublicKey $ssh_public_key + * Required. The SSH public key and expiration time. + * @type \Google\Protobuf\FieldMask $update_mask + * Mask to control which fields get updated. Updates all if not present. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * 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 fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * + * 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 SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\OsLogin\Common\SshPublicKey|null + */ + public function getSshPublicKey() + { + return $this->ssh_public_key; + } + + public function hasSshPublicKey() + { + return isset($this->ssh_public_key); + } + + public function clearSshPublicKey() + { + unset($this->ssh_public_key); + } + + /** + * Required. The SSH public key and expiration time. + * + * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\OsLogin\Common\SshPublicKey $var + * @return $this + */ + public function setSshPublicKey($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\Common\SshPublicKey::class); + $this->ssh_public_key = $var; + + return $this; + } + + /** + * Mask to control which fields get updated. Updates all if not present. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3; + * @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); + } + + /** + * Mask to control which fields get updated. Updates all if not present. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3; + * @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/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/WebAuthn.php b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/WebAuthn.php new file mode 100644 index 000000000000..713e944d0462 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/proto/src/Google/Cloud/OsLogin/V1beta/WebAuthn.php @@ -0,0 +1,67 @@ +google.cloud.oslogin.v1beta.WebAuthn + */ +class WebAuthn extends \Google\Protobuf\Internal\Message +{ + /** + * Relying party ID for Web Authentication. + * + * Generated from protobuf field string rp_id = 1; + */ + protected $rp_id = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $rp_id + * Relying party ID for Web Authentication. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); + parent::__construct($data); + } + + /** + * Relying party ID for Web Authentication. + * + * Generated from protobuf field string rp_id = 1; + * @return string + */ + public function getRpId() + { + return $this->rp_id; + } + + /** + * Relying party ID for Web Authentication. + * + * Generated from protobuf field string rp_id = 1; + * @param string $var + * @return $this + */ + public function setRpId($var) + { + GPBUtil::checkString($var, True); + $this->rp_id = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/create_ssh_public_key.php b/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/create_ssh_public_key.php new file mode 100644 index 000000000000..c29b2675fd93 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/create_ssh_public_key.php @@ -0,0 +1,69 @@ +createSshPublicKey($formattedParent, $sshPublicKey); + 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 = OsLoginServiceClient::userName('[USER]'); + + create_ssh_public_key_sample($formattedParent); +} +// [END oslogin_v1beta_generated_OsLoginService_CreateSshPublicKey_sync] diff --git a/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/delete_posix_account.php b/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/delete_posix_account.php new file mode 100644 index 000000000000..ec0d6028b26f --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/delete_posix_account.php @@ -0,0 +1,66 @@ +deletePosixAccount($formattedName); + 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 = OsLoginServiceClient::posixAccountName('[USER]', '[PROJECT]'); + + delete_posix_account_sample($formattedName); +} +// [END oslogin_v1beta_generated_OsLoginService_DeletePosixAccount_sync] diff --git a/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/delete_ssh_public_key.php b/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/delete_ssh_public_key.php new file mode 100644 index 000000000000..31fee99f2266 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/delete_ssh_public_key.php @@ -0,0 +1,66 @@ +deleteSshPublicKey($formattedName); + 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 = OsLoginServiceClient::sshPublicKeyName('[USER]', '[FINGERPRINT]'); + + delete_ssh_public_key_sample($formattedName); +} +// [END oslogin_v1beta_generated_OsLoginService_DeleteSshPublicKey_sync] diff --git a/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/get_login_profile.php b/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/get_login_profile.php new file mode 100644 index 000000000000..a09d262804dc --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/get_login_profile.php @@ -0,0 +1,67 @@ +getLoginProfile($formattedName); + 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 = OsLoginServiceClient::userName('[USER]'); + + get_login_profile_sample($formattedName); +} +// [END oslogin_v1beta_generated_OsLoginService_GetLoginProfile_sync] diff --git a/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/get_ssh_public_key.php b/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/get_ssh_public_key.php new file mode 100644 index 000000000000..e7ff3181c3e2 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/get_ssh_public_key.php @@ -0,0 +1,68 @@ +getSshPublicKey($formattedName); + 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 = OsLoginServiceClient::sshPublicKeyName('[USER]', '[FINGERPRINT]'); + + get_ssh_public_key_sample($formattedName); +} +// [END oslogin_v1beta_generated_OsLoginService_GetSshPublicKey_sync] diff --git a/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/import_ssh_public_key.php b/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/import_ssh_public_key.php new file mode 100644 index 000000000000..6cb03cee5787 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/import_ssh_public_key.php @@ -0,0 +1,59 @@ +importSshPublicKey($sshPublicKey); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END oslogin_v1beta_generated_OsLoginService_ImportSshPublicKey_sync] diff --git a/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/sign_ssh_public_key.php b/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/sign_ssh_public_key.php new file mode 100644 index 000000000000..2b0ecd11a9ad --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/sign_ssh_public_key.php @@ -0,0 +1,53 @@ +signSshPublicKey(); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END oslogin_v1beta_generated_OsLoginService_SignSshPublicKey_sync] diff --git a/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/update_ssh_public_key.php b/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/update_ssh_public_key.php new file mode 100644 index 000000000000..60ab450329fc --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/samples/V1beta/OsLoginServiceClient/update_ssh_public_key.php @@ -0,0 +1,72 @@ +updateSshPublicKey($formattedName, $sshPublicKey); + 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 = OsLoginServiceClient::sshPublicKeyName('[USER]', '[FINGERPRINT]'); + + update_ssh_public_key_sample($formattedName); +} +// [END oslogin_v1beta_generated_OsLoginService_UpdateSshPublicKey_sync] diff --git a/owl-bot-staging/OsLogin/v1beta/src/V1beta/Gapic/OsLoginServiceGapicClient.php b/owl-bot-staging/OsLogin/v1beta/src/V1beta/Gapic/OsLoginServiceGapicClient.php new file mode 100644 index 000000000000..8eff02fb6463 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/src/V1beta/Gapic/OsLoginServiceGapicClient.php @@ -0,0 +1,747 @@ +userName('[USER]'); + * $sshPublicKey = new SshPublicKey(); + * $response = $osLoginServiceClient->createSshPublicKey($formattedParent, $sshPublicKey); + * } finally { + * $osLoginServiceClient->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. + * + * @experimental + * + * @deprecated This class will be removed in the next major version update. + */ +class OsLoginServiceGapicClient +{ + use GapicClientTrait; + + /** The name of the service. */ + const SERVICE_NAME = 'google.cloud.oslogin.v1beta.OsLoginService'; + + /** + * The default address of the service. + * + * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. + */ + const SERVICE_ADDRESS = 'oslogin.googleapis.com'; + + /** The address template of the service. */ + private const SERVICE_ADDRESS_TEMPLATE = 'oslogin.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/cloud-platform.read-only', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/compute.readonly', + ]; + + private static $posixAccountNameTemplate; + + private static $sshPublicKeyNameTemplate; + + private static $userNameTemplate; + + private static $pathTemplateMap; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/os_login_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/os_login_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/os_login_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/os_login_service_rest_client_config.php', + ], + ], + ]; + } + + private static function getPosixAccountNameTemplate() + { + if (self::$posixAccountNameTemplate == null) { + self::$posixAccountNameTemplate = new PathTemplate('users/{user}/projects/{project}'); + } + + return self::$posixAccountNameTemplate; + } + + private static function getSshPublicKeyNameTemplate() + { + if (self::$sshPublicKeyNameTemplate == null) { + self::$sshPublicKeyNameTemplate = new PathTemplate('users/{user}/sshPublicKeys/{fingerprint}'); + } + + return self::$sshPublicKeyNameTemplate; + } + + private static function getUserNameTemplate() + { + if (self::$userNameTemplate == null) { + self::$userNameTemplate = new PathTemplate('users/{user}'); + } + + return self::$userNameTemplate; + } + + private static function getPathTemplateMap() + { + if (self::$pathTemplateMap == null) { + self::$pathTemplateMap = [ + 'posixAccount' => self::getPosixAccountNameTemplate(), + 'sshPublicKey' => self::getSshPublicKeyNameTemplate(), + 'user' => self::getUserNameTemplate(), + ]; + } + + return self::$pathTemplateMap; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * posix_account resource. + * + * @param string $user + * @param string $project + * + * @return string The formatted posix_account resource. + * + * @experimental + */ + public static function posixAccountName($user, $project) + { + return self::getPosixAccountNameTemplate()->render([ + 'user' => $user, + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * ssh_public_key resource. + * + * @param string $user + * @param string $fingerprint + * + * @return string The formatted ssh_public_key resource. + * + * @experimental + */ + public static function sshPublicKeyName($user, $fingerprint) + { + return self::getSshPublicKeyNameTemplate()->render([ + 'user' => $user, + 'fingerprint' => $fingerprint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a user + * resource. + * + * @param string $user + * + * @return string The formatted user resource. + * + * @experimental + */ + public static function userName($user) + { + return self::getUserNameTemplate()->render([ + 'user' => $user, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - posixAccount: users/{user}/projects/{project} + * - sshPublicKey: users/{user}/sshPublicKeys/{fingerprint} + * - user: users/{user} + * + * 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. + * + * @experimental + */ + 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 'oslogin.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 + * + * @experimental + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** + * Create an SSH public key + * + * Sample code: + * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); + * try { + * $formattedParent = $osLoginServiceClient->userName('[USER]'); + * $sshPublicKey = new SshPublicKey(); + * $response = $osLoginServiceClient->createSshPublicKey($formattedParent, $sshPublicKey); + * } finally { + * $osLoginServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. The unique ID for the user in format `users/{user}`. + * @param SshPublicKey $sshPublicKey Required. The SSH public key and expiration time. + * @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\OsLogin\Common\SshPublicKey + * + * @throws ApiException if the remote call fails + * + * @experimental + */ + public function createSshPublicKey($parent, $sshPublicKey, array $optionalArgs = []) + { + $request = new CreateSshPublicKeyRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setSshPublicKey($sshPublicKey); + $requestParamHeaders['parent'] = $parent; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateSshPublicKey', SshPublicKey::class, $optionalArgs, $request)->wait(); + } + + /** + * Deletes a POSIX account. + * + * Sample code: + * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); + * try { + * $formattedName = $osLoginServiceClient->posixAccountName('[USER]', '[PROJECT]'); + * $osLoginServiceClient->deletePosixAccount($formattedName); + * } finally { + * $osLoginServiceClient->close(); + * } + * ``` + * + * @param string $name Required. A reference to the POSIX account to update. POSIX accounts are + * identified by the project ID they are associated with. A reference to the + * POSIX account is in format `users/{user}/projects/{project}`. + * @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 + * + * @experimental + */ + public function deletePosixAccount($name, array $optionalArgs = []) + { + $request = new DeletePosixAccountRequest(); + $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('DeletePosixAccount', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Deletes an SSH public key. + * + * Sample code: + * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); + * try { + * $formattedName = $osLoginServiceClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + * $osLoginServiceClient->deleteSshPublicKey($formattedName); + * } finally { + * $osLoginServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * @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 + * + * @experimental + */ + public function deleteSshPublicKey($name, array $optionalArgs = []) + { + $request = new DeleteSshPublicKeyRequest(); + $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('DeleteSshPublicKey', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Retrieves the profile information used for logging in to a virtual machine + * on Google Compute Engine. + * + * Sample code: + * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); + * try { + * $formattedName = $osLoginServiceClient->userName('[USER]'); + * $response = $osLoginServiceClient->getLoginProfile($formattedName); + * } finally { + * $osLoginServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The unique ID for the user in format `users/{user}`. + * @param array $optionalArgs { + * Optional. + * + * @type string $projectId + * The project ID of the Google Cloud Platform project. + * @type string $systemId + * A system ID for filtering the results of the request. + * @type int $view + * The view configures whether to retrieve security keys information. + * For allowed values, use constants defined on {@see \Google\Cloud\OsLogin\V1beta\LoginProfileView} + * @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\OsLogin\V1beta\LoginProfile + * + * @throws ApiException if the remote call fails + * + * @experimental + */ + public function getLoginProfile($name, array $optionalArgs = []) + { + $request = new GetLoginProfileRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['projectId'])) { + $request->setProjectId($optionalArgs['projectId']); + } + + if (isset($optionalArgs['systemId'])) { + $request->setSystemId($optionalArgs['systemId']); + } + + if (isset($optionalArgs['view'])) { + $request->setView($optionalArgs['view']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetLoginProfile', LoginProfile::class, $optionalArgs, $request)->wait(); + } + + /** + * Retrieves an SSH public key. + * + * Sample code: + * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); + * try { + * $formattedName = $osLoginServiceClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + * $response = $osLoginServiceClient->getSshPublicKey($formattedName); + * } finally { + * $osLoginServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The fingerprint of the public key to retrieve. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * @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\OsLogin\Common\SshPublicKey + * + * @throws ApiException if the remote call fails + * + * @experimental + */ + public function getSshPublicKey($name, array $optionalArgs = []) + { + $request = new GetSshPublicKeyRequest(); + $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('GetSshPublicKey', SshPublicKey::class, $optionalArgs, $request)->wait(); + } + + /** + * Adds an SSH public key and returns the profile information. Default POSIX + * account information is set when no username and UID exist as part of the + * login profile. + * + * Sample code: + * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); + * try { + * $sshPublicKey = new SshPublicKey(); + * $response = $osLoginServiceClient->importSshPublicKey($sshPublicKey); + * } finally { + * $osLoginServiceClient->close(); + * } + * ``` + * + * @param SshPublicKey $sshPublicKey Required. The SSH public key and expiration time. + * @param array $optionalArgs { + * Optional. + * + * @type string $parent + * The unique ID for the user in format `users/{user}`. + * @type string $projectId + * The project ID of the Google Cloud Platform project. + * @type int $view + * The view configures whether to retrieve security keys information. + * For allowed values, use constants defined on {@see \Google\Cloud\OsLogin\V1beta\LoginProfileView} + * @type string[] $regions + * Optional. The regions to which to assert that the key was written. + * If unspecified, defaults to all regions. + * Regions are listed at https://cloud.google.com/about/locations#region. + * @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\OsLogin\V1beta\ImportSshPublicKeyResponse + * + * @throws ApiException if the remote call fails + * + * @experimental + */ + public function importSshPublicKey($sshPublicKey, array $optionalArgs = []) + { + $request = new ImportSshPublicKeyRequest(); + $requestParamHeaders = []; + $request->setSshPublicKey($sshPublicKey); + if (isset($optionalArgs['parent'])) { + $request->setParent($optionalArgs['parent']); + $requestParamHeaders['parent'] = $optionalArgs['parent']; + } + + if (isset($optionalArgs['projectId'])) { + $request->setProjectId($optionalArgs['projectId']); + } + + if (isset($optionalArgs['view'])) { + $request->setView($optionalArgs['view']); + } + + if (isset($optionalArgs['regions'])) { + $request->setRegions($optionalArgs['regions']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('ImportSshPublicKey', ImportSshPublicKeyResponse::class, $optionalArgs, $request)->wait(); + } + + /** + * Signs an SSH public key for a user to authenticate to an instance. + * + * Sample code: + * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); + * try { + * $response = $osLoginServiceClient->signSshPublicKey(); + * } finally { + * $osLoginServiceClient->close(); + * } + * ``` + * + * @param array $optionalArgs { + * Optional. + * + * @type string $sshPublicKey + * The SSH public key to sign. + * @type string $parent + * The parent project and zone for the signing request. This is needed to + * properly ensure per-organization ISS processing and potentially to provide + * for the possibility of zone-specific certificates used in the signing + * process. + * @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\OsLogin\V1beta\SignSshPublicKeyResponse + * + * @throws ApiException if the remote call fails + * + * @experimental + */ + public function signSshPublicKey(array $optionalArgs = []) + { + $request = new SignSshPublicKeyRequest(); + $requestParamHeaders = []; + if (isset($optionalArgs['sshPublicKey'])) { + $request->setSshPublicKey($optionalArgs['sshPublicKey']); + } + + if (isset($optionalArgs['parent'])) { + $request->setParent($optionalArgs['parent']); + $requestParamHeaders['parent'] = $optionalArgs['parent']; + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('SignSshPublicKey', SignSshPublicKeyResponse::class, $optionalArgs, $request)->wait(); + } + + /** + * Updates an SSH public key and returns the profile information. This method + * supports patch semantics. + * + * Sample code: + * ``` + * $osLoginServiceClient = new OsLoginServiceClient(); + * try { + * $formattedName = $osLoginServiceClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + * $sshPublicKey = new SshPublicKey(); + * $response = $osLoginServiceClient->updateSshPublicKey($formattedName, $sshPublicKey); + * } finally { + * $osLoginServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The fingerprint of the public key to update. Public keys are + * identified by their SHA-256 fingerprint. The fingerprint of the public key + * is in format `users/{user}/sshPublicKeys/{fingerprint}`. + * @param SshPublicKey $sshPublicKey Required. The SSH public key and expiration time. + * @param array $optionalArgs { + * Optional. + * + * @type FieldMask $updateMask + * Mask to control which fields get updated. Updates all if not present. + * @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\OsLogin\Common\SshPublicKey + * + * @throws ApiException if the remote call fails + * + * @experimental + */ + public function updateSshPublicKey($name, $sshPublicKey, array $optionalArgs = []) + { + $request = new UpdateSshPublicKeyRequest(); + $requestParamHeaders = []; + $request->setName($name); + $request->setSshPublicKey($sshPublicKey); + $requestParamHeaders['name'] = $name; + 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('UpdateSshPublicKey', SshPublicKey::class, $optionalArgs, $request)->wait(); + } +} diff --git a/owl-bot-staging/OsLogin/v1beta/src/V1beta/OsLoginServiceClient.php b/owl-bot-staging/OsLogin/v1beta/src/V1beta/OsLoginServiceClient.php new file mode 100644 index 000000000000..9bd3116e9afe --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/src/V1beta/OsLoginServiceClient.php @@ -0,0 +1,36 @@ + [ + 'google.cloud.oslogin.v1beta.OsLoginService' => [], + ], +]; diff --git a/owl-bot-staging/OsLogin/v1beta/src/V1beta/resources/os_login_service_rest_client_config.php b/owl-bot-staging/OsLogin/v1beta/src/V1beta/resources/os_login_service_rest_client_config.php new file mode 100644 index 000000000000..6e60ed77a8db --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/src/V1beta/resources/os_login_service_rest_client_config.php @@ -0,0 +1,108 @@ + [ + 'google.cloud.oslogin.v1beta.OsLoginService' => [ + 'CreateSshPublicKey' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=users/*}/sshPublicKeys', + 'body' => 'ssh_public_key', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'DeletePosixAccount' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1beta/{name=users/*/projects/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteSshPublicKey' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1beta/{name=users/*/sshPublicKeys/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetLoginProfile' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=users/*}/loginProfile', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetSshPublicKey' => [ + 'method' => 'get', + 'uriTemplate' => '/v1beta/{name=users/*/sshPublicKeys/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ImportSshPublicKey' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=users/*}:importSshPublicKey', + 'body' => 'ssh_public_key', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'SignSshPublicKey' => [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=users/*/projects/*/zones/*}:signSshPublicKey', + 'body' => '*', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=users/*/projects/*/locations/*}:signSshPublicKey', + 'body' => '*', + ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateSshPublicKey' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1beta/{name=users/*/sshPublicKeys/*}', + 'body' => 'ssh_public_key', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/owl-bot-staging/OsLogin/v1beta/tests/Unit/V1beta/OsLoginServiceClientTest.php b/owl-bot-staging/OsLogin/v1beta/tests/Unit/V1beta/OsLoginServiceClientTest.php new file mode 100644 index 000000000000..edcba5021be7 --- /dev/null +++ b/owl-bot-staging/OsLogin/v1beta/tests/Unit/V1beta/OsLoginServiceClientTest.php @@ -0,0 +1,559 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return OsLoginServiceClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new OsLoginServiceClient($options); + } + + /** @test */ + public function createSshPublicKeyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $key = 'key106079'; + $expirationTimeUsec = 2058878882; + $fingerprint = 'fingerprint-1375934236'; + $name = 'name3373707'; + $expectedResponse = new SshPublicKey(); + $expectedResponse->setKey($key); + $expectedResponse->setExpirationTimeUsec($expirationTimeUsec); + $expectedResponse->setFingerprint($fingerprint); + $expectedResponse->setName($name); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->userName('[USER]'); + $sshPublicKey = new SshPublicKey(); + $response = $gapicClient->createSshPublicKey($formattedParent, $sshPublicKey); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1beta.OsLoginService/CreateSshPublicKey', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getSshPublicKey(); + $this->assertProtobufEquals($sshPublicKey, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createSshPublicKeyExceptionTest() + { + $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->userName('[USER]'); + $sshPublicKey = new SshPublicKey(); + try { + $gapicClient->createSshPublicKey($formattedParent, $sshPublicKey); + // 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 deletePosixAccountTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->posixAccountName('[USER]', '[PROJECT]'); + $gapicClient->deletePosixAccount($formattedName); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1beta.OsLoginService/DeletePosixAccount', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deletePosixAccountExceptionTest() + { + $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->posixAccountName('[USER]', '[PROJECT]'); + try { + $gapicClient->deletePosixAccount($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 deleteSshPublicKeyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + $gapicClient->deleteSshPublicKey($formattedName); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1beta.OsLoginService/DeleteSshPublicKey', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteSshPublicKeyExceptionTest() + { + $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + try { + $gapicClient->deleteSshPublicKey($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 getLoginProfileTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $expectedResponse = new LoginProfile(); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->userName('[USER]'); + $response = $gapicClient->getLoginProfile($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1beta.OsLoginService/GetLoginProfile', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getLoginProfileExceptionTest() + { + $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->userName('[USER]'); + try { + $gapicClient->getLoginProfile($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 getSshPublicKeyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $key = 'key106079'; + $expirationTimeUsec = 2058878882; + $fingerprint = 'fingerprint-1375934236'; + $name2 = 'name2-1052831874'; + $expectedResponse = new SshPublicKey(); + $expectedResponse->setKey($key); + $expectedResponse->setExpirationTimeUsec($expirationTimeUsec); + $expectedResponse->setFingerprint($fingerprint); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + $response = $gapicClient->getSshPublicKey($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1beta.OsLoginService/GetSshPublicKey', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getSshPublicKeyExceptionTest() + { + $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + try { + $gapicClient->getSshPublicKey($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 importSshPublicKeyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $details = 'details1557721666'; + $expectedResponse = new ImportSshPublicKeyResponse(); + $expectedResponse->setDetails($details); + $transport->addResponse($expectedResponse); + // Mock request + $sshPublicKey = new SshPublicKey(); + $response = $gapicClient->importSshPublicKey($sshPublicKey); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1beta.OsLoginService/ImportSshPublicKey', $actualFuncCall); + $actualValue = $actualRequestObject->getSshPublicKey(); + $this->assertProtobufEquals($sshPublicKey, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function importSshPublicKeyExceptionTest() + { + $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 + $sshPublicKey = new SshPublicKey(); + try { + $gapicClient->importSshPublicKey($sshPublicKey); + // 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 signSshPublicKeyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $signedSshPublicKey = 'signedSshPublicKey-1764783709'; + $expectedResponse = new SignSshPublicKeyResponse(); + $expectedResponse->setSignedSshPublicKey($signedSshPublicKey); + $transport->addResponse($expectedResponse); + $response = $gapicClient->signSshPublicKey(); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1beta.OsLoginService/SignSshPublicKey', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function signSshPublicKeyExceptionTest() + { + $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); + try { + $gapicClient->signSshPublicKey(); + // 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 updateSshPublicKeyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $key = 'key106079'; + $expirationTimeUsec = 2058878882; + $fingerprint = 'fingerprint-1375934236'; + $name2 = 'name2-1052831874'; + $expectedResponse = new SshPublicKey(); + $expectedResponse->setKey($key); + $expectedResponse->setExpirationTimeUsec($expirationTimeUsec); + $expectedResponse->setFingerprint($fingerprint); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + $sshPublicKey = new SshPublicKey(); + $response = $gapicClient->updateSshPublicKey($formattedName, $sshPublicKey); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.oslogin.v1beta.OsLoginService/UpdateSshPublicKey', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $actualValue = $actualRequestObject->getSshPublicKey(); + $this->assertProtobufEquals($sshPublicKey, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateSshPublicKeyExceptionTest() + { + $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); + $sshPublicKey = new SshPublicKey(); + try { + $gapicClient->updateSshPublicKey($formattedName, $sshPublicKey); + // 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()); + } +}