Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts committed Feb 10, 2022
2 parents 256ed08 + 5854261 commit 6a75c0a
Show file tree
Hide file tree
Showing 51 changed files with 1,649 additions and 1,811 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ export class EchoRequester extends Requester {
{ headers, url, connectTimeout, responseTimeout }: EndRequest,
{ data, ...originalRequest }: Request
): Promise<Response> {
const urlSearchParams = new URL(url).searchParams;
const { host, searchParams: urlSearchParams } = new URL(url);
const userAgent = urlSearchParams.get('x-algolia-agent') || undefined;
const originalData =
data && Object.entries(data).length > 0 ? data : undefined;

return Promise.resolve({
content: JSON.stringify({
...originalRequest,
host,
headers,
connectTimeout,
responseTimeout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export type Response = {

export type EchoResponse = Request & {
connectTimeout: number;
host: string;
headers: Record<string, string>;
responseTimeout: number;
searchParams?: Record<string, string>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { PostURLJobInput } from './postURLJobInput';
import type { PostURLJobTarget } from './postURLJobTarget';

/**
* Object containing a URL job.
Expand All @@ -8,7 +9,12 @@ export type PostURLJob = {
* The type of the file to ingest.
*/
type: PostURLJobType;
/**
* The name of the column that hold the unique identifier.
*/
uniqueIDColumn?: string;
input: PostURLJobInput;
target: PostURLJobTarget;
};

export type PostURLJobType = 'csv';
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* The authentication scheme for the URL that will be fetched.
*/
export type PostURLJobAuth = {
/**
* The type of authentication to use.
*/
type: PostURLJobAuthType;
/**
* The login to use for Basic Auth.
*/
login: string;
/**
* The password to use for Basic Auth.
*/
password: string;
};

export type PostURLJobAuthType = 'basic';
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { PostURLJobAuth } from './postURLJobAuth';

/**
* The input of the job.
*/
Expand All @@ -6,4 +8,11 @@ export type PostURLJobInput = {
* The URL of the file to ingest.
*/
url: string;
/**
* The HTTP method that will be used to fetch the URL.
*/
method?: PostURLJobInputMethod;
auth?: PostURLJobAuth;
};

export type PostURLJobInputMethod = 'GET' | 'POST';
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* The target of the job.
*/
export type PostURLJobTarget = {
/**
* The product to target.
*/
type: PostURLJobTargetType;
/**
* The index name of the product.
*/
indexName: string;
/**
* The type of operation to execute.
*/
operation: PostURLJobTargetOperation;
};

export type PostURLJobTargetType = 'search';

export type PostURLJobTargetOperation = 'replace';
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ export const createSourcesApi = (
'Parameter `postURLJob.input` is required when calling `postIngestUrl`.'
);
}
if (!postURLJob.target) {
throw new Error(
'Parameter `postURLJob.target` is required when calling `postIngestUrl`.'
);
}

const request: Request = {
method: 'POST',
Expand Down
2 changes: 1 addition & 1 deletion clients/algoliasearch-client-php/lib/Algolia.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

final class Algolia
{
const VERSION = '1.0.0';
const VERSION = '4.0.0';

/**
* Holds an instance of the simple cache repository (PSR-16).
Expand Down
103 changes: 8 additions & 95 deletions clients/algoliasearch-client-php/lib/Api/AbtestingApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,30 +109,13 @@ public function addABTests($addABTestsRequest)

$resourcePath = '/2/abtests';
$queryParams = [];
$headerParams = [];
$httpBody = [];

$headers = [];
$headers['Accept'] = 'application/json';
$headers['Content-Type'] = 'application/json';
if (isset($addABTestsRequest)) {
$httpBody = $addABTestsRequest;
}

$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}

$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);

$query = \GuzzleHttp\Psr7\Query::build($queryParams);

return $this->sendRequest('POST', $resourcePath, $query, $httpBody);
return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody);
}
/**
* Operation deleteABTest
Expand All @@ -157,7 +140,6 @@ public function deleteABTest($id)

$resourcePath = '/2/abtests/{id}';
$queryParams = [];
$headerParams = [];
$httpBody = [];
// path params
if ($id !== null) {
Expand All @@ -168,24 +150,7 @@ public function deleteABTest($id)
);
}

$headers = [];
$headers['Accept'] = 'application/json';
$headers['Content-Type'] = 'application/json';

$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}

$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);

$query = \GuzzleHttp\Psr7\Query::build($queryParams);

return $this->sendRequest('DELETE', $resourcePath, $query, $httpBody);
return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody);
}
/**
* Operation getABTest
Expand All @@ -210,7 +175,6 @@ public function getABTest($id)

$resourcePath = '/2/abtests/{id}';
$queryParams = [];
$headerParams = [];
$httpBody = [];
// path params
if ($id !== null) {
Expand All @@ -221,24 +185,7 @@ public function getABTest($id)
);
}

$headers = [];
$headers['Accept'] = 'application/json';
$headers['Content-Type'] = 'application/json';

$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}

$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);

$query = \GuzzleHttp\Psr7\Query::build($queryParams);

return $this->sendRequest('GET', $resourcePath, $query, $httpBody);
return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody);
}
/**
* Operation listABTests
Expand All @@ -257,7 +204,6 @@ public function listABTests($offset = 0, $limit = 10)
{
$resourcePath = '/2/abtests';
$queryParams = [];
$headerParams = [];
$httpBody = [];

if ($offset !== null) {
Expand All @@ -280,24 +226,7 @@ public function listABTests($offset = 0, $limit = 10)
}
}

$headers = [];
$headers['Accept'] = 'application/json';
$headers['Content-Type'] = 'application/json';

$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}

$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);

$query = \GuzzleHttp\Psr7\Query::build($queryParams);

return $this->sendRequest('GET', $resourcePath, $query, $httpBody);
return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody);
}
/**
* Operation stopABTest
Expand All @@ -322,7 +251,6 @@ public function stopABTest($id)

$resourcePath = '/2/abtests/{id}/stop';
$queryParams = [];
$headerParams = [];
$httpBody = [];
// path params
if ($id !== null) {
Expand All @@ -333,28 +261,13 @@ public function stopABTest($id)
);
}

$headers = [];
$headers['Accept'] = 'application/json';
$headers['Content-Type'] = 'application/json';

$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}

$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);

$query = \GuzzleHttp\Psr7\Query::build($queryParams);

return $this->sendRequest('POST', $resourcePath, $query, $httpBody);
return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody);
}

private function sendRequest($method, $resourcePath, $query, $httpBody)
private function sendRequest($method, $resourcePath, $queryParams, $httpBody)
{
$query = \GuzzleHttp\Psr7\Query::build($queryParams);

if ($method === 'GET') {
$request = $this->api->read(
$method,
Expand Down
Loading

0 comments on commit 6a75c0a

Please sign in to comment.