From 69cc5ae4f738e4e48415a7546f5c20b0945f107c Mon Sep 17 00:00:00 2001 From: affinidibot Date: Wed, 18 Dec 2024 18:28:05 +0100 Subject: [PATCH 1/2] feat: update client iam --- README.md | 7 +- .../IamClient/.openapi-generator/FILES | 8 +- src/Clients/IamClient/README.md | 2 +- src/Clients/IamClient/docs/Api/ProjectsApi.md | 22 +- src/Clients/IamClient/docs/Api/TokensApi.md | 19 +- .../IamClient/docs/Model/ProjectList.md | 1 + src/Clients/IamClient/docs/Model/TokenList.md | 1 + .../IamClient/docs/Model/TypedPrincipalId.md | 9 + src/Clients/IamClient/docs/Model/UserList.md | 1 + .../IamClient/lib/Api/ConsumerAuthApi.php | 25 +- src/Clients/IamClient/lib/Api/DefaultApi.php | 151 ++++++- src/Clients/IamClient/lib/Api/PoliciesApi.php | 39 +- src/Clients/IamClient/lib/Api/ProjectsApi.php | 209 ++++++++- src/Clients/IamClient/lib/Api/StsApi.php | 39 +- src/Clients/IamClient/lib/Api/TokensApi.php | 195 +++++++-- .../IamClient/lib/Api/WellKnownApi.php | 39 +- .../IamClient/lib/InvalidJwtTokenError.php | 80 ++++ .../IamClient/lib/InvalidParameterError.php | 75 ++++ .../IamClient/lib/Model/ProjectList.php | 46 +- src/Clients/IamClient/lib/Model/TokenList.php | 46 +- .../IamClient/lib/Model/TypedPrincipalId.php | 413 ++++++++++++++++++ src/Clients/IamClient/lib/Model/UserList.php | 46 +- src/Clients/IamClient/lib/NotFoundError.php | 73 ++++ .../test/Model/TypedPrincipalIdTest.php | 91 ++++ 24 files changed, 1530 insertions(+), 107 deletions(-) create mode 100644 src/Clients/IamClient/docs/Model/TypedPrincipalId.md create mode 100644 src/Clients/IamClient/lib/InvalidJwtTokenError.php create mode 100644 src/Clients/IamClient/lib/InvalidParameterError.php create mode 100644 src/Clients/IamClient/lib/Model/TypedPrincipalId.php create mode 100644 src/Clients/IamClient/lib/NotFoundError.php create mode 100644 src/Clients/IamClient/test/Model/TypedPrincipalIdTest.php diff --git a/README.md b/README.md index ab31b11..4edca5a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,9 @@ -# Affinidi Trust Development Kit (Affinidi TDK) + + + + + +\# Affinidi Trust Development Kit (Affinidi TDK) [![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors-) diff --git a/src/Clients/IamClient/.openapi-generator/FILES b/src/Clients/IamClient/.openapi-generator/FILES index 87fbecc..5428dc3 100644 --- a/src/Clients/IamClient/.openapi-generator/FILES +++ b/src/Clients/IamClient/.openapi-generator/FILES @@ -42,7 +42,7 @@ docs/Model/TokenPrivateKeyAuthenticationMethodDto.md docs/Model/TokenPrivateKeyAuthenticationMethodDtoPublicKeyInfo.md docs/Model/TokenPrivateKeyAuthenticationMethodDtoPublicKeyInfoOneOf.md docs/Model/TokenPrivateKeyAuthenticationMethodDtoPublicKeyInfoOneOf1.md -docs/Model/TypedPricipalId.md +docs/Model/TypedPrincipalId.md docs/Model/UnauthorizedError.md docs/Model/UnexpectedError.md docs/Model/UpdateProjectInput.md @@ -61,6 +61,8 @@ lib/Api/WellKnownApi.php lib/ApiException.php lib/Configuration.php lib/HeaderSelector.php +lib/InvalidJwtTokenError.php +lib/InvalidParameterError.php lib/Model/ActionForbiddenError.php lib/Model/AddUserToProjectInput.php lib/Model/ConsumerAuthTokenEndpointInput.php @@ -96,7 +98,7 @@ lib/Model/TokenPrivateKeyAuthenticationMethodDto.php lib/Model/TokenPrivateKeyAuthenticationMethodDtoPublicKeyInfo.php lib/Model/TokenPrivateKeyAuthenticationMethodDtoPublicKeyInfoOneOf.php lib/Model/TokenPrivateKeyAuthenticationMethodDtoPublicKeyInfoOneOf1.php -lib/Model/TypedPricipalId.php +lib/Model/TypedPrincipalId.php lib/Model/UnauthorizedError.php lib/Model/UnexpectedError.php lib/Model/UpdateProjectInput.php @@ -105,5 +107,7 @@ lib/Model/UpdateTokenPrivateKeyAuthenticationMethodDto.php lib/Model/UserDto.php lib/Model/UserList.php lib/Model/WhoamiDto.php +lib/NotFoundError.php lib/ObjectSerializer.php phpunit.xml.dist +test/Model/TypedPrincipalIdTest.php diff --git a/src/Clients/IamClient/README.md b/src/Clients/IamClient/README.md index 1902c12..6800fff 100644 --- a/src/Clients/IamClient/README.md +++ b/src/Clients/IamClient/README.md @@ -126,7 +126,7 @@ Class | Method | HTTP request | Description - [TokenPrivateKeyAuthenticationMethodDtoPublicKeyInfo](docs/Model/TokenPrivateKeyAuthenticationMethodDtoPublicKeyInfo.md) - [TokenPrivateKeyAuthenticationMethodDtoPublicKeyInfoOneOf](docs/Model/TokenPrivateKeyAuthenticationMethodDtoPublicKeyInfoOneOf.md) - [TokenPrivateKeyAuthenticationMethodDtoPublicKeyInfoOneOf1](docs/Model/TokenPrivateKeyAuthenticationMethodDtoPublicKeyInfoOneOf1.md) -- [TypedPricipalId](docs/Model/TypedPricipalId.md) +- [TypedPrincipalId](docs/Model/TypedPrincipalId.md) - [UnauthorizedError](docs/Model/UnauthorizedError.md) - [UnexpectedError](docs/Model/UnexpectedError.md) - [UpdateProjectInput](docs/Model/UpdateProjectInput.md) diff --git a/src/Clients/IamClient/docs/Api/ProjectsApi.md b/src/Clients/IamClient/docs/Api/ProjectsApi.md index 53f5a86..d04331f 100644 --- a/src/Clients/IamClient/docs/Api/ProjectsApi.md +++ b/src/Clients/IamClient/docs/Api/ProjectsApi.md @@ -195,7 +195,7 @@ void (empty response body) ## `listPrincipalsOfProject()` ```php -listPrincipalsOfProject(): \AffinidiTdk\Clients\IamClient\Model\UserList +listPrincipalsOfProject($limit, $exclusive_start_key): \AffinidiTdk\Clients\IamClient\Model\UserList ``` @@ -219,9 +219,11 @@ $apiInstance = new AffinidiTdk\Clients\IamClient\Api\ProjectsApi( new GuzzleHttp\Client(), $config ); +$limit = 100; // int | Maximum number of records to fetch in a list +$exclusive_start_key = 'exclusive_start_key_example'; // string | The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. try { - $result = $apiInstance->listPrincipalsOfProject(); + $result = $apiInstance->listPrincipalsOfProject($limit, $exclusive_start_key); print_r($result); } catch (Exception $e) { echo 'Exception when calling ProjectsApi->listPrincipalsOfProject: ', $e->getMessage(), PHP_EOL; @@ -230,7 +232,10 @@ try { ### Parameters -This endpoint does not need any parameter. +| Name | Type | Description | Notes | +| ------------- | ------------- | ------------- | ------------- | +| **limit** | **int**| Maximum number of records to fetch in a list | [optional] [default to 100] | +| **exclusive_start_key** | **string**| The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. | [optional] | ### Return type @@ -252,7 +257,7 @@ This endpoint does not need any parameter. ## `listProject()` ```php -listProject(): \AffinidiTdk\Clients\IamClient\Model\ProjectList +listProject($limit, $exclusive_start_key): \AffinidiTdk\Clients\IamClient\Model\ProjectList ``` @@ -276,9 +281,11 @@ $apiInstance = new AffinidiTdk\Clients\IamClient\Api\ProjectsApi( new GuzzleHttp\Client(), $config ); +$limit = 100; // int | Maximum number of records to fetch in a list +$exclusive_start_key = 'exclusive_start_key_example'; // string | The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. try { - $result = $apiInstance->listProject(); + $result = $apiInstance->listProject($limit, $exclusive_start_key); print_r($result); } catch (Exception $e) { echo 'Exception when calling ProjectsApi->listProject: ', $e->getMessage(), PHP_EOL; @@ -287,7 +294,10 @@ try { ### Parameters -This endpoint does not need any parameter. +| Name | Type | Description | Notes | +| ------------- | ------------- | ------------- | ------------- | +| **limit** | **int**| Maximum number of records to fetch in a list | [optional] [default to 100] | +| **exclusive_start_key** | **string**| The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. | [optional] | ### Return type diff --git a/src/Clients/IamClient/docs/Api/TokensApi.md b/src/Clients/IamClient/docs/Api/TokensApi.md index 56ebbab..2b0770f 100644 --- a/src/Clients/IamClient/docs/Api/TokensApi.md +++ b/src/Clients/IamClient/docs/Api/TokensApi.md @@ -219,8 +219,8 @@ $apiInstance = new AffinidiTdk\Clients\IamClient\Api\TokensApi( $config ); $token_id = 'token_id_example'; // string -$limit = 56; // int | Maximum number of records to fetch in a list -$exclusive_start_key = 'exclusive_start_key_example'; // string | exclusiveStartKey for retrieving the next batch of data. +$limit = 100; // int | Maximum number of records to fetch in a list +$exclusive_start_key = 'exclusive_start_key_example'; // string | The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. try { $result = $apiInstance->listProjectsOfToken($token_id, $limit, $exclusive_start_key); @@ -235,8 +235,8 @@ try { | Name | Type | Description | Notes | | ------------- | ------------- | ------------- | ------------- | | **token_id** | **string**| | | -| **limit** | **int**| Maximum number of records to fetch in a list | [optional] | -| **exclusive_start_key** | **string**| exclusiveStartKey for retrieving the next batch of data. | [optional] | +| **limit** | **int**| Maximum number of records to fetch in a list | [optional] [default to 100] | +| **exclusive_start_key** | **string**| The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. | [optional] | ### Return type @@ -258,7 +258,7 @@ try { ## `listToken()` ```php -listToken(): \AffinidiTdk\Clients\IamClient\Model\TokenList +listToken($limit, $exclusive_start_key): \AffinidiTdk\Clients\IamClient\Model\TokenList ``` @@ -282,9 +282,11 @@ $apiInstance = new AffinidiTdk\Clients\IamClient\Api\TokensApi( new GuzzleHttp\Client(), $config ); +$limit = 100; // int | Maximum number of records to fetch in a list +$exclusive_start_key = 'exclusive_start_key_example'; // string | The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. try { - $result = $apiInstance->listToken(); + $result = $apiInstance->listToken($limit, $exclusive_start_key); print_r($result); } catch (Exception $e) { echo 'Exception when calling TokensApi->listToken: ', $e->getMessage(), PHP_EOL; @@ -293,7 +295,10 @@ try { ### Parameters -This endpoint does not need any parameter. +| Name | Type | Description | Notes | +| ------------- | ------------- | ------------- | ------------- | +| **limit** | **int**| Maximum number of records to fetch in a list | [optional] [default to 100] | +| **exclusive_start_key** | **string**| The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. | [optional] | ### Return type diff --git a/src/Clients/IamClient/docs/Model/ProjectList.md b/src/Clients/IamClient/docs/Model/ProjectList.md index 8d24e8b..74fc5be 100644 --- a/src/Clients/IamClient/docs/Model/ProjectList.md +++ b/src/Clients/IamClient/docs/Model/ProjectList.md @@ -5,5 +5,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **projects** | [**\AffinidiTdk\Clients\IamClient\Model\ProjectDto[]**](ProjectDto.md) | | +**last_evaluated_key** | **string** | | [optional] [[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/src/Clients/IamClient/docs/Model/TokenList.md b/src/Clients/IamClient/docs/Model/TokenList.md index 4d6e1bd..77b85c2 100644 --- a/src/Clients/IamClient/docs/Model/TokenList.md +++ b/src/Clients/IamClient/docs/Model/TokenList.md @@ -5,5 +5,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **tokens** | [**\AffinidiTdk\Clients\IamClient\Model\TokenDto[]**](TokenDto.md) | | +**last_evaluated_key** | **string** | | [optional] [[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/src/Clients/IamClient/docs/Model/TypedPrincipalId.md b/src/Clients/IamClient/docs/Model/TypedPrincipalId.md new file mode 100644 index 0000000..0174103 --- /dev/null +++ b/src/Clients/IamClient/docs/Model/TypedPrincipalId.md @@ -0,0 +1,9 @@ +# # TypedPrincipalId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**principal_id** | **string** | | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/src/Clients/IamClient/docs/Model/UserList.md b/src/Clients/IamClient/docs/Model/UserList.md index fc88cd1..9e11db4 100644 --- a/src/Clients/IamClient/docs/Model/UserList.md +++ b/src/Clients/IamClient/docs/Model/UserList.md @@ -5,5 +5,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **records** | [**\AffinidiTdk\Clients\IamClient\Model\UserDto[]**](UserDto.md) | | +**last_evaluated_key** | **string** | | [optional] [[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/src/Clients/IamClient/lib/Api/ConsumerAuthApi.php b/src/Clients/IamClient/lib/Api/ConsumerAuthApi.php index ca70a9b..2567427 100644 --- a/src/Clients/IamClient/lib/Api/ConsumerAuthApi.php +++ b/src/Clients/IamClient/lib/Api/ConsumerAuthApi.php @@ -36,6 +36,9 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use AffinidiTdk\Clients\IamClient\ApiException; +use AffinidiTdk\Clients\IamClient\InvalidJwtTokenError; +use AffinidiTdk\Clients\IamClient\InvalidParameterError; +use AffinidiTdk\Clients\IamClient\NotFoundError; use AffinidiTdk\Clients\IamClient\Configuration; use AffinidiTdk\Clients\IamClient\HeaderSelector; use AffinidiTdk\Clients\IamClient\ObjectSerializer; @@ -84,10 +87,10 @@ class ConsumerAuthApi * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: Configuration::getDefaultConfiguration(); @@ -162,6 +165,20 @@ public function consumerAuthTokenEndpointWithHttpInfo($consumer_auth_token_endpo try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), diff --git a/src/Clients/IamClient/lib/Api/DefaultApi.php b/src/Clients/IamClient/lib/Api/DefaultApi.php index b400ffd..6666e2c 100644 --- a/src/Clients/IamClient/lib/Api/DefaultApi.php +++ b/src/Clients/IamClient/lib/Api/DefaultApi.php @@ -36,6 +36,9 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use AffinidiTdk\Clients\IamClient\ApiException; +use AffinidiTdk\Clients\IamClient\InvalidJwtTokenError; +use AffinidiTdk\Clients\IamClient\InvalidParameterError; +use AffinidiTdk\Clients\IamClient\NotFoundError; use AffinidiTdk\Clients\IamClient\Configuration; use AffinidiTdk\Clients\IamClient\HeaderSelector; use AffinidiTdk\Clients\IamClient\ObjectSerializer; @@ -111,10 +114,10 @@ class DefaultApi * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: Configuration::getDefaultConfiguration(); @@ -184,6 +187,20 @@ public function v1AuthProxyDeleteWithHttpInfo($proxy, string $contentType = self try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -393,6 +410,20 @@ public function v1AuthProxyGetWithHttpInfo($proxy, string $contentType = self::c try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -602,6 +633,20 @@ public function v1AuthProxyPatchWithHttpInfo($proxy, string $contentType = self: try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -811,6 +856,20 @@ public function v1AuthProxyPostWithHttpInfo($proxy, string $contentType = self:: try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1020,6 +1079,20 @@ public function v1AuthProxyPutWithHttpInfo($proxy, string $contentType = self::c try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1229,6 +1302,20 @@ public function v1IdpProxyDeleteWithHttpInfo($proxy, string $contentType = self: try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1438,6 +1525,20 @@ public function v1IdpProxyGetWithHttpInfo($proxy, string $contentType = self::co try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1647,6 +1748,20 @@ public function v1IdpProxyPatchWithHttpInfo($proxy, string $contentType = self:: try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1856,6 +1971,20 @@ public function v1IdpProxyPostWithHttpInfo($proxy, string $contentType = self::c try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -2065,6 +2194,20 @@ public function v1IdpProxyPutWithHttpInfo($proxy, string $contentType = self::co try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), diff --git a/src/Clients/IamClient/lib/Api/PoliciesApi.php b/src/Clients/IamClient/lib/Api/PoliciesApi.php index c961da4..71d0a3d 100644 --- a/src/Clients/IamClient/lib/Api/PoliciesApi.php +++ b/src/Clients/IamClient/lib/Api/PoliciesApi.php @@ -36,6 +36,9 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use AffinidiTdk\Clients\IamClient\ApiException; +use AffinidiTdk\Clients\IamClient\InvalidJwtTokenError; +use AffinidiTdk\Clients\IamClient\InvalidParameterError; +use AffinidiTdk\Clients\IamClient\NotFoundError; use AffinidiTdk\Clients\IamClient\Configuration; use AffinidiTdk\Clients\IamClient\HeaderSelector; use AffinidiTdk\Clients\IamClient\ObjectSerializer; @@ -87,10 +90,10 @@ class PoliciesApi * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: Configuration::getDefaultConfiguration(); @@ -163,6 +166,20 @@ public function getPoliciesWithHttpInfo($principal_id, $principal_type, string $ try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -596,6 +613,20 @@ public function updatePoliciesWithHttpInfo($principal_id, $principal_type, $poli try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), diff --git a/src/Clients/IamClient/lib/Api/ProjectsApi.php b/src/Clients/IamClient/lib/Api/ProjectsApi.php index 9c1c07d..45be9ba 100644 --- a/src/Clients/IamClient/lib/Api/ProjectsApi.php +++ b/src/Clients/IamClient/lib/Api/ProjectsApi.php @@ -36,6 +36,9 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use AffinidiTdk\Clients\IamClient\ApiException; +use AffinidiTdk\Clients\IamClient\InvalidJwtTokenError; +use AffinidiTdk\Clients\IamClient\InvalidParameterError; +use AffinidiTdk\Clients\IamClient\NotFoundError; use AffinidiTdk\Clients\IamClient\Configuration; use AffinidiTdk\Clients\IamClient\HeaderSelector; use AffinidiTdk\Clients\IamClient\ObjectSerializer; @@ -99,10 +102,10 @@ class ProjectsApi * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: Configuration::getDefaultConfiguration(); @@ -172,6 +175,20 @@ public function addPrincipalToProjectWithHttpInfo($add_user_to_project_input, st try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -410,6 +427,20 @@ public function createProjectWithHttpInfo($create_project_input, string $content try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -785,6 +816,20 @@ public function deletePrincipalFromProjectWithHttpInfo($principal_id, $principal try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1027,36 +1072,54 @@ public function deletePrincipalFromProjectRequest($principal_id, $principal_type /** * Operation listPrincipalsOfProject * + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listPrincipalsOfProject'] to see the possible values for this operation * * @throws \AffinidiTdk\Clients\IamClient\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \AffinidiTdk\Clients\IamClient\Model\UserList|\AffinidiTdk\Clients\IamClient\Model\InvalidParameterError|\AffinidiTdk\Clients\IamClient\Model\ActionForbiddenError|\AffinidiTdk\Clients\IamClient\Model\UnexpectedError */ - public function listPrincipalsOfProject(string $contentType = self::contentTypes['listPrincipalsOfProject'][0]) + public function listPrincipalsOfProject($limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listPrincipalsOfProject'][0]) { - list($response) = $this->listPrincipalsOfProjectWithHttpInfo($contentType); + list($response) = $this->listPrincipalsOfProjectWithHttpInfo($limit, $exclusive_start_key, $contentType); return $response; } /** * Operation listPrincipalsOfProjectWithHttpInfo * + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listPrincipalsOfProject'] to see the possible values for this operation * * @throws \AffinidiTdk\Clients\IamClient\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \AffinidiTdk\Clients\IamClient\Model\UserList|\AffinidiTdk\Clients\IamClient\Model\InvalidParameterError|\AffinidiTdk\Clients\IamClient\Model\ActionForbiddenError|\AffinidiTdk\Clients\IamClient\Model\UnexpectedError, HTTP status code, HTTP response headers (array of strings) */ - public function listPrincipalsOfProjectWithHttpInfo(string $contentType = self::contentTypes['listPrincipalsOfProject'][0]) + public function listPrincipalsOfProjectWithHttpInfo($limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listPrincipalsOfProject'][0]) { - $request = $this->listPrincipalsOfProjectRequest($contentType); + $request = $this->listPrincipalsOfProjectRequest($limit, $exclusive_start_key, $contentType); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1269,14 +1332,16 @@ public function listPrincipalsOfProjectWithHttpInfo(string $contentType = self:: /** * Operation listPrincipalsOfProjectAsync * + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listPrincipalsOfProject'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function listPrincipalsOfProjectAsync(string $contentType = self::contentTypes['listPrincipalsOfProject'][0]) + public function listPrincipalsOfProjectAsync($limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listPrincipalsOfProject'][0]) { - return $this->listPrincipalsOfProjectAsyncWithHttpInfo($contentType) + return $this->listPrincipalsOfProjectAsyncWithHttpInfo($limit, $exclusive_start_key, $contentType) ->then( function ($response) { return $response[0]; @@ -1287,15 +1352,17 @@ function ($response) { /** * Operation listPrincipalsOfProjectAsyncWithHttpInfo * + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listPrincipalsOfProject'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function listPrincipalsOfProjectAsyncWithHttpInfo(string $contentType = self::contentTypes['listPrincipalsOfProject'][0]) + public function listPrincipalsOfProjectAsyncWithHttpInfo($limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listPrincipalsOfProject'][0]) { $returnType = '\AffinidiTdk\Clients\IamClient\Model\UserList'; - $request = $this->listPrincipalsOfProjectRequest($contentType); + $request = $this->listPrincipalsOfProjectRequest($limit, $exclusive_start_key, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1336,14 +1403,27 @@ function ($exception) { /** * Create request for operation 'listPrincipalsOfProject' * + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listPrincipalsOfProject'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function listPrincipalsOfProjectRequest(string $contentType = self::contentTypes['listPrincipalsOfProject'][0]) + public function listPrincipalsOfProjectRequest($limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listPrincipalsOfProject'][0]) { + if ($limit !== null && $limit > 100) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling ProjectsApi.listPrincipalsOfProject, must be smaller than or equal to 100.'); + } + if ($limit !== null && $limit < 1) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling ProjectsApi.listPrincipalsOfProject, must be bigger than or equal to 1.'); + } + + if ($exclusive_start_key !== null && strlen($exclusive_start_key) > 3000) { + throw new \InvalidArgumentException('invalid length for "$exclusive_start_key" when calling ProjectsApi.listPrincipalsOfProject, must be smaller than or equal to 3000.'); + } + $resourcePath = '/v1/projects/principals'; $formParams = []; @@ -1352,6 +1432,24 @@ public function listPrincipalsOfProjectRequest(string $contentType = self::conte $httpBody = ''; $multipart = false; + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $exclusive_start_key, + 'exclusiveStartKey', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); @@ -1417,36 +1515,54 @@ public function listPrincipalsOfProjectRequest(string $contentType = self::conte /** * Operation listProject * + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listProject'] to see the possible values for this operation * * @throws \AffinidiTdk\Clients\IamClient\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \AffinidiTdk\Clients\IamClient\Model\ProjectList|\AffinidiTdk\Clients\IamClient\Model\UnexpectedError */ - public function listProject(string $contentType = self::contentTypes['listProject'][0]) + public function listProject($limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listProject'][0]) { - list($response) = $this->listProjectWithHttpInfo($contentType); + list($response) = $this->listProjectWithHttpInfo($limit, $exclusive_start_key, $contentType); return $response; } /** * Operation listProjectWithHttpInfo * + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listProject'] to see the possible values for this operation * * @throws \AffinidiTdk\Clients\IamClient\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \AffinidiTdk\Clients\IamClient\Model\ProjectList|\AffinidiTdk\Clients\IamClient\Model\UnexpectedError, HTTP status code, HTTP response headers (array of strings) */ - public function listProjectWithHttpInfo(string $contentType = self::contentTypes['listProject'][0]) + public function listProjectWithHttpInfo($limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listProject'][0]) { - $request = $this->listProjectRequest($contentType); + $request = $this->listProjectRequest($limit, $exclusive_start_key, $contentType); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1589,14 +1705,16 @@ public function listProjectWithHttpInfo(string $contentType = self::contentTypes /** * Operation listProjectAsync * + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listProject'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function listProjectAsync(string $contentType = self::contentTypes['listProject'][0]) + public function listProjectAsync($limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listProject'][0]) { - return $this->listProjectAsyncWithHttpInfo($contentType) + return $this->listProjectAsyncWithHttpInfo($limit, $exclusive_start_key, $contentType) ->then( function ($response) { return $response[0]; @@ -1607,15 +1725,17 @@ function ($response) { /** * Operation listProjectAsyncWithHttpInfo * + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listProject'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function listProjectAsyncWithHttpInfo(string $contentType = self::contentTypes['listProject'][0]) + public function listProjectAsyncWithHttpInfo($limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listProject'][0]) { $returnType = '\AffinidiTdk\Clients\IamClient\Model\ProjectList'; - $request = $this->listProjectRequest($contentType); + $request = $this->listProjectRequest($limit, $exclusive_start_key, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1656,14 +1776,27 @@ function ($exception) { /** * Create request for operation 'listProject' * + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listProject'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function listProjectRequest(string $contentType = self::contentTypes['listProject'][0]) + public function listProjectRequest($limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listProject'][0]) { + if ($limit !== null && $limit > 100) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling ProjectsApi.listProject, must be smaller than or equal to 100.'); + } + if ($limit !== null && $limit < 1) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling ProjectsApi.listProject, must be bigger than or equal to 1.'); + } + + if ($exclusive_start_key !== null && strlen($exclusive_start_key) > 3000) { + throw new \InvalidArgumentException('invalid length for "$exclusive_start_key" when calling ProjectsApi.listProject, must be smaller than or equal to 3000.'); + } + $resourcePath = '/v1/projects'; $formParams = []; @@ -1672,6 +1805,24 @@ public function listProjectRequest(string $contentType = self::contentTypes['lis $httpBody = ''; $multipart = false; + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $exclusive_start_key, + 'exclusiveStartKey', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); @@ -1771,6 +1922,20 @@ public function updateProjectWithHttpInfo($project_id, $update_project_input, st try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), diff --git a/src/Clients/IamClient/lib/Api/StsApi.php b/src/Clients/IamClient/lib/Api/StsApi.php index 3472064..7b86086 100644 --- a/src/Clients/IamClient/lib/Api/StsApi.php +++ b/src/Clients/IamClient/lib/Api/StsApi.php @@ -36,6 +36,9 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use AffinidiTdk\Clients\IamClient\ApiException; +use AffinidiTdk\Clients\IamClient\InvalidJwtTokenError; +use AffinidiTdk\Clients\IamClient\InvalidParameterError; +use AffinidiTdk\Clients\IamClient\NotFoundError; use AffinidiTdk\Clients\IamClient\Configuration; use AffinidiTdk\Clients\IamClient\HeaderSelector; use AffinidiTdk\Clients\IamClient\ObjectSerializer; @@ -87,10 +90,10 @@ class StsApi * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: Configuration::getDefaultConfiguration(); @@ -161,6 +164,20 @@ public function createProjectScopedTokenWithHttpInfo($create_project_scoped_toke try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -568,6 +585,20 @@ public function whoamiWithHttpInfo(string $contentType = self::contentTypes['who try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), diff --git a/src/Clients/IamClient/lib/Api/TokensApi.php b/src/Clients/IamClient/lib/Api/TokensApi.php index 6b31912..9ac9769 100644 --- a/src/Clients/IamClient/lib/Api/TokensApi.php +++ b/src/Clients/IamClient/lib/Api/TokensApi.php @@ -36,6 +36,9 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use AffinidiTdk\Clients\IamClient\ApiException; +use AffinidiTdk\Clients\IamClient\InvalidJwtTokenError; +use AffinidiTdk\Clients\IamClient\InvalidParameterError; +use AffinidiTdk\Clients\IamClient\NotFoundError; use AffinidiTdk\Clients\IamClient\Configuration; use AffinidiTdk\Clients\IamClient\HeaderSelector; use AffinidiTdk\Clients\IamClient\ObjectSerializer; @@ -99,10 +102,10 @@ class TokensApi * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: Configuration::getDefaultConfiguration(); @@ -173,6 +176,20 @@ public function createTokenWithHttpInfo($create_token_input, string $contentType try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -546,6 +563,20 @@ public function deleteTokenWithHttpInfo($token_id, string $contentType = self::c try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -785,6 +816,20 @@ public function getTokenWithHttpInfo($token_id, string $contentType = self::cont try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1164,15 +1209,15 @@ public function getTokenRequest($token_id, string $contentType = self::contentTy * Operation listProjectsOfToken * * @param string $token_id token_id (required) - * @param int $limit Maximum number of records to fetch in a list (optional) - * @param string $exclusive_start_key exclusiveStartKey for retrieving the next batch of data. (optional) + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listProjectsOfToken'] to see the possible values for this operation * * @throws \AffinidiTdk\Clients\IamClient\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \AffinidiTdk\Clients\IamClient\Model\ProjectWithPolicyList|\AffinidiTdk\Clients\IamClient\Model\ActionForbiddenError|\AffinidiTdk\Clients\IamClient\Model\NotFoundError|\AffinidiTdk\Clients\IamClient\Model\UnexpectedError */ - public function listProjectsOfToken($token_id, $limit = null, $exclusive_start_key = null, string $contentType = self::contentTypes['listProjectsOfToken'][0]) + public function listProjectsOfToken($token_id, $limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listProjectsOfToken'][0]) { list($response) = $this->listProjectsOfTokenWithHttpInfo($token_id, $limit, $exclusive_start_key, $contentType); return $response; @@ -1182,15 +1227,15 @@ public function listProjectsOfToken($token_id, $limit = null, $exclusive_start_k * Operation listProjectsOfTokenWithHttpInfo * * @param string $token_id (required) - * @param int $limit Maximum number of records to fetch in a list (optional) - * @param string $exclusive_start_key exclusiveStartKey for retrieving the next batch of data. (optional) + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listProjectsOfToken'] to see the possible values for this operation * * @throws \AffinidiTdk\Clients\IamClient\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \AffinidiTdk\Clients\IamClient\Model\ProjectWithPolicyList|\AffinidiTdk\Clients\IamClient\Model\ActionForbiddenError|\AffinidiTdk\Clients\IamClient\Model\NotFoundError|\AffinidiTdk\Clients\IamClient\Model\UnexpectedError, HTTP status code, HTTP response headers (array of strings) */ - public function listProjectsOfTokenWithHttpInfo($token_id, $limit = null, $exclusive_start_key = null, string $contentType = self::contentTypes['listProjectsOfToken'][0]) + public function listProjectsOfTokenWithHttpInfo($token_id, $limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listProjectsOfToken'][0]) { $request = $this->listProjectsOfTokenRequest($token_id, $limit, $exclusive_start_key, $contentType); @@ -1199,6 +1244,20 @@ public function listProjectsOfTokenWithHttpInfo($token_id, $limit = null, $exclu try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1412,14 +1471,14 @@ public function listProjectsOfTokenWithHttpInfo($token_id, $limit = null, $exclu * Operation listProjectsOfTokenAsync * * @param string $token_id (required) - * @param int $limit Maximum number of records to fetch in a list (optional) - * @param string $exclusive_start_key exclusiveStartKey for retrieving the next batch of data. (optional) + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listProjectsOfToken'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function listProjectsOfTokenAsync($token_id, $limit = null, $exclusive_start_key = null, string $contentType = self::contentTypes['listProjectsOfToken'][0]) + public function listProjectsOfTokenAsync($token_id, $limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listProjectsOfToken'][0]) { return $this->listProjectsOfTokenAsyncWithHttpInfo($token_id, $limit, $exclusive_start_key, $contentType) ->then( @@ -1433,14 +1492,14 @@ function ($response) { * Operation listProjectsOfTokenAsyncWithHttpInfo * * @param string $token_id (required) - * @param int $limit Maximum number of records to fetch in a list (optional) - * @param string $exclusive_start_key exclusiveStartKey for retrieving the next batch of data. (optional) + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listProjectsOfToken'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function listProjectsOfTokenAsyncWithHttpInfo($token_id, $limit = null, $exclusive_start_key = null, string $contentType = self::contentTypes['listProjectsOfToken'][0]) + public function listProjectsOfTokenAsyncWithHttpInfo($token_id, $limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listProjectsOfToken'][0]) { $returnType = '\AffinidiTdk\Clients\IamClient\Model\ProjectWithPolicyList'; $request = $this->listProjectsOfTokenRequest($token_id, $limit, $exclusive_start_key, $contentType); @@ -1485,14 +1544,14 @@ function ($exception) { * Create request for operation 'listProjectsOfToken' * * @param string $token_id (required) - * @param int $limit Maximum number of records to fetch in a list (optional) - * @param string $exclusive_start_key exclusiveStartKey for retrieving the next batch of data. (optional) + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listProjectsOfToken'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function listProjectsOfTokenRequest($token_id, $limit = null, $exclusive_start_key = null, string $contentType = self::contentTypes['listProjectsOfToken'][0]) + public function listProjectsOfTokenRequest($token_id, $limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listProjectsOfToken'][0]) { // verify the required parameter 'token_id' is set @@ -1502,8 +1561,17 @@ public function listProjectsOfTokenRequest($token_id, $limit = null, $exclusive_ ); } - - + if ($limit !== null && $limit > 100) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling TokensApi.listProjectsOfToken, must be smaller than or equal to 100.'); + } + if ($limit !== null && $limit < 1) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling TokensApi.listProjectsOfToken, must be bigger than or equal to 1.'); + } + + if ($exclusive_start_key !== null && strlen($exclusive_start_key) > 3000) { + throw new \InvalidArgumentException('invalid length for "$exclusive_start_key" when calling TokensApi.listProjectsOfToken, must be smaller than or equal to 3000.'); + } + $resourcePath = '/v1/tokens/{tokenId}/projects'; $formParams = []; @@ -1603,36 +1671,54 @@ public function listProjectsOfTokenRequest($token_id, $limit = null, $exclusive_ /** * Operation listToken * + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listToken'] to see the possible values for this operation * * @throws \AffinidiTdk\Clients\IamClient\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \AffinidiTdk\Clients\IamClient\Model\TokenList|\AffinidiTdk\Clients\IamClient\Model\InvalidParameterError|\AffinidiTdk\Clients\IamClient\Model\UnexpectedError */ - public function listToken(string $contentType = self::contentTypes['listToken'][0]) + public function listToken($limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listToken'][0]) { - list($response) = $this->listTokenWithHttpInfo($contentType); + list($response) = $this->listTokenWithHttpInfo($limit, $exclusive_start_key, $contentType); return $response; } /** * Operation listTokenWithHttpInfo * + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listToken'] to see the possible values for this operation * * @throws \AffinidiTdk\Clients\IamClient\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \AffinidiTdk\Clients\IamClient\Model\TokenList|\AffinidiTdk\Clients\IamClient\Model\InvalidParameterError|\AffinidiTdk\Clients\IamClient\Model\UnexpectedError, HTTP status code, HTTP response headers (array of strings) */ - public function listTokenWithHttpInfo(string $contentType = self::contentTypes['listToken'][0]) + public function listTokenWithHttpInfo($limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listToken'][0]) { - $request = $this->listTokenRequest($contentType); + $request = $this->listTokenRequest($limit, $exclusive_start_key, $contentType); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1810,14 +1896,16 @@ public function listTokenWithHttpInfo(string $contentType = self::contentTypes[' /** * Operation listTokenAsync * + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listToken'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function listTokenAsync(string $contentType = self::contentTypes['listToken'][0]) + public function listTokenAsync($limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listToken'][0]) { - return $this->listTokenAsyncWithHttpInfo($contentType) + return $this->listTokenAsyncWithHttpInfo($limit, $exclusive_start_key, $contentType) ->then( function ($response) { return $response[0]; @@ -1828,15 +1916,17 @@ function ($response) { /** * Operation listTokenAsyncWithHttpInfo * + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listToken'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function listTokenAsyncWithHttpInfo(string $contentType = self::contentTypes['listToken'][0]) + public function listTokenAsyncWithHttpInfo($limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listToken'][0]) { $returnType = '\AffinidiTdk\Clients\IamClient\Model\TokenList'; - $request = $this->listTokenRequest($contentType); + $request = $this->listTokenRequest($limit, $exclusive_start_key, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1877,14 +1967,27 @@ function ($exception) { /** * Create request for operation 'listToken' * + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 100) + * @param string|null $exclusive_start_key The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listToken'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function listTokenRequest(string $contentType = self::contentTypes['listToken'][0]) + public function listTokenRequest($limit = 100, $exclusive_start_key = null, string $contentType = self::contentTypes['listToken'][0]) { + if ($limit !== null && $limit > 100) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling TokensApi.listToken, must be smaller than or equal to 100.'); + } + if ($limit !== null && $limit < 1) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling TokensApi.listToken, must be bigger than or equal to 1.'); + } + + if ($exclusive_start_key !== null && strlen($exclusive_start_key) > 3000) { + throw new \InvalidArgumentException('invalid length for "$exclusive_start_key" when calling TokensApi.listToken, must be smaller than or equal to 3000.'); + } + $resourcePath = '/v1/tokens'; $formParams = []; @@ -1893,6 +1996,24 @@ public function listTokenRequest(string $contentType = self::contentTypes['listT $httpBody = ''; $multipart = false; + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $exclusive_start_key, + 'exclusiveStartKey', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); @@ -1992,6 +2113,20 @@ public function updateTokenWithHttpInfo($token_id, $update_token_input, string $ try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), diff --git a/src/Clients/IamClient/lib/Api/WellKnownApi.php b/src/Clients/IamClient/lib/Api/WellKnownApi.php index 56d9630..f15751f 100644 --- a/src/Clients/IamClient/lib/Api/WellKnownApi.php +++ b/src/Clients/IamClient/lib/Api/WellKnownApi.php @@ -36,6 +36,9 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use AffinidiTdk\Clients\IamClient\ApiException; +use AffinidiTdk\Clients\IamClient\InvalidJwtTokenError; +use AffinidiTdk\Clients\IamClient\InvalidParameterError; +use AffinidiTdk\Clients\IamClient\NotFoundError; use AffinidiTdk\Clients\IamClient\Configuration; use AffinidiTdk\Clients\IamClient\HeaderSelector; use AffinidiTdk\Clients\IamClient\ObjectSerializer; @@ -87,10 +90,10 @@ class WellKnownApi * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: Configuration::getDefaultConfiguration(); @@ -159,6 +162,20 @@ public function getWellKnownDidWithHttpInfo(string $contentType = self::contentT try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -474,6 +491,20 @@ public function getWellKnownJwksWithHttpInfo(string $contentType = self::content try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), diff --git a/src/Clients/IamClient/lib/InvalidJwtTokenError.php b/src/Clients/IamClient/lib/InvalidJwtTokenError.php new file mode 100644 index 0000000..c1948ef --- /dev/null +++ b/src/Clients/IamClient/lib/InvalidJwtTokenError.php @@ -0,0 +1,80 @@ + $this->name, + 'message' => $this->message, + 'issue' => $issue, + 'traceId' => $traceId + ]; + + parent::__construct(json_encode($message), 403); + $this->issue = $issue; + $this->traceId = $traceId; + } +} diff --git a/src/Clients/IamClient/lib/InvalidParameterError.php b/src/Clients/IamClient/lib/InvalidParameterError.php new file mode 100644 index 0000000..fc31124 --- /dev/null +++ b/src/Clients/IamClient/lib/InvalidParameterError.php @@ -0,0 +1,75 @@ + $this->name, + 'message' => $message, + 'details' => $details, + 'traceId' => $traceId + ]; + + parent::__construct(json_encode($message), 400); + $this->details = $details; + $this->traceId = $traceId; + } +} diff --git a/src/Clients/IamClient/lib/Model/ProjectList.php b/src/Clients/IamClient/lib/Model/ProjectList.php index 06f1b98..0112954 100644 --- a/src/Clients/IamClient/lib/Model/ProjectList.php +++ b/src/Clients/IamClient/lib/Model/ProjectList.php @@ -58,7 +58,8 @@ class ProjectList implements ModelInterface, ArrayAccess, \JsonSerializable * @var string[] */ protected static $openAPITypes = [ - 'projects' => '\AffinidiTdk\Clients\IamClient\Model\ProjectDto[]' + 'projects' => '\AffinidiTdk\Clients\IamClient\Model\ProjectDto[]', + 'last_evaluated_key' => 'string' ]; /** @@ -69,7 +70,8 @@ class ProjectList implements ModelInterface, ArrayAccess, \JsonSerializable * @psalm-var array */ protected static $openAPIFormats = [ - 'projects' => null + 'projects' => null, + 'last_evaluated_key' => null ]; /** @@ -78,7 +80,8 @@ class ProjectList implements ModelInterface, ArrayAccess, \JsonSerializable * @var boolean[] */ protected static array $openAPINullables = [ - 'projects' => false + 'projects' => false, + 'last_evaluated_key' => false ]; /** @@ -167,7 +170,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ - 'projects' => 'projects' + 'projects' => 'projects', + 'last_evaluated_key' => 'lastEvaluatedKey' ]; /** @@ -176,7 +180,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ - 'projects' => 'setProjects' + 'projects' => 'setProjects', + 'last_evaluated_key' => 'setLastEvaluatedKey' ]; /** @@ -185,7 +190,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ - 'projects' => 'getProjects' + 'projects' => 'getProjects', + 'last_evaluated_key' => 'getLastEvaluatedKey' ]; /** @@ -246,6 +252,7 @@ public function getModelName() public function __construct(array $data = null) { $this->setIfExists('projects', $data ?? [], null); + $this->setIfExists('last_evaluated_key', $data ?? [], null); } /** @@ -319,6 +326,33 @@ public function setProjects($projects) return $this; } + + /** + * Gets last_evaluated_key + * + * @return string|null + */ + public function getLastEvaluatedKey() + { + return $this->container['last_evaluated_key']; + } + + /** + * Sets last_evaluated_key + * + * @param string|null $last_evaluated_key last_evaluated_key + * + * @return self + */ + public function setLastEvaluatedKey($last_evaluated_key) + { + if (is_null($last_evaluated_key)) { + throw new \InvalidArgumentException('non-nullable last_evaluated_key cannot be null'); + } + $this->container['last_evaluated_key'] = $last_evaluated_key; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/src/Clients/IamClient/lib/Model/TokenList.php b/src/Clients/IamClient/lib/Model/TokenList.php index d501dfa..7147bdd 100644 --- a/src/Clients/IamClient/lib/Model/TokenList.php +++ b/src/Clients/IamClient/lib/Model/TokenList.php @@ -58,7 +58,8 @@ class TokenList implements ModelInterface, ArrayAccess, \JsonSerializable * @var string[] */ protected static $openAPITypes = [ - 'tokens' => '\AffinidiTdk\Clients\IamClient\Model\TokenDto[]' + 'tokens' => '\AffinidiTdk\Clients\IamClient\Model\TokenDto[]', + 'last_evaluated_key' => 'string' ]; /** @@ -69,7 +70,8 @@ class TokenList implements ModelInterface, ArrayAccess, \JsonSerializable * @psalm-var array */ protected static $openAPIFormats = [ - 'tokens' => null + 'tokens' => null, + 'last_evaluated_key' => null ]; /** @@ -78,7 +80,8 @@ class TokenList implements ModelInterface, ArrayAccess, \JsonSerializable * @var boolean[] */ protected static array $openAPINullables = [ - 'tokens' => false + 'tokens' => false, + 'last_evaluated_key' => false ]; /** @@ -167,7 +170,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ - 'tokens' => 'tokens' + 'tokens' => 'tokens', + 'last_evaluated_key' => 'lastEvaluatedKey' ]; /** @@ -176,7 +180,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ - 'tokens' => 'setTokens' + 'tokens' => 'setTokens', + 'last_evaluated_key' => 'setLastEvaluatedKey' ]; /** @@ -185,7 +190,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ - 'tokens' => 'getTokens' + 'tokens' => 'getTokens', + 'last_evaluated_key' => 'getLastEvaluatedKey' ]; /** @@ -246,6 +252,7 @@ public function getModelName() public function __construct(array $data = null) { $this->setIfExists('tokens', $data ?? [], null); + $this->setIfExists('last_evaluated_key', $data ?? [], null); } /** @@ -319,6 +326,33 @@ public function setTokens($tokens) return $this; } + + /** + * Gets last_evaluated_key + * + * @return string|null + */ + public function getLastEvaluatedKey() + { + return $this->container['last_evaluated_key']; + } + + /** + * Sets last_evaluated_key + * + * @param string|null $last_evaluated_key last_evaluated_key + * + * @return self + */ + public function setLastEvaluatedKey($last_evaluated_key) + { + if (is_null($last_evaluated_key)) { + throw new \InvalidArgumentException('non-nullable last_evaluated_key cannot be null'); + } + $this->container['last_evaluated_key'] = $last_evaluated_key; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/src/Clients/IamClient/lib/Model/TypedPrincipalId.php b/src/Clients/IamClient/lib/Model/TypedPrincipalId.php new file mode 100644 index 0000000..d3af2dc --- /dev/null +++ b/src/Clients/IamClient/lib/Model/TypedPrincipalId.php @@ -0,0 +1,413 @@ + + */ +class TypedPrincipalId implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TypedPrincipalId'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'principal_id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'principal_id' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'principal_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'principal_id' => 'principalId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'principal_id' => 'setPrincipalId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'principal_id' => 'getPrincipalId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('principal_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['principal_id'] === null) { + $invalidProperties[] = "'principal_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets principal_id + * + * @return string + */ + public function getPrincipalId() + { + return $this->container['principal_id']; + } + + /** + * Sets principal_id + * + * @param string $principal_id principal_id + * + * @return self + */ + public function setPrincipalId($principal_id) + { + if (is_null($principal_id)) { + throw new \InvalidArgumentException('non-nullable principal_id cannot be null'); + } + $this->container['principal_id'] = $principal_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/src/Clients/IamClient/lib/Model/UserList.php b/src/Clients/IamClient/lib/Model/UserList.php index e757037..2c178f9 100644 --- a/src/Clients/IamClient/lib/Model/UserList.php +++ b/src/Clients/IamClient/lib/Model/UserList.php @@ -58,7 +58,8 @@ class UserList implements ModelInterface, ArrayAccess, \JsonSerializable * @var string[] */ protected static $openAPITypes = [ - 'records' => '\AffinidiTdk\Clients\IamClient\Model\UserDto[]' + 'records' => '\AffinidiTdk\Clients\IamClient\Model\UserDto[]', + 'last_evaluated_key' => 'string' ]; /** @@ -69,7 +70,8 @@ class UserList implements ModelInterface, ArrayAccess, \JsonSerializable * @psalm-var array */ protected static $openAPIFormats = [ - 'records' => null + 'records' => null, + 'last_evaluated_key' => null ]; /** @@ -78,7 +80,8 @@ class UserList implements ModelInterface, ArrayAccess, \JsonSerializable * @var boolean[] */ protected static array $openAPINullables = [ - 'records' => false + 'records' => false, + 'last_evaluated_key' => false ]; /** @@ -167,7 +170,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ - 'records' => 'records' + 'records' => 'records', + 'last_evaluated_key' => 'lastEvaluatedKey' ]; /** @@ -176,7 +180,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ - 'records' => 'setRecords' + 'records' => 'setRecords', + 'last_evaluated_key' => 'setLastEvaluatedKey' ]; /** @@ -185,7 +190,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ - 'records' => 'getRecords' + 'records' => 'getRecords', + 'last_evaluated_key' => 'getLastEvaluatedKey' ]; /** @@ -246,6 +252,7 @@ public function getModelName() public function __construct(array $data = null) { $this->setIfExists('records', $data ?? [], null); + $this->setIfExists('last_evaluated_key', $data ?? [], null); } /** @@ -319,6 +326,33 @@ public function setRecords($records) return $this; } + + /** + * Gets last_evaluated_key + * + * @return string|null + */ + public function getLastEvaluatedKey() + { + return $this->container['last_evaluated_key']; + } + + /** + * Sets last_evaluated_key + * + * @param string|null $last_evaluated_key last_evaluated_key + * + * @return self + */ + public function setLastEvaluatedKey($last_evaluated_key) + { + if (is_null($last_evaluated_key)) { + throw new \InvalidArgumentException('non-nullable last_evaluated_key cannot be null'); + } + $this->container['last_evaluated_key'] = $last_evaluated_key; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/src/Clients/IamClient/lib/NotFoundError.php b/src/Clients/IamClient/lib/NotFoundError.php new file mode 100644 index 0000000..392d4cf --- /dev/null +++ b/src/Clients/IamClient/lib/NotFoundError.php @@ -0,0 +1,73 @@ + $this->name, + 'message' => $message, + 'traceId' => $traceId + ]; + + parent::__construct(json_encode($message), 404); + $this->traceId = $traceId; + } +} diff --git a/src/Clients/IamClient/test/Model/TypedPrincipalIdTest.php b/src/Clients/IamClient/test/Model/TypedPrincipalIdTest.php new file mode 100644 index 0000000..d0b9c83 --- /dev/null +++ b/src/Clients/IamClient/test/Model/TypedPrincipalIdTest.php @@ -0,0 +1,91 @@ + Date: Wed, 18 Dec 2024 18:38:19 +0100 Subject: [PATCH 2/2] feat: update client iam --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index 4edca5a..ab31b11 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,4 @@ - - - - - -\# Affinidi Trust Development Kit (Affinidi TDK) +# Affinidi Trust Development Kit (Affinidi TDK) [![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors-)