All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mote-provider-service-api.8.34.0.source-code.apiv2.yaml Maven / Gradle / Ivy

There is a newer version: 10.7.0
Show newest version
swagger: '2.0'
info:
  version: 2.0.0
  title: 'Remote Provider Service'
  description: 'API for the Remote Provider Service. Exposes health checks and supports communication with Git Providers.'
  termsOfService: 'https://hello.world/terms/'
  contact:
    name: 'Blue Team'
    email: [email protected]
    url: 'https://www.codacy.com'
  license:
    name: 'Codacy. All rights reserved'
    url: 'https://www.codacy.com'

tags:
  - name: provider
    description: 'Provider endpoints'
  - name: restricted
    description: 'Endpoints that should only be used in special cases'

schemes:
  - http

host: rps.dev.codacy.org

basePath: /v2

produces:
  - application/json
consumes:
  - application/json

definitions:
  RemoteOrganizationIdentifier:
    type: string

  RemoteUserIdentifier:
    type: string

  RemoteRepositoryIdentifier:
    type: string

  RemoteOrganizationType:
    type: string
    enum: &organizationTypeEnum
      - Organization
      - Account

  PaginationInfo:
    type: object
    properties:
      cursor:
        type: string
      limit:
        type: integer
        format: int32
      total:
        type: integer
        format: int32

  RemoteOrganization:
    type: object
    required:
      - id
      - name
      - avatar
      - userId
      - userRole
    properties: &RemoteOrganizationProperties
      id:
        $ref: '#/definitions/RemoteOrganizationIdentifier'
      name:
        type: string
      avatar:
        type: string
      userId:
        type: string
      userRole:
        type: string
        enum:
          - Admin
          - Member

  RemoteOrganizationResponse:
    type: object
    required:
      - data
    properties:
      data:
        $ref: "#/definitions/RemoteOrganization"

  RemoteUser:
    type: object
    required:
      - id
      - name
      - avatar
    properties:
      id:
        $ref: '#/definitions/RemoteUserIdentifier'
      name:
        type: string
      avatar:
        type: string

  RemoteUserListResponse:
    type: object
    required:
      - data
    properties:
      pagination:
        $ref: "#/definitions/PaginationInfo"
      data:
        type: array
        items:
          $ref: "#/definitions/RemoteUser"

  RepositoryPermission:
    type: object
    required:
      - admin
      - push
      - pull
    properties:
      admin:
        type: boolean
      push:
        type: boolean
      pull:
        type: boolean

  RemoteRepository: &RemoteRepository
    type: object
    required:
      - id
      - name
      - owner
      - fullPath
      - isPrivate
      - url
      - permission
    properties:
      id:
        $ref: '#/definitions/RemoteRepositoryIdentifier'
      name:
        type: string
      owner:
        type: string
      fullPath:
        type: string
      isPrivate:
        type: boolean
      url:
        type: string
      permission:
        $ref: '#/definitions/RepositoryPermission'
      updatedAt:
        type: string
        format: date-time

  RemoteRepositoryListItem:
    <<: *RemoteRepository
    required:
      - id
      - name
      - owner
      - fullPath
      - isPrivate
      - url

  RemoteRepositoryResponse:
    type: object
    required:
      - data
    properties:
      data:
        $ref: "#/definitions/RemoteRepository"

  RemoteRepositoryListResponse:
    type: object
    required:
      - data
    properties:
      pagination:
        $ref: "#/definitions/PaginationInfo"
      data:
        type: array
        items:
          $ref: "#/definitions/RemoteRepositoryListItem"

  RemoteOrganizationListItem:
    properties:
      <<: *RemoteOrganizationProperties
      organizationType:
        type: string
        enum: *organizationTypeEnum
    required:
      - id
      - name
      - avatar
      - userId
      - organizationType


  RemoteOrganizationsListResponse:
    type: object
    required:
      - data
    properties:
      pagination:
        $ref: "#/definitions/PaginationInfo"
      data:
        type: array
        items:
          $ref: "#/definitions/RemoteOrganizationListItem"

  RemoteRepositoryMembership:
    type: object
    required:
      - userId
    properties:
      userId:
        $ref: '#/definitions/RemoteUserIdentifier'

  RemoteRepositoryMembershipListResponse:
    type: object
    required:
      - data
    properties:
      pagination:
        $ref: "#/definitions/PaginationInfo"
      data:
        type: array
        items:
          $ref: "#/definitions/RemoteRepositoryMembership"

  OrganizationHook:
    type: object
    required:
      - callback
      - secret
    properties:
      callback:
        description: "The url that GitHub will call when an event is fired"
        type: string
      secret:
        description: "Setting a webhook secret allows you to ensure that POST requests sent to the payload URL are from GitHub."
        type: string
      events:
        description: "An array of GitHub events which will trigger when changes happen. Will default to 'organization', 'meta', 'repository' if empty"
        type: array
        items:
          type: string

  SystemHook:
    type: object
    required:
      - callback
      - secret
    properties:
      callback:
        description: "The url that the provider will call when an event is fired"
        type: string
      secret:
        description: "Setting a webhook secret allows you to ensure that POST requests sent to the payload URL are from the provider."
        type: string

  NotificationsComment:
    type: object
    required:
      - path
      - severity
      - message
      - startLine
      - endLine
    properties:
      path:
        description: "The relative path of the file to comment"
        type: string
      severity:
        description: "The severity of the comment"
        type: string
        enum: [ info, warning, error ]
      message:
        description: "Message of the comment"
        type: string
      startLine:
        description: "Line where the comment starts"
        type: integer
        format: int64
      endLine:
        description: "Line where the comment ends"
        type: integer
        format: int64

  NotificationsStatus:
    type: object
    required:
      - state
    properties:
      state:
        description: "Current state of the analysis"
        type: string
        enum: [ in_progress, completed ]
      outcome:
        description: "Outcome of the analysis"
        type: string
        enum: [ success, failure, action_required ]

  NotificationsSummary:
    type: object
    required:
      - message
    properties:
      message:
        description: "Summary of the analysis results"
        type: string

  Notifications:
    type: object
    required:
      - identifier
      - name
      - detailsUrl
      - comments
    properties:
      identifier:
        description: "Short identifier of the analysis executed"
        type: string
        pattern: '^[a-zA-Z0-9\-_\/]{4,}$'
      name:
        description: "Name of the analysis executed"
        type: string
      detailsUrl:
        description: "URL with more details about the analysis"
        type: string
      status:
        $ref: '#/definitions/NotificationsStatus'
      comments:
        type: array
        description: "Comments after 50 will be discarded"
        items:
          $ref: '#/definitions/NotificationsComment'
        maxItems: 50
      summary:
        $ref: '#/definitions/NotificationsSummary'

  Error:
    type: object
    required:
      - description
    properties:
      description:
        type: string

  NotFound: #404
    allOf:
      - $ref: "#/definitions/Error"
      - type: object
        required:
          - error
        properties:
          error:
            type: string
            default: "NotFound"

  Forbidden: #403
    allOf:
      - $ref: "#/definitions/Error"
      - type: object
        required:
          - error
        properties:
          error:
            type: string
            default: "Forbidden"

