Skip to content

[DAS 281] DM advanced filtering #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 48 additions & 25 deletions datamanagement/source/api/foldersApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { RelationshipLinks } from '../model';
import { RelationshipRefs } from '../model';
import { RelationshipRefsPayload } from '../model';
import { Search } from '../model';
import { ComparisonTypes } from '../model';
/**
* FoldersApi - axios parameter creator
* @export
Expand Down Expand Up @@ -487,46 +488,68 @@ export const FoldersApiAxiosParamCreator = function (apsConfiguration?: IApsConf
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getFolderSearch: async (accessToken: string, projectId: string, folderId: string, filterFieldName?: string, filter?: Array<string>, pageNumber?: number, options: ApsServiceRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'projectId' is not null or undefined
assertParamExists('getFolderSearch', 'projectId', projectId)
// verify required parameter 'folderId' is not null or undefined
assertParamExists('getFolderSearch', 'folderId', folderId)
getFolderSearch: async (
accessToken: string,
projectId: string,
folderId: string,
filters?: { field: string; operator?: ComparisonTypes; value: string }[], // Operator is optional
pageNumber?: number,
options: ApsServiceRequestConfig = {}
): Promise<RequestArgs> => {
// Verify required parameters
assertParamExists('getFolderSearch', 'projectId', projectId);
assertParamExists('getFolderSearch', 'folderId', folderId);

// Construct the endpoint path
const localVarPath = `/data/v1/projects/{project_id}/folders/{folder_id}/search`
.replace(`{${"project_id"}}`, encodeURIComponent(String(projectId)))
.replace(`{${"folder_id"}}`, encodeURIComponent(String(folderId)));
const localVarUrlObj = new URL(localVarPath, apsConfiguration.baseAddress);

// Base options
let baseOptions;
if (apsConfiguration) {
baseOptions = apsConfiguration.baseOptions;
}

const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};

// Request options
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;

await setBearerAuthToObject(localVarHeaderParameter, accessToken)

if (filter) {
localVarQueryParameter[`filter[${filterFieldName}]`] = filter;

// Set Bearer Auth
await setBearerAuthToObject(localVarHeaderParameter, accessToken);

// Process filters
if (filters && filters.length > 0) {
filters.forEach(filter => {
const operator = filter.operator || ComparisonTypes.EqualTo; // Default to 'eq' if no operator is provided
const filterKey = `filter[${filter.field}]-${operator}`;
localVarQueryParameter[filterKey] = filter.value;
});
}


// Page number
if (pageNumber !== undefined) {
localVarQueryParameter['page[number]'] = pageNumber;
}




// Set headers
localVarHeaderParameter['User-Agent'] = 'APS SDK/DATA-MANAGEMENT/TypeScript/1.0.0';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

const headersFromBaseOptions = baseOptions?.headers ?? {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers,
};

// Return request args
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
},
/**
* Renames, moves, hides, or unhides a folder. Marking a BIM 360 Docs folder as hidden effectively deletes it. You can restore it by changing its ``hidden`` attribute. You can also move BIM 360 Docs folders by changing their parent folder. You cannot permanently delete BIM 360 Docs folders. They are tagged as hidden folders and are removed from the BIM 360 Docs UI and from regular Data Management API responses. You can use the hidden filter (``filter[hidden]=true``) to get a list of deleted folders with the [List Folder Contents](/en/docs/data/v2/reference/http/projects-project_id-folders-folder_id-contents-GET/) operation. Before you use the Data Management API to access BIM 360 Docs folders, provision your app through the BIM 360 Account Administrator portal. For details, see the [Manage Access to Docs tutorial](/en/docs/bim360/v1/tutorials/getting-started/manage-access-to-docs/). **Note:** This operation supports Autodesk Construction Cloud (ACC) Projects. For more information, see the [ACC Platform API documentation](/en.docs.acc.v1/overview/introduction/).
* @summary Modify a Folder
Expand Down Expand Up @@ -717,8 +740,8 @@ export const FoldersApiFp = function(sdkManager?: SdkManager) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getFolderSearch(accessToken: string, projectId: string, folderId: string, filterFieldName?: string, filter?: Array<string>, pageNumber?: number, options?: ApsServiceRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Search>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getFolderSearch(accessToken, projectId, folderId, filterFieldName, filter, pageNumber, options);
async getFolderSearch(accessToken: string, projectId: string, folderId: string, filters?: { field: string; operator?: ComparisonTypes; value: string }[], pageNumber?: number, options?: ApsServiceRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Search>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getFolderSearch(accessToken, projectId, folderId, filters, pageNumber, options);
return createRequestFunction(localVarAxiosArgs, sdkManager);
},
/**
Expand Down Expand Up @@ -877,7 +900,7 @@ export interface FoldersApiInterface {
* @throws {RequiredError}
* @memberof FoldersApiInterface
*/
getFolderSearch(accessToken: string,projectId: string, folderId: string, filterFieldName?: string, filter?: Array<string>, pageNumber?: number, options?: ApsServiceRequestConfig): Promise<ApiResponse>;
getFolderSearch(accessToken: string,projectId: string, folderId: string, filters?: { field: string; operator?: ComparisonTypes; value: string }[], pageNumber?: number, options?: ApsServiceRequestConfig): Promise<ApiResponse>;

