diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index d235bdcd3db3..c5aea6aff5d7 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -39547,6 +39547,74 @@ components: - type - id type: object + ManagedOrgsData: + description: The managed organizations resource. + properties: + id: + description: The UUID of the current organization. + example: "4dee724d-00cc-11ea-a77b-570c9d03c6c5" + format: uuid + type: string + relationships: + $ref: "#/components/schemas/ManagedOrgsRelationships" + type: + $ref: "#/components/schemas/ManagedOrgsType" + required: + - id + - type + - relationships + type: object + ManagedOrgsRelationshipToOrg: + description: Relationship to the current organization. + properties: + data: + $ref: "#/components/schemas/OrgRelationshipData" + required: + - data + type: object + ManagedOrgsRelationshipToOrgs: + description: Relationship to the managed organizations. + properties: + data: + description: List of managed organization references. + items: + $ref: "#/components/schemas/OrgRelationshipData" + type: array + required: + - data + type: object + ManagedOrgsRelationships: + description: Relationships of the managed organizations resource. + properties: + current_org: + $ref: "#/components/schemas/ManagedOrgsRelationshipToOrg" + managed_orgs: + $ref: "#/components/schemas/ManagedOrgsRelationshipToOrgs" + required: + - current_org + - managed_orgs + type: object + ManagedOrgsResponse: + description: Response containing the current organization and its managed organizations. + properties: + data: + $ref: "#/components/schemas/ManagedOrgsData" + included: + description: Included organization resources. + items: + $ref: "#/components/schemas/OrgData" + type: array + required: + - data + - included + type: object + ManagedOrgsType: + description: The resource type for managed organizations. + enum: [managed_orgs] + example: "managed_orgs" + type: string + x-enum-varnames: + - MANAGED_ORGS MemberTeam: description: A member team properties: @@ -48114,6 +48182,53 @@ components: x-enum-varnames: - ASC - DESC + OrgAttributes: + description: Attributes of an organization. + properties: + created_at: + description: The creation timestamp of the organization. + example: "2019-09-26T17:28:28Z" + format: date-time + type: string + description: + description: A description of the organization. + example: "Production organization." + type: string + disabled: + description: Whether the organization is disabled. + example: false + type: boolean + modified_at: + description: The last modification timestamp of the organization. + example: "2024-01-15T10:30:00Z" + format: date-time + type: string + name: + description: The name of the organization. + example: "My Organization" + type: string + public_id: + description: The public identifier of the organization. + example: "abcdef12345" + type: string + sharing: + description: The sharing setting of the organization. + example: "none" + type: string + url: + description: The URL of the organization. + example: "https://app.datadoghq.com/account/my-org" + type: string + required: + - public_id + - name + - description + - sharing + - url + - disabled + - created_at + - modified_at + type: object OrgConfigGetResponse: description: A response with a single Org Config. properties: @@ -48415,6 +48530,44 @@ components: type: string x-enum-varnames: - USERS + OrgData: + description: An organization resource. + properties: + attributes: + $ref: "#/components/schemas/OrgAttributes" + id: + description: The UUID of the organization. + example: "4dee724d-00cc-11ea-a77b-570c9d03c6c5" + format: uuid + type: string + type: + $ref: "#/components/schemas/OrgResourceType" + required: + - id + - type + - attributes + type: object + OrgRelationshipData: + description: Reference to an organization resource. + properties: + id: + description: The UUID of the organization. + example: "4dee724d-00cc-11ea-a77b-570c9d03c6c5" + format: uuid + type: string + type: + $ref: "#/components/schemas/OrgResourceType" + required: + - id + - type + type: object + OrgResourceType: + description: The resource type for organizations. + enum: [orgs] + example: "orgs" + type: string + x-enum-varnames: + - ORGS Organization: description: Organization object. properties: @@ -98143,6 +98296,83 @@ paths: operator: OR permissions: - on_call_read + /api/v2/org: + get: + description: Returns the current organization and its managed organizations in JSON:API format. + operationId: ListOrgsV2 + parameters: + - description: Filter managed organizations by name. + example: "My Child Org" + in: query + name: "filter[name]" + required: false + schema: + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + id: "4dee724d-00cc-11ea-a77b-570c9d03c6c5" + relationships: + current_org: + data: + id: "4dee724d-00cc-11ea-a77b-570c9d03c6c5" + type: "orgs" + managed_orgs: + data: + - id: "a1b2c3d4-00cc-11ea-a77b-570c9d03c6c5" + type: "orgs" + type: "managed_orgs" + included: + - attributes: + created_at: "2019-09-26T17:28:28Z" + description: "Production organization." + disabled: false + modified_at: "2024-01-15T10:30:00Z" + name: "My Organization" + public_id: "abcdef12345" + sharing: "none" + url: "https://app.datadoghq.com/account/my-org" + id: "4dee724d-00cc-11ea-a77b-570c9d03c6c5" + type: "orgs" + - attributes: + created_at: "2020-05-10T12:00:00Z" + description: "Child organization." + disabled: false + modified_at: "2024-06-20T08:15:00Z" + name: "My Child Org" + public_id: "ghijkl67890" + sharing: "none" + url: "https://app.datadoghq.com/account/my-child-org" + id: "a1b2c3d4-00cc-11ea-a77b-570c9d03c6c5" + type: "orgs" + schema: + $ref: "#/components/schemas/ManagedOrgsResponse" + description: OK + "401": + $ref: "#/components/responses/UnauthorizedResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - org_management + - org_connections_write + summary: List your managed organizations + tags: + - Organizations + "x-permission": + operator: OR + permissions: + - org_management + - org_connections_write /api/v2/org_configs: get: description: Returns all Org Configs (name, description, and value). @@ -114716,6 +114946,50 @@ paths: permissions: - user_access_manage - service_account_write + /api/v2/users/{user_id}/invitations: + delete: + description: |- + Cancel all pending invitations for a specified user. + Requires the `user_access_invite` permission. + operationId: DeleteUserInvitations + parameters: + - description: The UUID of the user whose pending invitations should be canceled. + in: path + name: user_id + required: true + schema: + example: "4dee724d-00cc-11ea-a77b-570c9d03c6c5" + format: uuid + type: string + responses: + "200": + description: OK + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Authentication error + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - user_access_invite + summary: Delete a pending user's invitations + tags: + - Users + "x-permission": + operator: OR + permissions: + - user_access_invite /api/v2/users/{user_id}/orgs: get: description: |- diff --git a/features/v2/organizations.feature b/features/v2/organizations.feature index ddec7484e764..b5e870d0d98d 100644 --- a/features/v2/organizations.feature +++ b/features/v2/organizations.feature @@ -41,6 +41,12 @@ Feature: Organizations When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/org-management + Scenario: List your managed organizations returns "OK" response + Given new "ListOrgsV2" request + When the request is sent + Then the response status is 200 OK + @team:DataDog/team-aaa-identity Scenario: Update a specific Org Config returns "Bad Request" response Given new "UpdateOrgConfig" request diff --git a/features/v2/undo.json b/features/v2/undo.json index 02afc91a4bbe..0e7f9515ea95 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -3951,6 +3951,12 @@ "type": "safe" } }, + "ListOrgsV2": { + "tag": "Organizations", + "undo": { + "type": "safe" + } + }, "ListOrgConfigs": { "tag": "Organizations", "undo": { @@ -6543,6 +6549,12 @@ "type": "idempotent" } }, + "DeleteUserInvitations": { + "tag": "Users", + "undo": { + "type": "safe" + } + }, "ListUserOrganizations": { "tag": "Users", "undo": { diff --git a/features/v2/users.feature b/features/v2/users.feature index ce27d729985f..3fc0a99938a9 100644 --- a/features/v2/users.feature +++ b/features/v2/users.feature @@ -25,6 +25,20 @@ Feature: Users And the response "data.attributes.disabled" is false And the response "data.attributes.service_account" is false + @generated @skip @team:DataDog/org-management + Scenario: Delete a pending user's invitations returns "Not found" response + Given new "DeleteUserInvitations" request + 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/org-management + Scenario: Delete a pending user's invitations returns "OK" response + Given new "DeleteUserInvitations" request + And request contains "user_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/team-aaa-identity Scenario: Disable a user returns "Not found" response Given new "DisableUser" request diff --git a/private/bdd_runner/src/support/scenarios_model_mapping.ts b/private/bdd_runner/src/support/scenarios_model_mapping.ts index 74369c97e1d1..c217ff1bed85 100644 --- a/private/bdd_runner/src/support/scenarios_model_mapping.ts +++ b/private/bdd_runner/src/support/scenarios_model_mapping.ts @@ -9120,6 +9120,13 @@ export const ScenariosModelMappings: { [key: string]: OperationMapping } = { }, operationResponseType: "{}", }, + "OrganizationsApi.V2.ListOrgsV2": { + filterName: { + type: "string", + format: "", + }, + operationResponseType: "ManagedOrgsResponse", + }, "OrganizationsApi.V2.ListOrgConfigs": { operationResponseType: "OrgConfigListResponse", }, @@ -12110,6 +12117,13 @@ export const ScenariosModelMappings: { [key: string]: OperationMapping } = { }, operationResponseType: "UserResponse", }, + "UsersApi.V2.DeleteUserInvitations": { + userId: { + type: "string", + format: "uuid", + }, + operationResponseType: "{}", + }, "UsersApi.V2.ListUserOrganizations": { userId: { type: "string", diff --git a/services/organizations/README.md b/services/organizations/README.md index fcfd03d25ac6..f2e7fe3d4ef6 100644 --- a/services/organizations/README.md +++ b/services/organizations/README.md @@ -26,8 +26,9 @@ import { v2 } from "@datadog/datadog-api-client-organizations"; const configuration = createConfiguration(); const apiInstance = new OrganizationsApiV2(configuration); +const params = {/* parameters */}; -apiInstance.listOrgConfigs().then((data) => { +apiInstance.listOrgsV2(params).then((data) => { console.log("API called successfully. Returned data: " + JSON.stringify(data)); }).catch((error) => { console.error("Error calling API: " + error); diff --git a/services/organizations/src/v2/OrganizationsApi.ts b/services/organizations/src/v2/OrganizationsApi.ts index be103fa9c04c..e6ddc0104aad 100644 --- a/services/organizations/src/v2/OrganizationsApi.ts +++ b/services/organizations/src/v2/OrganizationsApi.ts @@ -26,6 +26,7 @@ import FormData from "form-data"; import { TypingInfo } from "./models/TypingInfo"; import { APIErrorResponse } from "./models/APIErrorResponse"; +import { ManagedOrgsResponse } from "./models/ManagedOrgsResponse"; import { OrgConfigGetResponse } from "./models/OrgConfigGetResponse"; import { OrgConfigListResponse } from "./models/OrgConfigListResponse"; import { OrgConfigWriteRequest } from "./models/OrgConfigWriteRequest"; @@ -119,6 +120,52 @@ export class OrganizationsApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + public async listOrgsV2( + filterName?: string, + _options?: Configuration, + ): Promise { + const _config = _options || this.configuration; + + // Path Params + const localVarPath = "/api/v2/org"; + + // Make Request Context + const { server, overrides } = _config.getServerAndOverrides( + "OrganizationsApi.v2.listOrgsV2", + OrganizationsApi.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); + } + + // Query Params + if (filterName !== undefined) { + requestContext.setQueryParam( + "filter[name]", + serialize(filterName, TypingInfo, "string", ""), + "", + ); + } + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + "AuthZ", + ]); + + return requestContext; + } + public async updateOrgConfig( orgConfigName: string, body: OrgConfigWriteRequest, @@ -347,6 +394,66 @@ export class OrganizationsApiResponseProcessor { ); } + /** + * 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 listOrgsV2 + * @throws ApiException if the response code was not in [200, 299] + */ + public async listOrgsV2( + response: ResponseContext, + ): Promise { + const contentType = normalizeMediaType(response.headers["content-type"]); + if (response.httpStatusCode === 200) { + const body: ManagedOrgsResponse = deserialize( + parse(await response.body.text(), contentType), + TypingInfo, + "ManagedOrgsResponse", + ) as ManagedOrgsResponse; + return body; + } + if ( + response.httpStatusCode === 401 || + response.httpStatusCode === 403 || + 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: ManagedOrgsResponse = deserialize( + parse(await response.body.text(), contentType), + TypingInfo, + "ManagedOrgsResponse", + "", + ) as ManagedOrgsResponse; + 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 @@ -465,6 +572,14 @@ export interface OrganizationsApiGetOrgConfigRequest { orgConfigName: string; } +export interface OrganizationsApiListOrgsV2Request { + /** + * Filter managed organizations by name. + * @type string + */ + filterName?: string; +} + export interface OrganizationsApiUpdateOrgConfigRequest { /** * The name of an Org Config. @@ -542,6 +657,27 @@ export class OrganizationsApi { }); } + /** + * Returns the current organization and its managed organizations in JSON:API format. + * @param param The request object + */ + public listOrgsV2( + param: OrganizationsApiListOrgsV2Request = {}, + options?: Configuration, + ): Promise { + const requestContextPromise = this.requestFactory.listOrgsV2( + param.filterName, + options, + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.listOrgsV2(responseContext); + }); + }); + } + /** * Update the value of a specific Org Config. * @param param The request object diff --git a/services/organizations/src/v2/index.ts b/services/organizations/src/v2/index.ts index 91a71ad30691..ff8d8d6249d6 100644 --- a/services/organizations/src/v2/index.ts +++ b/services/organizations/src/v2/index.ts @@ -1,11 +1,19 @@ export { OrganizationsApiGetOrgConfigRequest, + OrganizationsApiListOrgsV2Request, OrganizationsApiUpdateOrgConfigRequest, OrganizationsApiUploadIdPMetadataRequest, OrganizationsApi, } from "./OrganizationsApi"; export { APIErrorResponse } from "./models/APIErrorResponse"; +export { ManagedOrgsData } from "./models/ManagedOrgsData"; +export { ManagedOrgsRelationships } from "./models/ManagedOrgsRelationships"; +export { ManagedOrgsRelationshipToOrg } from "./models/ManagedOrgsRelationshipToOrg"; +export { ManagedOrgsRelationshipToOrgs } from "./models/ManagedOrgsRelationshipToOrgs"; +export { ManagedOrgsResponse } from "./models/ManagedOrgsResponse"; +export { ManagedOrgsType } from "./models/ManagedOrgsType"; +export { OrgAttributes } from "./models/OrgAttributes"; export { OrgConfigGetResponse } from "./models/OrgConfigGetResponse"; export { OrgConfigListResponse } from "./models/OrgConfigListResponse"; export { OrgConfigRead } from "./models/OrgConfigRead"; @@ -14,3 +22,6 @@ export { OrgConfigType } from "./models/OrgConfigType"; export { OrgConfigWrite } from "./models/OrgConfigWrite"; export { OrgConfigWriteAttributes } from "./models/OrgConfigWriteAttributes"; export { OrgConfigWriteRequest } from "./models/OrgConfigWriteRequest"; +export { OrgData } from "./models/OrgData"; +export { OrgRelationshipData } from "./models/OrgRelationshipData"; +export { OrgResourceType } from "./models/OrgResourceType"; diff --git a/services/organizations/src/v2/models/ManagedOrgsData.ts b/services/organizations/src/v2/models/ManagedOrgsData.ts new file mode 100644 index 000000000000..dab587df765f --- /dev/null +++ b/services/organizations/src/v2/models/ManagedOrgsData.ts @@ -0,0 +1,67 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { ManagedOrgsRelationships } from "./ManagedOrgsRelationships"; +import { ManagedOrgsType } from "./ManagedOrgsType"; + +/** + * The managed organizations resource. + */ +export class ManagedOrgsData { + /** + * The UUID of the current organization. + */ + "id": string; + /** + * Relationships of the managed organizations resource. + */ + "relationships": ManagedOrgsRelationships; + /** + * The resource type for managed organizations. + */ + "type": ManagedOrgsType; + /** + * 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, + format: "uuid", + }, + relationships: { + baseName: "relationships", + type: "ManagedOrgsRelationships", + required: true, + }, + type: { + baseName: "type", + type: "ManagedOrgsType", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return ManagedOrgsData.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/organizations/src/v2/models/ManagedOrgsRelationshipToOrg.ts b/services/organizations/src/v2/models/ManagedOrgsRelationshipToOrg.ts new file mode 100644 index 000000000000..e5c7040cea4b --- /dev/null +++ b/services/organizations/src/v2/models/ManagedOrgsRelationshipToOrg.ts @@ -0,0 +1,47 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { OrgRelationshipData } from "./OrgRelationshipData"; + +/** + * Relationship to the current organization. + */ +export class ManagedOrgsRelationshipToOrg { + /** + * Reference to an organization resource. + */ + "data": OrgRelationshipData; + /** + * 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: "OrgRelationshipData", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return ManagedOrgsRelationshipToOrg.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/organizations/src/v2/models/ManagedOrgsRelationshipToOrgs.ts b/services/organizations/src/v2/models/ManagedOrgsRelationshipToOrgs.ts new file mode 100644 index 000000000000..bb6aa00db891 --- /dev/null +++ b/services/organizations/src/v2/models/ManagedOrgsRelationshipToOrgs.ts @@ -0,0 +1,47 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { OrgRelationshipData } from "./OrgRelationshipData"; + +/** + * Relationship to the managed organizations. + */ +export class ManagedOrgsRelationshipToOrgs { + /** + * List of managed organization references. + */ + "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 ManagedOrgsRelationshipToOrgs.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/organizations/src/v2/models/ManagedOrgsRelationships.ts b/services/organizations/src/v2/models/ManagedOrgsRelationships.ts new file mode 100644 index 000000000000..3a4f8f60e5af --- /dev/null +++ b/services/organizations/src/v2/models/ManagedOrgsRelationships.ts @@ -0,0 +1,57 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { ManagedOrgsRelationshipToOrg } from "./ManagedOrgsRelationshipToOrg"; +import { ManagedOrgsRelationshipToOrgs } from "./ManagedOrgsRelationshipToOrgs"; + +/** + * Relationships of the managed organizations resource. + */ +export class ManagedOrgsRelationships { + /** + * Relationship to the current organization. + */ + "currentOrg": ManagedOrgsRelationshipToOrg; + /** + * Relationship to the managed organizations. + */ + "managedOrgs": ManagedOrgsRelationshipToOrgs; + /** + * 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 = { + currentOrg: { + baseName: "current_org", + type: "ManagedOrgsRelationshipToOrg", + required: true, + }, + managedOrgs: { + baseName: "managed_orgs", + type: "ManagedOrgsRelationshipToOrgs", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return ManagedOrgsRelationships.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/organizations/src/v2/models/ManagedOrgsResponse.ts b/services/organizations/src/v2/models/ManagedOrgsResponse.ts new file mode 100644 index 000000000000..340e3c3d5de8 --- /dev/null +++ b/services/organizations/src/v2/models/ManagedOrgsResponse.ts @@ -0,0 +1,57 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { ManagedOrgsData } from "./ManagedOrgsData"; +import { OrgData } from "./OrgData"; + +/** + * Response containing the current organization and its managed organizations. + */ +export class ManagedOrgsResponse { + /** + * The managed organizations resource. + */ + "data": ManagedOrgsData; + /** + * Included organization resources. + */ + "included": 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: "ManagedOrgsData", + required: true, + }, + included: { + baseName: "included", + type: "Array", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return ManagedOrgsResponse.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/organizations/src/v2/models/ManagedOrgsType.ts b/services/organizations/src/v2/models/ManagedOrgsType.ts new file mode 100644 index 000000000000..b9b23d0c74e4 --- /dev/null +++ b/services/organizations/src/v2/models/ManagedOrgsType.ts @@ -0,0 +1,7 @@ +import { UnparsedObject } from "@datadog/datadog-api-client"; + +/** + * The resource type for managed organizations. + */ +export type ManagedOrgsType = typeof MANAGED_ORGS | UnparsedObject; +export const MANAGED_ORGS = "managed_orgs"; diff --git a/services/organizations/src/v2/models/OrgAttributes.ts b/services/organizations/src/v2/models/OrgAttributes.ts new file mode 100644 index 000000000000..c8512682d139 --- /dev/null +++ b/services/organizations/src/v2/models/OrgAttributes.ts @@ -0,0 +1,110 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * Attributes of an organization. + */ +export class OrgAttributes { + /** + * The creation timestamp of the organization. + */ + "createdAt": Date; + /** + * A description of the organization. + */ + "description": string; + /** + * Whether the organization is disabled. + */ + "disabled": boolean; + /** + * The last modification timestamp of the organization. + */ + "modifiedAt": Date; + /** + * The name of the organization. + */ + "name": string; + /** + * The public identifier of the organization. + */ + "publicId": string; + /** + * The sharing setting of the organization. + */ + "sharing": string; + /** + * The URL of the organization. + */ + "url": 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 = { + createdAt: { + baseName: "created_at", + type: "Date", + required: true, + format: "date-time", + }, + description: { + baseName: "description", + type: "string", + required: true, + }, + disabled: { + baseName: "disabled", + type: "boolean", + required: true, + }, + modifiedAt: { + baseName: "modified_at", + type: "Date", + required: true, + format: "date-time", + }, + name: { + baseName: "name", + type: "string", + required: true, + }, + publicId: { + baseName: "public_id", + type: "string", + required: true, + }, + sharing: { + baseName: "sharing", + type: "string", + required: true, + }, + url: { + baseName: "url", + type: "string", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return OrgAttributes.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/organizations/src/v2/models/OrgData.ts b/services/organizations/src/v2/models/OrgData.ts new file mode 100644 index 000000000000..9c15fee367b3 --- /dev/null +++ b/services/organizations/src/v2/models/OrgData.ts @@ -0,0 +1,67 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { OrgAttributes } from "./OrgAttributes"; +import { OrgResourceType } from "./OrgResourceType"; + +/** + * An organization resource. + */ +export class OrgData { + /** + * Attributes of an organization. + */ + "attributes": OrgAttributes; + /** + * The UUID of the organization. + */ + "id": string; + /** + * The resource type for organizations. + */ + "type": OrgResourceType; + /** + * 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 = { + attributes: { + baseName: "attributes", + type: "OrgAttributes", + required: true, + }, + id: { + baseName: "id", + type: "string", + required: true, + format: "uuid", + }, + type: { + baseName: "type", + type: "OrgResourceType", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return OrgData.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/organizations/src/v2/models/OrgRelationshipData.ts b/services/organizations/src/v2/models/OrgRelationshipData.ts new file mode 100644 index 000000000000..fca7271866c7 --- /dev/null +++ b/services/organizations/src/v2/models/OrgRelationshipData.ts @@ -0,0 +1,57 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { OrgResourceType } from "./OrgResourceType"; + +/** + * Reference to an organization resource. + */ +export class OrgRelationshipData { + /** + * The UUID of the organization. + */ + "id": string; + /** + * The resource type for organizations. + */ + "type": OrgResourceType; + /** + * 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, + format: "uuid", + }, + type: { + baseName: "type", + type: "OrgResourceType", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return OrgRelationshipData.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/organizations/src/v2/models/OrgResourceType.ts b/services/organizations/src/v2/models/OrgResourceType.ts new file mode 100644 index 000000000000..520c77eeb3e7 --- /dev/null +++ b/services/organizations/src/v2/models/OrgResourceType.ts @@ -0,0 +1,7 @@ +import { UnparsedObject } from "@datadog/datadog-api-client"; + +/** + * The resource type for organizations. + */ +export type OrgResourceType = typeof ORGS | UnparsedObject; +export const ORGS = "orgs"; diff --git a/services/organizations/src/v2/models/TypingInfo.ts b/services/organizations/src/v2/models/TypingInfo.ts index 7f7d0ac7735c..48da44a736f2 100644 --- a/services/organizations/src/v2/models/TypingInfo.ts +++ b/services/organizations/src/v2/models/TypingInfo.ts @@ -1,6 +1,12 @@ import { ModelTypingInfo } from "@datadog/datadog-api-client"; import { APIErrorResponse } from "./APIErrorResponse"; +import { ManagedOrgsData } from "./ManagedOrgsData"; +import { ManagedOrgsRelationshipToOrg } from "./ManagedOrgsRelationshipToOrg"; +import { ManagedOrgsRelationshipToOrgs } from "./ManagedOrgsRelationshipToOrgs"; +import { ManagedOrgsRelationships } from "./ManagedOrgsRelationships"; +import { ManagedOrgsResponse } from "./ManagedOrgsResponse"; +import { OrgAttributes } from "./OrgAttributes"; import { OrgConfigGetResponse } from "./OrgConfigGetResponse"; import { OrgConfigListResponse } from "./OrgConfigListResponse"; import { OrgConfigRead } from "./OrgConfigRead"; @@ -8,14 +14,24 @@ import { OrgConfigReadAttributes } from "./OrgConfigReadAttributes"; import { OrgConfigWrite } from "./OrgConfigWrite"; import { OrgConfigWriteAttributes } from "./OrgConfigWriteAttributes"; import { OrgConfigWriteRequest } from "./OrgConfigWriteRequest"; +import { OrgData } from "./OrgData"; +import { OrgRelationshipData } from "./OrgRelationshipData"; export const TypingInfo: ModelTypingInfo = { enumsMap: { + ManagedOrgsType: ["managed_orgs"], OrgConfigType: ["org_configs"], + OrgResourceType: ["orgs"], }, oneOfMap: {}, typeMap: { APIErrorResponse: APIErrorResponse, + ManagedOrgsData: ManagedOrgsData, + ManagedOrgsRelationshipToOrg: ManagedOrgsRelationshipToOrg, + ManagedOrgsRelationshipToOrgs: ManagedOrgsRelationshipToOrgs, + ManagedOrgsRelationships: ManagedOrgsRelationships, + ManagedOrgsResponse: ManagedOrgsResponse, + OrgAttributes: OrgAttributes, OrgConfigGetResponse: OrgConfigGetResponse, OrgConfigListResponse: OrgConfigListResponse, OrgConfigRead: OrgConfigRead, @@ -23,5 +39,7 @@ export const TypingInfo: ModelTypingInfo = { OrgConfigWrite: OrgConfigWrite, OrgConfigWriteAttributes: OrgConfigWriteAttributes, OrgConfigWriteRequest: OrgConfigWriteRequest, + OrgData: OrgData, + OrgRelationshipData: OrgRelationshipData, }, }; diff --git a/services/users/src/v2/UsersApi.ts b/services/users/src/v2/UsersApi.ts index 7929fd7dd763..3bff42a879df 100644 --- a/services/users/src/v2/UsersApi.ts +++ b/services/users/src/v2/UsersApi.ts @@ -95,6 +95,51 @@ export class UsersApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + public async deleteUserInvitations( + userId: string, + _options?: Configuration, + ): Promise { + const _config = _options || this.configuration; + + // verify required parameter 'userId' is not null or undefined + if (userId === null || userId === undefined) { + throw new RequiredError("userId", "deleteUserInvitations"); + } + + // Path Params + const localVarPath = "/api/v2/users/{user_id}/invitations".replace( + "{user_id}", + encodeURIComponent(String(userId)), + ); + + // Make Request Context + const { server, overrides } = _config.getServerAndOverrides( + "UsersApi.v2.deleteUserInvitations", + UsersApi.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 disableUser( userId: string, _options?: Configuration, @@ -578,6 +623,53 @@ export class UsersApiResponseProcessor { ); } + /** + * 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 deleteUserInvitations + * @throws ApiException if the response code was not in [200, 299] + */ + public async deleteUserInvitations(response: ResponseContext): Promise { + const contentType = normalizeMediaType(response.headers["content-type"]); + if (response.httpStatusCode === 200) { + return; + } + if ( + response.httpStatusCode === 403 || + response.httpStatusCode === 404 || + 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 @@ -1049,6 +1141,14 @@ export interface UsersApiCreateUserRequest { body: UserCreateRequest; } +export interface UsersApiDeleteUserInvitationsRequest { + /** + * The UUID of the user whose pending invitations should be canceled. + * @type string + */ + userId: string; +} + export interface UsersApiDisableUserRequest { /** * The ID of the user. @@ -1186,6 +1286,28 @@ export class UsersApi { }); } + /** + * Cancel all pending invitations for a specified user. + * Requires the `user_access_invite` permission. + * @param param The request object + */ + public deleteUserInvitations( + param: UsersApiDeleteUserInvitationsRequest, + options?: Configuration, + ): Promise { + const requestContextPromise = this.requestFactory.deleteUserInvitations( + param.userId, + options, + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.deleteUserInvitations(responseContext); + }); + }); + } + /** * Disable a user. Can only be used with an application key belonging * to an administrator user. diff --git a/services/users/src/v2/index.ts b/services/users/src/v2/index.ts index 757100e43734..cbba291c9c4e 100644 --- a/services/users/src/v2/index.ts +++ b/services/users/src/v2/index.ts @@ -1,5 +1,6 @@ export { UsersApiCreateUserRequest, + UsersApiDeleteUserInvitationsRequest, UsersApiDisableUserRequest, UsersApiGetInvitationRequest, UsersApiGetUserRequest,