swagger: '2.0'
# Added by API Auto Mocking Plugin
info:
  description: SDC Controller APIs
  version: 1.0.0
  title: MAS SDC Controller
tags:
  - name: Config Mapping Policies
    description: Describes Ingress Policies
parameters:
  id:
    name: id
    in: path
    type: string
    description: Policy ID
    required: true
  cluster_name:
    name: cluster_name
    in: path
    type: string
    description: cluster name
    required: true
  namespace:
    name: namespace
    in: path
    type: string
    description: namespace
    required: true
  ingress_name:
    name: ingress_name
    in: path
    type: string
    description: ingress name
    required: true
paths:
  /config_mapping_policies:
    get:
      tags:
        - Config Mapping Policies
      summary: Lists all Ingress Policies
      operationId: listAllIngressPolicies
      description: |
        Lists all the configured Config Mapping Policies
      produces:
        - application/json
      parameters: [
        {
          name: filter,
          in: query,
          description: pass an optional search string for looking up Ingress Policies that affect a certain cluster,
          required: false,
          type: string
        }
      ]
      responses:
        200:
          description: Config Mapping Policies that match criteria
          schema:
              $ref: '#/definitions/ConfigMappingPoliciesResponse'
        400:
          description: bad input parameter
    post:
      tags:
        - Config Mapping Policies
      summary: Creates a New Config Mapping Policy
      operationId: addConfigMappingPolicy
      description: Adds a new Config Mapping Policy
      responses:
        201:
          description: Config Mapping Policy Created
          schema:
            $ref: '#/definitions/ConfigMappingPolicyResponse'
        400:
          description: bad input parameter
          schema:
            $ref: '#/definitions/Error'
        409:
          description: an existing Config Mapping Policy already exists
      parameters:
        - name: Body
          in: body
          required: true
          x-is-map: false
          schema:
            $ref: '#/definitions/ConfigMappingPolicyCreateRequest'
  '/config_mapping_policies/{id}':
    put:
      tags:
        - Config Mapping Policies
      summary: Updates a Config Mapping Policy
      operationId: updateConfigMappingPolicy
      description: Updates a new Config Mapping Policy
      parameters:
          - $ref: '#/parameters/id'
          - name: Body
            in: body
            required: true
            x-is-map: false
            schema:
              $ref: '#/definitions/ConfigMappingPolicyUpdateRequest'
      responses:
        200:
          description: Config Mapping Policies that match criteria
          schema:
              $ref: '#/definitions/ConfigMappingPolicyResponse'
        400:
          description: bad input parameter
    delete:
      tags:
        - Config Mapping Policies
      summary: Delete a Config Mapping Policy
      operationId: deleteConfigMappingPolicy
      description: Delete a new Config Mapping Policy
      parameters:
        - $ref: '#/parameters/id'
      responses:
        204:
          description: Successful removal of a policy.
        400:
          description: bad input parameter
          schema:
              $ref: '#/definitions/Error'
        401:
          description: Failed Authentication
          schema:
              $ref: '#/definitions/Error'
        403:
          description: Unauthorized
          schema:
              $ref: '#/definitions/Error'
  /app_event:
    post:
      tags:
        - App Events
      summary: Push a new App Event to Service Delivery Controller
      operationId: addAppEvent
      description: Push a new App Event for SDC to process
      responses:
        201:
          description: Application Event Pushed to SDC
          schema:
            $ref: '#/definitions/AppEventCreateRequest'
        400:
          description: 'Invalid App Event'
      parameters:
        - name: Body
          in: body
          required: true
          x-is-map: false
          schema:
            $ref: '#/definitions/AppEventCreateRequest'              
  /config:
    post:
      tags:
        - Config operations
      summary: Config operations from agent
      operationId: configCreateOper
      description: config operations from agent
      responses:
        201:
          description: config operation from agent
          schema:
            $ref: '#/definitions/ConfigOperCreateRequestResponse'
        400:
          description: 'Invalid config operation'
      parameters:
        - name: Body
          in: body
          required: true
          x-is-map: false
          schema:
            $ref: '#/definitions/ConfigOperCreateRequest'              
  /config_bulk:
    post:
      tags:
        - Config bulk operations
      summary: Config operations from agent
      operationId: configBulkOper
      description: config bulk operations from agent
      responses:
        201:
          description: config operation from agent
          schema:
            $ref: '#/definitions/ConfigBulkRequestResponse'
        400:
          description: 'Invalid config operation'
      parameters:
        - name: Body
          in: body
          required: true
          x-is-map: false
          schema:
            $ref: '#/definitions/ConfigBulkRequest'              
  /env_config_status:
    get:
      tags:
        - env config status
      summary: Lists all env config status
      operationId: listAllEnvConfigStatus
      description: |
        Lists all the configured env config status
      produces:
        - application/json
      responses:
        200:
          description: env config status
          schema:
              $ref: '#/definitions/EnvConfigStatusResponse'
        400:
          description: bad input parameter
  /env_config_status/{env_name}/{context_name}/{resource_name}:
    get:
      tags:
        - env config status
      summary: Lists all env config status
      operationId: listAllEnvConfigStatus
      description: |
        Lists all the configured env config status
      produces:
        - application/json
      responses:
        200:
          description: env config status
          schema:
              $ref: '#/definitions/EnvConfigStatusResponse'
        400:
          description: bad input parameter
    
