这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 8 additions & 11 deletions src/Api/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
namespace Upsun\Api;

use Exception;
use InvalidArgumentException;
use JsonException;
use Http\Client\Common\Plugin\RedirectPlugin;
use Http\Client\Common\PluginClientFactory;
use Http\Discovery\Psr17FactoryDiscovery;
use InvalidArgumentException;
use JsonException;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Upsun\Core\OAuthProvider;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UriFactoryInterface;
use Psr\Http\Message\UriInterface;
use Upsun\Api\Serializer\ObjectSerializer;
use Upsun\Core\OAuthProvider;
use Psr\Http\Message\UriInterface;
use Psr\Http\Message\StreamInterface;

use function sprintf;

Expand All @@ -30,8 +30,7 @@
* @author Upsun Advocacy Team
* @license MIT
* @see https://docs.upsun.com
* @generated This file was generated by OpenAPI Generator. Do not edit manually.
*/
* @generated This file was generated by OpenAPI Generator. Do not edit manually. */
abstract class AbstractApi
{
private readonly StreamFactoryInterface $streamFactory;
Expand Down Expand Up @@ -138,7 +137,6 @@ protected function sendAuthenticatedRequest(
$e
);
}

throw $e;
} catch (Exception $e) {
if (isset($request)) {
Expand All @@ -149,7 +147,6 @@ protected function sendAuthenticatedRequest(
$e
);
}

throw $e;
}
}
Expand Down Expand Up @@ -218,9 +215,9 @@ protected function createUri(
/**
* @template T
* @param class-string<T>|string $dataType Fully-qualified class name, or scalar type like "string", "array"
* @return T
*
* @throws ApiException|Exception
* @return T
*/
protected function handleResponseWithDataType(
string $dataType,
Expand Down
55 changes: 23 additions & 32 deletions src/Api/AddOnsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,17 @@
use Psr\Http\Message\StreamFactoryInterface;
use Upsun\Api\Serializer\ObjectSerializer;
use Upsun\Core\OAuthProvider;
use Upsun\Model\OrganizationAddonsObject;
use Upsun\Model\UpdateOrgAddonsRequest;

/**
* Low level AddOnsApi (auto-generated)
*
* @author Upsun Advocacy Team
* @license MIT
* @see https://docs.upsun.com
* @generated This file was generated by OpenAPI Generator. Do not edit manually.
*/
* @generated This file was generated by OpenAPI Generator. Do not edit manually. */
final class AddOnsApi extends AbstractApi
{
private readonly ApiHeaderSelector $headerSelector;

private APIConfiguration $config;

public function __construct(
Expand Down Expand Up @@ -55,16 +51,16 @@ public function __construct(
*
* Retrieves information about the add-ons for an organization.
*
* @return \Upsun\Model\OrganizationAddonsObject
*
* @throws ApiException on non-2xx response
* @throws ClientExceptionInterface
* @return OrganizationAddonsObject
*
* @see https://docs.upsun.com/api/#tag/Add-ons/operation/get-org-addons
*/
public function getOrgAddons(
string $organizationId
): OrganizationAddonsObject {
): \Upsun\Model\OrganizationAddonsObject {
return $this->getOrgAddonsWithHttpInfo(
$organizationId
);
Expand All @@ -73,13 +69,13 @@ public function getOrgAddons(
/**
* Get add-ons with HTTP Info
*
* @return \Upsun\Model\OrganizationAddonsObject
*
* @throws ApiException|ClientExceptionInterface
* @return OrganizationAddonsObject
*/
private function getOrgAddonsWithHttpInfo(
string $organizationId
): OrganizationAddonsObject {
): \Upsun\Model\OrganizationAddonsObject {
$request = $this->getOrgAddonsRequest(
$organizationId
);
Expand All @@ -93,20 +89,20 @@ private function getOrgAddonsWithHttpInfo(
);

return $this->handleResponseWithDataType(
OrganizationAddonsObject::class,
'\Upsun\Model\OrganizationAddonsObject',
$request,
$response
);
} catch (Exception $exception) {
} catch (Exception $e) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$exception->getCode(),
$e->getCode(),
'/organizations/{organization_id}/addons'
),
$request,
$response ?? null,
$exception
$e
);
}
}
Expand All @@ -126,12 +122,11 @@ private function getOrgAddonsRequest(
|| (is_array($organizationId)
&& count($organizationId) === 0)
) {
throw new InvalidArgumentException(
throw new \InvalidArgumentException(
'Missing the required parameter $organizationId
when calling getOrgAddons'
);
}

$resourcePath = '/organizations/{organization_id}/addons';
$formParams = [];
$queryParams = [];
Expand Down Expand Up @@ -168,7 +163,6 @@ private function getOrgAddonsRequest(
];
}
}

// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($this->headerSelector->isJsonMime($headers['Content-Type'])) {
Expand Down Expand Up @@ -197,23 +191,22 @@ private function getOrgAddonsRequest(

return $this->createRequest('GET', $uri, $headers, $httpBody);
}

/**
* Update organization add-ons
*
* Updates the add-ons configuration for an organization.
*
* @return \Upsun\Model\OrganizationAddonsObject
*
* @throws ApiException on non-2xx response
* @throws ClientExceptionInterface
* @return OrganizationAddonsObject
*
* @see https://docs.upsun.com/api/#tag/Add-ons/operation/update-org-addons
*/
public function updateOrgAddons(
string $organizationId,
UpdateOrgAddonsRequest $updateOrgAddonsRequest
): OrganizationAddonsObject {
\Upsun\Model\UpdateOrgAddonsRequest $updateOrgAddonsRequest
): \Upsun\Model\OrganizationAddonsObject {
return $this->updateOrgAddonsWithHttpInfo(
$organizationId,
$updateOrgAddonsRequest
Expand All @@ -223,14 +216,14 @@ public function updateOrgAddons(
/**
* Update organization add-ons with HTTP Info
*
* @return \Upsun\Model\OrganizationAddonsObject
*
* @throws ApiException|ClientExceptionInterface
* @return OrganizationAddonsObject
*/
private function updateOrgAddonsWithHttpInfo(
string $organizationId,
UpdateOrgAddonsRequest $updateOrgAddonsRequest
): OrganizationAddonsObject {
\Upsun\Model\UpdateOrgAddonsRequest $updateOrgAddonsRequest
): \Upsun\Model\OrganizationAddonsObject {
$request = $this->updateOrgAddonsRequest(
$organizationId,
$updateOrgAddonsRequest
Expand All @@ -245,20 +238,20 @@ private function updateOrgAddonsWithHttpInfo(
);

return $this->handleResponseWithDataType(
OrganizationAddonsObject::class,
'\Upsun\Model\OrganizationAddonsObject',
$request,
$response
);
} catch (Exception $exception) {
} catch (Exception $e) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$exception->getCode(),
$e->getCode(),
'/organizations/{organization_id}/addons'
),
$request,
$response ?? null,
$exception
$e
);
}
}
Expand All @@ -270,7 +263,7 @@ private function updateOrgAddonsWithHttpInfo(
*/
private function updateOrgAddonsRequest(
string $organizationId,
UpdateOrgAddonsRequest $updateOrgAddonsRequest
\Upsun\Model\UpdateOrgAddonsRequest $updateOrgAddonsRequest
): RequestInterface {

// verify the required parameter 'organizationId' is set
Expand All @@ -279,7 +272,7 @@ private function updateOrgAddonsRequest(
|| (is_array($organizationId)
&& count($organizationId) === 0)
) {
throw new InvalidArgumentException(
throw new \InvalidArgumentException(
'Missing the required parameter $organizationId
when calling updateOrgAddons'
);
Expand All @@ -291,12 +284,11 @@ private function updateOrgAddonsRequest(
|| (is_array($updateOrgAddonsRequest)
&& count($updateOrgAddonsRequest) === 0)
) {
throw new InvalidArgumentException(
throw new \InvalidArgumentException(
'Missing the required parameter $updateOrgAddonsRequest
when calling updateOrgAddons'
);
}

$resourcePath = '/organizations/{organization_id}/addons';
$formParams = [];
$queryParams = [];
Expand Down Expand Up @@ -341,7 +333,6 @@ private function updateOrgAddonsRequest(
];
}
}

// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($this->headerSelector->isJsonMime($headers['Content-Type'])) {
Expand Down
Loading
Loading