require 'swagger/blocks'

require_relative 'devops_error'
require_relative 'devops_response'

module Devops
  module API3
    module Docs
      class FilterRoutes

        include Swagger::Blocks

        swagger_path "/filter/{provider}/images" do
          operation :get do
            key :description, 'Get filter for images for provider'
            key :operationId, 'getFilterImages'
            key :tags, [
              'filter'
            ]
            parameter do
              key :name, :provider
              key :in, :path
              key :description, 'Provider name'
              key :required, true
              key :type, :string
            end
            response 200 do
              key :description, 'List of images filters'
              schema do
                key :type, :array
                items do
                  key :type, :string
                end
              end
            end
            response :default do
              key :description, 'error'
              schema do
                key :'$ref', :DevopsError
              end
            end
          end
        end

        swagger_path "/filter/{provider}/images/add" do
          operation :post do
            key :description, 'Add filters for images for provider'
            key :operationId, 'addFilterImages'
            key :tags, [
              'filter'
            ]
            parameter do
              key :name, :provider
              key :in, :path
              key :description, 'Provider name'
              key :required, true
              key :type, :string
            end
            parameter do
              key :name, :filtes
              key :in, :body
              key :description, 'Filters for images'
              key :required, true
              schema do
                key :type, :array
                items do
                  key :type, :string
                end
              end
            end
            response 200 do
              key :description, 'List of images filters'
              schema do
                key :'$ref', :FilterResponse
              end
            end
            response :default do
              key :description, 'error'
              schema do
                key :'$ref', :DevopsError
              end
            end
          end
        end

        swagger_path "/filter/{provider}/images/delete" do
          operation :post do
            key :description, 'Delete filters for images for provider'
            key :operationId, 'deleteFilterImages'
            key :tags, [
              'filter'
            ]
            parameter do
              key :name, :provider
              key :in, :path
              key :description, 'Provider name'
              key :required, true
              key :type, :string
            end
            parameter do
              key :name, :filtes
              key :in, :body
              key :description, 'Filters for images'
              key :required, true
              schema do
                key :type, :array
                items do
                  key :type, :string
                end
              end
            end
            response 200 do
              key :description, 'List of images filters'
              schema do
                key :'$ref', :FilterResponse
              end
            end
            response :default do
              key :description, 'error'
              schema do
                key :'$ref', :DevopsError
              end
            end
          end
        end

        swagger_schema :FilterResponse do
          allOf do
            schema do
              key :'$ref', :DevopsResponse
            end
            schema do
              property :images do
                key :type, :array
                items do
                  key :type, :string
                end
              end
            end
          end
        end

      end
    end
  end
end
