Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
derpoho committed Feb 20, 2024
1 parent a425b4b commit 85e76bb
Show file tree
Hide file tree
Showing 19 changed files with 53 additions and 79 deletions.
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
};
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -41,10 +41,7 @@ public function __construct(
protected string $name,
protected int $replicas,
protected string $pod_type
)
{

}
) {}

/**
* @return string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -38,9 +38,7 @@ class Create extends Request implements HasBody
public function __construct(
protected string $name,
protected string $source,
)
{
}
) {}

/**
* @return string
Expand All @@ -56,7 +54,7 @@ public function resolveEndpoint(): string
protected function defaultBody(): array
{
return [
'name' => $this->name,
'name' => $this->name,
'source' => $this->source,
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -56,10 +56,7 @@ public function __construct(
protected ?string $pod_type = 'p1.x1',
protected ?array $metadataConfig = null,
protected ?string $sourceCollection = null,
)
{

}
) {}

/**
* @return string
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,9 +30,7 @@ class Delete extends Request
*/
public function __construct(
protected string $name
)
{
}
) {}

/**
* @return string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,9 +30,7 @@ class Delete extends Request
*/
public function __construct(
protected string $name,
)
{
}
) {}

/**
* @return string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,9 +33,7 @@ class Describe extends Request
*/
public function __construct(
protected string $name
)
{
}
) {}

/**
* @return string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,9 +45,7 @@ class Describe extends Request
*/
public function __construct(
protected string $name,
)
{
}
) {}

/**
* @return string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @response
* array of strings "$collectionName"
*/
class All extends Request
class ListCollections extends Request
{
/**
* @var Method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @response
* array of strings "$indexName"
*/
class All extends Request
class ListIndexes extends Request
{
/**
* @var Method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* typeUrl | string
* value | string
*/
class Delete extends Request implements HasBody
class DeleteVectors extends Request implements HasBody
{
use HasJsonBody;

Expand All @@ -50,9 +50,7 @@ public function __construct(
protected ?string $namespace = null,
protected bool $deleteAll = false,
protected array $filter = []
)
{
}
) {}

/**
* @return string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* typeUrl | string
* value | string
*/
class DescribeStats extends Request
class DescribeIndexStats extends Request
{
/**
* @var Method
Expand All @@ -43,9 +43,7 @@ class DescribeStats extends Request
public function __construct(
protected array $index,
protected array $filter = []
)
{
}
) {}

/**
* @return string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* typeUrl | string
* value | string
*/
class Fetch extends Request implements HasBody
class FetchVectors extends Request implements HasBody
{
use HasJsonBody, HasQuery;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* typeUrl | string
* value | string
*/
class Query extends Request implements HasBody
class QueryVectors extends Request implements HasBody
{
use HasJsonBody;

Expand Down Expand Up @@ -69,9 +69,7 @@ public function __construct(
protected bool $includeMetadata = true,
protected bool $includeVector = false,
protected ?string $id = null,
)
{
}
) {}

/**
* @return string
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* typeUrl | string
* value | string
*/
class Update extends Request implements HasBody
class UpdateVector extends Request implements HasBody
{
use HasJsonBody;

Expand All @@ -46,9 +46,7 @@ public function __construct(
protected array $sparseValues = [],
protected array $setMetadata = [],
protected ?string $namespace = null,
)
{
}
) {}

/**
* @return string[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* typeUrl | string
* value | string
*/
class Upsert extends Request implements HasBody
class UpsertVectors extends Request implements HasBody
{
use HasJsonBody;

Expand All @@ -40,9 +40,7 @@ public function __construct(
protected array $index,
protected array $vectors = [],
protected ?string $namespace = null,
)
{
}
) {}

/**
* @return string
Expand Down
10 changes: 5 additions & 5 deletions src/Resources/CollectionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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));
}


Expand All @@ -48,15 +48,15 @@ public function describe(): Response
{
$this->validateName();

return $this->connector->send(new Collections\Describe($this->name));
return $this->connector->send(new Collections\DescribeCollection($this->name));
}

/**
* @return Response
*/
public function list(): Response
{
return $this->connector->send(new Collections\All());
return $this->connector->send(new Collections\ListCollections());
}

/**
Expand All @@ -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));
}
}
Loading

0 comments on commit 85e76bb

Please sign in to comment.