You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

897 lines
36 KiB

<?php
/**
* DefaultApi
* PHP version 7.4
*
* @category Class
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Seaweedfs Master Server API
*
* The Seaweedfs Master Server API allows you to store blobs
*
* The version of the OpenAPI document: 3.43.0
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.4.0
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Api;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use OpenAPI\Client\ApiException;
use OpenAPI\Client\Configuration;
use OpenAPI\Client\HeaderSelector;
use OpenAPI\Client\ObjectSerializer;
/**
* DefaultApi Class Doc Comment
*
* @category Class
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class DefaultApi
{
/**
* @var ClientInterface
*/
protected $client;
/**
* @var Configuration
*/
protected $config;
/**
* @var HeaderSelector
*/
protected $headerSelector;
/**
* @var int Host index
*/
protected $hostIndex;
/** @var string[] $contentTypes **/
public const contentTypes = [
'dirAssign' => [
'application/json',
],
'dirLookup' => [
'application/json',
],
];
/**
* @param ClientInterface $client
* @param Configuration $config
* @param HeaderSelector $selector
* @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
*/
public function __construct(
ClientInterface $client = null,
Configuration $config = null,
HeaderSelector $selector = null,
$hostIndex = 0
) {
$this->client = $client ?: new Client();
$this->config = $config ?: new Configuration();
$this->headerSelector = $selector ?: new HeaderSelector();
$this->hostIndex = $hostIndex;
}
/**
* Set the host index
*
* @param int $hostIndex Host index (required)
*/
public function setHostIndex($hostIndex): void
{
$this->hostIndex = $hostIndex;
}
/**
* Get the host index
*
* @return int Host index
*/
public function getHostIndex()
{
return $this->hostIndex;
}
/**
* @return Configuration
*/
public function getConfig()
{
return $this->config;
}
/**
* Operation dirAssign
*
* Assign a file key
*
* @param mixed $count how many file ids to assign. Use &lt;fid&gt;_1, &lt;fid&gt;_2 for the assigned additional file ids. e.g. 3,01637037d6_1, 3,01637037d6_2 (optional)
* @param mixed $collection required collection name (optional)
* @param mixed $data_center preferred data center (optional)
* @param mixed $rack preferred rack (optional)
* @param mixed $data_node preferred volume server, e.g. 127.0.0.1:8080 (optional)
* @param mixed $disk If you have disks labelled, this must be supplied to specify the disk type to allocate on. (optional)
* @param mixed $replication replica placement strategy (optional)
* @param mixed $ttl file expiration time limit, example: 3m for 3 minutes. units: m-minute, h-hour, d-day, w-week, M-month, y-year (optional)
* @param mixed $preallocate If no matching volumes, pre-allocate this number of bytes on disk for new volumes. (optional)
* @param mixed $memory_map_max_size_mb Only implemented for windows. Use memory mapped files with specified size for new volumes. (optional)
* @param mixed $writable_volume_count If no matching volumes, create specified number of new volumes. (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['dirAssign'] to see the possible values for this operation
*
* @throws \OpenAPI\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \OpenAPI\Client\Model\FileKey
*/
public function dirAssign($count = null, $collection = null, $data_center = null, $rack = null, $data_node = null, $disk = null, $replication = null, $ttl = null, $preallocate = null, $memory_map_max_size_mb = null, $writable_volume_count = null, string $contentType = self::contentTypes['dirAssign'][0])
{
list($response) = $this->dirAssignWithHttpInfo($count, $collection, $data_center, $rack, $data_node, $disk, $replication, $ttl, $preallocate, $memory_map_max_size_mb, $writable_volume_count, $contentType);
return $response;
}
/**
* Operation dirAssignWithHttpInfo
*
* Assign a file key
*
* @param mixed $count how many file ids to assign. Use &lt;fid&gt;_1, &lt;fid&gt;_2 for the assigned additional file ids. e.g. 3,01637037d6_1, 3,01637037d6_2 (optional)
* @param mixed $collection required collection name (optional)
* @param mixed $data_center preferred data center (optional)
* @param mixed $rack preferred rack (optional)
* @param mixed $data_node preferred volume server, e.g. 127.0.0.1:8080 (optional)
* @param mixed $disk If you have disks labelled, this must be supplied to specify the disk type to allocate on. (optional)
* @param mixed $replication replica placement strategy (optional)
* @param mixed $ttl file expiration time limit, example: 3m for 3 minutes. units: m-minute, h-hour, d-day, w-week, M-month, y-year (optional)
* @param mixed $preallocate If no matching volumes, pre-allocate this number of bytes on disk for new volumes. (optional)
* @param mixed $memory_map_max_size_mb Only implemented for windows. Use memory mapped files with specified size for new volumes. (optional)
* @param mixed $writable_volume_count If no matching volumes, create specified number of new volumes. (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['dirAssign'] to see the possible values for this operation
*
* @throws \OpenAPI\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \OpenAPI\Client\Model\FileKey, HTTP status code, HTTP response headers (array of strings)
*/
public function dirAssignWithHttpInfo($count = null, $collection = null, $data_center = null, $rack = null, $data_node = null, $disk = null, $replication = null, $ttl = null, $preallocate = null, $memory_map_max_size_mb = null, $writable_volume_count = null, string $contentType = self::contentTypes['dirAssign'][0])
{
$request = $this->dirAssignRequest($count, $collection, $data_center, $rack, $data_node, $disk, $replication, $ttl, $preallocate, $memory_map_max_size_mb, $writable_volume_count, $contentType);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
);
} catch (ConnectException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
null,
null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\FileKey' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\FileKey' !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\FileKey', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\OpenAPI\Client\Model\FileKey';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\OpenAPI\Client\Model\FileKey',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation dirAssignAsync
*
* Assign a file key
*
* @param mixed $count how many file ids to assign. Use &lt;fid&gt;_1, &lt;fid&gt;_2 for the assigned additional file ids. e.g. 3,01637037d6_1, 3,01637037d6_2 (optional)
* @param mixed $collection required collection name (optional)
* @param mixed $data_center preferred data center (optional)
* @param mixed $rack preferred rack (optional)
* @param mixed $data_node preferred volume server, e.g. 127.0.0.1:8080 (optional)
* @param mixed $disk If you have disks labelled, this must be supplied to specify the disk type to allocate on. (optional)
* @param mixed $replication replica placement strategy (optional)
* @param mixed $ttl file expiration time limit, example: 3m for 3 minutes. units: m-minute, h-hour, d-day, w-week, M-month, y-year (optional)
* @param mixed $preallocate If no matching volumes, pre-allocate this number of bytes on disk for new volumes. (optional)
* @param mixed $memory_map_max_size_mb Only implemented for windows. Use memory mapped files with specified size for new volumes. (optional)
* @param mixed $writable_volume_count If no matching volumes, create specified number of new volumes. (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['dirAssign'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function dirAssignAsync($count = null, $collection = null, $data_center = null, $rack = null, $data_node = null, $disk = null, $replication = null, $ttl = null, $preallocate = null, $memory_map_max_size_mb = null, $writable_volume_count = null, string $contentType = self::contentTypes['dirAssign'][0])
{
return $this->dirAssignAsyncWithHttpInfo($count, $collection, $data_center, $rack, $data_node, $disk, $replication, $ttl, $preallocate, $memory_map_max_size_mb, $writable_volume_count, $contentType)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation dirAssignAsyncWithHttpInfo
*
* Assign a file key
*
* @param mixed $count how many file ids to assign. Use &lt;fid&gt;_1, &lt;fid&gt;_2 for the assigned additional file ids. e.g. 3,01637037d6_1, 3,01637037d6_2 (optional)
* @param mixed $collection required collection name (optional)
* @param mixed $data_center preferred data center (optional)
* @param mixed $rack preferred rack (optional)
* @param mixed $data_node preferred volume server, e.g. 127.0.0.1:8080 (optional)
* @param mixed $disk If you have disks labelled, this must be supplied to specify the disk type to allocate on. (optional)
* @param mixed $replication replica placement strategy (optional)
* @param mixed $ttl file expiration time limit, example: 3m for 3 minutes. units: m-minute, h-hour, d-day, w-week, M-month, y-year (optional)
* @param mixed $preallocate If no matching volumes, pre-allocate this number of bytes on disk for new volumes. (optional)
* @param mixed $memory_map_max_size_mb Only implemented for windows. Use memory mapped files with specified size for new volumes. (optional)
* @param mixed $writable_volume_count If no matching volumes, create specified number of new volumes. (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['dirAssign'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function dirAssignAsyncWithHttpInfo($count = null, $collection = null, $data_center = null, $rack = null, $data_node = null, $disk = null, $replication = null, $ttl = null, $preallocate = null, $memory_map_max_size_mb = null, $writable_volume_count = null, string $contentType = self::contentTypes['dirAssign'][0])
{
$returnType = '\OpenAPI\Client\Model\FileKey';
$request = $this->dirAssignRequest($count, $collection, $data_center, $rack, $data_node, $disk, $replication, $ttl, $preallocate, $memory_map_max_size_mb, $writable_volume_count, $contentType);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
);
}
/**
* Create request for operation 'dirAssign'
*
* @param mixed $count how many file ids to assign. Use &lt;fid&gt;_1, &lt;fid&gt;_2 for the assigned additional file ids. e.g. 3,01637037d6_1, 3,01637037d6_2 (optional)
* @param mixed $collection required collection name (optional)
* @param mixed $data_center preferred data center (optional)
* @param mixed $rack preferred rack (optional)
* @param mixed $data_node preferred volume server, e.g. 127.0.0.1:8080 (optional)
* @param mixed $disk If you have disks labelled, this must be supplied to specify the disk type to allocate on. (optional)
* @param mixed $replication replica placement strategy (optional)
* @param mixed $ttl file expiration time limit, example: 3m for 3 minutes. units: m-minute, h-hour, d-day, w-week, M-month, y-year (optional)
* @param mixed $preallocate If no matching volumes, pre-allocate this number of bytes on disk for new volumes. (optional)
* @param mixed $memory_map_max_size_mb Only implemented for windows. Use memory mapped files with specified size for new volumes. (optional)
* @param mixed $writable_volume_count If no matching volumes, create specified number of new volumes. (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['dirAssign'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function dirAssignRequest($count = null, $collection = null, $data_center = null, $rack = null, $data_node = null, $disk = null, $replication = null, $ttl = null, $preallocate = null, $memory_map_max_size_mb = null, $writable_volume_count = null, string $contentType = self::contentTypes['dirAssign'][0])
{
$resourcePath = '/dir/assign';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$count,
'count', // param base name
'mixed', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$collection,
'collection', // param base name
'mixed', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$data_center,
'dataCenter', // param base name
'mixed', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$rack,
'rack', // param base name
'mixed', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$data_node,
'dataNode', // param base name
'mixed', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$disk,
'disk', // param base name
'mixed', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$replication,
'replication', // param base name
'mixed', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$ttl,
'ttl', // param base name
'mixed', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$preallocate,
'preallocate', // param base name
'mixed', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$memory_map_max_size_mb,
'memoryMapMaxSizeMb', // param base name
'mixed', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$writable_volume_count,
'writableVolumeCount', // param base name
'mixed', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
$headers = $this->headerSelector->selectHeaders(
['application/json', ],
$contentType,
$multipart
);
// for model (json/xml)
if (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem
];
}
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
}
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$operationHost = $this->config->getHost();
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'GET',
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation dirLookup
*
* Lookup volume
*
* @param mixed $volume_id volume id (optional)
* @param mixed $collection optionally to speed up the lookup (optional)
* @param mixed $file_id If provided, this returns the fileId location and a JWT to update or delete the file. (optional)
* @param mixed $read works together with \&quot;fileId\&quot;, if read&#x3D;yes, JWT is generated for reads. (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['dirLookup'] to see the possible values for this operation
*
* @throws \OpenAPI\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return mixed
*/
public function dirLookup($volume_id = null, $collection = null, $file_id = null, $read = null, string $contentType = self::contentTypes['dirLookup'][0])
{
list($response) = $this->dirLookupWithHttpInfo($volume_id, $collection, $file_id, $read, $contentType);
return $response;
}
/**
* Operation dirLookupWithHttpInfo
*
* Lookup volume
*
* @param mixed $volume_id volume id (optional)
* @param mixed $collection optionally to speed up the lookup (optional)
* @param mixed $file_id If provided, this returns the fileId location and a JWT to update or delete the file. (optional)
* @param mixed $read works together with \&quot;fileId\&quot;, if read&#x3D;yes, JWT is generated for reads. (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['dirLookup'] to see the possible values for this operation
*
* @throws \OpenAPI\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of mixed, HTTP status code, HTTP response headers (array of strings)
*/
public function dirLookupWithHttpInfo($volume_id = null, $collection = null, $file_id = null, $read = null, string $contentType = self::contentTypes['dirLookup'][0])
{
$request = $this->dirLookupRequest($volume_id, $collection, $file_id, $read, $contentType);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
);
} catch (ConnectException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
null,
null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
switch($statusCode) {
case 200:
if ('mixed' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('mixed' !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, 'mixed', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = 'mixed';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'mixed',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation dirLookupAsync
*
* Lookup volume
*
* @param mixed $volume_id volume id (optional)
* @param mixed $collection optionally to speed up the lookup (optional)
* @param mixed $file_id If provided, this returns the fileId location and a JWT to update or delete the file. (optional)
* @param mixed $read works together with \&quot;fileId\&quot;, if read&#x3D;yes, JWT is generated for reads. (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['dirLookup'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function dirLookupAsync($volume_id = null, $collection = null, $file_id = null, $read = null, string $contentType = self::contentTypes['dirLookup'][0])
{
return $this->dirLookupAsyncWithHttpInfo($volume_id, $collection, $file_id, $read, $contentType)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation dirLookupAsyncWithHttpInfo
*
* Lookup volume
*
* @param mixed $volume_id volume id (optional)
* @param mixed $collection optionally to speed up the lookup (optional)
* @param mixed $file_id If provided, this returns the fileId location and a JWT to update or delete the file. (optional)
* @param mixed $read works together with \&quot;fileId\&quot;, if read&#x3D;yes, JWT is generated for reads. (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['dirLookup'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function dirLookupAsyncWithHttpInfo($volume_id = null, $collection = null, $file_id = null, $read = null, string $contentType = self::contentTypes['dirLookup'][0])
{
$returnType = 'mixed';
$request = $this->dirLookupRequest($volume_id, $collection, $file_id, $read, $contentType);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
);
}
/**
* Create request for operation 'dirLookup'
*
* @param mixed $volume_id volume id (optional)
* @param mixed $collection optionally to speed up the lookup (optional)
* @param mixed $file_id If provided, this returns the fileId location and a JWT to update or delete the file. (optional)
* @param mixed $read works together with \&quot;fileId\&quot;, if read&#x3D;yes, JWT is generated for reads. (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['dirLookup'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function dirLookupRequest($volume_id = null, $collection = null, $file_id = null, $read = null, string $contentType = self::contentTypes['dirLookup'][0])
{
$resourcePath = '/dir/lookup';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$volume_id,
'volumeId', // param base name
'mixed', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$collection,
'collection', // param base name
'mixed', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$file_id,
'fileId', // param base name
'mixed', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$read,
'read', // param base name
'mixed', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
$headers = $this->headerSelector->selectHeaders(
['application/json', ],
$contentType,
$multipart
);
// for model (json/xml)
if (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem
];
}
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
}
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$operationHost = $this->config->getHost();
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'GET',
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Create http client option
*
* @throws \RuntimeException on file opening failure
* @return array of http client options
*/
protected function createHttpClientOption()
{
$options = [];
if ($this->config->getDebug()) {
$options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
if (!$options[RequestOptions::DEBUG]) {
throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
}
}
return $options;
}
}