openapi: 3.0.1
info:
  title: python-ows-carveouts
  version: 1.0.0
servers:
  - url: https://qa-ows-carveouts-python.theorchard.io/
paths:
  /hello:
    get:
      summary: Health Check
      description: Monitors if the service is actively responding to requests
      responses:
        '200':
          description: A message
          content:
            '*/*':
              schema:
                type: string
  /delivery-restrictions/product/{product_id}:
    parameters:
      - description: product ID
        name: product_id
        in: path
        required: true
        schema:
          type: integer
    get:
      summary: Product carveouts get endpoint.
      description: Get endpoint for product carveouts from all vendor account, subaccount and product levels.
      responses:
        '200':
          description: product carveouts
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Carveout'
    post:
      summary: Product carveouts post endpoint.
      description: Post endpoint for product carveouts from all vendor account, subaccount and product levels.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CarveoutPost'
      responses:
        '204':
          description: product carveouts saved successfully
        '400':
          description: Invalid request data
        '500':
          description: Internal server error
  /delivery-restrictions/subaccount/{subaccount_id}:
    get:
      summary: Subaccount carveouts get endpoint.
      description: Get endpoint for subaccount carveouts from both vendor account and subaccount levels.
      parameters:
        - description: subaccount ID
          name: subaccount_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: subaccount carveouts
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Carveout'
  /delivery-restrictions/account/{account_id}:
    parameters:
      - description: account ID (vendor_id)
        name: account_id
        in: path
        required: true
        schema:
          type: integer
    get:
      summary: Vendor account carveouts get endpoint.
      description: Get endpoint for vendor account carveouts.
      responses:
        '200':
          description: account carveouts
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Carveout'
    post:
      summary: account carveouts post endpoint.
      description: Post endpoint for account carveouts.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CarveoutPost'
      responses:
        '204':
          description: account carveouts saved successfully
        '400':
          description: Invalid request data
        '500':
          description: Internal server error
  /release_dms_carveouts/{product_id}:
    delete:
      summary: delete release service carveouts
      description: Delete release-level service carveouts by product ID
      parameters:
        - description: product ID
          name: product_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: A message
          content:
            '*/*':
              schema:
                type: string
  /release_dms_master_carveouts/{product_id}:
    delete:
      summary: delete release master service carveouts
      description: Delete release-level master service carveouts by product ID
      parameters:
        - description: product ID
          name: product_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: A message
          content:
            '*/*':
              schema:
                type: string
  /vendor-contract-store-carveouts-dataloader:
    post:
      summary: Dataloader for vendor level store carveouts
      description: >-
        Allows the client to request carveouts for every (vendor_contract_id,
        store_id) pair
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DataloadVendorContractStoreCarveoutPayload'
      responses:
        '200':
          description: successful response
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/DataloadVendorContractStoreCarveoutResponse
  /delivery-restriction/apply-default-restrictions:
    post:
      summary: create default delivery restrictions
      description: >-
        Create default carveouts based on opt-out information at account and product 
        levels
      parameters:
        - description: Service/Store ID
          name: service_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                updated_by:
                  type: integer
                  description: User ID for the reqeust
      responses:
        '204':
          description: Success response
components:
  schemas:
    Error:
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
    DataloadVendorContractStoreCarveoutPayload:
      type: array
      items:
        type: object
        properties:
          vendor_contract_id:
            type: integer
          delivery_store_id:
            type: integer
    DataloadVendorContractStoreCarveoutResponse:
      type: object
      properties:
        results:
          type: array
          items:
            type: object
            required:
              - data
            properties:
              data:
                type: object
                properties:
                  store_id:
                    type: integer
                  distribution_type_ids:
                    type: array
                    items:
                      type: integer
              error:
                $ref: '#/components/schemas/Error'
    AccountCarveout:
      type: object
      properties:
        service:
          $ref: '#/components/schemas/ServiceCarveout'
        country:
          type: array
          items:
            type: string
        service_country:
          $ref: '#/components/schemas/ServiceCountryCarveout'
        new_service_opt_outs:
          type: array
          items:
            type: integer
    SubaccountCarveout:
      type: object
      properties:
        service:
          $ref: '#/components/schemas/ServiceCarveout'
        country:
          type: array
          items:
            type: string
        service_country:
          $ref: '#/components/schemas/ServiceCountryCarveout'
    ProductCarveout:
      $ref: '#/components/schemas/AccountCarveout'
    CarveoutPost:
      $ref: '#/components/schemas/ProductCarveoutPostPayload'
    Carveout:
      type: object
      properties:
        account:
          $ref: '#/components/schemas/AccountCarveout'
        subaccount:
          $ref: '#/components/schemas/SubaccountCarveout'
        product:
          $ref: '#/components/schemas/ProductCarveout'
    ServiceCarveout:
      type: array
      items:
        type: object
        properties:
          service_id:
            type: integer
          service_name:
            type: string
          distribution_types:
            type: array
            items:
              type: integer
    ServiceCountryCarveout:
      type: array
      items:
        type: object
        properties:
          service_id:
            type: integer
          country_id:
            type: integer
          country_code:
            type: string
    ProductCarveoutPostPayload:
      type: object
      properties:
        service:
          $ref: '#/components/schemas/ServiceCarveout'
        country:
          type: array
          items:
            type: string
        service_country:
          type: array
          items:
            type: object
            properties:
              service_id:
                type: integer
              country_codes:
                type: array
                items:
                  type: string
        new_service_opt_outs:
          type: array
          items:
            type: integer
        updated_by:
          description: OA user ID of the user making the update
          type: integer
