Skip to content
Merged
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
376 changes: 376 additions & 0 deletions construction/issues/source/api/issue-attachments-api.ts

Large diffs are not rendered by default.

72 changes: 70 additions & 2 deletions construction/issues/source/custom-code/issuesClient.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { SdkManager, ApiResponse, ApsServiceRequestConfig, BaseClient, IAuthenticationProvider, SdkManagerBuilder } from "@aps_sdk/autodesk-sdkmanager";
import { Region, DataType, AttrDefinitionPage, Fields, IssuePayload, SortBy, User, Issue, IssuesPage, TypesPage, RootCauseCategoriesPage, AttrMappingPage, CommentsPayload, Comments, CommentsPage } from "../model";
import { ApiResponse, ApsServiceRequestConfig, BaseClient, IAuthenticationProvider, SdkManager, SdkManagerBuilder } from "@aps_sdk/autodesk-sdkmanager";
import { IssueAttributeDefinitionsApi, IssueAttributeMappingsApi, IssueCommentsApi, IssueRootCauseCategoriesApi, IssueTypesApi, IssuesApi, IssuesProfileApi } from "../api";
import { Attachments, AttachmentsPayload, AttrDefinitionPage, AttrMappingPage, Comments, CommentsPage, CommentsPayload, DataType, Fields, Issue, IssuePayload, IssuesPage, Region, RootCauseCategoriesPage, SortBy, TypesPage, User } from "../model";
import { IssueAttachmentsApi } from "../api/issue-attachments-api";

