Files
metasploit-gs/documentation/api/v1/workspace_api_doc.rb
T

216 lines
6.1 KiB
Ruby
Raw Normal View History

2018-04-26 17:55:39 -05:00
require 'swagger/blocks'
module WorkspaceApiDoc
include Swagger::Blocks
2018-05-17 11:22:43 -05:00
NAME_DESC = 'The name of the workspace. This is the unique identifier for determining which workspace is being accessed.'
BOUNDARY_DESC = 'Comma separated list of IP ranges (in various formats) and IP addresses that users of this workspace are allowed to interact with if limit_to_network is true.'
2018-05-22 14:57:21 -05:00
BOUNDARY_EXAMPLE = '10.10.1.1-50,10.10.1.100,10.10.2.0/24'
2018-05-17 11:22:43 -05:00
DESCRIPTION_DESC = 'Long description that explains the purpose of this workspace.'
2018-05-22 14:57:21 -05:00
OWNER_ID_DESC = 'ID of the user who owns this workspace.'
2018-05-17 11:22:43 -05:00
LIMIT_TO_NETWORK_DESC = 'true to restrict the hosts and services in this workspace to the IP addresses listed in \'boundary\'.'
2018-05-22 14:57:21 -05:00
IMPORT_FINGERPRINT_DESC = 'Identifier that indicates if and where this workspace was imported from.'
2018-05-17 11:22:43 -05:00
2018-04-26 17:55:39 -05:00
# Swagger documentation for workspaces model
swagger_schema :Workspace do
2018-05-17 11:22:43 -05:00
key :required, [:name]
2018-05-22 14:57:21 -05:00
property :id, type: :integer, format: :int32, description: RootApiDoc::ID_DESC
2018-05-17 11:22:43 -05:00
property :name, type: :string, description: NAME_DESC
property :boundary, type: :string, description: BOUNDARY_DESC, example: BOUNDARY_EXAMPLE
property :description, type: :string, description: DESCRIPTION_DESC
2018-05-22 14:57:21 -05:00
property :owner_id, type: :integer, format: :int32, description: OWNER_ID_DESC
2018-05-17 11:22:43 -05:00
property :limit_to_network, type: :boolean, description: LIMIT_TO_NETWORK_DESC
2018-05-22 14:57:21 -05:00
property :import_fingerprint, type: :boolean, description: IMPORT_FINGERPRINT_DESC
property :created_at, type: :string, format: :date_time, description: RootApiDoc::CREATED_AT_DESC
property :updated_at, type: :string, format: :date_time, description: RootApiDoc::UPDATED_AT_DESC
2018-04-26 17:55:39 -05:00
end
swagger_path '/api/v1/workspaces' do
2018-05-02 14:47:17 -05:00
# Swagger documentation for /api/v1/workspaces GET
2018-04-26 17:55:39 -05:00
operation :get do
key :description, 'Return workspaces that are stored in the database.'
2018-04-30 16:40:07 -05:00
key :tags, [ 'workspace' ]
2018-04-26 17:55:39 -05:00
response 200 do
2018-05-17 11:22:43 -05:00
key :description, 'Returns workspace data.'
2018-04-26 17:55:39 -05:00
schema do
2018-07-25 18:01:05 -05:00
property :data do
key :type, :array
items do
key :'$ref', :Workspace
end
2018-04-26 17:55:39 -05:00
end
end
end
2018-07-25 21:46:33 -05:00
2018-08-14 13:35:59 -05:00
response 401 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_401
2018-08-14 13:35:59 -05:00
schema do
key :'$ref', :AuthErrorModel
end
end
2018-07-25 21:46:33 -05:00
response 500 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_500
2018-07-25 21:46:33 -05:00
schema do
key :'$ref', :ErrorModel
end
end
2018-04-26 17:55:39 -05:00
end
# Swagger documentation for /api/v1/workspaces POST
operation :post do
2018-05-17 11:22:43 -05:00
key :description, 'Create a workspace entry.'
2018-04-30 16:40:07 -05:00
key :tags, [ 'workspace' ]
2018-04-26 17:55:39 -05:00
parameter do
key :in, :body
key :name, :body
2018-05-17 11:22:43 -05:00
key :description, 'The attributes to assign to the workspace.'
2018-04-26 17:55:39 -05:00
key :required, true
schema do
2018-05-17 11:22:43 -05:00
property :name, type: :string, description: NAME_DESC
2018-04-26 17:55:39 -05:00
end
end
response 200 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_200
2018-04-26 17:55:39 -05:00
schema do
2018-07-25 18:01:05 -05:00
property :data do
key :'$ref', :Workspace
end
2018-04-26 17:55:39 -05:00
end
end
2018-07-25 21:46:33 -05:00
2018-08-14 13:35:59 -05:00
response 401 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_401
2018-08-14 13:35:59 -05:00
schema do
key :'$ref', :AuthErrorModel
end
end
2018-07-25 21:46:33 -05:00
response 500 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_500
2018-07-25 21:46:33 -05:00
schema do
key :'$ref', :ErrorModel
end
end
2018-04-26 17:55:39 -05:00
end
# Swagger documentation for /api/v1/workspaces/ DELETE
operation :delete do
key :description, 'Delete the specified workspaces.'
2018-04-30 16:40:07 -05:00
key :tags, [ 'workspace' ]
2018-04-26 17:55:39 -05:00
parameter :delete_opts
response 200 do
2018-07-26 08:43:05 -05:00
key :description, 'Returns an array containing the successfully deleted workspaces.'
2018-04-26 17:55:39 -05:00
schema do
2018-07-25 18:01:05 -05:00
property :data do
key :type, :array
items do
key :'$ref', :Workspace
end
2018-04-26 17:55:39 -05:00
end
end
end
2018-07-25 21:46:33 -05:00
2018-08-14 13:35:59 -05:00
response 401 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_401
2018-08-14 13:35:59 -05:00
schema do
key :'$ref', :AuthErrorModel
end
end
2018-07-25 21:46:33 -05:00
response 500 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_500
2018-07-25 21:46:33 -05:00
schema do
key :'$ref', :ErrorModel
end
end
2018-04-26 17:55:39 -05:00
end
end
2018-05-17 16:56:22 -05:00
swagger_path '/api/v1/workspaces/{id}' do
2018-05-02 14:47:17 -05:00
# Swagger documentation for api/v1/workspaces/:id GET
2018-04-26 17:55:39 -05:00
operation :get do
2018-05-17 16:56:22 -05:00
key :description, 'Return specific workspace that is stored in the database.'
2018-04-30 16:40:07 -05:00
key :tags, [ 'workspace' ]
2018-04-26 17:55:39 -05:00
parameter do
key :name, :id
key :in, :path
2018-05-17 16:56:22 -05:00
key :description, 'ID of workspace to retrieve.'
2018-04-26 17:55:39 -05:00
key :required, true
key :type, :integer
key :format, :int32
end
response 200 do
2018-05-17 16:56:22 -05:00
key :description, 'Returns workspace data.'
2018-04-26 17:55:39 -05:00
schema do
2018-07-25 18:01:05 -05:00
property :data do
2018-07-31 15:43:57 -05:00
key :'$ref', :Workspace
2018-04-26 17:55:39 -05:00
end
end
end
2018-07-25 21:46:33 -05:00
2018-08-14 13:35:59 -05:00
response 401 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_401
2018-08-14 13:35:59 -05:00
schema do
key :'$ref', :AuthErrorModel
end
end
2018-07-25 21:46:33 -05:00
response 500 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_500
2018-07-25 21:46:33 -05:00
schema do
key :'$ref', :ErrorModel
end
end
2018-04-26 17:55:39 -05:00
end
# Swagger documentation for /api/v1/workspaces/:id PUT
operation :put do
2019-01-11 13:20:32 -05:00
key :description, 'Update the attributes on an existing workspace.'
2018-04-30 16:40:07 -05:00
key :tags, [ 'workspace' ]
2018-04-26 17:55:39 -05:00
parameter :update_id
parameter do
key :in, :body
key :name, :body
2018-05-17 11:22:43 -05:00
key :description, 'The updated attributes to overwrite to the workspace.'
2018-04-26 17:55:39 -05:00
key :required, true
schema do
key :'$ref', :Workspace
end
end
response 200 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_200
2018-04-26 17:55:39 -05:00
schema do
2018-07-25 18:01:05 -05:00
property :data do
key :'$ref', :Workspace
end
2018-04-26 17:55:39 -05:00
end
end
2018-07-25 21:46:33 -05:00
2018-08-14 13:35:59 -05:00
response 401 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_401
2018-08-14 13:35:59 -05:00
schema do
key :'$ref', :AuthErrorModel
end
end
2018-07-25 21:46:33 -05:00
response 500 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_500
2018-07-25 21:46:33 -05:00
schema do
key :'$ref', :ErrorModel
end
end
2018-04-26 17:55:39 -05:00
end
end
2018-08-14 13:35:59 -05:00
end