Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,17 @@
],
"require": {
"php": "^8.1",
"jane-php/open-api-runtime": "^7.9"
"jane-php/open-api-runtime": "^7.9",
"nyholm/psr7": "^1.8"
},
"require-dev": {
"jane-php/open-api-3": "dev-fixes as 7.9.0",
"jane-php/json-schema": "dev-bugfix/array-objects as 7.9.0",
"jane-php/open-api-common": "dev-next as 7.9.0",
"jane-php/jane-php": "dev-next",
"friendsofphp/php-cs-fixer": "^3.75"
},
"repositories": [
{
"type": "vcs",
"url": "git@github.com:silverstripeltd/jane-php-json-schema.git"
},
{
"type": "vcs",
"url": "git@github.com:silverstripeltd/jane-php-open-api-3.git"
"url": "https://github.com/janephp/janephp.git"
}
],
"extra": {
Expand Down
5,555 changes: 5,554 additions & 1 deletion spec/openapi.json

Large diffs are not rendered by default.

451 changes: 424 additions & 27 deletions src/Client.php

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions src/Endpoint/BoostDelete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

namespace Silverstripe\Search\Client\Endpoint;

class BoostDelete extends \Silverstripe\Search\Client\Runtime\Client\BaseEndpoint implements \Silverstripe\Search\Client\Runtime\Client\Endpoint
{
protected $field_name;
protected $boost_id;
protected $engine_name;
/**
* Delete a specific boost by its ID.
* @param string $fieldName Name of the field
* @param string $boostId ID of the boost to delete
* @param string $engineName
*/
public function __construct(string $fieldName, string $boostId, string $engineName)
{
$this->field_name = $fieldName;
$this->boost_id = $boostId;
$this->engine_name = $engineName;
}
use \Silverstripe\Search\Client\Runtime\Client\EndpointTrait;
public function getMethod(): string
{
return 'DELETE';
}
public function getUri(): string
{
return str_replace(['{field_name}', '{boost_id}', '{engine_name}'], [$this->field_name, $this->boost_id, $this->engine_name], '/{engine_name}/field/{field_name}/boosts/{boost_id}');
}
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array
{
return [[], null];
}
public function getExtraHeaders(): array
{
return ['Accept' => ['application/json']];
}
/**
* {@inheritdoc}
*
* @throws \Silverstripe\Search\Client\Exception\BoostDeleteNotFoundException
* @throws \Silverstripe\Search\Client\Exception\BoostDeleteUnprocessableEntityException
* @throws \Silverstripe\Search\Client\Exception\UnexpectedStatusCodeException
*
* @return \Silverstripe\Search\Client\Model\ResponseSuccess
*/
protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
{
$status = $response->getStatusCode();
$body = (string) $response->getBody();
if (is_null($contentType) === false && (200 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
return $serializer->deserialize($body, 'Silverstripe\Search\Client\Model\ResponseSuccess', 'json');
}
if (404 === $status) {
throw new \Silverstripe\Search\Client\Exception\BoostDeleteNotFoundException($response);
}
if (is_null($contentType) === false && (422 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \Silverstripe\Search\Client\Exception\BoostDeleteUnprocessableEntityException($serializer->deserialize($body, 'Silverstripe\Search\Client\Model\HTTPValidationError', 'json'), $response);
}
throw new \Silverstripe\Search\Client\Exception\UnexpectedStatusCodeException($status, $body);
}
public function getAuthenticationScopes(): array
{
return ['HTTPBearer'];
}
}
67 changes: 67 additions & 0 deletions src/Endpoint/BoostGet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

namespace Silverstripe\Search\Client\Endpoint;

class BoostGet extends \Silverstripe\Search\Client\Runtime\Client\BaseEndpoint implements \Silverstripe\Search\Client\Runtime\Client\Endpoint
{
protected $field_name;
protected $boost_id;
protected $engine_name;
/**
* Get a specific boost by its ID.
* @param string $fieldName Name of the field
* @param string $boostId ID of the boost to retrieve
* @param string $engineName
*/
public function __construct(string $fieldName, string $boostId, string $engineName)
{
$this->field_name = $fieldName;
$this->boost_id = $boostId;
$this->engine_name = $engineName;
}
use \Silverstripe\Search\Client\Runtime\Client\EndpointTrait;
public function getMethod(): string
{
return 'GET';
}
public function getUri(): string
{
return str_replace(['{field_name}', '{boost_id}', '{engine_name}'], [$this->field_name, $this->boost_id, $this->engine_name], '/{engine_name}/field/{field_name}/boosts/{boost_id}');
}
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array
{
return [[], null];
}
public function getExtraHeaders(): array
{
return ['Accept' => ['application/json']];
}
/**
* {@inheritdoc}
*
* @throws \Silverstripe\Search\Client\Exception\BoostGetNotFoundException
* @throws \Silverstripe\Search\Client\Exception\BoostGetUnprocessableEntityException
* @throws \Silverstripe\Search\Client\Exception\UnexpectedStatusCodeException
*
* @return \Silverstripe\Search\Client\Model\BoostGetResponse
*/
protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
{
$status = $response->getStatusCode();
$body = (string) $response->getBody();
if (is_null($contentType) === false && (200 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
return $serializer->deserialize($body, 'Silverstripe\Search\Client\Model\BoostGetResponse', 'json');
}
if (404 === $status) {
throw new \Silverstripe\Search\Client\Exception\BoostGetNotFoundException($response);
}
if (is_null($contentType) === false && (422 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \Silverstripe\Search\Client\Exception\BoostGetUnprocessableEntityException($serializer->deserialize($body, 'Silverstripe\Search\Client\Model\HTTPValidationError', 'json'), $response);
}
throw new \Silverstripe\Search\Client\Exception\UnexpectedStatusCodeException($status, $body);
}
public function getAuthenticationScopes(): array
{
return ['HTTPBearer'];
}
}
72 changes: 72 additions & 0 deletions src/Endpoint/BoostPatch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace Silverstripe\Search\Client\Endpoint;

class BoostPatch extends \Silverstripe\Search\Client\Runtime\Client\BaseEndpoint implements \Silverstripe\Search\Client\Runtime\Client\Endpoint
{
protected $field_name;
protected $boost_id;
protected $engine_name;
/**
* Update a specific boost by its ID.
* @param string $fieldName Name of the field
* @param string $boostId ID of the boost to update
* @param string $engineName
* @param \Silverstripe\Search\Client\Model\BoostPatchRequest $requestBody
*/
public function __construct(string $fieldName, string $boostId, string $engineName, \Silverstripe\Search\Client\Model\BoostPatchRequest $requestBody)
{
$this->field_name = $fieldName;
$this->boost_id = $boostId;
$this->engine_name = $engineName;
$this->body = $requestBody;
}
use \Silverstripe\Search\Client\Runtime\Client\EndpointTrait;
public function getMethod(): string
{
return 'PATCH';
}
public function getUri(): string
{
return str_replace(['{field_name}', '{boost_id}', '{engine_name}'], [$this->field_name, $this->boost_id, $this->engine_name], '/{engine_name}/field/{field_name}/boosts/{boost_id}');
}
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array
{
if ($this->body instanceof \Silverstripe\Search\Client\Model\BoostPatchRequest) {
return [['Content-Type' => ['application/json']], $serializer->serialize($this->body, 'json')];
}
return [[], null];
}
public function getExtraHeaders(): array
{
return ['Accept' => ['application/json']];
}
/**
* {@inheritdoc}
*
* @throws \Silverstripe\Search\Client\Exception\BoostPatchNotFoundException
* @throws \Silverstripe\Search\Client\Exception\BoostPatchUnprocessableEntityException
* @throws \Silverstripe\Search\Client\Exception\UnexpectedStatusCodeException
*
* @return \Silverstripe\Search\Client\Model\BoostGetResponse
*/
protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
{
$status = $response->getStatusCode();
$body = (string) $response->getBody();
if (is_null($contentType) === false && (200 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
return $serializer->deserialize($body, 'Silverstripe\Search\Client\Model\BoostGetResponse', 'json');
}
if (404 === $status) {
throw new \Silverstripe\Search\Client\Exception\BoostPatchNotFoundException($response);
}
if (is_null($contentType) === false && (422 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \Silverstripe\Search\Client\Exception\BoostPatchUnprocessableEntityException($serializer->deserialize($body, 'Silverstripe\Search\Client\Model\HTTPValidationError', 'json'), $response);
}
throw new \Silverstripe\Search\Client\Exception\UnexpectedStatusCodeException($status, $body);
}
public function getAuthenticationScopes(): array
{
return ['HTTPBearer'];
}
}
64 changes: 64 additions & 0 deletions src/Endpoint/BoostsGet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace Silverstripe\Search\Client\Endpoint;

class BoostsGet extends \Silverstripe\Search\Client\Runtime\Client\BaseEndpoint implements \Silverstripe\Search\Client\Runtime\Client\Endpoint
{
protected $field_name;
protected $engine_name;
/**
* Get all boosts for a field.
* @param string $fieldName Name of the field to get boosts for
* @param string $engineName
*/
public function __construct(string $fieldName, string $engineName)
{
$this->field_name = $fieldName;
$this->engine_name = $engineName;
}
use \Silverstripe\Search\Client\Runtime\Client\EndpointTrait;
public function getMethod(): string
{
return 'GET';
}
public function getUri(): string
{
return str_replace(['{field_name}', '{engine_name}'], [$this->field_name, $this->engine_name], '/{engine_name}/field/{field_name}/boosts');
}
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array
{
return [[], null];
}
public function getExtraHeaders(): array
{
return ['Accept' => ['application/json']];
}
/**
* {@inheritdoc}
*
* @throws \Silverstripe\Search\Client\Exception\BoostsGetNotFoundException
* @throws \Silverstripe\Search\Client\Exception\BoostsGetUnprocessableEntityException
* @throws \Silverstripe\Search\Client\Exception\UnexpectedStatusCodeException
*
* @return \Silverstripe\Search\Client\Model\BoostGetResponse[]
*/
protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
{
$status = $response->getStatusCode();
$body = (string) $response->getBody();
if (is_null($contentType) === false && (200 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
return $serializer->deserialize($body, 'Silverstripe\Search\Client\Model\BoostGetResponse[]', 'json');
}
if (404 === $status) {
throw new \Silverstripe\Search\Client\Exception\BoostsGetNotFoundException($response);
}
if (is_null($contentType) === false && (422 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \Silverstripe\Search\Client\Exception\BoostsGetUnprocessableEntityException($serializer->deserialize($body, 'Silverstripe\Search\Client\Model\HTTPValidationError', 'json'), $response);
}
throw new \Silverstripe\Search\Client\Exception\UnexpectedStatusCodeException($status, $body);
}
public function getAuthenticationScopes(): array
{
return ['HTTPBearer'];
}
}
69 changes: 69 additions & 0 deletions src/Endpoint/BoostsPost.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace Silverstripe\Search\Client\Endpoint;

class BoostsPost extends \Silverstripe\Search\Client\Runtime\Client\BaseEndpoint implements \Silverstripe\Search\Client\Runtime\Client\Endpoint
{
protected $field_name;
protected $engine_name;
/**
* Create a new boost for a field.
* @param string $fieldName Name of the field to add boost to
* @param string $engineName
* @param \Silverstripe\Search\Client\Model\BoostPostRequest $requestBody
*/
public function __construct(string $fieldName, string $engineName, \Silverstripe\Search\Client\Model\BoostPostRequest $requestBody)
{
$this->field_name = $fieldName;
$this->engine_name = $engineName;
$this->body = $requestBody;
}
use \Silverstripe\Search\Client\Runtime\Client\EndpointTrait;
public function getMethod(): string
{
return 'POST';
}
public function getUri(): string
{
return str_replace(['{field_name}', '{engine_name}'], [$this->field_name, $this->engine_name], '/{engine_name}/field/{field_name}/boosts');
}
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array
{
if ($this->body instanceof \Silverstripe\Search\Client\Model\BoostPostRequest) {
return [['Content-Type' => ['application/json']], $serializer->serialize($this->body, 'json')];
}
return [[], null];
}
public function getExtraHeaders(): array
{
return ['Accept' => ['application/json']];
}
/**
* {@inheritdoc}
*
* @throws \Silverstripe\Search\Client\Exception\BoostsPostNotFoundException
* @throws \Silverstripe\Search\Client\Exception\BoostsPostUnprocessableEntityException
* @throws \Silverstripe\Search\Client\Exception\UnexpectedStatusCodeException
*
* @return \Silverstripe\Search\Client\Model\BoostPostResponse
*/
protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
{
$status = $response->getStatusCode();
$body = (string) $response->getBody();
if (is_null($contentType) === false && (200 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
return $serializer->deserialize($body, 'Silverstripe\Search\Client\Model\BoostPostResponse', 'json');
}
if (404 === $status) {
throw new \Silverstripe\Search\Client\Exception\BoostsPostNotFoundException($response);
}
if (is_null($contentType) === false && (422 === $status && mb_strpos(strtolower($contentType), 'application/json') !== false)) {
throw new \Silverstripe\Search\Client\Exception\BoostsPostUnprocessableEntityException($serializer->deserialize($body, 'Silverstripe\Search\Client\Model\HTTPValidationError', 'json'), $response);
}
throw new \Silverstripe\Search\Client\Exception\UnexpectedStatusCodeException($status, $body);
}
public function getAuthenticationScopes(): array
{
return ['HTTPBearer'];
}
}
Loading