swagger: '2.0'
info:
  title: Digital Products API
  version: 0.0.1
host: ows-product-digital.theorchard.io
basePath: /
schemes:
  - https
paths:
  /meta-language:
    get:
      description: >-
        Fetches a list of available languages that can be used for the product
        'meta_language' (metadata language) property
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/jsonContentType'
        - in: query
          name: productId
          type: integer
          required: false
        - in: query
          name: include_instrumental
          type: boolean
          required: false
          default: false
      responses:
        '200':
          description: OK
        '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.
          schema:
            $ref: '#/definitions/ErrorResponse'
  /product/<int:product_id>/copy:
    post:
      description: Create a copy of the product.
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/jsonContentType'
        - in: body
          name: body
          required: true
          schema:
            properties:
              delivered_version:
                type: string
              format:
                type: string
              product_code:
                type: string
              product_name:
                type: string
              upc: {}
              version: {}
            required:
              - product_name
              - format
      responses:
        '201':
          description: Created
        '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.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '403':
          description: >
            HTTP 403 Forbidden
            ------------------
            The account given in the Grass headers does not own the product.
          schema:
            $ref: '#/definitions/ErrorResponse'
  /product/<int:product_id>/correction:
    post:
      description: Create a new correction for the given product
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/orchardUserId'
        - $ref: '#/parameters/grassAccountId'
        - $ref: '#/parameters/grassAccountType'
        - $ref: '#/parameters/jsonContentType'
      responses:
        '201':
          description: successfully created a correction
        '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.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '403':
          description: >
            HTTP 403 Forbidden
            ------------------
            The account given in the Grass headers does not own the product.
          schema:
            $ref: '#/definitions/ErrorResponse'
  /product/<int:product_id>/correction/<int:release_correction_id>:
    delete:
      description: Delete a release correction
      produces:
        - applicaton/json
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/orchardUserId'
        - $ref: '#/parameters/grassAccountId'
        - $ref: '#/parameters/grassAccountType'
        - $ref: '#/parameters/jsonContentType'
      responses:
        '202':
          description: The release correction was successfully deleted.
        '400':
          description: The release correction status is not "active"
          schema:
            $ref: '#/definitions/ErrorResponse'
        '404':
          description: The release correction was not found.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '500':
          description: A database error occured.
          schema:
            $ref: '#/definitions/ErrorResponse'
  /product/<int:product_id>/correction/<int:release_correction_id>/details:
    post:
      description: Create the correction details for the given id and details.
      produces:
        - applicaton/json
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/orchardUserId'
        - $ref: '#/parameters/grassAccountId'
        - $ref: '#/parameters/grassAccountType'
        - $ref: '#/parameters/jsonContentType'
      responses:
        '201':
          description: 201 OK
  /product/<int:product_id>/pricing:
    get:
      description: Get existing pricing for a product.
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/grassAccountId'
        - $ref: '#/parameters/grassAccountType'
        - $ref: '#/parameters/jsonContentType'
      responses:
        '200':
          description: OK
        '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.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '403':
          description: >
            HTTP 403 Forbidden
            ------------------
            The account given in the Grass headers does not own the product.
          schema:
            $ref: '#/definitions/ErrorResponse'
    put:
      description: Apply pricing to an existing product.
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/grassAccountId'
        - $ref: '#/parameters/grassAccountType'
        - $ref: '#/parameters/jsonContentType'
        - in: body
          name: body
          required: true
          schema:
            properties:
              amazon_pricing_tier_id:
                description: Unique id of the Amazon pricing tier to apply.
                type: integer
              itunes_pricing_tier_id:
                description: Unique id of the iTunes pricing tier to apply.
                type: integer
            required:
              - itunes_pricing_tier_id
              - amazon_pricing_tier_id
      responses:
        '200':
          description: OK
        '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.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '403':
          description: >
            HTTP 403 Forbidden
            ------------------
            The account given in the Grass headers does not own the product.
          schema:
            $ref: '#/definitions/ErrorResponse'
  /product/<int:product_id>/scheduling-and-pricing:
    get:
      description: Get pricing and scheduling information for a product.
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/grassAccountId'
        - $ref: '#/parameters/grassAccountType'
        - $ref: '#/parameters/jsonContentType'
      responses:
        '200':
          description: OK
        '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.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '403':
          description: >
            HTTP 403 Forbidden
            ------------------
            The account given in the Grass headers does not own the product.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '404':
          description: Product is not found.
          schema:
            $ref: '#/definitions/ErrorResponse'
  /product/audio:
    post:
      description: Create a new product.
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/grassAccountId'
        - $ref: '#/parameters/grassAccountType'
        - $ref: '#/parameters/jsonContentType'
        - in: body
          name: body
          schema:
            $ref: '#/definitions/PostProduct'
      responses:
        '201':
          description: Created
        '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.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '403':
          description: >
            HTTP 403 Forbidden
            ------------------
            The account given in the Grass headers does not own the product.
          schema:
            $ref: '#/definitions/ErrorResponse'
  /product/audio/<int:product_id>:
    get:
      description: Fetch an existing product.
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/grassAccountId'
        - $ref: '#/parameters/grassAccountType'
      responses:
        '200':
          description: |
            HTTP 200 OK.
            ---------------
            JSON object representing product information for product fetched.
        '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.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '403':
          description: >
            HTTP 403 Forbidden
            ------------------
            The account given in the Grass headers does not own the product.
          schema:
            $ref: '#/definitions/ErrorResponse'
    put:
      description: Update an existing product.
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/grassAccountId'
        - $ref: '#/parameters/grassAccountType'
        - $ref: '#/parameters/jsonContentType'
        - in: body
          name: body
          schema:
            $ref: '#/definitions/PutAudio'
      responses:
        '200':
          description: OK
        '400':
          description: '#/definitions/BadRequesr'
          schema:
            $ref: '#/definitions/ErrorResponse'
        '403':
          description: >
            HTTP 403 Forbidden
            ------------------
            The account given in the Grass headers does not own the product.
          schema:
            $ref: '#/definitions/ErrorResponse'
  /product/audio/<int:product_id>/status:
    put:
      description: Change the status of a product.
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/grassAccountId'
        - $ref: '#/parameters/grassAccountType'
        - $ref: '#/parameters/jsonContentType'
        - in: body
          name: body
          schema:
            properties:
              account_id:
                description: the account/vendor id.
                type: string
              subaccount_id:
                description: the subaccount id.
                type: string
      responses:
        '200':
          description: OK
        '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.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '403':
          description: >
            HTTP 403 Forbidden
            ------------------
            The account given in the Grass headers does not own the product.
          schema:
            $ref: '#/definitions/ErrorResponse'
  /product/audio/<int:product_id>/validate:
    get:
      description: Get validation for a product.
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/grassAccountId'
        - $ref: '#/parameters/grassAccountType'
        - $ref: '#/parameters/jsonContentType'
      responses:
        '200':
          description: OK
        '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.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '403':
          description: >
            HTTP 403 Forbidden
            ------------------
            The account given in the Grass headers does not own the product.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '404':
          description: Product is not found.
          schema:
            $ref: '#/definitions/ErrorResponse'
  /product/audio/validate/dataloader:
    post:
      description: Dataload validations for a product.
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/grassAccountId'
        - $ref: '#/parameters/grassAccountType'
        - $ref: '#/parameters/jsonContentType'
      responses:
        '200':
          description: OK
        '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.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '403':
          description: >
            HTTP 403 Forbidden
            ------------------
            The account given in the Grass headers does not own the product.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '404':
          description: Product is not found.
          schema:
            $ref: '#/definitions/ErrorResponse'
  /release-approval/rejections:
    put:
      description: Update a collection of rejections
      parameters:
        - $ref: '#/parameters/correlationId'
        - in: body
          name: body
          required: true
          schema:
            properties:
              rejections:
                description: An array of rejection note information to update.
                type: array
            required:
              - rejections
      responses:
        '200':
          description: successfully updated rejections
  /product/audio/{productId}/unsubmit:
    put:
      summary: Unsubmit a product.
      parameters:
        - description: Primary key of a product.
          in: path
          name: productId
          required: true
          type: string
      responses:
        '200':
          description: A message confirming that the release approval queue was deleted.
          examples:
            default:
              message: product unsubmitted
        '400':
          description: An error message indicating that the product can not be unsubmitted.
          examples:
            default:
              message: product not in submitted stat
  /product/<int:product_id>/not_for_distribution:
    post:
      description: Update not_for_distribution on a product
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/orchardUserId'
        - $ref: '#/parameters/grassAccountId'
        - $ref: '#/parameters/grassAccountType'
        - $ref: '#/parameters/jsonContentType'
        - in: body
          name: body
          required: true
          schema:
            properties:
              not_for_distribution:
                description: Value to set not_for_distribution to.
                type: string
            required:
              - not_for_distribution
      responses:
        '200':
          description: successfully updated not_for_distribution
        '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.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '403':
          description: >
            HTTP 403 Forbidden
            ------------------
            The account given in the Grass headers does not own the product.
          schema:
            $ref: '#/definitions/ErrorResponse'
  /product/<int:product_id>/approve:
    post:
      description: Update release_status on a product to in_content
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/orchardUserId'
        - $ref: '#/parameters/grassAccountId'
        - $ref: '#/parameters/grassAccountType'
        - $ref: '#/parameters/jsonContentType'
      responses:
        '200':
          description: successfully updated release_status
        '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.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '403':
          description: >
            HTTP 403 Forbidden
            ------------------
            The account given in the Grass headers does not own the product.
          schema:
            $ref: '#/definitions/ErrorResponse'
  /product/<int:product_id>/spatial:
    get:
      description: Get the spatial UPC record for a product.
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/grassAccountId'
        - $ref: '#/parameters/grassAccountType'
        - $ref: '#/parameters/jsonContentType'
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/ReleaseSpatialResponse'
        '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.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '403':
          description: >
            HTTP 403 Forbidden
            ------------------
            The account given in the Grass headers does not own the product.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '404':
          description: No spatial record found for the given product.
          schema:
            $ref: '#/definitions/ErrorResponse'
    post:
      description: >
        Create a spatial UPC record for a product. If upc is not
        provided, one is provisioned automatically.
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/grassAccountId'
        - $ref: '#/parameters/grassAccountType'
        - $ref: '#/parameters/jsonContentType'
        - in: body
          name: body
          required: false
          schema:
            properties:
              upc:
                type: integer
                description: >
                  Optional. The spatial UPC to assign to the product. If
                  omitted, a UPC is provisioned automatically.
      responses:
        '200':
          description: Successfully created the spatial record.
          schema:
            $ref: '#/definitions/ReleaseSpatialResponse'
        '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.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '403':
          description: >
            HTTP 403 Forbidden
            ------------------
            The account given in the Grass headers does not own the product.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '409':
          description: >
            HTTP 409 Conflict
            -----------------
            A spatial record already exists for the given product.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '500':
          description: Failed to provision a UPC.
          schema:
            $ref: '#/definitions/ErrorResponse'
  /products/<int:product_id>/spatial:
    delete:
      description: Delete the spatial UPC record for a product.
      parameters:
        - $ref: '#/parameters/correlationId'
        - $ref: '#/parameters/grassAccountId'
        - $ref: '#/parameters/grassAccountType'
        - $ref: '#/parameters/jsonContentType'
      responses:
        '200':
          description: Spatial UPC record deleted successfully.
        '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.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '403':
          description: >
            HTTP 403 Forbidden
            ------------------
            The account given in the Grass headers does not own the product.
          schema:
            $ref: '#/definitions/ErrorResponse'
        '404':
          description: No spatial record found for the given product.
          schema:
            $ref: '#/definitions/ErrorResponse'
