Skip to content

Commit

Permalink
feat(specs): add authentications to ingestion transformations (genera…
Browse files Browse the repository at this point in the history
…ted)

algolia/api-clients-automation#3494

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
  • Loading branch information
algolia-bot and shortcuts committed Aug 8, 2024
1 parent 7d71353 commit 1852d61
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/ingestion/model/clientMethodProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type { TaskSortKeys } from './taskSortKeys';
import type { TaskUpdate } from './taskUpdate';
import type { TaskUpdateV1 } from './taskUpdateV1';
import type { TransformationCreate } from './transformationCreate';
import type { TransformationTry } from './transformationTry';
import type { TriggerType } from './triggerType';

/**
Expand Down Expand Up @@ -608,6 +609,17 @@ export type TriggerDockerSourceDiscoverProps = {
sourceID: string;
};

/**
* Properties for the `tryTransformationBeforeUpdate` method.
*/
export type TryTransformationBeforeUpdateProps = {
/**
* Unique identifier of a transformation.
*/
transformationID: string;
transformationTry: TransformationTry;
};

/**
* Properties for the `updateAuthentication` method.
*/
Expand Down
5 changes: 5 additions & 0 deletions packages/ingestion/model/transformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ export type Transformation = {
*/
transformationID: string;

/**
* The authentications associated for the current transformation.
*/
authenticationIDs?: string[];

/**
* The source code of the transformation.
*/
Expand Down
5 changes: 5 additions & 0 deletions packages/ingestion/model/transformationCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ export type TransformationCreate = {
* A descriptive name for your transformation of what it does.
*/
description?: string;

/**
* The authentications associated for the current transformation.
*/
authenticationIDs?: string[];
};
4 changes: 4 additions & 0 deletions packages/ingestion/model/transformationTry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

import type { AuthenticationCreate } from './authenticationCreate';

export type TransformationTry = {
/**
* The source code of the transformation.
Expand All @@ -10,4 +12,6 @@ export type TransformationTry = {
* The record to apply the given code to.
*/
sampleRecord: Record<string, any>;

authentications?: AuthenticationCreate[];
};
64 changes: 63 additions & 1 deletion packages/ingestion/src/ingestionClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import type {
RunTaskProps,
RunTaskV1Props,
TriggerDockerSourceDiscoverProps,
TryTransformationBeforeUpdateProps,
UpdateAuthenticationProps,
UpdateDestinationProps,
UpdateSourceProps,
Expand Down Expand Up @@ -2455,7 +2456,7 @@ export function createIngestionClient({
},

/**
* Try a transformation.
* Try a transformation before creating it.
*
* Required API Key ACLs:
* - addObject
Expand Down Expand Up @@ -2501,6 +2502,67 @@ export function createIngestionClient({
return transporter.request(request, requestOptions);
},

/**
* Try a transformation before updating it.
*
* Required API Key ACLs:
* - addObject
* - deleteIndex
* - editSettings.
*
* @param tryTransformationBeforeUpdate - The tryTransformationBeforeUpdate object.
* @param tryTransformationBeforeUpdate.transformationID - Unique identifier of a transformation.
* @param tryTransformationBeforeUpdate.transformationTry - The transformationTry object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
tryTransformationBeforeUpdate(
{
transformationID,
transformationTry,
}: TryTransformationBeforeUpdateProps,
requestOptions?: RequestOptions
): Promise<TransformationTryResponse> {
if (!transformationID) {
throw new Error(
'Parameter `transformationID` is required when calling `tryTransformationBeforeUpdate`.'
);
}

if (!transformationTry) {
throw new Error(
'Parameter `transformationTry` is required when calling `tryTransformationBeforeUpdate`.'
);
}

if (!transformationTry.code) {
throw new Error(
'Parameter `transformationTry.code` is required when calling `tryTransformationBeforeUpdate`.'
);
}
if (!transformationTry.sampleRecord) {
throw new Error(
'Parameter `transformationTry.sampleRecord` is required when calling `tryTransformationBeforeUpdate`.'
);
}

const requestPath = '/1/transformations/{transformationID}/try'.replace(
'{transformationID}',
encodeURIComponent(transformationID)
);
const headers: Headers = {};
const queryParameters: QueryParameters = {};

const request: Request = {
method: 'POST',
path: requestPath,
queryParameters,
headers,
data: transformationTry,
};

return transporter.request(request, requestOptions);
},

/**
* Updates an authentication resource.
*
Expand Down

0 comments on commit 1852d61

Please sign in to comment.