Skip to content

Commit 7e3291e

Browse files
authored
Add UNKNOWN_TO_SDK value to enums (#1998)
fix 1921
1 parent d066f92 commit 7e3291e

18 files changed

Lines changed: 47 additions & 9 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## NOT RELEASED
44

5+
### Added
6+
7+
- Add `UNKNOWN_TO_SDK` value to enums that is used when the API returns an value that is not (or not yet) known by the AsyncAws
8+
59
### Changed
610

711
- AWS enhancement: Documentation updates.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
},
3434
"extra": {
3535
"branch-alias": {
36-
"dev-master": "1.0-dev"
36+
"dev-master": "1.1-dev"
3737
}
3838
}
3939
}

src/Enum/ContentDataSourceType.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ final class ContentDataSourceType
66
{
77
public const CUSTOM = 'CUSTOM';
88
public const S3 = 'S3';
9+
public const UNKNOWN_TO_SDK = 'UNKNOWN_TO_SDK';
910

11+
/**
12+
* @psalm-assert-if-true self::* $value
13+
*/
1014
public static function exists(string $value): bool
1115
{
1216
return isset([

src/Enum/CustomSourceType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ final class CustomSourceType
77
public const IN_LINE = 'IN_LINE';
88
public const S3_LOCATION = 'S3_LOCATION';
99

10+
/**
11+
* @psalm-assert-if-true self::* $value
12+
*/
1013
public static function exists(string $value): bool
1114
{
1215
return isset([

src/Enum/DocumentStatus.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ final class DocumentStatus
1616
public const PARTIALLY_INDEXED = 'PARTIALLY_INDEXED';
1717
public const PENDING = 'PENDING';
1818
public const STARTING = 'STARTING';
19+
public const UNKNOWN_TO_SDK = 'UNKNOWN_TO_SDK';
1920

21+
/**
22+
* @psalm-assert-if-true self::* $value
23+
*/
2024
public static function exists(string $value): bool
2125
{
2226
return isset([

src/Enum/InlineContentType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ final class InlineContentType
77
public const BYTE = 'BYTE';
88
public const TEXT = 'TEXT';
99

10+
/**
11+
* @psalm-assert-if-true self::* $value
12+
*/
1013
public static function exists(string $value): bool
1114
{
1215
return isset([

src/Enum/MetadataSourceType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ final class MetadataSourceType
77
public const IN_LINE_ATTRIBUTE = 'IN_LINE_ATTRIBUTE';
88
public const S3_LOCATION = 'S3_LOCATION';
99

10+
/**
11+
* @psalm-assert-if-true self::* $value
12+
*/
1013
public static function exists(string $value): bool
1114
{
1215
return isset([

src/Enum/MetadataValueType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ final class MetadataValueType
99
public const STRING = 'STRING';
1010
public const STRING_LIST = 'STRING_LIST';
1111

12+
/**
13+
* @psalm-assert-if-true self::* $value
14+
*/
1215
public static function exists(string $value): bool
1316
{
1417
return isset([

src/Result/DeleteKnowledgeBaseDocumentsResponse.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace AsyncAws\BedrockAgent\Result;
44

5+
use AsyncAws\BedrockAgent\Enum\ContentDataSourceType;
6+
use AsyncAws\BedrockAgent\Enum\DocumentStatus;
57
use AsyncAws\BedrockAgent\ValueObject\CustomDocumentIdentifier;
68
use AsyncAws\BedrockAgent\ValueObject\DocumentIdentifier;
79
use AsyncAws\BedrockAgent\ValueObject\KnowledgeBaseDocumentDetail;
@@ -45,7 +47,7 @@ private function populateResultCustomDocumentIdentifier(array $json): CustomDocu
4547
private function populateResultDocumentIdentifier(array $json): DocumentIdentifier
4648
{
4749
return new DocumentIdentifier([
48-
'dataSourceType' => (string) $json['dataSourceType'],
50+
'dataSourceType' => !ContentDataSourceType::exists((string) $json['dataSourceType']) ? ContentDataSourceType::UNKNOWN_TO_SDK : (string) $json['dataSourceType'],
4951
's3' => empty($json['s3']) ? null : $this->populateResultS3Location($json['s3']),
5052
'custom' => empty($json['custom']) ? null : $this->populateResultCustomDocumentIdentifier($json['custom']),
5153
]);
@@ -56,7 +58,7 @@ private function populateResultKnowledgeBaseDocumentDetail(array $json): Knowled
5658
return new KnowledgeBaseDocumentDetail([
5759
'knowledgeBaseId' => (string) $json['knowledgeBaseId'],
5860
'dataSourceId' => (string) $json['dataSourceId'],
59-
'status' => (string) $json['status'],
61+
'status' => !DocumentStatus::exists((string) $json['status']) ? DocumentStatus::UNKNOWN_TO_SDK : (string) $json['status'],
6062
'identifier' => $this->populateResultDocumentIdentifier($json['identifier']),
6163
'statusReason' => isset($json['statusReason']) ? (string) $json['statusReason'] : null,
6264
'updatedAt' => isset($json['updatedAt']) && ($d = \DateTimeImmutable::createFromFormat(\DateTimeInterface::ATOM, $json['updatedAt'])) ? $d : null,

src/Result/GetKnowledgeBaseDocumentsResponse.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace AsyncAws\BedrockAgent\Result;
44

5+
use AsyncAws\BedrockAgent\Enum\ContentDataSourceType;
6+
use AsyncAws\BedrockAgent\Enum\DocumentStatus;
57
use AsyncAws\BedrockAgent\ValueObject\CustomDocumentIdentifier;
68
use AsyncAws\BedrockAgent\ValueObject\DocumentIdentifier;
79
use AsyncAws\BedrockAgent\ValueObject\KnowledgeBaseDocumentDetail;
@@ -45,7 +47,7 @@ private function populateResultCustomDocumentIdentifier(array $json): CustomDocu
4547
private function populateResultDocumentIdentifier(array $json): DocumentIdentifier
4648
{
4749
return new DocumentIdentifier([
48-
'dataSourceType' => (string) $json['dataSourceType'],
50+
'dataSourceType' => !ContentDataSourceType::exists((string) $json['dataSourceType']) ? ContentDataSourceType::UNKNOWN_TO_SDK : (string) $json['dataSourceType'],
4951
's3' => empty($json['s3']) ? null : $this->populateResultS3Location($json['s3']),
5052
'custom' => empty($json['custom']) ? null : $this->populateResultCustomDocumentIdentifier($json['custom']),
5153
]);
@@ -56,7 +58,7 @@ private function populateResultKnowledgeBaseDocumentDetail(array $json): Knowled
5658
return new KnowledgeBaseDocumentDetail([
5759
'knowledgeBaseId' => (string) $json['knowledgeBaseId'],
5860
'dataSourceId' => (string) $json['dataSourceId'],
59-
'status' => (string) $json['status'],
61+
'status' => !DocumentStatus::exists((string) $json['status']) ? DocumentStatus::UNKNOWN_TO_SDK : (string) $json['status'],
6062
'identifier' => $this->populateResultDocumentIdentifier($json['identifier']),
6163
'statusReason' => isset($json['statusReason']) ? (string) $json['statusReason'] : null,
6264
'updatedAt' => isset($json['updatedAt']) && ($d = \DateTimeImmutable::createFromFormat(\DateTimeInterface::ATOM, $json['updatedAt'])) ? $d : null,

0 commit comments

Comments
 (0)