-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from moe-mizrak/feat/create-collection
feat: createCollection, deleteCollection and listCollections added
- Loading branch information
Showing
23 changed files
with
1,070 additions
and
492 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MoeMizrak\Rekognition\Data\Contracts; | ||
|
||
/** | ||
* Interface for Rekognition Data Format where it uses capital letter as first letter for the properties. | ||
* e.g. 'Image' instead of 'image', 'MaxLabels' instead of 'maxLabels'. | ||
* | ||
* @class RekognitionDataFormatInterface | ||
*/ | ||
interface RekognitionDataFormatInterface | ||
{ | ||
/** | ||
* Convert the data to an AWS Rekognition array format, excluding null values. | ||
* | ||
* @return array | ||
*/ | ||
public function toRekognitionDataFormat(): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MoeMizrak\Rekognition\Data; | ||
|
||
use MoeMizrak\Rekognition\Data\Contracts\RekognitionDataFormatInterface; | ||
use Spatie\LaravelData\Data; | ||
|
||
/** | ||
* CreateCollectionData is for the data of the Rekognition API createCollection request. | ||
* For more info: https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-rekognition-2016-06-27.html#createcollection | ||
* | ||
* @class CreateCollectionData | ||
*/ | ||
final class CreateCollectionData extends Data implements RekognitionDataFormatInterface | ||
{ | ||
public function __construct( | ||
/* | ||
* ID for the collection that you are creating. | ||
* | ||
* @param string | ||
*/ | ||
public string $collectionId, | ||
|
||
/* | ||
* A set of tags (key-value pairs) that you want to attach to the collection. | ||
* - Associative array of custom strings keys (TagKey) to strings | ||
* | ||
* @param array|null | ||
*/ | ||
public ?array $tags = null, | ||
) {} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function toRekognitionDataFormat(): array | ||
{ | ||
return array_filter( | ||
[ | ||
'CollectionId' => $this->collectionId, | ||
'Tags' => $this->tags, | ||
], | ||
fn ($value) => $value !== null | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MoeMizrak\Rekognition\Data; | ||
|
||
use MoeMizrak\Rekognition\Data\Contracts\RekognitionDataFormatInterface; | ||
use Spatie\LaravelData\Data; | ||
|
||
/** | ||
* DeleteCollectionData is for the data of the Rekognition API deleteCollection request. | ||
* For more info: https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-rekognition-2016-06-27.html#deletecollection | ||
* | ||
* @class DeleteCollectionData | ||
*/ | ||
final class DeleteCollectionData extends Data implements RekognitionDataFormatInterface | ||
{ | ||
public function __construct( | ||
/* | ||
* The ID of the collection to delete. | ||
* | ||
* @param string | ||
*/ | ||
public string $collectionId, | ||
) {} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function toRekognitionDataFormat(): array | ||
{ | ||
return [ | ||
'CollectionId' => $this->collectionId, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MoeMizrak\Rekognition\Data; | ||
|
||
use MoeMizrak\Rekognition\Data\Contracts\RekognitionDataFormatInterface; | ||
use Spatie\LaravelData\Data; | ||
|
||
/** | ||
* ListCollectionsData is for listCollections method related context data such as maxResults and nextToken. | ||
* For more detail: https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-rekognition-2016-06-27.html#listcollections | ||
* | ||
* @class ListCollectionsData | ||
*/ | ||
final class ListCollectionsData extends Data implements RekognitionDataFormatInterface | ||
{ | ||
public function __construct( | ||
/* | ||
* Maximum number of collection IDs to return. | ||
* | ||
* @param int|null | ||
*/ | ||
public ?int $maxResults = null, | ||
|
||
/* | ||
* Pagination token from the previous response. | ||
* | ||
* @param string|null | ||
*/ | ||
public ?string $nextToken = null, | ||
) {} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function toRekognitionDataFormat(): array | ||
{ | ||
return array_filter( | ||
[ | ||
'MaxResults' => $this->maxResults, | ||
'NextToken' => $this->nextToken, | ||
], | ||
fn ($value) => $value !== null | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MoeMizrak\Rekognition\Data\ResultData; | ||
|
||
use Spatie\LaravelData\Data; | ||
|
||
/** | ||
* CreateCollectionResultData is for the result of the Rekognition API createCollection request. | ||
* For more info: https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-rekognition-2016-06-27.html#createcollection | ||
* | ||
* @class CreateCollectionResultData | ||
*/ | ||
final class CreateCollectionResultData extends Data | ||
{ | ||
public function __construct( | ||
/* | ||
* Amazon Resource Name (ARN) of the collection. You can use this to manage permissions on your resources. | ||
* | ||
* @param string|null | ||
*/ | ||
public ?string $collectionArn = null, | ||
|
||
/* | ||
* Version number of the face detection model associated with the collection you are creating. | ||
* | ||
* @param string|null | ||
*/ | ||
public ?string $faceModelVersion = null, | ||
|
||
/* | ||
* HTTP status code indicating the result of the operation. | ||
* | ||
* @param int|null | ||
*/ | ||
public ?int $statusCode = null, | ||
|
||
/* | ||
* Metadata about the request. | ||
* | ||
* @param MetaData|null | ||
*/ | ||
public ?MetaData $metadata = null, | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MoeMizrak\Rekognition\Data\ResultData; | ||
|
||
use Spatie\LaravelData\Data; | ||
|
||
/** | ||
* DeleteCollectionResultData is for the result of the Rekognition API deleteCollection request. | ||
* For more info: https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-rekognition-2016-06-27.html#deletecollection | ||
* | ||
* @class DeleteCollectionResultData | ||
*/ | ||
final class DeleteCollectionResultData extends Data | ||
{ | ||
public function __construct( | ||
/* | ||
* HTTP status code that indicates the result of the operation. | ||
* | ||
* @param int|null | ||
*/ | ||
public ?int $statusCode = null, | ||
|
||
/* | ||
* Metadata about the request. | ||
* | ||
* @param MetaData|null | ||
*/ | ||
public ?MetaData $metadata = null, | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.