/**
* Renames, moves, hides, or unhides a folder. Marking a BIM 360 Docs folder as hidden effectively deletes it. You can restore it by changing its ``hidden`` attribute. You can also move BIM 360 Docs folders by changing their parent folder. You cannot permanently delete BIM 360 Docs folders. They are tagged as hidden folders and are removed from the BIM 360 Docs UI and from regular Data Management API responses. You can use the hidden filter (``filter[hidden]=true``) to get a list of deleted folders with the [List Folder Contents](/en/docs/data/v2/reference/http/projects-project_id-folders-folder_id-contents-GET/) operation. Before you use the Data Management API to access BIM 360 Docs folders, provision your app through the BIM 360 Account Administrator portal. For details, see the [Manage Access to Docs tutorial](/en/docs/bim360/v1/tutorials/getting-started/manage-access-to-docs/). **Note:** This operation supports Autodesk Construction Cloud (ACC) Projects. For more information, see the [ACC Platform API documentation](/en.docs.acc.v1/overview/introduction/).
Expand Down Expand Up @@ -1180,10 +1203,10 @@ export class FoldersApi extends BaseApi implements FoldersApiInterface {
* @throws {RequiredError}
* @memberof FoldersApi
*/
public async getFolderSearch(accessToken: string, projectId: string, folderId: string, filterFieldName?: string, filter?: Array<string>, pageNumber?: number, options?: ApsServiceRequestConfig) {
public async getFolderSearch(accessToken: string, projectId: string, folderId: string, filters?: { field: string; operator?: ComparisonTypes; value: string }[], pageNumber?: number, options?: ApsServiceRequestConfig) {
this.logger.logInfo("Entered into getFolderSearch ");
try {
const request = await FoldersApiFp(this.sdkManager).getFolderSearch(accessToken, projectId, folderId, filterFieldName, filter, pageNumber, options);
const request = await FoldersApiFp(this.sdkManager).getFolderSearch(accessToken, projectId, folderId, filters, pageNumber, options);
const response = await request(this.axios);
this.logger.logInfo(`getFolderSearch Request completed successfully with status code: ${response.status}`);
return new ApiResponse(response,response.data);
Expand Down
6 changes: 3 additions & 3 deletions datamanagement/source/custom-code/dataManagementClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ApiResponse, ApsServiceRequestConfig, BaseClient, IAuthenticationProvid
import { CommandsApi, HubsApi, ItemsApi, ProjectsApi, FoldersApi, VersionsApi } from "../api";
import { CreatedDownload, CreatedVersion, Download, DownloadFormats, DownloadPayload, Downloads, FilterType, FolderContents, FolderPayload, FolderRefs, Job, ModifyFolderPayload, ModifyVersionPayload, Project, Projects, Search, StoragePayload, TopFolders, Version, VersionPayload } from "../model";
import { Hub, Hubs } from "../model";
import { CheckPermission, CheckPermissionPayload, Command, PublishModelJobPayload, CommandPayload, CreatedItem, FilterDirection, FilterRefType, FilterTypeVersion, Folder, Item, ItemPayload, ItemTip, JsonApiVersion, JsonApiVersionValue, ListItems, ListItemsPayload, ListRefs, ListRefsPayload, ModifyItemPayload, Refs, RelationshipLinks, RelationshipRefs, RelationshipRefsPayload, Versions, PublishWithoutLinksPayload, PublishWithoutLinks, PublishModel, PublishModelPayload } from "../model";
import { CheckPermission, CheckPermissionPayload, Command, PublishModelJobPayload, CommandPayload, CreatedItem, FilterDirection, FilterRefType, FilterTypeVersion, Folder, Item, ItemPayload, ItemTip, JsonApiVersion, JsonApiVersionValue, ListItems, ListItemsPayload, ListRefs, ListRefsPayload, ModifyItemPayload, Refs, RelationshipLinks, RelationshipRefs, RelationshipRefsPayload, Versions, PublishWithoutLinksPayload, PublishWithoutLinks, PublishModel, PublishModelPayload, ComparisonTypes } from "../model";

export class DataManagementClient extends BaseClient {
public commandsApi: CommandsApi;
Expand Down Expand Up @@ -429,14 +429,14 @@ export class DataManagementClient extends BaseClient {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public async getFolderSearch(projectId: string, folderId: string, optionalArgs?:{filterFieldName?: string , filterValue?: Array<string>, pageNumber?: number, accessToken?: string, options?: ApsServiceRequestConfig}): Promise<Search> {
public async getFolderSearch(projectId: string, folderId: string, optionalArgs?:{filters?: { field: string; operator?: ComparisonTypes; value: string }[], pageNumber?: number, accessToken?: string, options?: ApsServiceRequestConfig}): Promise<Search> {
if (!optionalArgs?.accessToken && !this.authenticationProvider) {
throw new Error("Please provide a valid access token or an authentication provider");
}
else if (!optionalArgs?.accessToken) {
(optionalArgs ??= {}).accessToken = await this.authenticationProvider.getAccessToken();
}
const response = await this.foldersApi.getFolderSearch(optionalArgs?.accessToken,projectId, folderId, optionalArgs?.filterFieldName, optionalArgs?.filterValue, optionalArgs?.pageNumber, optionalArgs?.options);
const response = await this.foldersApi.getFolderSearch(optionalArgs?.accessToken,projectId, folderId, optionalArgs?.filters, optionalArgs?.pageNumber, optionalArgs?.options);
return response.content;
}

Expand Down
25 changes: 25 additions & 0 deletions datamanagement/source/model/comparisonTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* tslint:disable */
/* eslint-disable */


/**
* The type of the resource. Possible values are ``lt``, ``le``, ``eq``, ``ge``, ``gt``, ``starts``, ``ends``, ``contains``.
* @export
* @enum {string}
*/

export const ComparisonTypes = {
LessThan: 'lt',
LessThanOrEqualTo: 'le',
EqualTo: 'eq',
GreaterThanOrEqualTO: 'ge',
GreaterThan: 'gt',
StartsWith: 'starts',
EndsWith: 'ends',
Contains: 'contains'
} as const;

export type ComparisonTypes = typeof ComparisonTypes[keyof typeof ComparisonTypes];



1 change: 1 addition & 0 deletions datamanagement/source/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export * from './commandData';
export * from './commandExecutionStatus';
export * from './commandPayload';
export * from './commandPayloadData';
export * from './comparisonTypes';
export * from './conformingStatus';
export * from './createdDownload';
export * from './createdDownloadData';
Expand Down
Loading