definitions:
    EnvConfigStatusResponse:
      type: object
      properties:
        env_config_status:
          type: array      
          items:
            $ref: "#/definitions/EnvConfigStatusSpec"
    EnvConfigStatusSpec:
      type: object
      properties:
        env_name:
          type: string
          example: "DevTeam-A"
        context_name:
          type: string
          example: "citrixadm"
        resource_name:
          type: string
          example: "pig"
        event_id:
          type: string
          example: "ebae1df8-9c71-475d-98f0-d57d0a68a8f0"
        env_type:
          type: string
          example: "Kubernetes"
        resource_id:
          type: string
          example: "83236150-95ac-11e8-a902-e20118d8ffd7"
        resource_type:
          type: string
          example: "Ingress"
        resource_inclination_number:
          type: string
          example: "1"
        resource_version:
          type: string
          example: "36276666"
        env_config_status:
          type: string
          example: "Success"
        message:
          type: string
          example: "could not get instance_id from the spec"
    ConfigMappingPoliciesResponse:
      type: object
      properties:
        config_mapping_policies:
          type: array      
          items:
            $ref: "#/definitions/ConfigMappingPolicy"
    ConfigMappingPolicyResponse:
      type: object
      properties:
        config_mapping_policy:
            $ref: "#/definitions/ConfigMappingPolicy"
    ConfigMappingPolicyUpdateRequest:
      type: object
      properties:
        config_mapping_policy:
          $ref: "#/definitions/ConfigMappingPolicy"
    ConfigMappingPolicyCreateRequest:
      type: object
      properties:
        config_mapping_policy:
          $ref: "#/definitions/ConfigMappingPolicyRequest"
    ConfigMappingPolicyGetResponse:
      type: object
      properties:
        name:
          type: string
          example: staging_pol
        app_environment:
          type: string
          example: kubernetes
          enum:
            - kubernetes
            - aws
            - azure
            - openstack
            - vmware
        condition:
          type: object
          properties:
            clauses:
              type: array
              items:
                type: object
                properties:
                  attribute_name:
                    type: string
                    example: resource_labels
                  attribute_type:
                    type: string
                    example: string
                    enum: ["string", "[string]"]
                  operator:
                    type: string
                    example: contains_any
                    enum:
                      - is
                      - is_not
                      - in
                      - not_in
                      - contains_any
                      - contains_all
                      - not_contains_all
                  values:
                    type: array
                    items:
                      type: string
                    example: 
                      - xyz 
                      - abc
                  value:
                    type: string
                    example: somevalue
        infrastructure:
          type: array
          items:
            $ref: "#/definitions/Infrastructure"
        ipam_network_id:
          type: string
          format: uuid
          example: d290f1ee-6c54-4b01-90e6-d701748f0851
    ConfigMappingPolicyRequest:
      type: object
      required:
        - name
        - app_environment
        - condition
      properties:
        name:
          type: string
          example: staging_pol
        app_environment:
          type: string
          example: kubernetes
          enum:
            - kubernetes
            - aws
            - azure
            - openstack
            - vmware
        condition:
          type: object
          properties:
            clauses:
              type: array
              items:
                type: object
                properties:
                  attribute_name:
                    type: string
                    example: resource_labels
                  attribute_type:
                    type: string
                    example: string
                    enum: ["string", "[string]"]
                  operator:
                    type: string
                    example: contains_any
                    enum:
                      - is
                      - is_not
                      - in
                      - not_in
                      - contains_any
                      - contains_all
                      - not_contains_all
                  values:
                    type: array
                    items:
                      type: string
                    example: 
                      - xyz 
                      - abc
                  value:
                    type: string
                    example: somevalue
        infrastructure:
          type: array
          items:
            $ref: "#/definitions/Infrastructure"
        ipam_network_id:
          type: string
          format: uuid
          example: d290f1ee-6c54-4b01-90e6-d701748f0851
    ConfigMappingPolicy:
      allOf:
        - 
          properties:
            id:
                  type: string
                  format: uuid
                  example: d290f1ee-6c54-4b01-90e6-d701748f0851
        - $ref: '#/definitions/ConfigMappingPolicyGetResponse'

    AppEventCreateRequest:
      type: object
      properties:
        app_environment_type:
          type: string
          example: AWS, Kubernetes
        app_environment_id:
          type: string
          example: a249ddee-6c54-4b01-90e4-d701748f0831
        type:
          type: string
          example: ADDED
          enum:
            - ADDED
            - MODIFIED
            - DELETED
            - ERROR
        app_event_id:
          type: string
          example: 9299ddee-6c54-4b01-90e6-d701748f0851
        message:
          type: string
          example: "<App Environment Event in Raw format>"
        resource_type:
          type: string
          example: "Ingress, ScaleUp"
        resource_name:
          type: string
          example: "PiggyAppIngressEvent"
        resource_id:
          type: string
          example: "<App Environment Specific Resource ID>"
        server_group_id:
          type: string
          example: "server group identifier"
        trig_time:
          type: string
          example: "Event Trigger Time"
        recv_time:
          type: string
          example: "Event Receive Time"

    ConfigOperCreateRequest:
      type: object
      properties:
        type:
          type: string
          example: "get_all"
        object_name:
          type: string
          example: "env_configs"
        filter_data:
          type: object
          additionalProperties: true
          example: "<Config params>"
        properties:
          type: object
          additionalProperties: true
          example: "<Config additional params>"

    ConfigOperCreateRequestResponse:
      type: object
      additionalProperties: true
      properties:
        message:
          type: string
          example: "<config response string>"

    ConfigBulkRequest:
      type: array
      items:
          $ref: "#/definitions/ConfigOperCreateRequest"

    ConfigBulkRequestResponse:
      type: object
      additionalProperties: true
      properties:
        message:
          type: string
          example: "<config response string>"

    Error:
      properties:
        errorcode:
          type: string
          format: int32
          example: 1920
        errormessage:
          type: string
          example: "id cannot be found"
    Infrastructure:
      type: object
      properties:
        infra_type:
          type: string
          example: adc
        infra_topology:
          type: string
          example: standalone_adc
        flavor:
          type: string
          example: standalone_instance
        provisioning_condition:
          type: boolean
          description: Condition that if true results in new infrastructure being provisioned.
          example: false
        selection_details:
          type: object
          description: details needed for the infrastructure selection such as instance ID,
        details:
          type: object
          description: details needed for the infrastructure provisioning
          properties:
            id:
              type: string
              example: 657cff08-9bc4-4185-922c-cf1f3ca3b835
            site_id:
              type: string
              example: 589cff08-9bc4-4185-922c-cf1f3ca3b835
          
# Added by API Auto Mocking Plugin
host: 'adm.cloud.com' 
# basePath: /sdc/nitro/v1/config
schemes:
 - https
# Added by API Auto Mocking Plugin
basePath: /sdc/nitro/v1/config