parameters:
  providerParam: &providerParam
    in: path
    name: provider
    description: 'Git Provider'
    required: true
    type: string
    enum: [ gh, ghe, gl, gle, bb, bbe ]
    x-example: gh
  remoteOrganizationIdentifierParam: &remoteOrganizationIdentifierParam
    in: path
    name: remoteOrganizationIdentifier
    description: 'Remote organization identifier'
    required: true
    type: string
    x-example: 1234
  remoteOrganizationNameParam: &remoteOrganizationNameParam
    in: path
    name: remoteOrganizationName
    description: 'Remote organization name'
    required: true
    type: string
    x-example: Codacy
  remoteOrganizationPathParam: &remoteOrganizationPathParam
    in: path
    name: remoteOrganizationPath
    description: 'Remote organization full path'
    required: true
    type: string
    x-example: Codacy
  remoteUserIdentifierParam: &remoteUserIdentifierParam
    in: path
    name: remoteUserIdentifier
    description: 'Remote user identifier'
    required: true
    type: string
    x-example: "codacy"
  remoteRepositoryIdentifierParam: &remoteRepositoryIdentifierParam
    in: path
    name: remoteRepositoryIdentifier
    description: 'Remote repository identifier'
    required: true
    type: string
    x-example: "123"
  remoteRepositoryNameParam: &remoteRepositoryNameParam
    in: path
    name: remoteRepositoryName
    description: 'Remote repository name'
    required: true
    type: string
    x-example: "ui-components"
  cursorParam: &cursorParam
    in: query
    name: cursor
    required: false
    type: string
    description: Cursor to list elements after.
    x-example: "Yms345gh=="
  limitParam: &limitParam
    in: query
    name: limit
    required: false
    type: integer
    format: int32
    minimum: 1
    maximum: 100
    default: 100
    description: Number of items to return.
    x-example: 20
  searchParam: &searchParam
    in: query
    name: search
    required: false
    type: string
    description: Filter the results searching by this string.
    x-example: "my-repository-name"
  organizationTypeParam: &organizationTypeParam
    in: query
    name: organizationType
    required: false
    type: string
    enum: *organizationTypeEnum
    description: The organization type to search.
    x-example: "Account"
  providerTokenParam: &providerTokenParam
    in: header
    name: token
    description: 'Provider Token'
    required: false
    type: string

