diff --git a/src/api/relationship-tuples.ts b/src/api/relationship-tuples.ts index 7a777c5..9d3d92c 100644 --- a/src/api/relationship-tuples.ts +++ b/src/api/relationship-tuples.ts @@ -4,7 +4,9 @@ import { IPermitConfig } from '../config'; import { RelationshipTuplesApi as AutogenRelationshipTuplesApi, RelationshipTupleCreate, + RelationshipTupleCreateBulkOperation, RelationshipTupleDelete, + RelationshipTupleDeleteBulkOperation, RelationshipTupleRead, } from '../openapi'; import { BASE_PATH } from '../openapi/base'; @@ -16,6 +18,8 @@ export { RelationshipTupleCreate, RelationshipTupleDelete, RelationshipTupleRead, + RelationshipTupleCreateBulkOperation, + RelationshipTupleDeleteBulkOperation, } from '../openapi'; /** @@ -76,6 +80,32 @@ export interface IRelationshipTuplesApi { * @throws {@link PermitContextError} If the configured {@link ApiContext} does not match the required endpoint context. */ delete(tuple: RelationshipTupleDelete): Promise; + + /** + * Creates multiple relationship tuples at once using the provided tuple data. + * Each tuple object is of type RelationshipTupleCreate and is essentially a tuple of (subject, relation, object, tenant). + * + * @param tuples - The relationship tuples to create. + * @returns A promise that resolves with the bulk assignment report. + * @throws {@link PermitApiError} If the API returns an error HTTP status code. + * @throws {@link PermitContextError} If the configured {@link ApiContext} does not match the required endpoint context. + */ + bulkRelationshipTuples( + tuples: RelationshipTupleCreate[], + ): Promise; + + /** + * Deletes multiple relationship tuples at once using the provided tuple data. + * Each tuple object is of type RelationshipTupleDelete and is essentially a tuple of (subject, relation, object). + * + * @param tuples - he relationship tuples to delete. + * @returns A promise that resolves with the bulk un relationship tuples report. + * @throws {@link PermitApiError} If the API returns an error HTTP status code. + * @throws {@link PermitContextError} If the configured {@link ApiContext} does not match the required endpoint context. + */ + bulkUnRelationshipTuples( + tuples: RelationshipTupleDelete[], + ): Promise; } /** @@ -174,4 +204,60 @@ export class RelationshipTuplesApi extends BasePermitApi implements IRelationshi this.handleApiError(err); } } + + /** + * Creates a new relationship tuple, that states that a relationship (of type: relation) + * exists between two resource instances: the subject and the object. + * + * @returns A promise that resolves to the created relationship tuple. + * @throws {@link PermitApiError} If the API returns an error HTTP status code. + * @throws {@link PermitContextError} If the configured {@link ApiContext} does not match the required endpoint context. + * @param tuples + */ + public async bulkRelationshipTuples( + tuples: RelationshipTupleCreate[], + ): Promise { + await this.ensureAccessLevel(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + await this.ensureContext(ApiContextLevel.ENVIRONMENT); + try { + return ( + await this.relationshipTuples.bulkCreateRelationshipTuples({ + ...this.config.apiContext.environmentContext, + relationshipTupleCreateBulkOperation: { + operations: tuples, + }, + }) + ).data; + } catch (err) { + this.handleApiError(err); + } + } + + /** + * Deletes multiple relationship tuples at once using the provided tuple data. + * Each tuple object is of type RelationshipTupleDelete and is essentially a tuple of (subject, relation, object). + * + * @param tuples - he relationship tuples to delete. + * @returns A promise that resolves with the bulk un relationship tuples report. + * @throws {@link PermitApiError} If the API returns an error HTTP status code. + * @throws {@link PermitContextError} If the configured {@link ApiContext} does not match the required endpoint context. + */ + public async bulkUnRelationshipTuples( + tuples: RelationshipTupleDelete[], + ): Promise { + await this.ensureAccessLevel(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + await this.ensureContext(ApiContextLevel.ENVIRONMENT); + try { + return ( + await this.relationshipTuples.bulkDeleteRelationshipTuples({ + ...this.config.apiContext.environmentContext, + relationshipTupleDeleteBulkOperation: { + idents: tuples, + }, + }) + ).data; + } catch (err) { + this.handleApiError(err); + } + } } diff --git a/src/openapi/api/relationship-tuples-api.ts b/src/openapi/api/relationship-tuples-api.ts index 34f5c97..773db3a 100644 --- a/src/openapi/api/relationship-tuples-api.ts +++ b/src/openapi/api/relationship-tuples-api.ts @@ -35,8 +35,12 @@ import { HTTPValidationError } from '../types'; // @ts-ignore import { RelationshipTupleCreate } from '../types'; // @ts-ignore +import { RelationshipTupleCreateBulkOperation } from '../types'; +// @ts-ignore import { RelationshipTupleDelete } from '../types'; // @ts-ignore +import { RelationshipTupleDeleteBulkOperation } from '../types'; +// @ts-ignore import { RelationshipTupleRead } from '../types'; /** * RelationshipTuplesApi - axios parameter creator @@ -44,6 +48,132 @@ import { RelationshipTupleRead } from '../types'; */ export const RelationshipTuplesApiAxiosParamCreator = function (configuration?: Configuration) { return { + /** + * + * @summary Bulk create relationship tuples(EAP) + * @param {any} projId Either the unique id of the project, or the URL-friendly key of the project (i.e: the \"slug\"). + * @param {any} envId Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the \"slug\"). + * @param {RelationshipTupleCreateBulkOperation} relationshipTupleCreateBulkOperation + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + bulkCreateRelationshipTuples: async ( + projId: any, + envId: any, + relationshipTupleCreateBulkOperation: RelationshipTupleCreateBulkOperation, + options: AxiosRequestConfig = {}, + ): Promise => { + // verify required parameter 'projId' is not null or undefined + assertParamExists('bulkCreateRelationshipTuples', 'projId', projId); + // verify required parameter 'envId' is not null or undefined + assertParamExists('bulkCreateRelationshipTuples', 'envId', envId); + // verify required parameter 'relationshipTupleCreateBulkOperation' is not null or undefined + assertParamExists( + 'bulkCreateRelationshipTuples', + 'relationshipTupleCreateBulkOperation', + relationshipTupleCreateBulkOperation, + ); + const localVarPath = `/v2/facts/{proj_id}/{env_id}/relationship_tuples/bulk` + .replace(`{${'proj_id'}}`, encodeURIComponent(String(projId))) + .replace(`{${'env_id'}}`, encodeURIComponent(String(envId))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options }; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication HTTPBearer required + // http bearer authentication required + await setBearerAuthToObject(localVarHeaderParameter, configuration); + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + localVarRequestOptions.data = serializeDataIfNeeded( + relationshipTupleCreateBulkOperation, + localVarRequestOptions, + configuration, + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Bulk Delete Relationship Tuples + * @param {any} projId Either the unique id of the project, or the URL-friendly key of the project (i.e: the \"slug\"). + * @param {any} envId Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the \"slug\"). + * @param {RelationshipTupleDeleteBulkOperation} relationshipTupleDeleteBulkOperation + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + bulkDeleteRelationshipTuples: async ( + projId: any, + envId: any, + relationshipTupleDeleteBulkOperation: RelationshipTupleDeleteBulkOperation, + options: AxiosRequestConfig = {}, + ): Promise => { + // verify required parameter 'projId' is not null or undefined + assertParamExists('bulkDeleteRelationshipTuples', 'projId', projId); + // verify required parameter 'envId' is not null or undefined + assertParamExists('bulkDeleteRelationshipTuples', 'envId', envId); + // verify required parameter 'relationshipTupleDeleteBulkOperation' is not null or undefined + assertParamExists( + 'bulkDeleteRelationshipTuples', + 'relationshipTupleDeleteBulkOperation', + relationshipTupleDeleteBulkOperation, + ); + const localVarPath = `/v2/facts/{proj_id}/{env_id}/relationship_tuples/bulk` + .replace(`{${'proj_id'}}`, encodeURIComponent(String(projId))) + .replace(`{${'env_id'}}`, encodeURIComponent(String(envId))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options }; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication HTTPBearer required + // http bearer authentication required + await setBearerAuthToObject(localVarHeaderParameter, configuration); + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + localVarRequestOptions.data = serializeDataIfNeeded( + relationshipTupleDeleteBulkOperation, + localVarRequestOptions, + configuration, + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, /** * Create a relationship between two resource instances using a relation. * @summary Create Relationship Tuple @@ -187,12 +317,15 @@ export const RelationshipTuplesApiAxiosParamCreator = function (configuration?: listRelationshipTuples: async ( projId: string, envId: string, + detailed?: any, page?: number, perPage?: number, tenant?: string, subject?: string, relation?: string, object?: string, + objectType?: string, + subjectType?: string, options: AxiosRequestConfig = {}, ): Promise => { // verify required parameter 'projId' is not null or undefined @@ -217,6 +350,10 @@ export const RelationshipTuplesApiAxiosParamCreator = function (configuration?: // http bearer authentication required await setBearerAuthToObject(localVarHeaderParameter, configuration); + if (detailed !== undefined) { + localVarQueryParameter['detailed'] = detailed; + } + if (page !== undefined) { localVarQueryParameter['page'] = page; } @@ -241,6 +378,14 @@ export const RelationshipTuplesApiAxiosParamCreator = function (configuration?: localVarQueryParameter['object'] = object; } + if (objectType !== undefined) { + localVarQueryParameter['object_type'] = objectType; + } + + if (subjectType !== undefined) { + localVarQueryParameter['subject_type'] = subjectType; + } + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { @@ -264,6 +409,52 @@ export const RelationshipTuplesApiAxiosParamCreator = function (configuration?: export const RelationshipTuplesApiFp = function (configuration?: Configuration) { const localVarAxiosParamCreator = RelationshipTuplesApiAxiosParamCreator(configuration); return { + /** + * + * @summary Bulk create relationship tuples(EAP) + * @param {any} projId Either the unique id of the project, or the URL-friendly key of the project (i.e: the \"slug\"). + * @param {any} envId Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the \"slug\"). + * @param {RelationshipTupleCreateBulkOperation} relationshipTupleCreateBulkOperation + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async bulkCreateRelationshipTuples( + projId: any, + envId: any, + relationshipTupleCreateBulkOperation: RelationshipTupleCreateBulkOperation, + options?: AxiosRequestConfig, + ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.bulkCreateRelationshipTuples( + projId, + envId, + relationshipTupleCreateBulkOperation, + options, + ); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * + * @summary Bulk Delete Relationship Tuples + * @param {any} projId Either the unique id of the project, or the URL-friendly key of the project (i.e: the \"slug\"). + * @param {any} envId Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the \"slug\"). + * @param {RelationshipTupleDeleteBulkOperation} relationshipTupleDeleteBulkOperation + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async bulkDeleteRelationshipTuples( + projId: any, + envId: any, + relationshipTupleDeleteBulkOperation: RelationshipTupleDeleteBulkOperation, + options?: AxiosRequestConfig, + ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.bulkDeleteRelationshipTuples( + projId, + envId, + relationshipTupleDeleteBulkOperation, + options, + ); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * Create a relationship between two resource instances using a relation. * @summary Create Relationship Tuple @@ -327,12 +518,15 @@ export const RelationshipTuplesApiFp = function (configuration?: Configuration) async listRelationshipTuples( projId: string, envId: string, + detailed?: any, page?: number, perPage?: number, tenant?: string, subject?: string, relation?: string, object?: string, + objectType?: string, + subjectType?: string, options?: AxiosRequestConfig, ): Promise< (axios?: AxiosInstance, basePath?: string) => AxiosPromise> @@ -340,12 +534,15 @@ export const RelationshipTuplesApiFp = function (configuration?: Configuration) const localVarAxiosArgs = await localVarAxiosParamCreator.listRelationshipTuples( projId, envId, + detailed, page, perPage, tenant, subject, relation, object, + objectType, + subjectType, options, ); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); @@ -364,6 +561,44 @@ export const RelationshipTuplesApiFactory = function ( ) { const localVarFp = RelationshipTuplesApiFp(configuration); return { + /** + * + * @summary Bulk create relationship tuples(EAP) + * @param {any} projId Either the unique id of the project, or the URL-friendly key of the project (i.e: the \"slug\"). + * @param {any} envId Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the \"slug\"). + * @param {RelationshipTupleCreateBulkOperation} relationshipTupleCreateBulkOperation + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + bulkCreateRelationshipTuples( + projId: any, + envId: any, + relationshipTupleCreateBulkOperation: RelationshipTupleCreateBulkOperation, + options?: any, + ): AxiosPromise { + return localVarFp + .bulkCreateRelationshipTuples(projId, envId, relationshipTupleCreateBulkOperation, options) + .then((request) => request(axios, basePath)); + }, + /** + * + * @summary Bulk Delete Relationship Tuples + * @param {any} projId Either the unique id of the project, or the URL-friendly key of the project (i.e: the \"slug\"). + * @param {any} envId Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the \"slug\"). + * @param {RelationshipTupleDeleteBulkOperation} relationshipTupleDeleteBulkOperation + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + bulkDeleteRelationshipTuples( + projId: any, + envId: any, + relationshipTupleDeleteBulkOperation: RelationshipTupleDeleteBulkOperation, + options?: any, + ): AxiosPromise { + return localVarFp + .bulkDeleteRelationshipTuples(projId, envId, relationshipTupleDeleteBulkOperation, options) + .then((request) => request(axios, basePath)); + }, /** * Create a relationship between two resource instances using a relation. * @summary Create Relationship Tuple @@ -407,36 +642,45 @@ export const RelationshipTuplesApiFactory = function ( * @summary List Relationship Tuples * @param {string} projId Either the unique id of the project, or the URL-friendly key of the project (i.e: the \"slug\"). * @param {string} envId Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the \"slug\"). + * @param {string} [detailed] If true, will return the full subject and object resource instances. * @param {number} [page] Page number of the results to fetch, starting at 1. * @param {number} [perPage] The number of results per page (max 100). * @param {string} [tenant] The tenant key or id to filter by * @param {string} [subject] The subject to filter by, accepts either the resource instance id or resource_type:resource_instance * @param {string} [relation] The relation id or key to filter by * @param {string} [object] The object to filter by, accepts either the resource instance id or resource_type:resource_instance + * @param {string} [objectType] The object type to filter by, accepts resource type id or key + * @param {string} [subjectType] The subject type to filter by, accepts resource type id or key * @param {*} [options] Override http request option. * @throws {RequiredError} */ listRelationshipTuples( projId: string, envId: string, + detailed?: any, page?: number, perPage?: number, tenant?: string, subject?: string, relation?: string, object?: string, + objectType?: string, + subjectType?: string, options?: any, ): AxiosPromise> { return localVarFp .listRelationshipTuples( projId, envId, + detailed, page, perPage, tenant, subject, relation, object, + objectType, + subjectType, options, ) .then((request) => request(axios, basePath)); @@ -444,6 +688,62 @@ export const RelationshipTuplesApiFactory = function ( }; }; +/** + * Request parameters for bulkCreateRelationshipTuples operation in RelationshipTuplesApi. + * @export + * @interface RelationshipTuplesApiBulkCreateRelationshipTuplesRequest + */ +export interface RelationshipTuplesApiBulkCreateRelationshipTuplesRequest { + /** + * Either the unique id of the project, or the URL-friendly key of the project (i.e: the \"slug\"). + * @type {any} + * @memberof RelationshipTuplesApiBulkCreateRelationshipTuples + */ + readonly projId: any; + + /** + * Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the \"slug\"). + * @type {any} + * @memberof RelationshipTuplesApiBulkCreateRelationshipTuples + */ + readonly envId: any; + + /** + * + * @type {RelationshipTupleCreateBulkOperation} + * @memberof RelationshipTuplesApiBulkCreateRelationshipTuples + */ + readonly relationshipTupleCreateBulkOperation: RelationshipTupleCreateBulkOperation; +} + +/** + * Request parameters for bulkDeleteRelationshipTuples operation in RelationshipTuplesApi. + * @export + * @interface RelationshipTuplesApiBulkDeleteRelationshipTuplesRequest + */ +export interface RelationshipTuplesApiBulkDeleteRelationshipTuplesRequest { + /** + * Either the unique id of the project, or the URL-friendly key of the project (i.e: the \"slug\"). + * @type {any} + * @memberof RelationshipTuplesApiBulkDeleteRelationshipTuples + */ + readonly projId: any; + + /** + * Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the \"slug\"). + * @type {any} + * @memberof RelationshipTuplesApiBulkDeleteRelationshipTuples + */ + readonly envId: any; + + /** + * + * @type {RelationshipTupleDeleteBulkOperation} + * @memberof RelationshipTuplesApiBulkDeleteRelationshipTuples + */ + readonly relationshipTupleDeleteBulkOperation: RelationshipTupleDeleteBulkOperation; +} + /** * Request parameters for createRelationshipTuple operation in RelationshipTuplesApi. * @export @@ -520,6 +820,13 @@ export interface RelationshipTuplesApiListRelationshipTuplesRequest { */ readonly envId: string; + /** + * If true, will return the full subject and object resource instances. + * @type {any} + * @memberof RelationshipTuplesApiListRelationshipTuples + */ + readonly detailed?: any; + /** * Page number of the results to fetch, starting at 1. * @type {number} @@ -561,6 +868,20 @@ export interface RelationshipTuplesApiListRelationshipTuplesRequest { * @memberof RelationshipTuplesApiListRelationshipTuples */ readonly object?: string; + + /** + * The object type to filter by, accepts resource type id or key + * @type {string} + * @memberof RelationshipTuplesApiListRelationshipTuples + */ + readonly objectType?: string; + + /** + * The subject type to filter by, accepts resource type id or key + * @type {string} + * @memberof RelationshipTuplesApiListRelationshipTuples + */ + readonly subjectType?: string; } /** @@ -570,6 +891,48 @@ export interface RelationshipTuplesApiListRelationshipTuplesRequest { * @extends {BaseAPI} */ export class RelationshipTuplesApi extends BaseAPI { + /** + * + * @summary Bulk create relationship tuples(EAP) + * @param {RelationshipTuplesApiBulkCreateRelationshipTuplesRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof RelationshipTuplesApi + */ + public async bulkCreateRelationshipTuples( + requestParameters: RelationshipTuplesApiBulkCreateRelationshipTuplesRequest, + options?: AxiosRequestConfig, + ) { + let request = await RelationshipTuplesApiFp(this.configuration).bulkCreateRelationshipTuples( + requestParameters.projId, + requestParameters.envId, + requestParameters.relationshipTupleCreateBulkOperation, + options, + ); + return request(this.axios, this.basePath); + } + + /** + * + * @summary Bulk Delete Relationship Tuples + * @param {RelationshipTuplesApiBulkDeleteRelationshipTuplesRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof RelationshipTuplesApi + */ + public async bulkDeleteRelationshipTuples( + requestParameters: RelationshipTuplesApiBulkDeleteRelationshipTuplesRequest, + options?: AxiosRequestConfig, + ) { + let request = await RelationshipTuplesApiFp(this.configuration).bulkDeleteRelationshipTuples( + requestParameters.projId, + requestParameters.envId, + requestParameters.relationshipTupleDeleteBulkOperation, + options, + ); + return request(this.axios, this.basePath); + } + /** * Create a relationship between two resource instances using a relation. * @summary Create Relationship Tuple @@ -630,12 +993,15 @@ export class RelationshipTuplesApi extends BaseAPI { .listRelationshipTuples( requestParameters.projId, requestParameters.envId, + requestParameters.detailed, requestParameters.page, requestParameters.perPage, requestParameters.tenant, requestParameters.subject, requestParameters.relation, requestParameters.object, + requestParameters.objectType, + requestParameters.subjectType, options, ) .then((request) => request(this.axios, this.basePath)); diff --git a/src/openapi/types/index.ts b/src/openapi/types/index.ts index 52d6314..0e1cebd 100644 --- a/src/openapi/types/index.ts +++ b/src/openapi/types/index.ts @@ -28,6 +28,8 @@ export * from './authn-me-read'; export * from './authn-me-user-read'; export * from './bulk-role-assignment-report'; export * from './bulk-role-un-assignment-report'; +export * from './relationship-tuple-create-bulk-operation'; +export * from './relationship-tuple-delete-bulk-operation'; export * from './callbacks-inner'; export * from './condition-set-create'; export * from './condition-set-data'; diff --git a/src/openapi/types/relationship-tuple-create-bulk-operation.ts b/src/openapi/types/relationship-tuple-create-bulk-operation.ts new file mode 100644 index 0000000..0ffebd8 --- /dev/null +++ b/src/openapi/types/relationship-tuple-create-bulk-operation.ts @@ -0,0 +1,27 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Permit.io API + * Authorization as a service + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * + * @export + * @interface RelationshipTupleCreateBulkOperation + */ +export interface RelationshipTupleCreateBulkOperation { + /** + * + * @type {any} + * @memberof RelationshipTupleCreateBulkOperation + */ + operations: any; +} diff --git a/src/openapi/types/relationship-tuple-delete-bulk-operation.ts b/src/openapi/types/relationship-tuple-delete-bulk-operation.ts new file mode 100644 index 0000000..8edd2ca --- /dev/null +++ b/src/openapi/types/relationship-tuple-delete-bulk-operation.ts @@ -0,0 +1,27 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Permit.io API + * Authorization as a service + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * + * @export + * @interface RelationshipTupleDeleteBulkOperation + */ +export interface RelationshipTupleDeleteBulkOperation { + /** + * + * @type {any} + * @memberof RelationshipTupleDeleteBulkOperation + */ + idents: any; +} diff --git a/src/tests/bulk_test.spec.ts b/src/tests/bulk_test.spec.ts new file mode 100644 index 0000000..2baad6e --- /dev/null +++ b/src/tests/bulk_test.spec.ts @@ -0,0 +1,39 @@ +import anyTest, { TestInterface } from 'ava'; + +import { provideTestExecutionContext, TestContext } from './fixtures'; + +const test = anyTest as TestInterface; +test.before(provideTestExecutionContext); +test('Bulk relationship tuples test', async (t) => { + const permit = t.context.permit; + const logger = t.context.logger; + + try { + const tuples = [ + { + subject: 'folders:pdf', + relation: 'parent', + object: 'docs:tasks', + tenant: 'default', + }, + { + subject: 'folders:png', + relation: 'parent', + object: 'docs:files', + tenant: 'default', + }, + ]; + logger.info('Tuples: ' + JSON.stringify(tuples)); + const result = await permit.api.relationshipTuples.bulkRelationshipTuples(tuples); + logger.error('Result:', result.operations.toString()); + // const array_test: any[] = result.operations; + // const resultLength = array_test.length + // t.is(resultLength, 2); + // t.deepEqual(array_test[0], tuples[0]); + // t.deepEqual(array_test[1], tuples[1]); + // logger.info('Bulk relationship tuples test passed'); + } catch (error) { + logger.error(`Got error: ${error}`); + t.fail(`Got error: ${error}`); + } +});