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

227 lines
6.5 KiB
Ruby
Raw Normal View History

2018-04-26 17:42:03 -05:00
require 'swagger/blocks'
module NoteApiDoc
include Swagger::Blocks
2018-05-22 14:57:21 -05:00
NTYPE_DESC = 'The type of note this is.'
NTYPE_EXAMPLE = "'host.info', 'host.os.session_fingerprint', 'smb_peer_os', etc."
HOST_ID_DESC = 'The ID of the host record this note is associated with.'
HOST_DESC = 'The IP address of the host this note is associated with.'
SERVICE_ID_DESC = 'The ID of the host record this service is associated with.'
VULN_ID_DESC = 'The ID of the host record this note is associated with.'
2018-05-08 16:15:40 -05:00
CRITICAL_DESC = 'Boolean regarding the criticality of this note\'s contents.'
SEEN_DESC = 'Boolean regarding if this note has been acknowledged.'
DATA_DESC = 'The contents of the note.'
2018-04-26 17:42:03 -05:00
# Swagger documentation for notes model
swagger_schema :Note do
2018-05-22 14:57:21 -05:00
key :required, [:ntype]
property :id, type: :integer, format: :int32, description: RootApiDoc::ID_DESC
property :ntype, type: :string, description: NTYPE_DESC, example: NTYPE_EXAMPLE
property :workspace_id, type: :integer, format: :int32, description: RootApiDoc::WORKSPACE_ID_DESC
property :host_id, type: :integer, format: :int32, description: HOST_ID_DESC
property :service_id, type: :integer, format: :int32, description: SERVICE_ID_DESC
property :vuln_id, type: :integer, format: :int32, description: VULN_ID_DESC
2018-05-08 16:15:40 -05:00
property :critical, type: :boolean, description: CRITICAL_DESC
property :seen, type: :boolean, description: SEEN_DESC
property :data, type: :string, description: DATA_DESC
2018-05-22 14:57:21 -05:00
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:42:03 -05:00
end
swagger_path '/api/v1/notes' do
2018-05-02 14:47:17 -05:00
# Swagger documentation for /api/v1/notes GET
2018-04-26 17:42:03 -05:00
operation :get do
key :description, 'Return notes that are stored in the database.'
2018-04-30 16:40:07 -05:00
key :tags, [ 'note' ]
2018-04-26 17:42:03 -05:00
parameter :workspace
response 200 do
2018-05-17 16:56:22 -05:00
key :description, 'Returns note data.'
2018-04-26 17:42:03 -05:00
schema do
2018-07-25 18:01:05 -05:00
property :data do
key :type, :array
items do
key :'$ref', :Note
end
2018-04-26 17:42:03 -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:42:03 -05:00
end
# Swagger documentation for /api/v1/notes POST
operation :post do
2018-05-17 16:56:22 -05:00
key :description, 'Create a note entry.'
2018-04-30 16:40:07 -05:00
key :tags, [ 'note' ]
2018-04-26 17:42:03 -05:00
parameter do
key :in, :body
key :name, :body
2018-05-17 16:56:22 -05:00
key :description, 'The attributes to assign to the note.'
2018-04-26 17:42:03 -05:00
key :required, true
schema do
2018-05-22 14:57:21 -05:00
property :ntype, type: :string, description: NTYPE_DESC, example: NTYPE_EXAMPLE, required: true
property :workspace, type: :string, required: true, description: RootApiDoc::WORKSPACE_POST_DESC, example: RootApiDoc::WORKSPACE_POST_EXAMPLE
property :host, type: :integer, format: :ipv4, description: HOST_DESC, example: RootApiDoc::HOST_EXAMPLE
2018-05-08 16:15:40 -05:00
property :critical, type: :boolean, description: CRITICAL_DESC
property :seen, type: :boolean, description: SEEN_DESC
property :data, type: :string, description: DATA_DESC
2018-04-26 17:42:03 -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:42:03 -05:00
schema do
2018-07-25 18:01:05 -05:00
property :data do
key :'$ref', :Note
end
2018-04-26 17:42:03 -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:42:03 -05:00
end
# Swagger documentation for /api/v1/notes/ DELETE
operation :delete do
key :description, 'Delete the specified notes.'
2018-04-30 16:40:07 -05:00
key :tags, [ 'note' ]
2018-04-26 17:42:03 -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 notes.'
2018-04-26 17:42:03 -05:00
schema do
2018-07-25 18:01:05 -05:00
property :data do
key :type, :array
items do
key :'$ref', :Note
end
2018-04-26 17:42:03 -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:42:03 -05:00
end
end
2018-05-08 16:15:40 -05:00
swagger_path '/api/v1/notes/{id}' do
2018-05-02 14:47:17 -05:00
# Swagger documentation for api/v1/notes/:id GET
2018-04-26 17:42:03 -05:00
operation :get do
2018-05-17 16:56:22 -05:00
key :description, 'Return specific note that is stored in the database.'
2018-04-30 16:40:07 -05:00
key :tags, [ 'note' ]
2018-04-26 17:42:03 -05:00
parameter do
key :name, :id
key :in, :path
2018-05-17 16:56:22 -05:00
key :description, 'ID of note to retrieve.'
2018-04-26 17:42:03 -05:00
key :required, true
key :type, :integer
key :format, :int32
end
response 200 do
2018-07-25 18:01:05 -05:00
key :description, 'Returns note data.'
2018-04-26 17:42:03 -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', :Note
2018-04-26 17:42:03 -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:42:03 -05:00
end
# Swagger documentation for /api/v1/notes/:id PUT
operation :put do
2019-01-11 13:20:32 -05:00
key :description, 'Update the attributes on an existing note.'
2018-04-30 16:40:07 -05:00
key :tags, [ 'note' ]
2018-04-26 17:42:03 -05:00
parameter :update_id
parameter do
key :in, :body
key :name, :body
2018-05-17 16:56:22 -05:00
key :description, 'The updated attributes to overwrite to the note.'
2018-04-26 17:42:03 -05:00
key :required, true
schema do
key :'$ref', :Note
end
end
response 200 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_200
2018-04-26 17:42:03 -05:00
schema do
2018-07-25 18:01:05 -05:00
property :data do
key :'$ref', :Note
end
2018-04-26 17:42:03 -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:42:03 -05:00
end
end
2018-08-14 13:35:59 -05:00
end