paths:

  '/{provider}/users/{remoteUserIdentifier}/organizations/{remoteOrganizationIdentifier}/{remoteOrganizationName}/repositories':
    get:
      tags:
        - organization
      x-jvm-package: organization
      summary: 'Finds all repos for remote organization name of a specific provider'
      description: 'Finds all repos for remote organization name of a specific provider.'
      operationId: listOrganizationRepositories
      parameters:
        - *providerParam
        - *remoteUserIdentifierParam
        - *remoteOrganizationIdentifierParam
        - *remoteOrganizationNameParam
        - *organizationTypeParam
        - *searchParam
        - *cursorParam
        - *limitParam
        - *providerTokenParam
      responses:
        '200':
          description: 'Successful operation'
          schema:
            $ref: "#/definitions/RemoteRepositoryListResponse"
          examples:
            application/json:
              pagination:
                cursor: "YugfO05=="
                limit: 20
                total: 73
              data:
                - id: 1
                  name: Website
                  owner: Codacy
                  isPrivate: true
                  permissions:
                    admin: true
                    push: true
                    pull: true
        '400':
          description: 'Missing authentication token or unknown provider'
          schema:
            $ref: '#/definitions/Error'
        '500':
          description: 'Unexpected error happened'
          schema:
            $ref: '#/definitions/Error'

  '/{provider}/users/{remoteUserIdentifier}/organizations/{remoteOrganizationIdentifier}/{remoteOrganizationName}/repositories/{remoteRepositoryIdentifier}/{remoteRepositoryName}/memberships':
    get:
      tags:
        - organization
      x-jvm-package: organization
      summary: 'List people that have access to a repository'
      description: 'List people that have access to a repository.'
      operationId: listRepositoryMembers
      parameters:
        - *providerParam
        - *remoteUserIdentifierParam
        - *remoteOrganizationIdentifierParam
        - *remoteOrganizationNameParam
        - *remoteRepositoryIdentifierParam
        - *remoteRepositoryNameParam
        - *cursorParam
        - *limitParam
        - *providerTokenParam
      responses:
        '200':
          description: 'Successful operation'
          schema:
            $ref: "#/definitions/RemoteRepositoryMembershipListResponse"
          examples:
            application/json:
              pagination:
                cursor: "YugfO05=="
                limit: 20
                total: 73
              data:
                - id: 1
                - id: 2
        '400':
          description: 'Missing authentication token or unknown provider'
          schema:
            $ref: '#/definitions/Error'
        '500':
          description: 'Unexpected error happened'
          schema:
            $ref: '#/definitions/Error'

  '/{provider}/users/{remoteUserIdentifier}/organizations':
    get:
      tags:
        - organization
      x-jvm-package: organization
      summary: 'Finds all organizations for a remote user of a specific provider.'
      description: 'Finds all organizations for a remote user of a specific provider.'
      operationId: listOrganizations
      parameters:
        - *providerParam
        - *remoteUserIdentifierParam
        - *cursorParam
        - *limitParam
        - *providerTokenParam
      responses:
        '200':
          description: 'Successful operation'
          schema:
            $ref: "#/definitions/RemoteOrganizationsListResponse"
          examples:
            application/json:
              pagination:
                cursor: "YugfO05=="
                limit: 20
                total: 73
              data:
                - userId: 1
                  organizationId: 1
                  status: active
                  role: admin
        '400':
          description: 'Missing authentication token or unknown provider'
          schema:
            $ref: '#/definitions/Error'
        '500':
          description: 'Unexpected error happened'
          schema:
            $ref: '#/definitions/Error'

  '/{provider}/users/{remoteUserIdentifier}/organizations/{remoteOrganizationIdentifier}/{remoteOrganizationName}/repositories/{remoteRepositoryIdentifier}/{remoteRepositoryName}':
    get:
      tags:
        - organization
      x-jvm-package: organization
      summary: 'Finds a specific repo for remote organization name and id and repository name and id of a specific provider'
      description: 'Finds a specific repo for remote organization name and id and repository name and id of a specific provider.'
      operationId: getRepository
      parameters:
        - *providerParam
        - *remoteUserIdentifierParam
        - *remoteOrganizationIdentifierParam
        - *remoteOrganizationNameParam
        - *remoteRepositoryIdentifierParam
        - *remoteRepositoryNameParam
        - *providerTokenParam
      responses:
        '200':
          description: 'Successful operation'
          schema:
            $ref: '#/definitions/RemoteRepositoryResponse'
          examples:
            application/json:
              data:
                id: 1
                name: Website
                owner: Codacy
                isPrivate: true
                permissions:
                  admin: true
                  push: true
                  pull: true
        '400':
          description: 'Missing authentication token or unknown provider'
          schema:
            $ref: '#/definitions/Error'
        '403':
          $ref: '#/responses/Forbidden'
        '404':
          $ref: '#/responses/NotFound'
        '500':
          description: 'Unexpected error happened'
          schema:
            $ref: '#/definitions/Error'

  '/{provider}/users/{remoteUserIdentifier}/organizations/{remoteOrganizationPath}/repositories/{remoteRepositoryName}':
    get:
      tags:
        - restricted
      x-jvm-package: restricted
      summary: 'Finds a specific repo for remote organization path, and repository name of a specific provider'
      description: 'This endpoint should only be used when the caller does not have access to organization or repository ids. It introduces the concept of path which has a very restricted usage in the Codacy platform. Prefer to use the endpoint with organization and repository ids and names.'
      operationId: getRepositoryByName
      parameters:
        - *providerParam
        - *remoteUserIdentifierParam
        - *remoteOrganizationPathParam
        - *remoteRepositoryNameParam
        - *providerTokenParam
      responses:
        '200':
          description: 'Successful operation'
          schema:
            $ref: '#/definitions/RemoteRepositoryResponse'
          examples:
            application/json:
              data:
                id: 1
                name: Website
                owner: Codacy
                isPrivate: true
                permissions:
                  admin: true
                  push: true
                  pull: true
        '400':
          description: 'Missing authentication token or unknown provider'
          schema:
            $ref: '#/definitions/Error'
        '403':
          $ref: '#/responses/Forbidden'
        '404':
          $ref: '#/responses/NotFound'
        '500':
          description: 'Unexpected error happened'
          schema:
            $ref: '#/definitions/Error'

  '/{provider}/organizations/{remoteOrganizationIdentifier}/{remoteOrganizationName}/repositories/{remoteRepositoryIdentifier}/{remoteRepositoryName}/pullRequest/{pullRequestNumber}/commit/{headSha}/notifications':
    post:
      tags:
        - organization
      x-jvm-package: organization
      summary: 'Creates notifications on a specific commit'
      operationId: createNotifications
      parameters:
        - *providerParam
        - *remoteOrganizationIdentifierParam
        - *remoteOrganizationNameParam
        - *remoteRepositoryIdentifierParam
        - *remoteRepositoryNameParam
        - in: path
          name: pullRequestNumber
          description: 'Number of the pull request analysed'
          required: true
          type: integer
          format: int64
          x-example: 1
        - in: path
          name: headSha
          description: 'Commit SHA analysed'
          required: true
          type: string
          x-example: "86533ffbcfc755ba5e6f5cc901d5927a627720dc"
        - in: body
          name: "Notifications"
          required: true
          schema:
            $ref: "#/definitions/Notifications"
      responses:
        '204':
          description: 'Successful operation'
        '400':
          description: 'Problem encountered in the request'
          schema:
            $ref: '#/definitions/Error'
        '500':
          description: 'Unexpected error happened'
          schema:
            $ref: '#/definitions/Error'

  '/{provider}/users/{remoteUserIdentifier}/organizations/{remoteOrganizationIdentifier}/{remoteOrganizationName}':
    get:
      tags:
        - organization
      x-jvm-package: organization
      summary: 'Finds information for a specific organization and membership for the user'
      description: 'Finds membership status for the user in a specific organization.'
      operationId: getOrganization
      parameters:
        - *providerParam
        - *remoteUserIdentifierParam
        - *remoteOrganizationIdentifierParam
        - *remoteOrganizationNameParam
        - *providerTokenParam
        - *organizationTypeParam
      responses:
        '200':
          description: 'Successful operation'
          schema:
            $ref: '#/definitions/RemoteOrganizationResponse'
          examples:
            application/json:
              data:
                id: 1
                name: Codacy
                avatar: https://www.gravatar.com/avatar/some-random-avatar
                userId: '1'
                userRole: Admin
        '400':
          description: 'Missing authentication token or unknown provider'
          schema:
            $ref: '#/definitions/Error'
        '500':
          description: 'Unexpected error happened'
          schema:
            $ref: '#/definitions/Error'

  '/{provider}/users/{remoteUserIdentifier}/organizations/{remoteOrganizationIdentifier}/{remoteOrganizationName}/permission':
    get:
      tags:
        - organization
      x-jvm-package: organization
      summary: 'Finds permission for the user for a specific organization'
      description: 'Finds membership status for the user in a specific organization.'
      operationId: getUserPermissionOnOrganization
      parameters:
        - *providerParam
        - *remoteUserIdentifierParam
        - *remoteOrganizationIdentifierParam
        - *remoteOrganizationNameParam
        - *providerTokenParam
        - *organizationTypeParam
      responses:
        '200':
          description: 'Successful operation'
          schema:
            $ref: '#/definitions/RemoteOrganizationResponse'
          examples:
            application/json:
              data:
                id: 1
                name: Codacy
                avatar: https://www.gravatar.com/avatar/some-random-avatar
                userId: '1'
                userRole: Admin
        '400':
          description: 'Missing authentication token or unknown provider'
          schema:
            $ref: '#/definitions/Error'
        '500':
          description: 'Unexpected error happened'
          schema:
            $ref: '#/definitions/Error'

  /cleanCache:
    post:
      tags:
        - organization
      x-jvm-package: organization
      summary: 'Cleans all cache entries for a user token'
      description: 'Cleans all cache entries for a user token.'
      operationId: cleanCache
      parameters:
        - in: header
          name: token
          description: 'Provider Token'
          required: true
          type: string
      responses:
        '200':
          description: 'Successful operation'
        '400':
          description: 'Missing authentication token or unknown provider'
          schema:
            $ref: '#/definitions/Error'
        '500':
          description: 'Unexpected error happened'
          schema:
            $ref: '#/definitions/Error'

  '/{provider}/users/{remoteUserIdentifier}/organizations/{remoteOrganizationIdentifier}/{remoteOrganizationName}/hooks':
    post:
      tags:
        - organization
      x-jvm-package: organization
      summary: 'Creates a hook against the given organization'
      operationId: createOrganizationHook
      parameters:
        - *providerParam
        - *remoteUserIdentifierParam
        - *remoteOrganizationIdentifierParam
        - *remoteOrganizationNameParam
        - *providerTokenParam
        - in: body
          name: "OrganizationHook"
          required: true
          schema:
            $ref: "#/definitions/OrganizationHook"
      responses:
        '201':
          description: Created
        '400':
          description: 'Missing authentication token or unknown provider'
          schema:
            $ref: '#/definitions/Error'
        '500':
          description: 'Unexpected error happened'
          schema:
            $ref: '#/definitions/Error'

  '/{provider}/users/{remoteUserIdentifier}/hooks/system':
    post:
      tags:
        - organization
      x-jvm-package: organization
      summary: 'Creates a hook in the platform'
      operationId: createSystemHook
      parameters:
        - *providerParam
        - *remoteUserIdentifierParam
        - *providerTokenParam
        - in: body
          name: "SystemHook"
          required: true
          schema:
            $ref: "#/definitions/SystemHook"
      produces:
        - application/json
      responses:
        '201':
          description: Created
        '400':
          description: 'Missing authentication token or unknown provider'
          schema:
            $ref: '#/definitions/Error'
        '500':
          description: 'Unexpected error happened'
          schema:
            $ref: '#/definitions/Error'



responses:
  NotFound: #404
    description: 'Not Found'
    x-ms-error-response: true
    schema:
      $ref: "#/definitions/NotFound"

  Forbidden: #403
    description: 'Forbidden'
    x-ms-error-response: true
    schema:
      $ref: "#/definitions/Forbidden"




© 2015 - 2025 Weber Informatics LLC | Privacy Policy