export class IssuesClient extends BaseClient {

public issueAttachmentsApi: IssueAttachmentsApi;
public issueattributedefinitionsapi: IssueAttributeDefinitionsApi;
public issueAttributemappingsapi: IssueAttributeMappingsApi;
public issuecommentsapi: IssueCommentsApi;
Expand All @@ -16,6 +18,7 @@ export class IssuesClient extends BaseClient {
if (!optionalArgs?.sdkManager) {
(optionalArgs ??= {}).sdkManager = SdkManagerBuilder.create().build();
}
this.issueAttachmentsApi = new IssueAttachmentsApi(optionalArgs.sdkManager);
this.issueattributedefinitionsapi = new IssueAttributeDefinitionsApi(optionalArgs.sdkManager);
this.issueAttributemappingsapi = new IssueAttributeMappingsApi(optionalArgs.sdkManager);
this.issuecommentsapi = new IssueCommentsApi(optionalArgs.sdkManager);
Expand All @@ -24,6 +27,71 @@ export class IssuesClient extends BaseClient {
this.issuesapi = new IssuesApi(optionalArgs.sdkManager);
this.issuesprofileapi = new IssuesProfileApi(optionalArgs.sdkManager);
}
/**
* Adds attachments to an existing issue.
*
* Links one or more files in Autodesk Docs (uploaded via the Data Management OSS API) to the specified issue.
*
* Note that an issue can have up to 100 attachments. Files can include images,
* PDFs, or other supported formats.
*
* For more information about uploading attachments, see the Upload Issue Attachment tutorial.
* @summary Your POST endpoint
* @param {string} projectId The ID of the project.
* @param {AttachmentsPayload} attachmentsPayload
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public async addAttachments(projectId: string, attachmentsPayload: AttachmentsPayload, optionalArgs?: { accessToken?: string, options?: ApsServiceRequestConfig }): Promise<Attachments> {
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.issueAttachmentsApi.addAttachments(optionalArgs?.accessToken, projectId, attachmentsPayload, optionalArgs?.options);
return response.content;
}
/**
* Deletes a specific attachment from an issue in a project.
* @summary Your DELETE endpoint
* @param {string} projectId The ID of the project. Use the Data Management API to retrieve the project ID. For more information, see the Retrieve a Project ID tutorial. You need to convert the project ID into a project ID for the ACC API by removing the “b." prefix. For example, a project ID of b.a4be0c34a-4ab7 translates to a project ID of a4be0c34a-4ab7.
* @param {string} issueId The unique identifier of the issue. To find the ID, call GET issues.
* @param {string} attachmentId The unique identifier of the attachment. To find the ID, call GET attachments.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public async deleteAttachment(projectId: string, issueId: string, attachmentId: string, optionalArgs?: { accessToken?: string, options?: ApsServiceRequestConfig }): Promise<ApiResponse> {
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.issueAttachmentsApi.deleteAttachment(optionalArgs?.accessToken, projectId, issueId, attachmentId, optionalArgs?.options);
return response;
}
/**
* Retrieves all attachments for a specific issue in a project.
* For details about retrieving metadata for a specific attachment, see the Retrieve Issue Attachment tutorial.
* For details about downloading an attachment, see the Download Issue Attachment tutorial.
* @summary Your GET endpoint
* @param {string} projectId The ID of the project. Use the Data Management API to retrieve the project ID. For more information, see the Retrieve a Project ID tutorial. You need to convert the project ID into a project ID for the ACC API by removing the “b." prefix. For example, a project ID of b.a4be0c34a-4ab7 translates to a project ID of a4be0c34a-4ab7.
* @param {string} issueId The unique identifier of the issue. To find the ID, call GET issues.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public async getAttachments(projectId: string, issueId: string, optionalArgs?: { accessToken?: string, options?: ApsServiceRequestConfig }): Promise<Attachments> {
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.issueAttachmentsApi.getAttachments(optionalArgs?.accessToken, projectId, issueId, optionalArgs?.options);
return response.content;
}

/**
* Retrieves information about issue custom attributes (custom fields) for a project, including the custom attribute title, description and type.
* @summary Your GET endpoint
Expand Down
141 changes: 141 additions & 0 deletions construction/issues/source/model/attachment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@


/**
* A list of attachments to add to the issue.
* @export
* @interface Attachment
*/
export interface Attachment {
/**
* The unique identifier for the attachment, set by the client when creating the attachment reference. This can be any unique GUID, but it is recommended to use the OSS storage GUID. For more information, see the Upload Issue Attachment tutorial.
* @type {string}
* @memberof Attachment
*/
'attachmentId'?: string;
/**
* The human-readable display name for the attachment, including the file extension (for example, .pdf, .jpg, .dwg). This name appears in the ACC web UI and is used when downloading the file from the issue.
* @type {string}
* @memberof Attachment
*/
'displayName'?: string;
/**
* The unique filename of the attachment, typically formatted as {attachmentId}.{fileExtension}.
* This value must exactly match the name of the file stored in Autodesk Docs (OSS) that you uploaded via the OSS process.
*
* For more information, see the Upload Issue Attachment tutorial.
* @type {string}
* @memberof Attachment
*/
'fileName'?: string;
/**
* The type of attachment to create. Set to issue-attachment. Will always be: issue-attachment
* @type {string}
* @memberof Attachment
*/
'attachmentType'?: AttachmentAttachmentTypeEnum;
/**
* The Object Storage Service (OSS) URN that uniquely identifies where the file is stored in Autodesk’s cloud infrastructure. You obtain this value after uploading the file to OSS (see the Upload Issue Attachment tutorial) or by retrieving it from an existing attachment (see the Downloading Issue Attachments tutorial).
* @type {string}
* @memberof Attachment
*/
'storageUrn'?: string;
/**
* The size of the file in bytes.
* @type {number}
* @memberof Attachment
*/
'fileSize'?: number;
/**
* The file extension (without the dot), for example pdf or jpg.
* @type {string}
* @memberof Attachment
*/
'fileType'?: string;
/**
* The ID of the issue that owns the attachment.
* @type {string}
* @memberof Attachment
*/
'domainEntityId'?: string;
/**
* The document lineage URN for the attachment’s source file.
* @type {string}
* @memberof Attachment
*/
'lineageUrn'?: string;
/**
* The document version number.
* @type {number}
* @memberof Attachment
*/
'version'?: number;
/**
* The URN for the specific file version that was attached to the issue. This may differ from the latest version URN (tipVersionUrn) if a newer version of the file exists in Autodesk Docs.
* @type {string}
* @memberof Attachment
*/
'versionUrn'?: string;
/**
* The URN for the latest (tip) version of the file.
* @type {string}
* @memberof Attachment
*/
'tipVersionUrn'?: string;
/**
* Not relevant
* @type {string}
* @memberof Attachment
*/
'bubbleUrn'?: string;
/**
* The ID of the user who created the issue attachment. For details about the user, call GET users.
* @type {string}
* @memberof Attachment
*/
'createdBy'?: string;
/**
* The date and time when the issue attachment was created, in ISO8601 format.
* @type {string}
* @memberof Attachment
*/
'createdOn'?: string;
/**
* Not relevant
* @type {string}
* @memberof Attachment
*/
'modifiedBy'?: string;
/**
* Not relevant
* @type {string}
* @memberof Attachment
*/
'modifiedOn'?: string;
/**
* The ID of the user who deleted the issue attachment, if applicable. For details about the user, call GET users.
* @type {string}
* @memberof Attachment
*/
'deletedBy'?: string;
/**
* The date and time when the issue attachment was deleted, if applicable.
* @type {string}
* @memberof Attachment
*/
'deletedOn'?: string;
/**
* true: The attachment has been deleted.
* false: (default) The attachment has not been deleted.
* @type {boolean}
* @memberof Attachment
*/
'isDeleted'?: boolean;
}

export const AttachmentAttachmentTypeEnum = {
IssueAttachment: 'issue-attachment'
} as const;

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


50 changes: 50 additions & 0 deletions construction/issues/source/model/attachmentObject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@


/**
* A list of attachments to add to the issue.
* @export
* @interface AttachmentObject
*/
export interface AttachmentObject {
/**
* The unique identifier for the attachment, set by the client when creating the attachment reference. This can be any unique GUID, but it is recommended to use the OSS storage GUID. For more information, see the Upload Issue Attachment tutorial.
* @type {string}
* @memberof AttachmentObject
*/
'attachmentId': string;
/**
* The human-readable display name for the attachment, including the file extension (for example, .pdf, .jpg, .dwg). This name appears in the ACC web UI and is used when downloading the file from the issue.
* @type {string}
* @memberof AttachmentObject
*/
'displayName': string;
/**
* The unique filename of the attachment, typically formatted as {attachmentId}.{fileExtension}.
* This value must exactly match the name of the file stored in Autodesk Docs (OSS) that you uploaded via the OSS process.
*
* For more information, see the Upload Issue Attachment tutorial.
* @type {string}
* @memberof AttachmentObject
*/
'fileName': string;
/**
* The type of attachment to create. Set to issue-attachment. Will always be: issue-attachment
* @type {string}
* @memberof AttachmentObject
*/
'attachmentType': AttachmentObjectAttachmentTypeEnum;
/**
* The Object Storage Service (OSS) URN that uniquely identifies where the file is stored in Autodesk’s cloud infrastructure. You obtain this value after uploading the file to OSS (see the Upload Issue Attachment tutorial) or by retrieving it from an existing attachment (see the Downloading Issue Attachments tutorial).
* @type {string}
* @memberof AttachmentObject
*/
'storageUrn': string;
}

export const AttachmentObjectAttachmentTypeEnum = {
IssueAttachment: 'issue-attachment'
} as const;

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


17 changes: 17 additions & 0 deletions construction/issues/source/model/attachments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

import { Attachment } from './attachment';

/**
* An optional array of attachments associated with this object.
* @export
* @interface Attachments
*/
export interface Attachments {
/**
* An optional array of attachments associated with this object.
* @type {Array<Attachment>}
* @memberof Attachments
*/
'attachmentList'?: Array<Attachment>;
}

23 changes: 23 additions & 0 deletions construction/issues/source/model/attachmentsPayload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

import { AttachmentObject } from './attachmentObject';

/**
* Represents the payload for adding attachments to an issue.
* @export
* @interface AttachmentsPayload
*/
export interface AttachmentsPayload {
/**
* The unique identifier of the issue to which the attachments will be added.
* @type {string}
* @memberof AttachmentsPayload
*/
'domainEntityId'?: string;
/**
* The list of attachments to be added to the issue.
* @type {Array<AttachmentObject>}
* @memberof AttachmentsPayload
*/
'attachments'?: Array<AttachmentObject>;
}

4 changes: 4 additions & 0 deletions construction/issues/source/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ export * from './user';
export * from './userIssues';
export * from './userIssuesFilter';
export * from './userIssuesNew';
export * from './attachment';
export * from './attachmentObject';
export * from './attachmentsPayload';
export * from './attachments';