diff --git a/src/Client.php b/src/Client.php index 1d7962b..f981270 100644 --- a/src/Client.php +++ b/src/Client.php @@ -3,7 +3,7 @@ namespace Probots\Pinecone; use Probots\Pinecone\Contracts\ClientContract; -use Probots\Pinecone\Requests\Index\Vectors\Fetch; +use Probots\Pinecone\Requests\Index\Vectors\FetchVectors; use Probots\Pinecone\Resources\CollectionResource; use Probots\Pinecone\Resources\IndexResource; use Psr\Http\Message\RequestInterface; @@ -29,7 +29,7 @@ public function __construct( // (Temporary) Workaround for https://github.com/probots-io/pinecone-php/issues/3 $this->sender()->addMiddleware(function (callable $handler) { return function (RequestInterface $request, array $options) use ($handler) { - return $handler(Fetch::queryIdsWorkaround($request), $options); + return $handler(FetchVectors::queryIdsWorkaround($request), $options); }; }); } diff --git a/src/Requests/Index/Configure.php b/src/Requests/Control/ConfigureIndex.php similarity index 95% rename from src/Requests/Index/Configure.php rename to src/Requests/Control/ConfigureIndex.php index f019fdb..5a7c675 100644 --- a/src/Requests/Index/Configure.php +++ b/src/Requests/Control/ConfigureIndex.php @@ -23,7 +23,7 @@ * 404 | Index not found. * 500 | Internal error. Can be caused by invalid parameters. */ -class Configure extends Request implements HasBody +class ConfigureIndex extends Request implements HasBody { use HasJsonBody; @@ -41,10 +41,7 @@ public function __construct( protected string $name, protected int $replicas, protected string $pod_type - ) - { - - } + ) {} /** * @return string diff --git a/src/Requests/Collections/Create.php b/src/Requests/Control/CreateCollection.php similarity index 92% rename from src/Requests/Collections/Create.php rename to src/Requests/Control/CreateCollection.php index 3547344..e464de7 100644 --- a/src/Requests/Collections/Create.php +++ b/src/Requests/Control/CreateCollection.php @@ -22,7 +22,7 @@ * 409 | A collection with the name provided already exists. * 500 | Internal error. Can be caused by invalid parameters. */ -class Create extends Request implements HasBody +class CreateCollection extends Request implements HasBody { use HasJsonBody; @@ -38,9 +38,7 @@ class Create extends Request implements HasBody public function __construct( protected string $name, protected string $source, - ) - { - } + ) {} /** * @return string @@ -56,7 +54,7 @@ public function resolveEndpoint(): string protected function defaultBody(): array { return [ - 'name' => $this->name, + 'name' => $this->name, 'source' => $this->source, ]; } diff --git a/src/Requests/Index/Create.php b/src/Requests/Control/CreateIndex.php similarity index 89% rename from src/Requests/Index/Create.php rename to src/Requests/Control/CreateIndex.php index f9ecf08..71bfdb0 100644 --- a/src/Requests/Index/Create.php +++ b/src/Requests/Control/CreateIndex.php @@ -28,7 +28,7 @@ * 409 | Index of given name already exists. * 500 | Internal error. Can be caused by invalid parameters. */ -class Create extends Request implements HasBody +class CreateIndex extends Request implements HasBody { use HasJsonBody; @@ -56,10 +56,7 @@ public function __construct( protected ?string $pod_type = 'p1.x1', protected ?array $metadataConfig = null, protected ?string $sourceCollection = null, - ) - { - - } + ) {} /** * @return string @@ -75,12 +72,12 @@ public function resolveEndpoint(): string protected function defaultBody(): array { $payload = [ - 'name' => $this->name, + 'name' => $this->name, 'dimension' => $this->dimension, - 'metric' => $this->metric, - 'pods' => $this->pods, - 'replicas' => $this->replicas, - 'pod_type' => $this->pod_type, + 'metric' => $this->metric, + 'pods' => $this->pods, + 'replicas' => $this->replicas, + 'pod_type' => $this->pod_type, ]; if ($this->metadataConfig !== null) { diff --git a/src/Requests/Collections/Delete.php b/src/Requests/Control/DeleteCollection.php similarity index 94% rename from src/Requests/Collections/Delete.php rename to src/Requests/Control/DeleteCollection.php index 0e8783b..9f18bd3 100644 --- a/src/Requests/Collections/Delete.php +++ b/src/Requests/Control/DeleteCollection.php @@ -18,7 +18,7 @@ * 404 | Collection not found. * 500 | Internal error. Can be caused by invalid parameters. */ -class Delete extends Request +class DeleteCollection extends Request { /** * @var Method @@ -30,9 +30,7 @@ class Delete extends Request */ public function __construct( protected string $name - ) - { - } + ) {} /** * @return string diff --git a/src/Requests/Index/Delete.php b/src/Requests/Control/DeleteIndex.php similarity index 94% rename from src/Requests/Index/Delete.php rename to src/Requests/Control/DeleteIndex.php index f8a76e3..9f61116 100644 --- a/src/Requests/Index/Delete.php +++ b/src/Requests/Control/DeleteIndex.php @@ -18,7 +18,7 @@ * 404 | Index not found. * 500 | Internal error. Can be caused by invalid parameters. */ -class Delete extends Request +class DeleteIndex extends Request { /** * @var Method @@ -30,9 +30,7 @@ class Delete extends Request */ public function __construct( protected string $name, - ) - { - } + ) {} /** * @return string diff --git a/src/Requests/Collections/Describe.php b/src/Requests/Control/DescribeCollection.php similarity index 95% rename from src/Requests/Collections/Describe.php rename to src/Requests/Control/DescribeCollection.php index c2d0fee..83e71bd 100644 --- a/src/Requests/Collections/Describe.php +++ b/src/Requests/Control/DescribeCollection.php @@ -21,7 +21,7 @@ * 404 | Collection not found. * 500 | Internal error. Can be caused by invalid parameters. */ -class Describe extends Request +class DescribeCollection extends Request { /** * @var Method @@ -33,9 +33,7 @@ class Describe extends Request */ public function __construct( protected string $name - ) - { - } + ) {} /** * @return string diff --git a/src/Requests/Index/Describe.php b/src/Requests/Control/DescribeIndex.php similarity index 96% rename from src/Requests/Index/Describe.php rename to src/Requests/Control/DescribeIndex.php index a1a94e5..294dc64 100644 --- a/src/Requests/Index/Describe.php +++ b/src/Requests/Control/DescribeIndex.php @@ -33,7 +33,7 @@ * 404 | Index not found. * 500 | Internal error. Can be caused by invalid parameters. */ -class Describe extends Request +class DescribeIndex extends Request { /** * @var Method @@ -45,9 +45,7 @@ class Describe extends Request */ public function __construct( protected string $name, - ) - { - } + ) {} /** * @return string diff --git a/src/Requests/Collections/All.php b/src/Requests/Control/ListCollections.php similarity index 94% rename from src/Requests/Collections/All.php rename to src/Requests/Control/ListCollections.php index b7f52ad..cbc5288 100644 --- a/src/Requests/Collections/All.php +++ b/src/Requests/Control/ListCollections.php @@ -12,7 +12,7 @@ * @response * array of strings "$collectionName" */ -class All extends Request +class ListCollections extends Request { /** * @var Method diff --git a/src/Requests/Index/All.php b/src/Requests/Control/ListIndexes.php similarity index 95% rename from src/Requests/Index/All.php rename to src/Requests/Control/ListIndexes.php index 86f95e1..5d239da 100644 --- a/src/Requests/Index/All.php +++ b/src/Requests/Control/ListIndexes.php @@ -12,7 +12,7 @@ * @response * array of strings "$indexName" */ -class All extends Request +class ListIndexes extends Request { /** * @var Method diff --git a/src/Requests/Index/Vectors/Delete.php b/src/Requests/Data/DeleteVectors.php similarity index 96% rename from src/Requests/Index/Vectors/Delete.php rename to src/Requests/Data/DeleteVectors.php index 0aa5c61..f340d24 100644 --- a/src/Requests/Index/Vectors/Delete.php +++ b/src/Requests/Data/DeleteVectors.php @@ -28,7 +28,7 @@ * typeUrl | string * value | string */ -class Delete extends Request implements HasBody +class DeleteVectors extends Request implements HasBody { use HasJsonBody; @@ -50,9 +50,7 @@ public function __construct( protected ?string $namespace = null, protected bool $deleteAll = false, protected array $filter = [] - ) - { - } + ) {} /** * @return string diff --git a/src/Requests/Index/Vectors/DescribeStats.php b/src/Requests/Data/DescribeIndexStats.php similarity index 96% rename from src/Requests/Index/Vectors/DescribeStats.php rename to src/Requests/Data/DescribeIndexStats.php index 5d16681..d4ace8c 100644 --- a/src/Requests/Index/Vectors/DescribeStats.php +++ b/src/Requests/Data/DescribeIndexStats.php @@ -29,7 +29,7 @@ * typeUrl | string * value | string */ -class DescribeStats extends Request +class DescribeIndexStats extends Request { /** * @var Method @@ -43,9 +43,7 @@ class DescribeStats extends Request public function __construct( protected array $index, protected array $filter = [] - ) - { - } + ) {} /** * @return string diff --git a/src/Requests/Index/Vectors/Fetch.php b/src/Requests/Data/FetchVectors.php similarity index 97% rename from src/Requests/Index/Vectors/Fetch.php rename to src/Requests/Data/FetchVectors.php index 58706c5..aef5f80 100644 --- a/src/Requests/Index/Vectors/Fetch.php +++ b/src/Requests/Data/FetchVectors.php @@ -28,7 +28,7 @@ * typeUrl | string * value | string */ -class Fetch extends Request implements HasBody +class FetchVectors extends Request implements HasBody { use HasJsonBody, HasQuery; diff --git a/src/Requests/Index/Vectors/Query.php b/src/Requests/Data/QueryVectors.php similarity index 94% rename from src/Requests/Index/Vectors/Query.php rename to src/Requests/Data/QueryVectors.php index bcccabd..5809d84 100644 --- a/src/Requests/Index/Vectors/Query.php +++ b/src/Requests/Data/QueryVectors.php @@ -40,7 +40,7 @@ * typeUrl | string * value | string */ -class Query extends Request implements HasBody +class QueryVectors extends Request implements HasBody { use HasJsonBody; @@ -69,9 +69,7 @@ public function __construct( protected bool $includeMetadata = true, protected bool $includeVector = false, protected ?string $id = null, - ) - { - } + ) {} /** * @return string @@ -87,9 +85,9 @@ public function resolveEndpoint(): string protected function defaultBody(): array { $payload = [ - 'topK' => $this->topK, + 'topK' => $this->topK, 'includeMetadata' => $this->includeMetadata, - 'includeVector' => $this->includeVector, + 'includeVector' => $this->includeVector, ]; if (count($this->vector) > 0) { diff --git a/src/Requests/Index/Vectors/Update.php b/src/Requests/Data/UpdateVector.php similarity index 96% rename from src/Requests/Index/Vectors/Update.php rename to src/Requests/Data/UpdateVector.php index 25407b5..5322b4f 100644 --- a/src/Requests/Index/Vectors/Update.php +++ b/src/Requests/Data/UpdateVector.php @@ -22,7 +22,7 @@ * typeUrl | string * value | string */ -class Update extends Request implements HasBody +class UpdateVector extends Request implements HasBody { use HasJsonBody; @@ -46,9 +46,7 @@ public function __construct( protected array $sparseValues = [], protected array $setMetadata = [], protected ?string $namespace = null, - ) - { - } + ) {} /** * @return string[] diff --git a/src/Requests/Index/Vectors/Upsert.php b/src/Requests/Data/UpsertVectors.php similarity index 95% rename from src/Requests/Index/Vectors/Upsert.php rename to src/Requests/Data/UpsertVectors.php index 01e9b84..1dbb08d 100644 --- a/src/Requests/Index/Vectors/Upsert.php +++ b/src/Requests/Data/UpsertVectors.php @@ -22,7 +22,7 @@ * typeUrl | string * value | string */ -class Upsert extends Request implements HasBody +class UpsertVectors extends Request implements HasBody { use HasJsonBody; @@ -40,9 +40,7 @@ public function __construct( protected array $index, protected array $vectors = [], protected ?string $namespace = null, - ) - { - } + ) {} /** * @return string diff --git a/src/Resources/CollectionResource.php b/src/Resources/CollectionResource.php index dd44279..15f4a91 100644 --- a/src/Resources/CollectionResource.php +++ b/src/Resources/CollectionResource.php @@ -3,7 +3,7 @@ namespace Probots\Pinecone\Resources; use Probots\Pinecone\Requests\Collections; -use Probots\Pinecone\Exceptions\MissingNameException; +use Probots\Pinecone\Requests\Exceptions\MissingNameException; use Saloon\Contracts\Connector; use Saloon\Contracts\Response; @@ -36,7 +36,7 @@ private function validateName() */ public function create(string $name, string $source): Response { - return $this->connector->send(new Collections\Create($name, $source)); + return $this->connector->send(new Collections\CreateCollection($name, $source)); } @@ -48,7 +48,7 @@ public function describe(): Response { $this->validateName(); - return $this->connector->send(new Collections\Describe($this->name)); + return $this->connector->send(new Collections\DescribeCollection($this->name)); } /** @@ -56,7 +56,7 @@ public function describe(): Response */ public function list(): Response { - return $this->connector->send(new Collections\All()); + return $this->connector->send(new Collections\ListCollections()); } /** @@ -67,6 +67,6 @@ public function delete(): Response { $this->validateName(); - return $this->connector->send(new Collections\Delete($this->name)); + return $this->connector->send(new Collections\DeleteCollection($this->name)); } } diff --git a/src/Resources/IndexResource.php b/src/Resources/IndexResource.php index e9a95f6..00d83a1 100644 --- a/src/Resources/IndexResource.php +++ b/src/Resources/IndexResource.php @@ -64,7 +64,7 @@ public function describe(): Response { $this->validateName(); - return $this->connector->send(new Index\Describe($this->name)); + return $this->connector->send(new Index\DescribeIndex($this->name)); } /** @@ -89,7 +89,7 @@ public function create( null|string $sourceCollection = null ): Response { - return $this->connector->send(new Index\Create( + return $this->connector->send(new Index\CreateIndex( name: $name, dimension: $dimension, metric: $metric, @@ -106,7 +106,7 @@ public function create( */ public function list(): Response { - return $this->connector->send(new Index\All()); + return $this->connector->send(new Index\ListIndexes()); } /** @@ -120,7 +120,7 @@ public function configure(string $pod_type, int $replicas): Response { $this->validateName(); - return $this->connector->send(new Index\Configure($this->name, $replicas, $pod_type)); + return $this->connector->send(new Index\ConfigureIndex($this->name, $replicas, $pod_type)); } /** @@ -131,6 +131,6 @@ public function delete(): Response { $this->validateName(); - return $this->connector->send(new Index\Delete($this->name)); + return $this->connector->send(new Index\DeleteIndex($this->name)); } } \ No newline at end of file diff --git a/src/Resources/VectorResource.php b/src/Resources/VectorResource.php index bbd7f4e..18f1942 100644 --- a/src/Resources/VectorResource.php +++ b/src/Resources/VectorResource.php @@ -25,7 +25,7 @@ public function __construct(protected Connector $connector, protected array $ind */ public function stats(): Response { - return $this->connector->send(new Vectors\DescribeStats($this->index)); + return $this->connector->send(new Vectors\DescribeIndexStats($this->index)); } /** @@ -44,7 +44,7 @@ public function update(string $id, { - return $this->connector->send(new Vectors\Update($this->index, id: $id, values: $values, sparseValues: $sparseValues, setMetadata: $setMetadata, namespace: $namespace)); + return $this->connector->send(new Vectors\UpdateVector($this->index, id: $id, values: $values, sparseValues: $sparseValues, setMetadata: $setMetadata, namespace: $namespace)); } /** @@ -54,7 +54,7 @@ public function update(string $id, */ public function upsert(array $vectors, ?string $namespace = null): Response { - return $this->connector->send(new Vectors\Upsert($this->index, $vectors, $namespace)); + return $this->connector->send(new Vectors\UpsertVectors($this->index, $vectors, $namespace)); } /** @@ -77,7 +77,7 @@ public function query( ?string $id = null ): Response { - return $this->connector->send(new Vectors\Query($this->index, vector: $vector, namespace: $namespace, filter: $filter, topK: $topK, includeMetadata: $includeMetadata, includeVector: $includeVector, id: $id)); + return $this->connector->send(new Vectors\QueryVectors($this->index, vector: $vector, namespace: $namespace, filter: $filter, topK: $topK, includeMetadata: $includeMetadata, includeVector: $includeVector, id: $id)); } /** @@ -94,7 +94,7 @@ public function delete( array $filter = [] ): Response { - return $this->connector->send(new Vectors\Delete($this->index, ids: $ids, namespace: $namespace, deleteAll: $deleteAll, filter: $filter)); + return $this->connector->send(new Vectors\DeleteVectors($this->index, ids: $ids, namespace: $namespace, deleteAll: $deleteAll, filter: $filter)); } /** @@ -104,6 +104,6 @@ public function delete( */ public function fetch(array $ids, ?string $namespace = null): Response { - return $this->connector->send(new Vectors\Fetch($this->index, ids: $ids, namespace: $namespace)); + return $this->connector->send(new Vectors\FetchVectors($this->index, ids: $ids, namespace: $namespace)); } } \ No newline at end of file