definitions:
  ReleaseSpatialResponse:
    type: object
    properties:
      release_id:
        type: integer
      upc:
        type: integer
    example:
      release_id: 12345
      upc: 9876543210123
  ErrorResponse:
    type: object
    required:
      - message
      - code
    properties:
      code:
        type: string
      message:
        type: object
    example:
      code: not_found_error
      message: Product not found
  PostProduct:
    type: object
    required:
      - product_highlights
      - project_id
      - product_name
    properties:
      account_id:
        description: Unique id of the account for microservice calls.
        type: integer
      account_type:
        description: The type of the account either vendor or subaccount.
        enum:
          - vendor
          - subaccount
        type: string
      delivered_version:
        description: The store-deliverable version of this product, e.g. "Live at Wembley"
        maxLength: 255
        type: string
      format:
        description: Release format.
        enum:
          - Single
          - EP
          - Full Length
        type: string
      product_code:
        description: >
          Identifier for the product, must be unique at the vendor or
          subaccount level.
        type: string
      product_highlights:
        description: Marketing highlight associated with product.
        type: string
      product_name:
        description: The name of the product.
        type: string
      project_id:
        description: Unique identifer for the associated project.
        type: integer
      subaccount_id:
        description: |
          Identifier for the subaccount the release belongs to for D3 labels.
        type: integer
      upc:
        description: The universal product code associated with the product.
        maxLength: 13
        minLength: 12
        type: string
      version:
        description: The internal version of this product, e.g. "Apple Version"
        maxLength: 255
        type: string
  PutAudio:
    type: object
    required:
      - product_highlights
    properties:
      account_id:
        description: Unique id of the account for microservice calls.
        type: integer
      account_type:
        description: The type of the account either vendor or subaccount.
        enum:
          - vendor
          - subaccount
        type: string
      artist_id:
        description: Unique identifier of the associated artist.
        type: integer
      c_line:
        description: C-line information for the product.
        pattern: ^[0-9]{4}(,\s[0-9]{4})*(\s\S+)+$
        type: string
      delivered_version:
        description: The store-deliverable version of this product, e.g. "Live at Wembley"
        maxLength: 255
        type: string
      description:
        description: Description of the product.
        type: string
      format:
        description: Release format.
        enum:
          - Single
          - EP
          - Full Length
        type: string
      genre_id:
        description: Unique identifier of the associated genre.
        type: integer
      imprint:
        description: The name of the label that owns the product.
        type: string
      manufacturer_upc:
        description: Manufacturer's universal product code for the product.
        maxLength: 13
        minLength: 12
        type: string
      meta_language:
        description: The language used in the product metadata.
        type: string
      p_line:
        description: P-line information for the product.
        pattern: ^[0-9]{4}(,\s[0-9]{4})*(\s\S+)+$
        type: string
      preorder_date:
        description: The date when preorders of the product begin (or began).
        pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}$
        type: string
      previewable:
        description: Whether or not the product is previewable on iTunes.
        enum:
          - 'yes'
          - 'no'
        type: string
      product_artists:
        description: |
          Array of objects containing the name and role of artists featured.
        type: array
        items:
          default:
            - name: Great Artist
              role: primary_artist
      product_code:
        description: >
          Identifier for the product, must be unique at the vendor or
          subaccount level.
        type: string
      product_highlights:
        description: Marketing highlight associated with product.
        type: string
      product_name:
        description: The name (title) of the product.
        type: string
      project_code:
        description: Unique identifer for the associated project.
        type: string
      project_id:
        description: Unique identifer for the associated project.
        type: integer
      release_date:
        description: The date when the product will be (or was) released.
        pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}$
        type: string
      sale_start_date:
        description: The date when sales of the product begin (or began).
        pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}$
        type: string
      special_instructions:
        description: Special instructions to be included with the product.
        type: string
      subgenre_id:
        description: Unique identifier of the associated subgenre.
        type: integer
      vendor_release_identifier:
        description: Idenitfier for vendors mainly for use by RED.
        maxLength: 32
        type: string
      version:
        description: The internal version of this product, e.g. "Apple Version"
        type: string
parameters:
  correlationId:
    in: header
    name: Correlation-Id
    required: false
    type: string
    description: UUID
  orchardUserId:
    in: header
    name: Orchard-User-Id
    required: false
    type: string
    pattern: ^(oa:|alw:)
    description: Orchard user ID from Grass
  grassAccountId:
    in: header
    name: Grass-Account-Id
    required: false
    type: integer
    description: Vendor /subaccount ID from Grass
  grassAccountType:
    in: header
    name: Grass-Account-Type
    required: false
    type: string
    enum:
      - vendor
      - subaccount
    description: Type of account (vendor or subaccount) for the Grass-authenticated user
  jsonContentType:
    in: header
    name: Content-Type
    pattern: application/json
    required: true
    type: string
securityDefinitions: {}
