diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index ca425e6bd9f2..685088a65d17 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1125,6 +1125,14 @@ components: schema: example: 00000000-0000-9999-0000-000000000000 type: string + UserUUIDPathParameter: + description: User UUID + example: 8146583c-0b5f-11ec-abf8-da7ad0900001 + in: path + name: user_id + required: true + schema: + type: string WorkflowId: description: The ID of the workflow. in: path @@ -64692,6 +64700,57 @@ components: - X_CONTENT_TYPE_HEADER_MISSING - X_PATH_INJECTION - XSS + Watcher: + description: Case watcher + properties: + id: + description: User UUID of the watcher + example: 8146583c-0b5f-11ec-abf8-da7ad0900001 + type: string + relationships: + $ref: '#/components/schemas/WatcherRelationships' + type: + $ref: '#/components/schemas/WatcherResourceType' + required: + - id + - type + - relationships + type: object + WatcherRelationships: + description: Watcher relationships + properties: + user: + $ref: '#/components/schemas/WatcherUserRelationship' + required: + - user + type: object + WatcherResourceType: + description: Watcher resource type + enum: + - watcher + example: watcher + type: string + x-enum-varnames: + - WATCHER + WatcherUserRelationship: + description: Relationship to user + properties: + data: + $ref: '#/components/schemas/UserRelationshipData' + required: + - data + type: object + WatchersResponse: + description: Response with case watchers + properties: + data: + description: Array of watchers + items: + $ref: '#/components/schemas/Watcher' + type: array + required: + - data + type: object Weekday: description: A day of the week. enum: @@ -70202,6 +70261,149 @@ paths: summary: Unassign case tags: - Case Management + /api/v2/cases/{case_id}/watchers: + get: + description: Get all users watching a case + operationId: ListCaseWatchers + parameters: + - $ref: '#/components/parameters/CaseIDPathParameter' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/WatchersResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cases_read + summary: Get case watchers + tags: + - Case Management + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/cases/{case_id}/watchers/{user_id}: + delete: + description: Remove a user from the watchers list for a case + operationId: UnwatchCase + parameters: + - $ref: '#/components/parameters/CaseIDPathParameter' + - $ref: '#/components/parameters/UserUUIDPathParameter' + responses: + '204': + description: No Content + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cases_write + summary: Remove user as watcher + tags: + - Case Management + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: Add a user as a watcher for a case + operationId: WatchCase + parameters: + - $ref: '#/components/parameters/CaseIDPathParameter' + - $ref: '#/components/parameters/UserUUIDPathParameter' + responses: + '201': + description: Created + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cases_write + summary: Add user as watcher + tags: + - Case Management + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/catalog/entity: get: description: Get a list of entities from Software Catalog. diff --git a/features/v2/case_management.feature b/features/v2/case_management.feature index 2f239155671f..4f3de0519bd4 100644 --- a/features/v2/case_management.feature +++ b/features/v2/case_management.feature @@ -10,6 +10,33 @@ Feature: Case Management And a valid "appKeyAuth" key in the system And an instance of "CaseManagement" API + @generated @skip @team:DataDog/case-management + Scenario: Add user as watcher returns "Bad Request" response + Given operation "WatchCase" enabled + And new "WatchCase" request + And request contains "case_id" parameter from "REPLACE.ME" + And request contains "user_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/case-management + Scenario: Add user as watcher returns "Created" response + Given operation "WatchCase" enabled + And new "WatchCase" request + And request contains "case_id" parameter from "REPLACE.ME" + And request contains "user_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/case-management + Scenario: Add user as watcher returns "Not Found" response + Given operation "WatchCase" enabled + And new "WatchCase" request + And request contains "case_id" parameter from "REPLACE.ME" + And request contains "user_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @team:DataDog/case-management Scenario: Archive case returns "Bad Request" response Given new "ArchiveCase" request @@ -203,6 +230,30 @@ Feature: Case Management When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/case-management + Scenario: Get case watchers returns "Bad Request" response + Given operation "ListCaseWatchers" enabled + And new "ListCaseWatchers" request + And request contains "case_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/case-management + Scenario: Get case watchers returns "Not Found" response + Given operation "ListCaseWatchers" enabled + And new "ListCaseWatchers" request + And request contains "case_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/case-management + Scenario: Get case watchers returns "OK" response + Given operation "ListCaseWatchers" enabled + And new "ListCaseWatchers" request + And request contains "case_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @skip @team:DataDog/case-management Scenario: Get the details of a case returns "Bad Request" response Given new "GetCase" request @@ -261,6 +312,33 @@ Feature: Case Management When the request is sent Then the response status is 204 No Content + @generated @skip @team:DataDog/case-management + Scenario: Remove user as watcher returns "Bad Request" response + Given operation "UnwatchCase" enabled + And new "UnwatchCase" request + And request contains "case_id" parameter from "REPLACE.ME" + And request contains "user_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/case-management + Scenario: Remove user as watcher returns "No Content" response + Given operation "UnwatchCase" enabled + And new "UnwatchCase" request + And request contains "case_id" parameter from "REPLACE.ME" + And request contains "user_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/case-management + Scenario: Remove user as watcher returns "Not Found" response + Given operation "UnwatchCase" enabled + And new "UnwatchCase" request + And request contains "case_id" parameter from "REPLACE.ME" + And request contains "user_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/case-management Scenario: Search cases returns "Bad Request" response Given new "SearchCases" request diff --git a/features/v2/undo.json b/features/v2/undo.json index 5a347bddf111..6e3e67d08e9a 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -819,6 +819,26 @@ "type": "idempotent" } }, + "ListCaseWatchers": { + "tag": "Case Management", + "undo": { + "type": "safe" + } + }, + "UnwatchCase": { + "tag": "Case Management", + "undo": { + "type": "idempotent" + } + }, + "WatchCase": { + "tag": "Case Management", + "undo": { + "operationId": "TODO", + "parameters": [], + "type": "unsafe" + } + }, "ListCatalogEntity": { "tag": "Software Catalog", "undo": { diff --git a/private/bdd_runner/src/support/scenarios_model_mapping.ts b/private/bdd_runner/src/support/scenarios_model_mapping.ts index 3203ea3c7488..b7977b41c6dc 100644 --- a/private/bdd_runner/src/support/scenarios_model_mapping.ts +++ b/private/bdd_runner/src/support/scenarios_model_mapping.ts @@ -3506,6 +3506,35 @@ export const ScenariosModelMappings: { [key: string]: OperationMapping } = { }, operationResponseType: "CaseResponse", }, + "CaseManagementApi.V2.ListCaseWatchers": { + caseId: { + type: "string", + format: "", + }, + operationResponseType: "WatchersResponse", + }, + "CaseManagementApi.V2.WatchCase": { + caseId: { + type: "string", + format: "", + }, + userId: { + type: "string", + format: "", + }, + operationResponseType: "{}", + }, + "CaseManagementApi.V2.UnwatchCase": { + caseId: { + type: "string", + format: "", + }, + userId: { + type: "string", + format: "", + }, + operationResponseType: "{}", + }, "CaseManagementTypeApi.V2.GetAllCaseTypes": { operationResponseType: "CaseTypesResponse", }, diff --git a/services/case_management/src/v2/CaseManagementApi.ts b/services/case_management/src/v2/CaseManagementApi.ts index bfb23c046de7..d1415246858a 100644 --- a/services/case_management/src/v2/CaseManagementApi.ts +++ b/services/case_management/src/v2/CaseManagementApi.ts @@ -37,10 +37,12 @@ import { CaseUpdateDescriptionRequest } from "./models/CaseUpdateDescriptionRequ import { CaseUpdatePriorityRequest } from "./models/CaseUpdatePriorityRequest"; import { CaseUpdateStatusRequest } from "./models/CaseUpdateStatusRequest"; import { CaseUpdateTitleRequest } from "./models/CaseUpdateTitleRequest"; +import { JSONAPIErrorResponse } from "./models/JSONAPIErrorResponse"; import { ProjectCreateRequest } from "./models/ProjectCreateRequest"; import { ProjectResponse } from "./models/ProjectResponse"; import { ProjectsResponse } from "./models/ProjectsResponse"; import { TimelineResponse } from "./models/TimelineResponse"; +import { WatchersResponse } from "./models/WatchersResponse"; import { version } from "../version"; export class CaseManagementApiRequestFactory extends BaseAPIRequestFactory { @@ -608,6 +610,57 @@ export class CaseManagementApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + public async listCaseWatchers( + caseId: string, + _options?: Configuration, + ): Promise { + const _config = _options || this.configuration; + + if (!_config.unstableOperations["CaseManagementApi.v2.listCaseWatchers"]) { + throw new Error( + "Unstable operation 'listCaseWatchers' is disabled. Enable it by setting `configuration.unstableOperations['CaseManagementApi.v2.listCaseWatchers'] = true`", + ); + } + + // verify required parameter 'caseId' is not null or undefined + if (caseId === null || caseId === undefined) { + throw new RequiredError("caseId", "listCaseWatchers"); + } + + // Path Params + const localVarPath = "/api/v2/cases/{case_id}/watchers".replace( + "{case_id}", + encodeURIComponent(String(caseId)), + ); + + // Make Request Context + const { server, overrides } = _config.getServerAndOverrides( + "CaseManagementApi.v2.listCaseWatchers", + CaseManagementApi.operationServers, + ); + const requestContext = server.makeRequestContext( + localVarPath, + HttpMethod.GET, + overrides, + ); + requestContext.setHeaderParam("Accept", "application/json"); + requestContext.setHttpConfig(_config.httpConfig); + + // Set User-Agent + if (this.userAgent) { + requestContext.setHeaderParam("User-Agent", this.userAgent); + } + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + "AuthZ", + ]); + + return requestContext; + } + public async searchCases( pageSize?: number, pageNumber?: number, @@ -806,6 +859,62 @@ export class CaseManagementApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + public async unwatchCase( + caseId: string, + userId: string, + _options?: Configuration, + ): Promise { + const _config = _options || this.configuration; + + if (!_config.unstableOperations["CaseManagementApi.v2.unwatchCase"]) { + throw new Error( + "Unstable operation 'unwatchCase' is disabled. Enable it by setting `configuration.unstableOperations['CaseManagementApi.v2.unwatchCase'] = true`", + ); + } + + // verify required parameter 'caseId' is not null or undefined + if (caseId === null || caseId === undefined) { + throw new RequiredError("caseId", "unwatchCase"); + } + + // verify required parameter 'userId' is not null or undefined + if (userId === null || userId === undefined) { + throw new RequiredError("userId", "unwatchCase"); + } + + // Path Params + const localVarPath = "/api/v2/cases/{case_id}/watchers/{user_id}" + .replace("{case_id}", encodeURIComponent(String(caseId))) + .replace("{user_id}", encodeURIComponent(String(userId))); + + // Make Request Context + const { server, overrides } = _config.getServerAndOverrides( + "CaseManagementApi.v2.unwatchCase", + CaseManagementApi.operationServers, + ); + const requestContext = server.makeRequestContext( + localVarPath, + HttpMethod.DELETE, + overrides, + ); + requestContext.setHeaderParam("Accept", "*/*"); + requestContext.setHttpConfig(_config.httpConfig); + + // Set User-Agent + if (this.userAgent) { + requestContext.setHeaderParam("User-Agent", this.userAgent); + } + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + "AuthZ", + ]); + + return requestContext; + } + public async updateAttributes( caseId: string, body: CaseUpdateAttributesRequest, @@ -1177,6 +1286,62 @@ export class CaseManagementApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + + public async watchCase( + caseId: string, + userId: string, + _options?: Configuration, + ): Promise { + const _config = _options || this.configuration; + + if (!_config.unstableOperations["CaseManagementApi.v2.watchCase"]) { + throw new Error( + "Unstable operation 'watchCase' is disabled. Enable it by setting `configuration.unstableOperations['CaseManagementApi.v2.watchCase'] = true`", + ); + } + + // verify required parameter 'caseId' is not null or undefined + if (caseId === null || caseId === undefined) { + throw new RequiredError("caseId", "watchCase"); + } + + // verify required parameter 'userId' is not null or undefined + if (userId === null || userId === undefined) { + throw new RequiredError("userId", "watchCase"); + } + + // Path Params + const localVarPath = "/api/v2/cases/{case_id}/watchers/{user_id}" + .replace("{case_id}", encodeURIComponent(String(caseId))) + .replace("{user_id}", encodeURIComponent(String(userId))); + + // Make Request Context + const { server, overrides } = _config.getServerAndOverrides( + "CaseManagementApi.v2.watchCase", + CaseManagementApi.operationServers, + ); + const requestContext = server.makeRequestContext( + localVarPath, + HttpMethod.POST, + overrides, + ); + requestContext.setHeaderParam("Accept", "*/*"); + requestContext.setHttpConfig(_config.httpConfig); + + // Set User-Agent + if (this.userAgent) { + requestContext.setHeaderParam("User-Agent", this.userAgent); + } + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + "AuthZ", + ]); + + return requestContext; + } } export class CaseManagementApiResponseProcessor { @@ -1823,6 +1988,88 @@ export class CaseManagementApiResponseProcessor { ); } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to listCaseWatchers + * @throws ApiException if the response code was not in [200, 299] + */ + public async listCaseWatchers( + response: ResponseContext, + ): Promise { + const contentType = normalizeMediaType(response.headers["content-type"]); + if (response.httpStatusCode === 200) { + const body: WatchersResponse = deserialize( + parse(await response.body.text(), contentType), + TypingInfo, + "WatchersResponse", + ) as WatchersResponse; + return body; + } + if ( + response.httpStatusCode === 400 || + response.httpStatusCode === 401 || + response.httpStatusCode === 403 || + response.httpStatusCode === 404 + ) { + const bodyText = parse(await response.body.text(), contentType); + let body: JSONAPIErrorResponse; + try { + body = deserialize( + bodyText, + TypingInfo, + "JSONAPIErrorResponse", + ) as JSONAPIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText, + ); + } + throw new ApiException( + response.httpStatusCode, + body, + ); + } + if (response.httpStatusCode === 429) { + const bodyText = parse(await response.body.text(), contentType); + let body: APIErrorResponse; + try { + body = deserialize( + bodyText, + TypingInfo, + "APIErrorResponse", + ) as APIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText, + ); + } + throw new ApiException(response.httpStatusCode, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: WatchersResponse = deserialize( + parse(await response.body.text(), contentType), + TypingInfo, + "WatchersResponse", + "", + ) as WatchersResponse; + return body; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"', + ); + } + /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects @@ -2003,6 +2250,75 @@ export class CaseManagementApiResponseProcessor { ); } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to unwatchCase + * @throws ApiException if the response code was not in [200, 299] + */ + public async unwatchCase(response: ResponseContext): Promise { + const contentType = normalizeMediaType(response.headers["content-type"]); + if (response.httpStatusCode === 204) { + return; + } + if ( + response.httpStatusCode === 400 || + response.httpStatusCode === 401 || + response.httpStatusCode === 403 || + response.httpStatusCode === 404 + ) { + const bodyText = parse(await response.body.text(), contentType); + let body: JSONAPIErrorResponse; + try { + body = deserialize( + bodyText, + TypingInfo, + "JSONAPIErrorResponse", + ) as JSONAPIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText, + ); + } + throw new ApiException( + response.httpStatusCode, + body, + ); + } + if (response.httpStatusCode === 429) { + const bodyText = parse(await response.body.text(), contentType); + let body: APIErrorResponse; + try { + body = deserialize( + bodyText, + TypingInfo, + "APIErrorResponse", + ) as APIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText, + ); + } + throw new ApiException(response.httpStatusCode, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"', + ); + } + /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects @@ -2372,6 +2688,75 @@ export class CaseManagementApiResponseProcessor { 'Unknown API Status Code!\nBody: "' + body + '"', ); } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to watchCase + * @throws ApiException if the response code was not in [200, 299] + */ + public async watchCase(response: ResponseContext): Promise { + const contentType = normalizeMediaType(response.headers["content-type"]); + if (response.httpStatusCode === 201) { + return; + } + if ( + response.httpStatusCode === 400 || + response.httpStatusCode === 401 || + response.httpStatusCode === 403 || + response.httpStatusCode === 404 + ) { + const bodyText = parse(await response.body.text(), contentType); + let body: JSONAPIErrorResponse; + try { + body = deserialize( + bodyText, + TypingInfo, + "JSONAPIErrorResponse", + ) as JSONAPIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText, + ); + } + throw new ApiException( + response.httpStatusCode, + body, + ); + } + if (response.httpStatusCode === 429) { + const bodyText = parse(await response.body.text(), contentType); + let body: APIErrorResponse; + try { + body = deserialize( + bodyText, + TypingInfo, + "APIErrorResponse", + ) as APIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText, + ); + } + throw new ApiException(response.httpStatusCode, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"', + ); + } } export interface CaseManagementApiArchiveCaseRequest { @@ -2479,6 +2864,14 @@ export interface CaseManagementApiGetProjectRequest { projectId: string; } +export interface CaseManagementApiListCaseWatchersRequest { + /** + * Case's UUID or key + * @type string + */ + caseId: string; +} + export interface CaseManagementApiSearchCasesRequest { /** * Size for a given page. The maximum allowed value is 100. @@ -2533,6 +2926,19 @@ export interface CaseManagementApiUnassignCaseRequest { body: CaseEmptyRequest; } +export interface CaseManagementApiUnwatchCaseRequest { + /** + * Case's UUID or key + * @type string + */ + caseId: string; + /** + * User UUID + * @type string + */ + userId: string; +} + export interface CaseManagementApiUpdateAttributesRequest { /** * Case's UUID or key @@ -2616,6 +3022,19 @@ export interface CaseManagementApiUpdateStatusRequest { body: CaseUpdateStatusRequest; } +export interface CaseManagementApiWatchCaseRequest { + /** + * Case's UUID or key + * @type string + */ + caseId: string; + /** + * User UUID + * @type string + */ + userId: string; +} + export class CaseManagementApi { private requestFactory: CaseManagementApiRequestFactory; private responseProcessor: CaseManagementApiResponseProcessor; @@ -2867,6 +3286,27 @@ export class CaseManagementApi { }); } + /** + * Get all users watching a case + * @param param The request object + */ + public listCaseWatchers( + param: CaseManagementApiListCaseWatchersRequest, + options?: Configuration, + ): Promise { + const requestContextPromise = this.requestFactory.listCaseWatchers( + param.caseId, + options, + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.listCaseWatchers(responseContext); + }); + }); + } + /** * Search cases. * @param param The request object @@ -2978,6 +3418,28 @@ export class CaseManagementApi { }); } + /** + * Remove a user from the watchers list for a case + * @param param The request object + */ + public unwatchCase( + param: CaseManagementApiUnwatchCaseRequest, + options?: Configuration, + ): Promise { + const requestContextPromise = this.requestFactory.unwatchCase( + param.caseId, + param.userId, + options, + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.unwatchCase(responseContext); + }); + }); + } + /** * Update case attributes * @param param The request object @@ -3112,4 +3574,26 @@ export class CaseManagementApi { }); }); } + + /** + * Add a user as a watcher for a case + * @param param The request object + */ + public watchCase( + param: CaseManagementApiWatchCaseRequest, + options?: Configuration, + ): Promise { + const requestContextPromise = this.requestFactory.watchCase( + param.caseId, + param.userId, + options, + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.watchCase(responseContext); + }); + }); + } } diff --git a/services/case_management/src/v2/index.ts b/services/case_management/src/v2/index.ts index e7ab08c6f51c..19095e3d4536 100644 --- a/services/case_management/src/v2/index.ts +++ b/services/case_management/src/v2/index.ts @@ -9,15 +9,18 @@ export { CaseManagementApiDeleteProjectRequest, CaseManagementApiGetCaseRequest, CaseManagementApiGetProjectRequest, + CaseManagementApiListCaseWatchersRequest, CaseManagementApiSearchCasesRequest, CaseManagementApiUnarchiveCaseRequest, CaseManagementApiUnassignCaseRequest, + CaseManagementApiUnwatchCaseRequest, CaseManagementApiUpdateAttributesRequest, CaseManagementApiUpdateCaseCustomAttributeRequest, CaseManagementApiUpdateCaseDescriptionRequest, CaseManagementApiUpdateCaseTitleRequest, CaseManagementApiUpdatePriorityRequest, CaseManagementApiUpdateStatusRequest, + CaseManagementApiWatchCaseRequest, CaseManagementApi, } from "./CaseManagementApi"; @@ -70,6 +73,9 @@ export { CustomAttributeValue } from "./models/CustomAttributeValue"; export { CustomAttributeValuesUnion } from "./models/CustomAttributeValuesUnion"; export { JiraIssue } from "./models/JiraIssue"; export { JiraIssueResult } from "./models/JiraIssueResult"; +export { JSONAPIErrorItem } from "./models/JSONAPIErrorItem"; +export { JSONAPIErrorItemSource } from "./models/JSONAPIErrorItemSource"; +export { JSONAPIErrorResponse } from "./models/JSONAPIErrorResponse"; export { NullableUserRelationship } from "./models/NullableUserRelationship"; export { NullableUserRelationshipData } from "./models/NullableUserRelationshipData"; export { Project } from "./models/Project"; @@ -103,3 +109,8 @@ export { TimelineResponse } from "./models/TimelineResponse"; export { UserRelationshipData } from "./models/UserRelationshipData"; export { UserResourceType } from "./models/UserResourceType"; export { UsersRelationship } from "./models/UsersRelationship"; +export { Watcher } from "./models/Watcher"; +export { WatcherRelationships } from "./models/WatcherRelationships"; +export { WatcherResourceType } from "./models/WatcherResourceType"; +export { WatchersResponse } from "./models/WatchersResponse"; +export { WatcherUserRelationship } from "./models/WatcherUserRelationship"; diff --git a/services/case_management/src/v2/models/JSONAPIErrorItem.ts b/services/case_management/src/v2/models/JSONAPIErrorItem.ts new file mode 100644 index 000000000000..a1ca45cd463c --- /dev/null +++ b/services/case_management/src/v2/models/JSONAPIErrorItem.ts @@ -0,0 +1,78 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { JSONAPIErrorItemSource } from "./JSONAPIErrorItemSource"; + +/** + * API error response body + */ +export class JSONAPIErrorItem { + /** + * A human-readable explanation specific to this occurrence of the error. + */ + "detail"?: string; + /** + * Non-standard meta-information about the error + */ + "meta"?: { [key: string]: any }; + /** + * References to the source of the error. + */ + "source"?: JSONAPIErrorItemSource; + /** + * Status code of the response. + */ + "status"?: string; + /** + * Short human-readable summary of the error. + */ + "title"?: string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + detail: { + baseName: "detail", + type: "string", + }, + meta: { + baseName: "meta", + type: "{ [key: string]: any; }", + }, + source: { + baseName: "source", + type: "JSONAPIErrorItemSource", + }, + status: { + baseName: "status", + type: "string", + }, + title: { + baseName: "title", + type: "string", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return JSONAPIErrorItem.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/case_management/src/v2/models/JSONAPIErrorItemSource.ts b/services/case_management/src/v2/models/JSONAPIErrorItemSource.ts new file mode 100644 index 000000000000..5889114315fa --- /dev/null +++ b/services/case_management/src/v2/models/JSONAPIErrorItemSource.ts @@ -0,0 +1,60 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * References to the source of the error. + */ +export class JSONAPIErrorItemSource { + /** + * A string indicating the name of a single request header which caused the error. + */ + "header"?: string; + /** + * A string indicating which URI query parameter caused the error. + */ + "parameter"?: string; + /** + * A JSON pointer to the value in the request document that caused the error. + */ + "pointer"?: string; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + header: { + baseName: "header", + type: "string", + }, + parameter: { + baseName: "parameter", + type: "string", + }, + pointer: { + baseName: "pointer", + type: "string", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return JSONAPIErrorItemSource.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/case_management/src/v2/models/JSONAPIErrorResponse.ts b/services/case_management/src/v2/models/JSONAPIErrorResponse.ts new file mode 100644 index 000000000000..68aa04ffc27b --- /dev/null +++ b/services/case_management/src/v2/models/JSONAPIErrorResponse.ts @@ -0,0 +1,47 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { JSONAPIErrorItem } from "./JSONAPIErrorItem"; + +/** + * API error response. + */ +export class JSONAPIErrorResponse { + /** + * A list of errors. + */ + "errors": Array; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + errors: { + baseName: "errors", + type: "Array", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return JSONAPIErrorResponse.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/case_management/src/v2/models/TypingInfo.ts b/services/case_management/src/v2/models/TypingInfo.ts index df796c3f0a7c..311dc010cadb 100644 --- a/services/case_management/src/v2/models/TypingInfo.ts +++ b/services/case_management/src/v2/models/TypingInfo.ts @@ -38,6 +38,9 @@ import { CasesResponse } from "./CasesResponse"; import { CasesResponseMeta } from "./CasesResponseMeta"; import { CasesResponseMetaPagination } from "./CasesResponseMetaPagination"; import { CustomAttributeValue } from "./CustomAttributeValue"; +import { JSONAPIErrorItem } from "./JSONAPIErrorItem"; +import { JSONAPIErrorItemSource } from "./JSONAPIErrorItemSource"; +import { JSONAPIErrorResponse } from "./JSONAPIErrorResponse"; import { JiraIssue } from "./JiraIssue"; import { JiraIssueResult } from "./JiraIssueResult"; import { NullableUserRelationship } from "./NullableUserRelationship"; @@ -65,6 +68,10 @@ import { TimelineCellResource } from "./TimelineCellResource"; import { TimelineResponse } from "./TimelineResponse"; import { UserRelationshipData } from "./UserRelationshipData"; import { UsersRelationship } from "./UsersRelationship"; +import { Watcher } from "./Watcher"; +import { WatcherRelationships } from "./WatcherRelationships"; +import { WatcherUserRelationship } from "./WatcherUserRelationship"; +import { WatchersResponse } from "./WatchersResponse"; export const TypingInfo: ModelTypingInfo = { enumsMap: { @@ -82,6 +89,7 @@ export const TypingInfo: ModelTypingInfo = { TimelineCellResourceType: ["timeline_cell"], TimelineCellType: ["COMMENT"], UserResourceType: ["user"], + WatcherResourceType: ["watcher"], }, oneOfMap: { CustomAttributeValuesUnion: [ @@ -132,6 +140,9 @@ export const TypingInfo: ModelTypingInfo = { CasesResponseMeta: CasesResponseMeta, CasesResponseMetaPagination: CasesResponseMetaPagination, CustomAttributeValue: CustomAttributeValue, + JSONAPIErrorItem: JSONAPIErrorItem, + JSONAPIErrorItemSource: JSONAPIErrorItemSource, + JSONAPIErrorResponse: JSONAPIErrorResponse, JiraIssue: JiraIssue, JiraIssueResult: JiraIssueResult, NullableUserRelationship: NullableUserRelationship, @@ -159,5 +170,9 @@ export const TypingInfo: ModelTypingInfo = { TimelineResponse: TimelineResponse, UserRelationshipData: UserRelationshipData, UsersRelationship: UsersRelationship, + Watcher: Watcher, + WatcherRelationships: WatcherRelationships, + WatcherUserRelationship: WatcherUserRelationship, + WatchersResponse: WatchersResponse, }, }; diff --git a/services/case_management/src/v2/models/Watcher.ts b/services/case_management/src/v2/models/Watcher.ts new file mode 100644 index 000000000000..f6c48c563389 --- /dev/null +++ b/services/case_management/src/v2/models/Watcher.ts @@ -0,0 +1,66 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { WatcherRelationships } from "./WatcherRelationships"; +import { WatcherResourceType } from "./WatcherResourceType"; + +/** + * Case watcher + */ +export class Watcher { + /** + * User UUID of the watcher + */ + "id": string; + /** + * Watcher relationships + */ + "relationships": WatcherRelationships; + /** + * Watcher resource type + */ + "type": WatcherResourceType; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + id: { + baseName: "id", + type: "string", + required: true, + }, + relationships: { + baseName: "relationships", + type: "WatcherRelationships", + required: true, + }, + type: { + baseName: "type", + type: "WatcherResourceType", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return Watcher.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/case_management/src/v2/models/WatcherRelationships.ts b/services/case_management/src/v2/models/WatcherRelationships.ts new file mode 100644 index 000000000000..4d3cdeb35596 --- /dev/null +++ b/services/case_management/src/v2/models/WatcherRelationships.ts @@ -0,0 +1,47 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { WatcherUserRelationship } from "./WatcherUserRelationship"; + +/** + * Watcher relationships + */ +export class WatcherRelationships { + /** + * Relationship to user + */ + "user": WatcherUserRelationship; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + user: { + baseName: "user", + type: "WatcherUserRelationship", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return WatcherRelationships.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/case_management/src/v2/models/WatcherResourceType.ts b/services/case_management/src/v2/models/WatcherResourceType.ts new file mode 100644 index 000000000000..19a2bd83ba26 --- /dev/null +++ b/services/case_management/src/v2/models/WatcherResourceType.ts @@ -0,0 +1,7 @@ +import { UnparsedObject } from "@datadog/datadog-api-client"; + +/** + * Watcher resource type + */ +export type WatcherResourceType = typeof WATCHER | UnparsedObject; +export const WATCHER = "watcher"; diff --git a/services/case_management/src/v2/models/WatcherUserRelationship.ts b/services/case_management/src/v2/models/WatcherUserRelationship.ts new file mode 100644 index 000000000000..bf60d6cd52da --- /dev/null +++ b/services/case_management/src/v2/models/WatcherUserRelationship.ts @@ -0,0 +1,47 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { UserRelationshipData } from "./UserRelationshipData"; + +/** + * Relationship to user + */ +export class WatcherUserRelationship { + /** + * Relationship to user object. + */ + "data": UserRelationshipData; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + data: { + baseName: "data", + type: "UserRelationshipData", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return WatcherUserRelationship.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/case_management/src/v2/models/WatchersResponse.ts b/services/case_management/src/v2/models/WatchersResponse.ts new file mode 100644 index 000000000000..7ff8252bccde --- /dev/null +++ b/services/case_management/src/v2/models/WatchersResponse.ts @@ -0,0 +1,47 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { Watcher } from "./Watcher"; + +/** + * Response with case watchers + */ +export class WatchersResponse { + /** + * Array of watchers + */ + "data": Array; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + data: { + baseName: "data", + type: "Array", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return WatchersResponse.attributeTypeMap; + } + + public constructor() {} +}