openapi: 3.0.0
info:
  version: "v1"
  title: 'B2B Self Service Management API Definition'
  description: 'This is the RESTful API for Self Service Organization Management. This API allows users to create and retrieve sub-organizations.
    Other than that the API supports to update self service configurations'
  contact:
    name: WSO2
    url: 'http://wso2.com/products/identity-server/'
    email: iam-dev@wso2.org
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
servers:
  - url: 'https://localhost:9443/o/{organization-domain}/api/server/v1/self-service'
    variables:
      organization-domain:
        default: 10084a8d-113f-4211-a0d5-efe36b082211
security:
  - OAuth2: []
  - BasicAuth: []
  - BearerAuth: []
paths:
  /self-service/preferences:
    patch:
      description:
        This API provides the capability to update properties related to self service for an organization<br>
        <b>Permission required:</b> <br>
        * /permission/admin/manage/identity/organizationmgt/update <br>
        <b>Scope required:</b> <br>
        * internal_organization_update
      summary:
        Patch is supported only self service governance configs.
      operationId: organizationPreferencePatch
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PropertyPatchReq'
        required: true
      responses:
        '200':
          $ref: '#/components/responses/OK'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/ServerError'
      tags:
        - SelfService
    get:
      description:
        This API provides the capability to retrieve properties related to self service <br>
        <b>Permission required:</b> <br>
        * /permission/admin/manage/identity/organizationmgt/view <br>
        <b>Scope required:</b> <br>
        * internal_organization_view
      summary:
        Get is supported only for auto login & enable/disable self service.
      operationId: organizationPreferenceGet
      responses:
        '200':
          description: Requested self service properties.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PropertiesGetRes'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/ServerError'
      tags:
        - SelfService

components:
  parameters:
    filterQueryParam:
      in: query
      name: filter
      required: false
      description:
        Condition to filter the retrieval of records.
      schema:
        type: string
    limitQueryParam:
      in: query
      name: limit
      required: false
      description:
        Maximum number of records to be returned. (Should be greater than 0)
      schema:
        type: integer
        format: int32
        minimum: 0
    beforeQueryParam:
      in: query
      name: before
      required: false
      description:
        Points to the previous range of data that can be retrieved.
      schema:
        type: string
    afterQueryParam:
      in: query
      name: after
      required: false
      description:
        Points to the next range of data to be returned.
      schema:
        type: string
    recursiveQueryParam:
      in: query
      name: recursive
      required: false
      description:
        Determines whether a recursive search should happen.
      schema:
        type: boolean
        default: false
    showChildrenQueryParam:
      in: query
      name: showChildren
      required: false
      description:
        Returns the organization details along with the child organization IDs belonging to this organization.
      schema:
        type: boolean
        default: false
    includePermissionsQueryParam:
      in: query
      name: includePermissions
      required: false
      description:
        Returns the organization details along with permissions assigned for the requested user in this organization.
      schema:
        type: boolean
        default: false

  schemas:
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          example: ORG-00000
          description: An error code.
        message:
          type: string
          example: Some Error Message
          description: An error message.
        description:
          type: string
          example: Some Error Description
          description: An error description.
        traceId:
          type: string
          example: e0fbcfeb-3617-43c4-8dd0-7b7d38e13047
          description: An error trace identifier.

    PropertyPatchReq:
      type: object
      description: Self-service property patch request.
      required:
        - operation
        - properties
      properties:
        operation:
          type: string
          description: Self-service properties patch operation.
          enum:
            - UPDATE
          example: UPDATE
        properties:
          type: array
          description: Self-service properties to patch.
          items:
            $ref: '#/components/schemas/PropertyReq'
    PropertyReq:
      type: object
      description: Self service property to patch.
      required:
        - name
        - value
      properties:
        name:
          type: string
          description: Property name.
          example: auto.login.enable
        value:
          type: string
          description: Property value.
          example: 'false'
    PropertiesGetRes:
      type: array
      description: Define any additional properties if required.
      items:
        $ref: '#/components/schemas/PropertyRes'
    PropertyRes:
      type: object
      description: Governance connector property.
      properties:
        name:
          type: string
          description: Property name.
          example: auto.login.enable
        value:
          type: string
          description: Property value.
          example: 'false'
        displayName:
          type: string
          description: Property display name.
          example: Auto Login
        description:
          type: string
          description: Property description.
          example: Enable auto login after onboarding.


  #--------------------------------------------------------
  # Descriptions of Organization Management API responses.
  #--------------------------------------------------------
  responses:
    OK:
      description: OK.
    BadRequest:
      description: Invalid input in the request.
      content:
        'application/json':
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Requested resource is not found.
      content:
        'application/json':
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Authentication information is missing or invalid.
    Forbidden:
      description: Access forbidden.
    ServerError:
      description: Internal server error.
      content:
        'application/json':
          schema:
            $ref: '#/components/schemas/Error'
    NotImplemented:
      description: Not Implemented.
      content:
        'application/json':
          schema:
            $ref: '#/components/schemas/Error'
  #-----------------------------------------------------
  # Applicable authentication mechanisms.
  #-----------------------------------------------------
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
    BearerAuth:
      type: http
      scheme: bearer
    OAuth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: 'https://localhost:9443/oauth2/authorize'
          tokenUrl: 'https://localhost:9443/oauth2/token'
          scopes: {}
