2018-04-26 19:38:16 +00:00
|
|
|
require 'swagger/blocks'
|
|
|
|
|
|
|
|
module ServiceApiDoc
|
|
|
|
include Swagger::Blocks
|
|
|
|
|
|
|
|
# Swagger documentation for Service model
|
|
|
|
swagger_schema :Service do
|
|
|
|
key :required, [:id, :port, :proto]
|
|
|
|
property :id, type: :integer, format: :int32
|
|
|
|
property :host_id, type: :integer, format: :int32
|
|
|
|
property :created_at, type: :string, format: :date_time
|
|
|
|
property :port, type: :integer, format: :int32
|
|
|
|
property :proto, type: :string, enum: ['tcp','udp']
|
|
|
|
property :state, type: :string
|
|
|
|
property :name, type: :string
|
|
|
|
property :updated_at, type: :string, format: :date_time
|
|
|
|
property :info, type: :string
|
|
|
|
end
|
|
|
|
|
|
|
|
swagger_path '/api/v1/services' do
|
2018-05-02 19:47:17 +00:00
|
|
|
# Swagger documentation for /api/v1/services GET
|
2018-04-26 19:38:16 +00:00
|
|
|
operation :get do
|
|
|
|
key :description, 'Return services that are stored in the database.'
|
2018-04-30 21:40:07 +00:00
|
|
|
key :tags, [ 'service' ]
|
2018-04-26 19:38:16 +00:00
|
|
|
|
|
|
|
parameter :workspace
|
|
|
|
|
|
|
|
response 200 do
|
|
|
|
key :description, 'Returns Service data'
|
|
|
|
schema do
|
|
|
|
key :type, :array
|
|
|
|
items do
|
|
|
|
key :'$ref', :Service
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Swagger documentation for /api/v1/services POST
|
|
|
|
operation :post do
|
|
|
|
key :description, 'Create a Service.'
|
2018-04-30 21:40:07 +00:00
|
|
|
key :tags, [ 'service' ]
|
2018-04-26 19:38:16 +00:00
|
|
|
|
|
|
|
parameter do
|
|
|
|
key :in, :body
|
|
|
|
key :name, :body
|
|
|
|
key :description, 'The attributes to assign to the Service'
|
|
|
|
key :required, true
|
|
|
|
schema do
|
|
|
|
key :'$ref', :Service
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
response 200 do
|
|
|
|
key :description, 'Successful operation'
|
|
|
|
schema do
|
|
|
|
key :type, :object
|
|
|
|
key :'$ref', :Service
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Swagger documentation for /api/v1/services/ DELETE
|
|
|
|
operation :delete do
|
|
|
|
key :description, 'Delete the specified services.'
|
2018-04-30 21:40:07 +00:00
|
|
|
key :tags, [ 'service' ]
|
2018-04-26 19:38:16 +00:00
|
|
|
|
|
|
|
parameter :delete_opts
|
|
|
|
|
|
|
|
response 200 do
|
|
|
|
key :description, 'Successful operation'
|
|
|
|
schema do
|
|
|
|
key :type, :array
|
|
|
|
items do
|
|
|
|
key :'$ref', :Service
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
swagger_path '/api/v1/services/:id' do
|
2018-05-02 19:47:17 +00:00
|
|
|
# Swagger documentation for api/v1/services/:id GET
|
2018-04-26 19:38:16 +00:00
|
|
|
operation :get do
|
|
|
|
key :description, 'Return services that are stored in the database.'
|
2018-04-30 21:40:07 +00:00
|
|
|
key :tags, [ 'service' ]
|
2018-04-26 19:38:16 +00:00
|
|
|
|
|
|
|
parameter :workspace
|
|
|
|
|
|
|
|
parameter do
|
|
|
|
key :name, :id
|
|
|
|
key :in, :path
|
|
|
|
key :description, 'ID of Service to retrieve'
|
|
|
|
key :required, true
|
|
|
|
key :type, :integer
|
|
|
|
key :format, :int32
|
|
|
|
end
|
|
|
|
|
|
|
|
response 200 do
|
|
|
|
key :description, 'Returns Service data'
|
|
|
|
schema do
|
|
|
|
key :type, :array
|
|
|
|
items do
|
|
|
|
key :'$ref', :Service
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Swagger documentation for /api/v1/services/:id PUT
|
|
|
|
operation :put do
|
|
|
|
key :description, 'Update the attributes an existing Service.'
|
2018-04-30 21:40:07 +00:00
|
|
|
key :tags, [ 'service' ]
|
2018-04-26 19:38:16 +00:00
|
|
|
|
|
|
|
parameter :update_id
|
|
|
|
|
|
|
|
parameter do
|
|
|
|
key :in, :body
|
|
|
|
key :name, :body
|
|
|
|
key :description, 'The updated attributes to overwrite to the Service'
|
|
|
|
key :required, true
|
|
|
|
schema do
|
|
|
|
key :'$ref', :Service
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
response 200 do
|
|
|
|
key :description, 'Successful operation'
|
|
|
|
schema do
|
|
|
|
key :type, :object
|
|
|
|
key :'$ref', :Service
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|