Skip to content

Commit

Permalink
rebuild other index functions
Browse files Browse the repository at this point in the history
  • Loading branch information
derpoho committed Feb 21, 2024
1 parent 959c6d9 commit cb3e2d8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 26 deletions.
10 changes: 7 additions & 3 deletions src/Requests/Control/ConfigureIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(
*/
public function resolveEndpoint(): string
{
return '/databases/' . $this->name;
return '/indexes/' . $this->name;
}

/**
Expand All @@ -56,8 +56,12 @@ public function resolveEndpoint(): string
protected function defaultBody(): array
{
return [
'replicas' => $this->replicas,
'pod_type' => $this->pod_type,
'spec' => [
'pod' => [
'replicas' => $this->replicas,
'pod_type' => $this->pod_type,
],
]
];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Requests/Control/DeleteIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DeleteIndex extends Request
/**
* @var Method
*/
protected Method $method = Method::POST;
protected Method $method = Method::DELETE;

/**
* @param string $name
Expand All @@ -37,7 +37,7 @@ public function __construct(
*/
public function resolveEndpoint(): string
{
return '/databases/' . $this->name;
return '/indexes/' . $this->name;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Requests/Control/DescribeIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct(
*/
public function resolveEndpoint(): string
{
return '/databases/' . $this->name;
return '/indexes/' . $this->name;
}

/**
Expand Down
14 changes: 3 additions & 11 deletions src/Requests/Control/ListIndexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,15 @@
*/
class ListIndexes extends Request
{
/**
* @var Method
*/

protected Method $method = Method::GET;

/**
* @return string
*/

public function resolveEndpoint(): string
{
return '/databases';
return '/indexes';
}

/**
* @param Response $response
* @return bool|null
*/
public function hasRequestFailed(Response $response): ?bool
{
return $response->status() !== 200;
Expand Down
25 changes: 16 additions & 9 deletions src/Resources/Control/IndexResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ public function __construct(protected Connector $connector)
parent::__construct($connector);
}


public function describe(): Response
public function list(): Response
{
return $this->connector->send(new Index\DescribeIndex());
return $this->connector->send(new Index\ListIndexes());
}

public function createPod(
Expand Down Expand Up @@ -74,18 +73,26 @@ public function createServerless(

}

public function list(): Response

public function describe(string $name): Response
{
return $this->connector->send(new Index\ListIndexes());
return $this->connector->send(new Index\DescribeIndex(
name: $name
));
}

public function configure(string $pod_type, int $replicas): Response
public function configure(string $name, string $pod_type, int $replicas): Response
{
return $this->connector->send(new Index\ConfigureIndex($replicas, $pod_type));
return $this->connector->send(new Index\ConfigureIndex(
name: $name,
replicas: $replicas,
pod_type: $pod_type));
}

public function delete(): Response
public function delete(string $name): Response
{
return $this->connector->send(new Index\DeleteIndex());
return $this->connector->send(new Index\DeleteIndex(
name: $name
));
}
}

0 comments on commit cb3e2d8

Please sign in to comment.