Skip to content

Commit

Permalink
feat: update client iam
Browse files Browse the repository at this point in the history
  • Loading branch information
affinidibot authored and maratsh committed Dec 18, 2024
1 parent f59edf4 commit 69cc5ae
Show file tree
Hide file tree
Showing 24 changed files with 1,530 additions and 107 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Affinidi Trust Development Kit (Affinidi TDK)





\# Affinidi Trust Development Kit (Affinidi TDK)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
Expand Down
8 changes: 6 additions & 2 deletions src/Clients/IamClient/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion src/Clients/IamClient/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 16 additions & 6 deletions src/Clients/IamClient/docs/Api/ProjectsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```


Expand All @@ -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;
Expand All @@ -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

Expand All @@ -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
```


Expand All @@ -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;
Expand All @@ -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

Expand Down
19 changes: 12 additions & 7 deletions src/Clients/IamClient/docs/Api/TokensApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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

Expand All @@ -258,7 +258,7 @@ try {
## `listToken()`

```php
listToken(): \AffinidiTdk\Clients\IamClient\Model\TokenList
listToken($limit, $exclusive_start_key): \AffinidiTdk\Clients\IamClient\Model\TokenList
```


Expand All @@ -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;
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/Clients/IamClient/docs/Model/ProjectList.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions src/Clients/IamClient/docs/Model/TokenList.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
9 changes: 9 additions & 0 deletions src/Clients/IamClient/docs/Model/TypedPrincipalId.md
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions src/Clients/IamClient/docs/Model/UserList.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
25 changes: 21 additions & 4 deletions src/Clients/IamClient/lib/Api/ConsumerAuthApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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(),
Expand Down
Loading

0 comments on commit 69cc5ae

Please sign in to comment.