diff --git a/Iap/metadata/V1/Service.php b/Iap/metadata/V1/Service.php index 9369b5a36696..43bc0e33e4b7 100644 Binary files a/Iap/metadata/V1/Service.php and b/Iap/metadata/V1/Service.php differ diff --git a/Iap/src/V1/AccessSettings.php b/Iap/src/V1/AccessSettings.php index 6243cdddad09..85693b1decac 100644 --- a/Iap/src/V1/AccessSettings.php +++ b/Iap/src/V1/AccessSettings.php @@ -33,6 +33,12 @@ class AccessSettings extends \Google\Protobuf\Internal\Message * Generated from protobuf field .google.cloud.iap.v1.OAuthSettings oauth_settings = 3; */ private $oauth_settings = null; + /** + * Settings to configure reauthentication policies in IAP. + * + * Generated from protobuf field .google.cloud.iap.v1.ReauthSettings reauth_settings = 6; + */ + private $reauth_settings = null; /** * Constructor. @@ -46,6 +52,8 @@ class AccessSettings extends \Google\Protobuf\Internal\Message * Configuration to allow cross-origin requests via IAP. * @type \Google\Cloud\Iap\V1\OAuthSettings $oauth_settings * Settings to configure IAP's OAuth behavior. + * @type \Google\Cloud\Iap\V1\ReauthSettings $reauth_settings + * Settings to configure reauthentication policies in IAP. * } */ public function __construct($data = NULL) { @@ -161,5 +169,41 @@ public function setOauthSettings($var) return $this; } + /** + * Settings to configure reauthentication policies in IAP. + * + * Generated from protobuf field .google.cloud.iap.v1.ReauthSettings reauth_settings = 6; + * @return \Google\Cloud\Iap\V1\ReauthSettings|null + */ + public function getReauthSettings() + { + return $this->reauth_settings; + } + + public function hasReauthSettings() + { + return isset($this->reauth_settings); + } + + public function clearReauthSettings() + { + unset($this->reauth_settings); + } + + /** + * Settings to configure reauthentication policies in IAP. + * + * Generated from protobuf field .google.cloud.iap.v1.ReauthSettings reauth_settings = 6; + * @param \Google\Cloud\Iap\V1\ReauthSettings $var + * @return $this + */ + public function setReauthSettings($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Iap\V1\ReauthSettings::class); + $this->reauth_settings = $var; + + return $this; + } + } diff --git a/Iap/src/V1/CreateTunnelDestGroupRequest.php b/Iap/src/V1/CreateTunnelDestGroupRequest.php new file mode 100644 index 000000000000..03236db0b1f2 --- /dev/null +++ b/Iap/src/V1/CreateTunnelDestGroupRequest.php @@ -0,0 +1,165 @@ +google.cloud.iap.v1.CreateTunnelDestGroupRequest + */ +class CreateTunnelDestGroupRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Google Cloud Project ID and location. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Required. The TunnelDestGroup to create. + * + * Generated from protobuf field .google.cloud.iap.v1.TunnelDestGroup tunnel_dest_group = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $tunnel_dest_group = null; + /** + * Required. The ID to use for the TunnelDestGroup, which becomes the final component of + * the resource name. + * This value must be 4-63 characters, and valid characters + * are `[a-z][0-9]-`. + * + * Generated from protobuf field string tunnel_dest_group_id = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + private $tunnel_dest_group_id = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. Google Cloud Project ID and location. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}`. + * @type \Google\Cloud\Iap\V1\TunnelDestGroup $tunnel_dest_group + * Required. The TunnelDestGroup to create. + * @type string $tunnel_dest_group_id + * Required. The ID to use for the TunnelDestGroup, which becomes the final component of + * the resource name. + * This value must be 4-63 characters, and valid characters + * are `[a-z][0-9]-`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Iap\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. Google Cloud Project ID and location. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}`. + * + * 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. Google Cloud Project ID and location. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}`. + * + * 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 TunnelDestGroup to create. + * + * Generated from protobuf field .google.cloud.iap.v1.TunnelDestGroup tunnel_dest_group = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Iap\V1\TunnelDestGroup|null + */ + public function getTunnelDestGroup() + { + return $this->tunnel_dest_group; + } + + public function hasTunnelDestGroup() + { + return isset($this->tunnel_dest_group); + } + + public function clearTunnelDestGroup() + { + unset($this->tunnel_dest_group); + } + + /** + * Required. The TunnelDestGroup to create. + * + * Generated from protobuf field .google.cloud.iap.v1.TunnelDestGroup tunnel_dest_group = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Iap\V1\TunnelDestGroup $var + * @return $this + */ + public function setTunnelDestGroup($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Iap\V1\TunnelDestGroup::class); + $this->tunnel_dest_group = $var; + + return $this; + } + + /** + * Required. The ID to use for the TunnelDestGroup, which becomes the final component of + * the resource name. + * This value must be 4-63 characters, and valid characters + * are `[a-z][0-9]-`. + * + * Generated from protobuf field string tunnel_dest_group_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getTunnelDestGroupId() + { + return $this->tunnel_dest_group_id; + } + + /** + * Required. The ID to use for the TunnelDestGroup, which becomes the final component of + * the resource name. + * This value must be 4-63 characters, and valid characters + * are `[a-z][0-9]-`. + * + * Generated from protobuf field string tunnel_dest_group_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setTunnelDestGroupId($var) + { + GPBUtil::checkString($var, True); + $this->tunnel_dest_group_id = $var; + + return $this; + } + +} + diff --git a/Iap/src/V1/DeleteTunnelDestGroupRequest.php b/Iap/src/V1/DeleteTunnelDestGroupRequest.php new file mode 100644 index 000000000000..309478331229 --- /dev/null +++ b/Iap/src/V1/DeleteTunnelDestGroupRequest.php @@ -0,0 +1,75 @@ +google.cloud.iap.v1.DeleteTunnelDestGroupRequest + */ +class DeleteTunnelDestGroupRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Name of the TunnelDestGroup to delete. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. Name of the TunnelDestGroup to delete. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Iap\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. Name of the TunnelDestGroup to delete. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. Name of the TunnelDestGroup to delete. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}`. + * + * 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/Iap/src/V1/Gapic/IdentityAwareProxyAdminServiceGapicClient.php b/Iap/src/V1/Gapic/IdentityAwareProxyAdminServiceGapicClient.php index 1883befb375c..ad8c0b458a00 100644 --- a/Iap/src/V1/Gapic/IdentityAwareProxyAdminServiceGapicClient.php +++ b/Iap/src/V1/Gapic/IdentityAwareProxyAdminServiceGapicClient.php @@ -26,8 +26,9 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; - use Google\ApiCore\GapicClientTrait; + +use Google\ApiCore\PathTemplate; use Google\ApiCore\RequestParamsHeaderDescriptor; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -39,10 +40,18 @@ use Google\Cloud\Iam\V1\SetIamPolicyRequest; use Google\Cloud\Iam\V1\TestIamPermissionsRequest; use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Iap\V1\CreateTunnelDestGroupRequest; +use Google\Cloud\Iap\V1\DeleteTunnelDestGroupRequest; use Google\Cloud\Iap\V1\GetIapSettingsRequest; +use Google\Cloud\Iap\V1\GetTunnelDestGroupRequest; use Google\Cloud\Iap\V1\IapSettings; +use Google\Cloud\Iap\V1\ListTunnelDestGroupsRequest; +use Google\Cloud\Iap\V1\ListTunnelDestGroupsResponse; +use Google\Cloud\Iap\V1\TunnelDestGroup; use Google\Cloud\Iap\V1\UpdateIapSettingsRequest; +use Google\Cloud\Iap\V1\UpdateTunnelDestGroupRequest; use Google\Protobuf\FieldMask; +use Google\Protobuf\GPBEmpty; /** * Service Description: APIs for Identity-Aware Proxy Admin configurations. @@ -53,12 +62,19 @@ * ``` * $identityAwareProxyAdminServiceClient = new IdentityAwareProxyAdminServiceClient(); * try { - * $resource = 'resource'; - * $response = $identityAwareProxyAdminServiceClient->getIamPolicy($resource); + * $formattedParent = $identityAwareProxyAdminServiceClient->tunnelLocationName('[PROJECT]', '[LOCATION]'); + * $tunnelDestGroup = new TunnelDestGroup(); + * $tunnelDestGroupId = 'tunnel_dest_group_id'; + * $response = $identityAwareProxyAdminServiceClient->createTunnelDestGroup($formattedParent, $tunnelDestGroup, $tunnelDestGroupId); * } finally { * $identityAwareProxyAdminServiceClient->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. */ class IdentityAwareProxyAdminServiceGapicClient { @@ -91,6 +107,12 @@ class IdentityAwareProxyAdminServiceGapicClient 'https://www.googleapis.com/auth/cloud-platform', ]; + private static $tunnelDestGroupNameTemplate; + + private static $tunnelLocationNameTemplate; + + private static $pathTemplateMap; + private static function getClientDefaults() { return [ @@ -119,6 +141,122 @@ private static function getClientDefaults() ]; } + private static function getTunnelDestGroupNameTemplate() + { + if (self::$tunnelDestGroupNameTemplate == null) { + self::$tunnelDestGroupNameTemplate = new PathTemplate( + 'projects/{project}/iap_tunnel/locations/{location}/destGroups/{dest_group}' + ); + } + + return self::$tunnelDestGroupNameTemplate; + } + + private static function getTunnelLocationNameTemplate() + { + if (self::$tunnelLocationNameTemplate == null) { + self::$tunnelLocationNameTemplate = new PathTemplate( + 'projects/{project}/iap_tunnel/locations/{location}' + ); + } + + return self::$tunnelLocationNameTemplate; + } + + private static function getPathTemplateMap() + { + if (self::$pathTemplateMap == null) { + self::$pathTemplateMap = [ + 'tunnelDestGroup' => self::getTunnelDestGroupNameTemplate(), + 'tunnelLocation' => self::getTunnelLocationNameTemplate(), + ]; + } + + return self::$pathTemplateMap; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * tunnel_dest_group resource. + * + * @param string $project + * @param string $location + * @param string $destGroup + * + * @return string The formatted tunnel_dest_group resource. + */ + public static function tunnelDestGroupName($project, $location, $destGroup) + { + return self::getTunnelDestGroupNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'dest_group' => $destGroup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * tunnel_location resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted tunnel_location resource. + */ + public static function tunnelLocationName($project, $location) + { + return self::getTunnelLocationNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - tunnelDestGroup: projects/{project}/iap_tunnel/locations/{location}/destGroups/{dest_group} + * - tunnelLocation: projects/{project}/iap_tunnel/locations/{location} + * + * 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. * @@ -182,6 +320,120 @@ public function __construct(array $options = []) $this->setClientOptions($clientOptions); } + /** + * Creates a new TunnelDestGroup. + * + * Sample code: + * ``` + * $identityAwareProxyAdminServiceClient = new IdentityAwareProxyAdminServiceClient(); + * try { + * $formattedParent = $identityAwareProxyAdminServiceClient->tunnelLocationName('[PROJECT]', '[LOCATION]'); + * $tunnelDestGroup = new TunnelDestGroup(); + * $tunnelDestGroupId = 'tunnel_dest_group_id'; + * $response = $identityAwareProxyAdminServiceClient->createTunnelDestGroup($formattedParent, $tunnelDestGroup, $tunnelDestGroupId); + * } finally { + * $identityAwareProxyAdminServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. Google Cloud Project ID and location. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}`. + * @param TunnelDestGroup $tunnelDestGroup Required. The TunnelDestGroup to create. + * @param string $tunnelDestGroupId Required. The ID to use for the TunnelDestGroup, which becomes the final component of + * the resource name. + * + * This value must be 4-63 characters, and valid characters + * are `[a-z][0-9]-`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Iap\V1\TunnelDestGroup + * + * @throws ApiException if the remote call fails + */ + public function createTunnelDestGroup( + $parent, + $tunnelDestGroup, + $tunnelDestGroupId, + array $optionalArgs = [] + ) { + $request = new CreateTunnelDestGroupRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setTunnelDestGroup($tunnelDestGroup); + $request->setTunnelDestGroupId($tunnelDestGroupId); + $requestParamHeaders['parent'] = $parent; + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->startCall( + 'CreateTunnelDestGroup', + TunnelDestGroup::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Deletes a TunnelDestGroup. + * + * Sample code: + * ``` + * $identityAwareProxyAdminServiceClient = new IdentityAwareProxyAdminServiceClient(); + * try { + * $formattedName = $identityAwareProxyAdminServiceClient->tunnelDestGroupName('[PROJECT]', '[LOCATION]', '[DEST_GROUP]'); + * $identityAwareProxyAdminServiceClient->deleteTunnelDestGroup($formattedName); + * } finally { + * $identityAwareProxyAdminServiceClient->close(); + * } + * ``` + * + * @param string $name Required. Name of the TunnelDestGroup to delete. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @throws ApiException if the remote call fails + */ + public function deleteTunnelDestGroup($name, array $optionalArgs = []) + { + $request = new DeleteTunnelDestGroupRequest(); + $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( + 'DeleteTunnelDestGroup', + GPBEmpty::class, + $optionalArgs, + $request + )->wait(); + } + /** * Gets the access control policy for an Identity-Aware Proxy protected * resource. @@ -293,6 +545,140 @@ public function getIapSettings($name, array $optionalArgs = []) )->wait(); } + /** + * Retrieves an existing TunnelDestGroup. + * + * Sample code: + * ``` + * $identityAwareProxyAdminServiceClient = new IdentityAwareProxyAdminServiceClient(); + * try { + * $formattedName = $identityAwareProxyAdminServiceClient->tunnelDestGroupName('[PROJECT]', '[LOCATION]', '[DEST_GROUP]'); + * $response = $identityAwareProxyAdminServiceClient->getTunnelDestGroup($formattedName); + * } finally { + * $identityAwareProxyAdminServiceClient->close(); + * } + * ``` + * + * @param string $name Required. Name of the TunnelDestGroup to be fetched. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Iap\V1\TunnelDestGroup + * + * @throws ApiException if the remote call fails + */ + public function getTunnelDestGroup($name, array $optionalArgs = []) + { + $request = new GetTunnelDestGroupRequest(); + $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( + 'GetTunnelDestGroup', + TunnelDestGroup::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Lists the existing TunnelDestGroups. To group across all locations, use a + * `-` as the location ID. For example: + * `/v1/projects/123/iap_tunnel/locations/-/destGroups` + * + * Sample code: + * ``` + * $identityAwareProxyAdminServiceClient = new IdentityAwareProxyAdminServiceClient(); + * try { + * $formattedParent = $identityAwareProxyAdminServiceClient->tunnelLocationName('[PROJECT]', '[LOCATION]'); + * // Iterate over pages of elements + * $pagedResponse = $identityAwareProxyAdminServiceClient->listTunnelDestGroups($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $identityAwareProxyAdminServiceClient->listTunnelDestGroups($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $identityAwareProxyAdminServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. Google Cloud Project ID and location. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}`. + * A `-` can be used for the location to group across all locations. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listTunnelDestGroups($parent, array $optionalArgs = []) + { + $request = new ListTunnelDestGroupsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->getPagedListResponse( + 'ListTunnelDestGroups', + $optionalArgs, + ListTunnelDestGroupsResponse::class, + $request + ); + } + /** * Sets the access control policy for an Identity-Aware Proxy protected * resource. Replaces any existing policy. @@ -483,4 +869,65 @@ public function updateIapSettings($iapSettings, array $optionalArgs = []) $request )->wait(); } + + /** + * Updates a TunnelDestGroup. + * + * Sample code: + * ``` + * $identityAwareProxyAdminServiceClient = new IdentityAwareProxyAdminServiceClient(); + * try { + * $tunnelDestGroup = new TunnelDestGroup(); + * $response = $identityAwareProxyAdminServiceClient->updateTunnelDestGroup($tunnelDestGroup); + * } finally { + * $identityAwareProxyAdminServiceClient->close(); + * } + * ``` + * + * @param TunnelDestGroup $tunnelDestGroup Required. The new values for the TunnelDestGroup. + * @param array $optionalArgs { + * Optional. + * + * @type FieldMask $updateMask + * A field mask that specifies which IAP settings to update. + * If omitted, then all of the settings are updated. See + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Iap\V1\TunnelDestGroup + * + * @throws ApiException if the remote call fails + */ + public function updateTunnelDestGroup( + $tunnelDestGroup, + array $optionalArgs = [] + ) { + $request = new UpdateTunnelDestGroupRequest(); + $requestParamHeaders = []; + $request->setTunnelDestGroup($tunnelDestGroup); + $requestParamHeaders[ + 'tunnel_dest_group.name' + ] = $tunnelDestGroup->getName(); + 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( + 'UpdateTunnelDestGroup', + TunnelDestGroup::class, + $optionalArgs, + $request + )->wait(); + } } diff --git a/Iap/src/V1/Gapic/IdentityAwareProxyOAuthServiceGapicClient.php b/Iap/src/V1/Gapic/IdentityAwareProxyOAuthServiceGapicClient.php index 7cd30d05eab2..74af3204acb5 100644 --- a/Iap/src/V1/Gapic/IdentityAwareProxyOAuthServiceGapicClient.php +++ b/Iap/src/V1/Gapic/IdentityAwareProxyOAuthServiceGapicClient.php @@ -191,11 +191,12 @@ public function __construct(array $options = []) /** * Constructs a new OAuth brand for the project if one does not exist. * The created brand is "internal only", meaning that OAuth clients created - * under it only accept requests from users who belong to the same G Suite - * organization as the project. The brand is created in an un-reviewed status. - * NOTE: The "internal only" status can be manually changed in the Google - * Cloud console. Requires that a brand does not already exist for the - * project, and that the specified support email is owned by the caller. + * under it only accept requests from users who belong to the same Google + * Workspace organization as the project. The brand is created in an + * un-reviewed status. NOTE: The "internal only" status can be manually + * changed in the Google Cloud Console. Requires that a brand does not already + * exist for the project, and that the specified support email is owned by the + * caller. * * Sample code: * ``` diff --git a/Iap/src/V1/GetTunnelDestGroupRequest.php b/Iap/src/V1/GetTunnelDestGroupRequest.php new file mode 100644 index 000000000000..cd62c887c03e --- /dev/null +++ b/Iap/src/V1/GetTunnelDestGroupRequest.php @@ -0,0 +1,75 @@ +google.cloud.iap.v1.GetTunnelDestGroupRequest + */ +class GetTunnelDestGroupRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Name of the TunnelDestGroup to be fetched. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. Name of the TunnelDestGroup to be fetched. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Iap\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. Name of the TunnelDestGroup to be fetched. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. Name of the TunnelDestGroup to be fetched. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}`. + * + * 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/Iap/src/V1/IdentityAwareProxyAdminServiceGrpcClient.php b/Iap/src/V1/IdentityAwareProxyAdminServiceGrpcClient.php index ab2dca25f590..08a5ea126af1 100644 --- a/Iap/src/V1/IdentityAwareProxyAdminServiceGrpcClient.php +++ b/Iap/src/V1/IdentityAwareProxyAdminServiceGrpcClient.php @@ -117,4 +117,81 @@ public function UpdateIapSettings(\Google\Cloud\Iap\V1\UpdateIapSettingsRequest $metadata, $options); } + /** + * Lists the existing TunnelDestGroups. To group across all locations, use a + * `-` as the location ID. For example: + * `/v1/projects/123/iap_tunnel/locations/-/destGroups` + * @param \Google\Cloud\Iap\V1\ListTunnelDestGroupsRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function ListTunnelDestGroups(\Google\Cloud\Iap\V1\ListTunnelDestGroupsRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.iap.v1.IdentityAwareProxyAdminService/ListTunnelDestGroups', + $argument, + ['\Google\Cloud\Iap\V1\ListTunnelDestGroupsResponse', 'decode'], + $metadata, $options); + } + + /** + * Creates a new TunnelDestGroup. + * @param \Google\Cloud\Iap\V1\CreateTunnelDestGroupRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function CreateTunnelDestGroup(\Google\Cloud\Iap\V1\CreateTunnelDestGroupRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.iap.v1.IdentityAwareProxyAdminService/CreateTunnelDestGroup', + $argument, + ['\Google\Cloud\Iap\V1\TunnelDestGroup', 'decode'], + $metadata, $options); + } + + /** + * Retrieves an existing TunnelDestGroup. + * @param \Google\Cloud\Iap\V1\GetTunnelDestGroupRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function GetTunnelDestGroup(\Google\Cloud\Iap\V1\GetTunnelDestGroupRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.iap.v1.IdentityAwareProxyAdminService/GetTunnelDestGroup', + $argument, + ['\Google\Cloud\Iap\V1\TunnelDestGroup', 'decode'], + $metadata, $options); + } + + /** + * Deletes a TunnelDestGroup. + * @param \Google\Cloud\Iap\V1\DeleteTunnelDestGroupRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function DeleteTunnelDestGroup(\Google\Cloud\Iap\V1\DeleteTunnelDestGroupRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.iap.v1.IdentityAwareProxyAdminService/DeleteTunnelDestGroup', + $argument, + ['\Google\Protobuf\GPBEmpty', 'decode'], + $metadata, $options); + } + + /** + * Updates a TunnelDestGroup. + * @param \Google\Cloud\Iap\V1\UpdateTunnelDestGroupRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function UpdateTunnelDestGroup(\Google\Cloud\Iap\V1\UpdateTunnelDestGroupRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.iap.v1.IdentityAwareProxyAdminService/UpdateTunnelDestGroup', + $argument, + ['\Google\Cloud\Iap\V1\TunnelDestGroup', 'decode'], + $metadata, $options); + } + } diff --git a/Iap/src/V1/IdentityAwareProxyOAuthServiceGrpcClient.php b/Iap/src/V1/IdentityAwareProxyOAuthServiceGrpcClient.php index c3daf3d6ab67..4ef9fd0bedc8 100644 --- a/Iap/src/V1/IdentityAwareProxyOAuthServiceGrpcClient.php +++ b/Iap/src/V1/IdentityAwareProxyOAuthServiceGrpcClient.php @@ -52,11 +52,12 @@ public function ListBrands(\Google\Cloud\Iap\V1\ListBrandsRequest $argument, /** * Constructs a new OAuth brand for the project if one does not exist. * The created brand is "internal only", meaning that OAuth clients created - * under it only accept requests from users who belong to the same G Suite - * organization as the project. The brand is created in an un-reviewed status. - * NOTE: The "internal only" status can be manually changed in the Google - * Cloud console. Requires that a brand does not already exist for the - * project, and that the specified support email is owned by the caller. + * under it only accept requests from users who belong to the same Google + * Workspace organization as the project. The brand is created in an + * un-reviewed status. NOTE: The "internal only" status can be manually + * changed in the Google Cloud Console. Requires that a brand does not already + * exist for the project, and that the specified support email is owned by the + * caller. * @param \Google\Cloud\Iap\V1\CreateBrandRequest $argument input argument * @param array $metadata metadata * @param array $options call options diff --git a/Iap/src/V1/ListTunnelDestGroupsRequest.php b/Iap/src/V1/ListTunnelDestGroupsRequest.php new file mode 100644 index 000000000000..24999a29ca5a --- /dev/null +++ b/Iap/src/V1/ListTunnelDestGroupsRequest.php @@ -0,0 +1,175 @@ +google.cloud.iap.v1.ListTunnelDestGroupsRequest + */ +class ListTunnelDestGroupsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Google Cloud Project ID and location. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}`. + * A `-` can be used for the location to group across all locations. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * The maximum number of groups to return. The service might return fewer than + * this value. + * If unspecified, at most 100 groups are returned. + * The maximum value is 1000; values above 1000 are coerced to 1000. + * + * Generated from protobuf field int32 page_size = 2; + */ + private $page_size = 0; + /** + * A page token, received from a previous `ListTunnelDestGroups` + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * `ListTunnelDestGroups` must match the call that provided the page + * token. + * + * Generated from protobuf field string page_token = 3; + */ + private $page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. Google Cloud Project ID and location. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}`. + * A `-` can be used for the location to group across all locations. + * @type int $page_size + * The maximum number of groups to return. The service might return fewer than + * this value. + * If unspecified, at most 100 groups are returned. + * The maximum value is 1000; values above 1000 are coerced to 1000. + * @type string $page_token + * A page token, received from a previous `ListTunnelDestGroups` + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * `ListTunnelDestGroups` must match the call that provided the page + * token. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Iap\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. Google Cloud Project ID and location. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}`. + * A `-` can be used for the location to group across all locations. + * + * 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. Google Cloud Project ID and location. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}`. + * A `-` can be used for the location to group across all locations. + * + * 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; + } + + /** + * The maximum number of groups to return. The service might return fewer than + * this value. + * If unspecified, at most 100 groups are returned. + * The maximum value is 1000; values above 1000 are coerced to 1000. + * + * Generated from protobuf field int32 page_size = 2; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * The maximum number of groups to return. The service might return fewer than + * this value. + * If unspecified, at most 100 groups are returned. + * The maximum value is 1000; values above 1000 are coerced to 1000. + * + * Generated from protobuf field int32 page_size = 2; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * A page token, received from a previous `ListTunnelDestGroups` + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * `ListTunnelDestGroups` must match the call that provided the page + * token. + * + * Generated from protobuf field string page_token = 3; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * A page token, received from a previous `ListTunnelDestGroups` + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * `ListTunnelDestGroups` must match the call that provided the page + * token. + * + * Generated from protobuf field string page_token = 3; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/Iap/src/V1/ListTunnelDestGroupsResponse.php b/Iap/src/V1/ListTunnelDestGroupsResponse.php new file mode 100644 index 000000000000..7610b31fdaca --- /dev/null +++ b/Iap/src/V1/ListTunnelDestGroupsResponse.php @@ -0,0 +1,105 @@ +google.cloud.iap.v1.ListTunnelDestGroupsResponse + */ +class ListTunnelDestGroupsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * TunnelDestGroup existing in the project. + * + * Generated from protobuf field repeated .google.cloud.iap.v1.TunnelDestGroup tunnel_dest_groups = 1; + */ + private $tunnel_dest_groups; + /** + * A token that you can send as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + * + * Generated from protobuf field string next_page_token = 2; + */ + private $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Iap\V1\TunnelDestGroup[]|\Google\Protobuf\Internal\RepeatedField $tunnel_dest_groups + * TunnelDestGroup existing in the project. + * @type string $next_page_token + * A token that you can send as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Iap\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * TunnelDestGroup existing in the project. + * + * Generated from protobuf field repeated .google.cloud.iap.v1.TunnelDestGroup tunnel_dest_groups = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getTunnelDestGroups() + { + return $this->tunnel_dest_groups; + } + + /** + * TunnelDestGroup existing in the project. + * + * Generated from protobuf field repeated .google.cloud.iap.v1.TunnelDestGroup tunnel_dest_groups = 1; + * @param \Google\Cloud\Iap\V1\TunnelDestGroup[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setTunnelDestGroups($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Iap\V1\TunnelDestGroup::class); + $this->tunnel_dest_groups = $arr; + + return $this; + } + + /** + * A token that you can send as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * A token that you can send as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/Iap/src/V1/ReauthSettings.php b/Iap/src/V1/ReauthSettings.php new file mode 100644 index 000000000000..6f4c198a1637 --- /dev/null +++ b/Iap/src/V1/ReauthSettings.php @@ -0,0 +1,153 @@ +google.cloud.iap.v1.ReauthSettings + */ +class ReauthSettings extends \Google\Protobuf\Internal\Message +{ + /** + * Reauth method required by the policy. + * + * Generated from protobuf field .google.cloud.iap.v1.ReauthSettings.Method method = 1; + */ + private $method = 0; + /** + * Reauth session lifetime, how long before a user has to reauthenticate + * again. + * + * Generated from protobuf field .google.protobuf.Duration max_age = 2; + */ + private $max_age = null; + /** + * How IAP determines the effective policy in cases of hierarchial policies. + * Policies are merged from higher in the hierarchy to lower in the hierarchy. + * + * Generated from protobuf field .google.cloud.iap.v1.ReauthSettings.PolicyType policy_type = 3; + */ + private $policy_type = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $method + * Reauth method required by the policy. + * @type \Google\Protobuf\Duration $max_age + * Reauth session lifetime, how long before a user has to reauthenticate + * again. + * @type int $policy_type + * How IAP determines the effective policy in cases of hierarchial policies. + * Policies are merged from higher in the hierarchy to lower in the hierarchy. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Iap\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Reauth method required by the policy. + * + * Generated from protobuf field .google.cloud.iap.v1.ReauthSettings.Method method = 1; + * @return int + */ + public function getMethod() + { + return $this->method; + } + + /** + * Reauth method required by the policy. + * + * Generated from protobuf field .google.cloud.iap.v1.ReauthSettings.Method method = 1; + * @param int $var + * @return $this + */ + public function setMethod($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Iap\V1\ReauthSettings\Method::class); + $this->method = $var; + + return $this; + } + + /** + * Reauth session lifetime, how long before a user has to reauthenticate + * again. + * + * Generated from protobuf field .google.protobuf.Duration max_age = 2; + * @return \Google\Protobuf\Duration|null + */ + public function getMaxAge() + { + return $this->max_age; + } + + public function hasMaxAge() + { + return isset($this->max_age); + } + + public function clearMaxAge() + { + unset($this->max_age); + } + + /** + * Reauth session lifetime, how long before a user has to reauthenticate + * again. + * + * Generated from protobuf field .google.protobuf.Duration max_age = 2; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setMaxAge($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->max_age = $var; + + return $this; + } + + /** + * How IAP determines the effective policy in cases of hierarchial policies. + * Policies are merged from higher in the hierarchy to lower in the hierarchy. + * + * Generated from protobuf field .google.cloud.iap.v1.ReauthSettings.PolicyType policy_type = 3; + * @return int + */ + public function getPolicyType() + { + return $this->policy_type; + } + + /** + * How IAP determines the effective policy in cases of hierarchial policies. + * Policies are merged from higher in the hierarchy to lower in the hierarchy. + * + * Generated from protobuf field .google.cloud.iap.v1.ReauthSettings.PolicyType policy_type = 3; + * @param int $var + * @return $this + */ + public function setPolicyType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Iap\V1\ReauthSettings\PolicyType::class); + $this->policy_type = $var; + + return $this; + } + +} + diff --git a/Iap/src/V1/ReauthSettings/Method.php b/Iap/src/V1/ReauthSettings/Method.php new file mode 100644 index 000000000000..2b134d540b9e --- /dev/null +++ b/Iap/src/V1/ReauthSettings/Method.php @@ -0,0 +1,75 @@ +google.cloud.iap.v1.ReauthSettings.Method + */ +class Method +{ + /** + * Reauthentication disabled. + * + * Generated from protobuf enum METHOD_UNSPECIFIED = 0; + */ + const METHOD_UNSPECIFIED = 0; + /** + * Mimics the behavior as if the user had logged out and tried to log in + * again. Users with 2SV (2-step verification) enabled see their 2SV + * challenges if they did not opt to have their second factor responses + * saved. Apps Core (GSuites) admins can configure settings to disable 2SV + * cookies and require 2SV for all Apps Core users in their domains. + * + * Generated from protobuf enum LOGIN = 1; + */ + const LOGIN = 1; + /** + * User must type their password. + * + * Generated from protobuf enum PASSWORD = 2; + */ + const PASSWORD = 2; + /** + * User must use their secure key 2nd factor device. + * + * Generated from protobuf enum SECURE_KEY = 3; + */ + const SECURE_KEY = 3; + + private static $valueToName = [ + self::METHOD_UNSPECIFIED => 'METHOD_UNSPECIFIED', + self::LOGIN => 'LOGIN', + self::PASSWORD => 'PASSWORD', + self::SECURE_KEY => 'SECURE_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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Method::class, \Google\Cloud\Iap\V1\ReauthSettings_Method::class); + diff --git a/Iap/src/V1/ReauthSettings/PolicyType.php b/Iap/src/V1/ReauthSettings/PolicyType.php new file mode 100644 index 000000000000..d513b9863402 --- /dev/null +++ b/Iap/src/V1/ReauthSettings/PolicyType.php @@ -0,0 +1,65 @@ +google.cloud.iap.v1.ReauthSettings.PolicyType + */ +class PolicyType +{ + /** + * Default value. This value is unused. + * + * Generated from protobuf enum POLICY_TYPE_UNSPECIFIED = 0; + */ + const POLICY_TYPE_UNSPECIFIED = 0; + /** + * This policy acts as a minimum to other policies, lower in the hierarchy. + * Effective policy may only be the same or stricter. + * + * Generated from protobuf enum MINIMUM = 1; + */ + const MINIMUM = 1; + /** + * This policy acts as a default if no other reauth policy is set. + * + * Generated from protobuf enum DEFAULT = 2; + */ + const PBDEFAULT = 2; + + private static $valueToName = [ + self::POLICY_TYPE_UNSPECIFIED => 'POLICY_TYPE_UNSPECIFIED', + self::MINIMUM => 'MINIMUM', + self::PBDEFAULT => 'PBDEFAULT', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(PolicyType::class, \Google\Cloud\Iap\V1\ReauthSettings_PolicyType::class); + diff --git a/Iap/src/V1/ReauthSettings_Method.php b/Iap/src/V1/ReauthSettings_Method.php new file mode 100644 index 000000000000..50989afef0ca --- /dev/null +++ b/Iap/src/V1/ReauthSettings_Method.php @@ -0,0 +1,16 @@ +google.cloud.iap.v1.TunnelDestGroup + */ +class TunnelDestGroup extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Immutable. Identifier for the TunnelDestGroup. Must be unique within the + * project. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.field_behavior) = IMMUTABLE]; + */ + private $name = ''; + /** + * null List of CIDRs that this group applies to. + * + * Generated from protobuf field repeated string cidrs = 2 [(.google.api.field_behavior) = UNORDERED_LIST]; + */ + private $cidrs; + /** + * null List of FQDNs that this group applies to. + * + * Generated from protobuf field repeated string fqdns = 3 [(.google.api.field_behavior) = UNORDERED_LIST]; + */ + private $fqdns; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. Immutable. Identifier for the TunnelDestGroup. Must be unique within the + * project. + * @type string[]|\Google\Protobuf\Internal\RepeatedField $cidrs + * null List of CIDRs that this group applies to. + * @type string[]|\Google\Protobuf\Internal\RepeatedField $fqdns + * null List of FQDNs that this group applies to. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Iap\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. Immutable. Identifier for the TunnelDestGroup. Must be unique within the + * project. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.field_behavior) = IMMUTABLE]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. Immutable. Identifier for the TunnelDestGroup. Must be unique within the + * project. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.field_behavior) = IMMUTABLE]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * null List of CIDRs that this group applies to. + * + * Generated from protobuf field repeated string cidrs = 2 [(.google.api.field_behavior) = UNORDERED_LIST]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getCidrs() + { + return $this->cidrs; + } + + /** + * null List of CIDRs that this group applies to. + * + * Generated from protobuf field repeated string cidrs = 2 [(.google.api.field_behavior) = UNORDERED_LIST]; + * @param string[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setCidrs($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->cidrs = $arr; + + return $this; + } + + /** + * null List of FQDNs that this group applies to. + * + * Generated from protobuf field repeated string fqdns = 3 [(.google.api.field_behavior) = UNORDERED_LIST]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getFqdns() + { + return $this->fqdns; + } + + /** + * null List of FQDNs that this group applies to. + * + * Generated from protobuf field repeated string fqdns = 3 [(.google.api.field_behavior) = UNORDERED_LIST]; + * @param string[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setFqdns($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->fqdns = $arr; + + return $this; + } + +} + diff --git a/Iap/src/V1/UpdateTunnelDestGroupRequest.php b/Iap/src/V1/UpdateTunnelDestGroupRequest.php new file mode 100644 index 000000000000..2c122a2da11c --- /dev/null +++ b/Iap/src/V1/UpdateTunnelDestGroupRequest.php @@ -0,0 +1,129 @@ +google.cloud.iap.v1.UpdateTunnelDestGroupRequest + */ +class UpdateTunnelDestGroupRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The new values for the TunnelDestGroup. + * + * Generated from protobuf field .google.cloud.iap.v1.TunnelDestGroup tunnel_dest_group = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $tunnel_dest_group = null; + /** + * A field mask that specifies which IAP settings to update. + * If omitted, then all of the settings are updated. See + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; + */ + private $update_mask = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Iap\V1\TunnelDestGroup $tunnel_dest_group + * Required. The new values for the TunnelDestGroup. + * @type \Google\Protobuf\FieldMask $update_mask + * A field mask that specifies which IAP settings to update. + * If omitted, then all of the settings are updated. See + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Iap\V1\Service::initOnce(); + parent::__construct($data); + } + + /** + * Required. The new values for the TunnelDestGroup. + * + * Generated from protobuf field .google.cloud.iap.v1.TunnelDestGroup tunnel_dest_group = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Iap\V1\TunnelDestGroup|null + */ + public function getTunnelDestGroup() + { + return $this->tunnel_dest_group; + } + + public function hasTunnelDestGroup() + { + return isset($this->tunnel_dest_group); + } + + public function clearTunnelDestGroup() + { + unset($this->tunnel_dest_group); + } + + /** + * Required. The new values for the TunnelDestGroup. + * + * Generated from protobuf field .google.cloud.iap.v1.TunnelDestGroup tunnel_dest_group = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Iap\V1\TunnelDestGroup $var + * @return $this + */ + public function setTunnelDestGroup($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Iap\V1\TunnelDestGroup::class); + $this->tunnel_dest_group = $var; + + return $this; + } + + /** + * A field mask that specifies which IAP settings to update. + * If omitted, then all of the settings are updated. See + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; + * @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); + } + + /** + * A field mask that specifies which IAP settings to update. + * If omitted, then all of the settings are updated. See + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; + * @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/Iap/src/V1/gapic_metadata.json b/Iap/src/V1/gapic_metadata.json index f6981db2719c..7d6b3af3a00f 100644 --- a/Iap/src/V1/gapic_metadata.json +++ b/Iap/src/V1/gapic_metadata.json @@ -10,6 +10,16 @@ "grpc": { "libraryClient": "IdentityAwareProxyAdminServiceGapicClient", "rpcs": { + "CreateTunnelDestGroup": { + "methods": [ + "createTunnelDestGroup" + ] + }, + "DeleteTunnelDestGroup": { + "methods": [ + "deleteTunnelDestGroup" + ] + }, "GetIamPolicy": { "methods": [ "getIamPolicy" @@ -20,6 +30,16 @@ "getIapSettings" ] }, + "GetTunnelDestGroup": { + "methods": [ + "getTunnelDestGroup" + ] + }, + "ListTunnelDestGroups": { + "methods": [ + "listTunnelDestGroups" + ] + }, "SetIamPolicy": { "methods": [ "setIamPolicy" @@ -34,6 +54,11 @@ "methods": [ "updateIapSettings" ] + }, + "UpdateTunnelDestGroup": { + "methods": [ + "updateTunnelDestGroup" + ] } } } diff --git a/Iap/src/V1/resources/identity_aware_proxy_admin_service_client_config.json b/Iap/src/V1/resources/identity_aware_proxy_admin_service_client_config.json index 04370cba0dd1..da2a29c85576 100644 --- a/Iap/src/V1/resources/identity_aware_proxy_admin_service_client_config.json +++ b/Iap/src/V1/resources/identity_aware_proxy_admin_service_client_config.json @@ -26,6 +26,16 @@ } }, "methods": { + "CreateTunnelDestGroup": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "DeleteTunnelDestGroup": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, "GetIamPolicy": { "timeout_millis": 60000, "retry_codes_name": "no_retry_1_codes", @@ -36,6 +46,16 @@ "retry_codes_name": "no_retry_1_codes", "retry_params_name": "no_retry_1_params" }, + "GetTunnelDestGroup": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "ListTunnelDestGroups": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, "SetIamPolicy": { "timeout_millis": 60000, "retry_codes_name": "no_retry_1_codes", @@ -50,6 +70,11 @@ "timeout_millis": 60000, "retry_codes_name": "no_retry_1_codes", "retry_params_name": "no_retry_1_params" + }, + "UpdateTunnelDestGroup": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" } } } diff --git a/Iap/src/V1/resources/identity_aware_proxy_admin_service_descriptor_config.php b/Iap/src/V1/resources/identity_aware_proxy_admin_service_descriptor_config.php index c37b21b26920..4f939282065e 100644 --- a/Iap/src/V1/resources/identity_aware_proxy_admin_service_descriptor_config.php +++ b/Iap/src/V1/resources/identity_aware_proxy_admin_service_descriptor_config.php @@ -2,6 +2,17 @@ return [ 'interfaces' => [ - 'google.cloud.iap.v1.IdentityAwareProxyAdminService' => [], + 'google.cloud.iap.v1.IdentityAwareProxyAdminService' => [ + 'ListTunnelDestGroups' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getTunnelDestGroups', + ], + ], + ], ], ]; diff --git a/Iap/src/V1/resources/identity_aware_proxy_admin_service_rest_client_config.php b/Iap/src/V1/resources/identity_aware_proxy_admin_service_rest_client_config.php index ceba143ec01e..e877a86dd66b 100644 --- a/Iap/src/V1/resources/identity_aware_proxy_admin_service_rest_client_config.php +++ b/Iap/src/V1/resources/identity_aware_proxy_admin_service_rest_client_config.php @@ -3,6 +3,32 @@ return [ 'interfaces' => [ 'google.cloud.iap.v1.IdentityAwareProxyAdminService' => [ + 'CreateTunnelDestGroup' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*/iap_tunnel/locations/*}/destGroups', + 'body' => 'tunnel_dest_group', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + 'queryParams' => [ + 'tunnel_dest_group_id', + ], + ], + 'DeleteTunnelDestGroup' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/iap_tunnel/locations/*/destGroups/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], 'GetIamPolicy' => [ 'method' => 'post', 'uriTemplate' => '/v1/{resource=**}:getIamPolicy', @@ -26,6 +52,28 @@ ], ], ], + 'GetTunnelDestGroup' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/iap_tunnel/locations/*/destGroups/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListTunnelDestGroups' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/iap_tunnel/locations/*}/destGroups', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], 'SetIamPolicy' => [ 'method' => 'post', 'uriTemplate' => '/v1/{resource=**}:setIamPolicy', @@ -63,6 +111,19 @@ ], ], ], + 'UpdateTunnelDestGroup' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{tunnel_dest_group.name=projects/*/iap_tunnel/locations/*/destGroups/*}', + 'body' => 'tunnel_dest_group', + 'placeholders' => [ + 'tunnel_dest_group.name' => [ + 'getters' => [ + 'getTunnelDestGroup', + 'getName', + ], + ], + ], + ], ], ], ]; diff --git a/Iap/tests/Unit/V1/IdentityAwareProxyAdminServiceClientTest.php b/Iap/tests/Unit/V1/IdentityAwareProxyAdminServiceClientTest.php index f8dc306f828e..a827dccc4a8d 100644 --- a/Iap/tests/Unit/V1/IdentityAwareProxyAdminServiceClientTest.php +++ b/Iap/tests/Unit/V1/IdentityAwareProxyAdminServiceClientTest.php @@ -23,14 +23,18 @@ namespace Google\Cloud\Iap\Tests\Unit\V1; use Google\ApiCore\ApiException; + use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; - use Google\ApiCore\Testing\MockTransport; + use Google\Cloud\Iam\V1\Policy; use Google\Cloud\Iam\V1\TestIamPermissionsResponse; use Google\Cloud\Iap\V1\IapSettings; use Google\Cloud\Iap\V1\IdentityAwareProxyAdminServiceClient; +use Google\Cloud\Iap\V1\ListTunnelDestGroupsResponse; +use Google\Cloud\Iap\V1\TunnelDestGroup; +use Google\Protobuf\GPBEmpty; use Google\Rpc\Code; use stdClass; @@ -68,6 +72,143 @@ private function createClient(array $options = []) return new IdentityAwareProxyAdminServiceClient($options); } + /** + * @test + */ + public function createTunnelDestGroupTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $expectedResponse = new TunnelDestGroup(); + $expectedResponse->setName($name); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $client->tunnelLocationName('[PROJECT]', '[LOCATION]'); + $tunnelDestGroup = new TunnelDestGroup(); + $tunnelDestGroupName = 'tunnelDestGroupName1906281888'; + $tunnelDestGroup->setName($tunnelDestGroupName); + $tunnelDestGroupId = 'tunnelDestGroupId-1205367743'; + $response = $client->createTunnelDestGroup($formattedParent, $tunnelDestGroup, $tunnelDestGroupId); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.iap.v1.IdentityAwareProxyAdminService/CreateTunnelDestGroup', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getTunnelDestGroup(); + $this->assertProtobufEquals($tunnelDestGroup, $actualValue); + $actualValue = $actualRequestObject->getTunnelDestGroupId(); + $this->assertProtobufEquals($tunnelDestGroupId, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function createTunnelDestGroupExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 = $client->tunnelLocationName('[PROJECT]', '[LOCATION]'); + $tunnelDestGroup = new TunnelDestGroup(); + $tunnelDestGroupName = 'tunnelDestGroupName1906281888'; + $tunnelDestGroup->setName($tunnelDestGroupName); + $tunnelDestGroupId = 'tunnelDestGroupId-1205367743'; + try { + $client->createTunnelDestGroup($formattedParent, $tunnelDestGroup, $tunnelDestGroupId); + // If the $client 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 deleteTunnelDestGroupTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $client->tunnelDestGroupName('[PROJECT]', '[LOCATION]', '[DEST_GROUP]'); + $client->deleteTunnelDestGroup($formattedName); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.iap.v1.IdentityAwareProxyAdminService/DeleteTunnelDestGroup', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function deleteTunnelDestGroupExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 = $client->tunnelDestGroupName('[PROJECT]', '[LOCATION]', '[DEST_GROUP]'); + try { + $client->deleteTunnelDestGroup($formattedName); + // If the $client 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 */ @@ -198,6 +339,142 @@ public function getIapSettingsExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** + * @test + */ + public function getTunnelDestGroupTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $expectedResponse = new TunnelDestGroup(); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $client->tunnelDestGroupName('[PROJECT]', '[LOCATION]', '[DEST_GROUP]'); + $response = $client->getTunnelDestGroup($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.iap.v1.IdentityAwareProxyAdminService/GetTunnelDestGroup', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getTunnelDestGroupExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 = $client->tunnelDestGroupName('[PROJECT]', '[LOCATION]', '[DEST_GROUP]'); + try { + $client->getTunnelDestGroup($formattedName); + // If the $client 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 listTunnelDestGroupsTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $tunnelDestGroupsElement = new TunnelDestGroup(); + $tunnelDestGroups = [ + $tunnelDestGroupsElement, + ]; + $expectedResponse = new ListTunnelDestGroupsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setTunnelDestGroups($tunnelDestGroups); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $client->tunnelLocationName('[PROJECT]', '[LOCATION]'); + $response = $client->listTunnelDestGroups($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getTunnelDestGroups()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.iap.v1.IdentityAwareProxyAdminService/ListTunnelDestGroups', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listTunnelDestGroupsExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 = $client->tunnelLocationName('[PROJECT]', '[LOCATION]'); + try { + $client->listTunnelDestGroups($formattedParent); + // If the $client 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 */ @@ -401,4 +678,72 @@ public function updateIapSettingsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** + * @test + */ + public function updateTunnelDestGroupTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $expectedResponse = new TunnelDestGroup(); + $expectedResponse->setName($name); + $transport->addResponse($expectedResponse); + // Mock request + $tunnelDestGroup = new TunnelDestGroup(); + $tunnelDestGroupName = 'tunnelDestGroupName1906281888'; + $tunnelDestGroup->setName($tunnelDestGroupName); + $response = $client->updateTunnelDestGroup($tunnelDestGroup); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.iap.v1.IdentityAwareProxyAdminService/UpdateTunnelDestGroup', $actualFuncCall); + $actualValue = $actualRequestObject->getTunnelDestGroup(); + $this->assertProtobufEquals($tunnelDestGroup, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function updateTunnelDestGroupExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 + $tunnelDestGroup = new TunnelDestGroup(); + $tunnelDestGroupName = 'tunnelDestGroupName1906281888'; + $tunnelDestGroup->setName($tunnelDestGroupName); + try { + $client->updateTunnelDestGroup($tunnelDestGroup); + // If the $client 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()); + } }