---
swagger: '2.0'
info:
  title: Orchard OWS Carveouts API
  version: v1
host: qa-ows-carveouts.theorchard.io
schemes:
  - https
consumes:
  - application/json
produces:
  - application/json
paths:
  '/carveout/projection/{upc}/dms/{dmsId}':
    get:
      parameters:
        - description: UPC for release to calculate data for.
          in: path
          name: upc
          required: true
          type: integer
        - description: Store ID to calculate data for.
          in: path
          name: dmsId
          required: true
          type: integer
      responses:
        '200':
          description: Successfully calculated carveout projection
  '/carveout/product/{productId}/carveout-default-phys-dms':
    post:
      parameters:
        - description: Product ID to copy carveouts from.
          in: path
          name: productId
          required: true
          type: integer
        - in: body
          name: body
          required: true
          schema:
            properties:
              vendor_id:
                type: integer
            required:
              - vendor_id
      responses:
        '204':
          description: Successfully applied carveouts.
      description: >-
        Apply physical supply chain carveouts based on label level default
        physical supply chain opt-ins.
  '/carveout/product/{productId}/carveout-default-video-dms':
    post:
      parameters:
        - description: Product ID to assign carveouts to.
          in: path
          name: productId
          required: true
          type: integer
        - in: body
          name: body
          required: true
          schema:
            properties:
              ids_to_exclude_from_carveout:
                type: array
            required:
              - vendor_id
      responses:
        '204':
          description: Successfully applied carveouts.
      description: >-
        Apply physical supply chain carveouts based on label level and default
        video product rules.
  '/carveout/product/{productId}/copy/{newProductId}':
    post:
      parameters:
        - description: Product ID to copy carveouts from.
          in: path
          name: productId
          required: true
          type: integer
        - description: Product ID to copy carveouts to.
          in: path
          name: newProductId
          required: true
          type: integer
      responses:
        '201':
          description: |
            HTTP 201 CREATED
            ----------------
            Territory restrictions copied from product to new product.
        '400':
          description: |
            HTTP 400 Bad Request
            --------------------
            Validation error.
        '404':
          description: |
            HTTP 404 Not Found
            ------------------
            The product does not exist.
        '500':
          description: |
            HTTP 500 Internal Server Error.
      description: Copy product level carveouts from product to new product.
  '/carveout/release/{upc}':
    get:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
      responses:
        '200':
          description: >
            HTTP 200 OK

            ---------------

            It returns all the release level carveouts applied to the release,
            separated by master store,

            territory, and substore.
          examples:
            default:
              store:
                '1':
                  distros:
                    - '1'
                    - '3'
                  dms_name: iTunes
                '286':
                  distros:
                    - '1'
                  dms_name: Spotify
              territory:
                '1': US
                '2': CA
                '3': GB
                '4': DE
              substore:
                '187':
                  '6': FR
                  '8': AU
                '496':
                  '9': JP
        '404':
          description: Not Found
        '500':
          description: Server Error
      description: Requests all release level carveouts for specified UPC.
  '/carveout/release/{upc}/dms':
    get:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
      responses:
        '200':
          description: >
            HTTP 200 OK

            ---------------

            It returns release level dms master carveouts applied to the
            release.
          examples:
            default:
              '1':
                distros:
                  - '1'
                  - '3'
                dms_name: iTunes
              '286':
                distros:
                  - '1'
                dms_name: Spotify
        '404':
          description: Not Found
        '500':
          description: Server Error
      description:
        Requests release level master store carveouts for specified UPC.
    put:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
        - in: header
          name: Content-Type
          pattern: ^application/json$
          required: true
          type: string
        - in: header
          name: Correlation-Id
          required: true
          type: string
        - description: vendor | subaccount
          enum:
            - vendor
            - subaccount
          in: header
          name: Grass-Account-Type
          required: false
          type: string
        - description: vendor_id | subaccount_id
          in: header
          name: Grass-Account-Id
          pattern: ^\d+$
          required: false
          type: string
        - in: body
          name: body
          description: The payload to create.
          schema:
            type: array
            items:
              type: object
              properties:
                dms_id:
                  type: integer
                  example: 0
          required: true
      responses:
        '200':
          description: |
            HTTP 200 OK
            ---------------
            It returns the release level carved-out DMS ids set for the release.
        '400':
          description: >
            HTTP 400 Bad Request

            ---------------------

            Missing Grass-Account-Type OR Grass-Account-Id.  Both values may be
            omitted (in the case of a request from

            another ows microservice), but if one is present, the other must
            also be present.
        '403':
          description: >
            HTTP 403 Forbidden

            ------------------

            The request includes a project_id where the owner of the project
            does not match the value given in the Grass

            headers.
        '404':
          description: Not Found
        '500':
          description: Server Error
      description: Replaces and stores list of DMS carveouts for specified UPC.
  '/carveout/release/{upc}/territory':
    get:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
      responses:
        '200':
          description: |
            HTTP 200 OK
            ---------------
            It returns release level territory carveouts applied to the release.
          examples:
            default:
              '1': US
              '2': CA
              '3': GB
              '4': DE
        '404':
          description: Not Found
        '500':
          description: Server Error
      description: Requests release level territory carveouts for specified UPC.
    put:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
        - in: header
          name: Content-Type
          pattern: ^application/json$
          required: true
          type: string
        - in: header
          name: Correlation-Id
          required: true
          type: string
        - in: body
          name: body
          description: The payload to create.
          schema:
            type: array
            items:
              type: object
              properties:
                country_id:
                  type: integer
                  example: 0
      responses:
        '200':
          description: >
            HTTP 200 OK

            ---------------

            It returns the release level carved-out territory ids set for the
            release.
        '404':
          description: Not Found
        '500':
          description: Server Error
      description: >-
        Replaces and stores list of release territory carveouts for specified
        UPC.
  '/carveout/release/{upc}/territory/{dmsId}':
    get:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
        - description: UPC for requested release.
          in: path
          name: dmsId
          required: true
          type: integer
      responses:
        '200':
          description: >
            HTTP 200 OK

            ---------------

            It returns release level substore carveouts applied to the release
            for the provided DMS.
        '404':
          description: Not Found
        '500':
          description: Server Error
      description:
        Requests release level substore carveouts for specified UPC and DMS.
  /stores:
    get:
      responses:
        '200':
          description: |
            HTTP 200 OK
            ---------------
            It returns all DMS from art_relations.customer_master_master table.
      description: Returns all DMS
  '/carveout/subaccount/{upc}':
    get:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
      responses:
        '200':
          description: >
            HTTP 200 OK

            ---------------

            It returns all the subaccount level carveouts applied to the
            release, separated by master store,

            territory, and substore.
        '404':
          description: Not Found
        '500':
          description: Server Error
      description: Requests all subaccount level carveouts for specified UPC.
  '/carveout/subaccount/{upc}/dms':
    get:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
      responses:
        '200':
          description: >
            HTTP 200 OK

            ---------------

            It returns subaccount level dms master carveouts applied to the
            release.
        '404':
          description: Not Found
        '500':
          description: Server Error
      description:
        Requests subaccount level master store carveouts for specified UPC.
  '/carveout/subaccount/{upc}/territory':
    get:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
      responses:
        '200':
          description: >
            HTTP 200 OK

            ---------------

            It returns subaccount level territory carveouts applied to the
            release.
        '404':
          description: Not Found
        '500':
          description: Server Error
      description:
        Requests subaccount level territory carveouts for specified UPC.
  '/carveout/subaccount/{upc}/territory/{dmsId}':
    get:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
        - description: UPC for requested release.
          in: path
          name: dmsId
          required: true
          type: integer
      responses:
        '200':
          description: >
            HTTP 200 OK

            ---------------

            It returns subaccount level substore carveouts applied to the
            release for the provided DMS.
        '404':
          description: Not Found
        '500':
          description: Server Error
      description:
        Requests subaccount level substore carveouts for specified UPC and DMS.
  '/carveout/vendor/{upc}':
    get:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
      responses:
        '200':
          description: >
            HTTP 200 OK

            ---------------

            It returns all the vendor level carveouts applied to the release,
            separated by master store,

            territory, and substore.
          examples:
            default:
              store:
                '1':
                  distros:
                    - '1'
                    - '3'
                  dms_name: iTunes
                '286':
                  distros:
                    - '1'
                  dms_name: Spotify
              territory:
                '1': US
                '2': CA
                '3': GB
                '4': DE
              substore:
                '187':
                  '6': FR
                  '8': AU
                '496':
                  '9': JP
              optout:
                - 1
                - 2
                - 3
        '404':
          description: Not Found
        '500':
          description: Server Error
      description: Requests all vendor level carveouts for specified UPC.
  '/carveout/vendor/{upc}/dms':
    get:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
      responses:
        '200':
          description: |
            HTTP 200 OK
            ---------------
            It returns vendor level dms master carveouts applied to the release.
          examples:
            default:
              '1':
                distros:
                  - '1'
                  - '3'
                dms_name: iTunes
              '286':
                distros:
                  - '1'
                dms_name: Spotify
        '404':
          description: Not Found
        '500':
          description: Server Error
      description:
        Requests vendor level master store carveouts for specified UPC.
  '/carveout/vendor/{upc}/territory':
    get:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
      responses:
        '200':
          description: |
            HTTP 200 OK
            ---------------
            It returns vendor level territory carveouts applied to the release.
          examples:
            default:
              '1': US
              '2': CA
              '3': GB
              '4': DE
        '404':
          description: Not Found
        '500':
          description: Server Error
      description: Requests vendor level territory carveouts for specified UPC.
  '/carveout/vendor/{upc}/territory/{dmsId}':
    get:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
        - description: UPC for requested release.
          in: path
          name: dmsId
          required: true
          type: integer
      responses:
        '200':
          description: >
            HTTP 200 OK

            ---------------

            It returns vendor level substore carveouts applied to the release
            for the provided DMS.
          examples:
            default:
              '1': US
              '2': CA
              '3': GB
              '4': DE
        '404':
          description: Not Found
        '500':
          description: Server Error
      description:
        Requests vendor level substore carveouts for specified UPC and DMS.
  '/carveout/{upc}':
    get:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
      responses:
        '200':
          description: >
            HTTP 200 OK

            ---------------

            It returns all the carveouts applied to the release, separated by
            release, territory, and substore.
          examples:
            default:
              store:
                '1':
                  distros:
                    - '1'
                    - '3'
                  dms_name: iTunes
                '286':
                  distros:
                    - '1'
                  dms_name: Spotify
              territory:
                '1': US
                '2': CA
                '3': GB
                '4': DE
              substore:
                '187':
                  '6': FR
                  '8': AU
                '496':
                  '9': JP
              optout:
                - 1
                - 2
                - 3
        '404':
          description: Not Found
        '500':
          description: Server Error
      description: Requests combined level carveouts for specified UPC.
  '/carveout/{upc}/dms':
    get:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
      responses:
        '200':
          description: >
            HTTP 200 OK

            ---------------

            It returns all the combined level dms master carveouts applied to
            the release.
          examples:
            default:
              '1':
                distros:
                  - '1'
                  - '3'
                dms_name: iTunes
              '286':
                distros:
                  - '1'
                dms_name: Spotify
        '404':
          description: Not Found
        '500':
          description: Server Error
      description:
        Requests combined level master store carveouts for specified UPC.
  '/carveout/{upc}/territory':
    get:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
      responses:
        '200':
          description: >
            HTTP 200 OK

            ---------------

            It returns all the combined level territory carveouts applied to the
            release.
          examples:
            default:
              '1': US
              '2': CA
              '3': GB
              '4': DE
        '404':
          description: Not Found
        '500':
          description: Server Error
      description:
        Requests combined level territory carveouts for specified UPC.
  '/carveout/{upc}/territory/structured':
    get:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
        - in: header
          name: Content-Type
          pattern: ^application/json$
          required: true
          type: string
        - in: header
          name: Correlation-Id
          required: true
          type: string
      responses:
        '200':
          description: >
            HTTP 200 OK

            ---------------

            It returns all the combined level carved-out territory ids applied
            to the release for the provided DMS,

            grouped by restriction level.
          examples:
            default:
              vendor:
                - country_id: 1
                - country_id: 2
              subaccount:
                - country_id: 3
                - country_id: 4
              release:
                - country_id: 5
                - country_id: 6
        '404':
          description: Not Found
        '500':
          description: Server Error
      description: >-
        Requests territory carveouts for specified UPC, grouped by restriction
        level.
  '/carveout/{upc}/territory/{dmsId}':
    get:
      parameters:
        - description: UPC for requested release.
          in: path
          name: upc
          required: true
          type: integer
        - description: UPC for requested release.
          in: path
          name: dmsId
          required: true
          type: integer
      responses:
        '200':
          description: >
            HTTP 200 OK

            ---------------

            It returns all the combined level substore carveouts applied to the
            release for the provided DMS.
        '404':
          description: Not Found
        '500':
          description: Server Error
      description:
        Requests combined level substore carveouts for specified UPC and DMS.
definitions: {}
securityDefinitions: {}
