openapi: "3.0.2" info: title: Api for managing Organization version: "1.0" servers: - url: https://organization-rest-service.sonam.cloud security: - bearerAuth: [] paths: /organizations: post: description: create a new Organization requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/OrganizationBody' responses: '201': description: Successfully created new organization content: application/json: schema: $ref: '#/components/schemas/UuidResponseBody' '400': description: failed to create new organization content: application/json: schema: $ref: '#/components/schemas/BadRequestBody' put: description: Update Organization requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/OrganizationBody' responses: '200': description: Successfully updated Organization content: application/json: schema: $ref: '#/components/schemas/UuidResponseBody' '400': description: failed to update organization content: application/json: schema: $ref: '#/components/schemas/BadRequestBody' get: description: get organizations by page parameters: - name: size in: query description: number of items on a page schema: type: integer - name: page in: query description: Page number of the organizations to retrieve schema: type: integer responses: '200': description: Successfully retrieved a page of organizations content: application/json: schema: allOf: - $ref: '#/components/schemas/Page' - type: object properties: content: type: array items: $ref: '#/components/schemas/OrganizationBody' '400': description: failed to retrieve a page of organization content: application/json: schema: $ref: '#/components/schemas/BadRequestBody' /organizations/{organizationId}: delete: description: delete organization by id parameters: - name: organizationId in: path required: true schema: type: string format: uuid responses: '200': description: deleted organization by id content: application/json: schema: type: object properties: message: type: string '400': description: failed to delete organization by id content: application/json: schema: $ref: '#/components/schemas/BadRequestBody' get: description: get organization by id parameters: - name: organizationId in: path schema: type: string format: uuid responses: '200': description: Successfully retrived organization by id content: application/json: schema: $ref: '#/components/schemas/Organization' '400': description: No organization found with id content: application/schema: $ref: '#/components/schemas/BadRequestBody' /organizations/subdomain/{subdomain}: get: description: get first organization mapped to a subdomain parameters: - name: subdomain in: path required: true schema: type: string responses: '200': description: Successfully retrieved organization by subdomain content: application/json: schema: $ref: '#/components/schemas/Organization' '400': description: No organization found with subdomain content: application/json: schema: $ref: '#/components/schemas/BadRequestBody' /organizations/subdomain/{subdomain}/organizations: get: description: get organizations mapped to a subdomain parameters: - name: subdomain in: path required: true schema: type: string responses: '200': description: Successfully retrieved organizations by subdomain content: application/json: schema: type: array items: $ref: '#/components/schemas/Organization' '400': description: failed to retrieve organizations by subdomain content: application/json: schema: $ref: '#/components/schemas/BadRequestBody' /organizations/subdomain/{subdomain}/users: get: description: get users across organizations mapped to a subdomain parameters: - name: subdomain in: path required: true schema: type: string - name: size in: query description: number of items on a page schema: type: integer - name: page in: query description: Page number of user organization memberships to retrieve schema: type: integer responses: '200': description: Successfully retrieved users by subdomain content: application/json: schema: allOf: - $ref: '#/components/schemas/Page' - type: object properties: content: type: array items: $ref: '#/components/schemas/SubdomainOrganizationUser' '400': description: failed to retrieve users by subdomain content: application/json: schema: $ref: '#/components/schemas/BadRequestBody' /organizations/subdomain/{subdomain}/users/{userId}/organizations/{organizationId}: get: description: check that an organization is mapped to a subdomain and contains the user parameters: - name: subdomain in: path required: true schema: type: string - name: userId in: path required: true schema: type: string format: uuid - name: organizationId in: path required: true schema: type: string format: uuid responses: '200': description: Successfully checked user organization membership within subdomain content: application/json: schema: type: object properties: message: type: boolean '400': description: failed to check user organization membership within subdomain content: application/json: schema: $ref: '#/components/schemas/BadRequestBody' /organizations/subdomain/{subdomain}/users/{userId}/default-organization-id: get: description: get the user's default organization id if it is mapped to the subdomain parameters: - name: subdomain in: path required: true schema: type: string - name: userId in: path required: true schema: type: string format: uuid responses: '200': description: Successfully retrieved default organization id for subdomain and user content: application/json: schema: type: object properties: message: type: string format: uuid '400': description: failed to retrieve default organization id for subdomain and user content: application/json: schema: $ref: '#/components/schemas/BadRequestBody' /organizations/subdomain/{subdomain}/organizations/{organizationId}/exists: get: description: check whether an organization is mapped to a subdomain parameters: - name: subdomain in: path required: true schema: type: string - name: organizationId in: path required: true schema: type: string format: uuid responses: '200': description: Successfully checked whether organization is mapped to subdomain content: application/json: schema: type: object properties: message: type: boolean /organizations/subdomain/{subdomain}/organizations/{organizationId}: post: description: map an organization to a subdomain parameters: - name: subdomain in: path required: true schema: type: string - name: organizationId in: path required: true schema: type: string format: uuid responses: '200': description: Successfully mapped organization to subdomain content: application/json: schema: $ref: '#/components/schemas/OkResponseBody' '400': description: failed to map organization to subdomain content: application/json: schema: $ref: '#/components/schemas/BadRequestBody' delete: description: remove an organization from a subdomain parameters: - name: subdomain in: path required: true schema: type: string - name: organizationId in: path required: true schema: type: string format: uuid responses: '200': description: Successfully removed organization from subdomain content: application/json: schema: $ref: '#/components/schemas/OkResponseBody' '400': description: failed to remove organization from subdomain content: application/json: schema: $ref: '#/components/schemas/BadRequestBody' /organizations/users: put: description: Update list of organization user association requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/OrganizationUserBody' responses: '200': description: Successfully updated list of organization user associations content: application/json: schema: $ref: '#/components/schemas/OkResponseBody' '400': description: failed to update list of organization and user assocations content: application/json: schema: $ref: '#/components/schemas/BadRequestBody' /organizations/{organizationId}/users: get: description: Get organizationusers in the organization id parameters: - name: organizationId in: path schema: type: string format: uuid responses: '200': description: Successfully retrieved organization-users list for organization id content: application/json: schema: $ref: '#/components/schemas/OrganizationUser' '400': description: failed to get organization-users for organziation id content: application/json: schema: $ref: '#/components/schemas/BadRequestBody' /organizations/{organizationId}/users/{userId}/default: put: description: set the user's default organization parameters: - name: organizationId in: path required: true schema: type: string format: uuid - name: userId in: path required: true schema: type: string format: uuid responses: '200': description: Successfully set default organization content: application/json: schema: $ref: '#/components/schemas/OkResponseBody' '400': description: failed to set default organization content: application/json: schema: $ref: '#/components/schemas/BadRequestBody' /organizations/users/{userId}/default-organization-id: get: description: get the user's global default organization id parameters: - name: userId in: path required: true schema: type: string format: uuid responses: '200': description: Successfully retrieved default organization id content: application/json: schema: type: object properties: message: type: string format: uuid '400': description: failed to retrieve default organization id content: application/json: schema: $ref: '#/components/schemas/BadRequestBody' components: securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT schemas: Page: type: object properties: number: type: integer size: type: integer Organization: allOf: - $ref: '#/components/schemas/OrganizationBody' OrganizationBody: type: object properties: id: type: string format: uuid name: type: string creatorUserId: type: string format: uuid OrganizationUser: type: object properties: id: type: string format: uuid organizationId: type: string format: uuid userId: type: string format: uuid userRole: type: string OrganizationUserBody: allOf: - $ref: '#/components/schemas/OrganizationUser' - type: object # single other specific property for OrganizationUserBody properties: updateAction: type: string enum: - add - update - delete subdomain: type: string description: Subdomain boundary to enforce when restrictToSubdomain is true. restrictToSubdomain: type: boolean description: When true, rejects adding the user if they already belong to an organization mapped to another subdomain. SubdomainOrganizationUser: type: object properties: userId: type: string format: uuid organizationId: type: string format: uuid organizationName: type: string BadRequestBody: type: object properties: message: type: string UuidResponseBody: type: object properties: message: type: string format: uuid CanAddUserResponseBody: type: object properties: message: type: boolean reason: type: string OkResponseBody: type: object properties: message: type: string