Class: CtdDocumentation::QueriesController
- Inherits:
-
BaseController
- Object
- BaseController
- CtdDocumentation::QueriesController
- Defined in:
- lib/ctd_documentation/controllers/queries_controller.rb
Overview
QueriesController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#all_queries_fields_types_and_validations ⇒ Object
This is used to determine the payload needed to be sent for creating/updating a query by a certain query type enum value.
-
#create_a_new_query(body) ⇒ CreateANewQueryResponse
This route creates a query.
-
#delete_a_query(content_type) ⇒ DeleteAQueryResponse
Delete a query by a list of selected resource IDs.
-
#get_information_for_all_queries ⇒ Object
Get descriptions and enums for all queries (can be used later to retrieve parameters per task type enum).
-
#get_queries(sort: nil, page: nil, per_page: nil, name__icontains: nil, site_id__exact: nil) ⇒ GetQueriesResponse
Get all queries and their information.
-
#update_a_single_query(resource_id, body) ⇒ CreateANewQueryResponse
This route updates a query to update.
Methods inherited from BaseController
#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent
Constructor Details
This class inherits a constructor from CtdDocumentation::BaseController
Instance Method Details
#all_queries_fields_types_and_validations ⇒ Object
This is used to determine the payload needed to be sent for creating/updating a query by a certain query type enum value
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/ctd_documentation/controllers/queries_controller.rb', line 116 def all_queries_fields_types_and_validations new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/ranger/queries/get_params', Server::DEFAULT) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize))) .execute end |
#create_a_new_query(body) ⇒ CreateANewQueryResponse
This route creates a query
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ctd_documentation/controllers/queries_controller.rb', line 41 def create_a_new_query(body) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/ranger/queries', Server::DEFAULT) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(CreateANewQueryResponse.method(:from_hash))) .execute end |
#delete_a_query(content_type) ⇒ DeleteAQueryResponse
Delete a query by a list of selected resource IDs
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ctd_documentation/controllers/queries_controller.rb', line 60 def delete_a_query(content_type) new_api_call_builder .request(new_request_builder(HttpMethodEnum::DELETE, '/ranger/queries', Server::DEFAULT) .header_param(new_parameter(content_type, key: 'Content-Type')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(DeleteAQueryResponse.method(:from_hash))) .execute end |
#get_information_for_all_queries ⇒ Object
Get descriptions and enums for all queries (can be used later to retrieve parameters per task type enum)
101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/ctd_documentation/controllers/queries_controller.rb', line 101 def get_information_for_all_queries new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/ranger/queries/get_types', Server::DEFAULT) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize))) .execute end |
#get_queries(sort: nil, page: nil, per_page: nil, name__icontains: nil, site_id__exact: nil) ⇒ GetQueriesResponse
Get all queries and their information
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ctd_documentation/controllers/queries_controller.rb', line 16 def get_queries(sort: nil, page: nil, per_page: nil, name__icontains: nil, site_id__exact: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/ranger/queries', Server::DEFAULT) .query_param(new_parameter(sort, key: 'sort')) .query_param(new_parameter(page, key: 'page')) .query_param(new_parameter(per_page, key: 'per_page')) .query_param(new_parameter(name__icontains, key: 'name__icontains')) .query_param(new_parameter(site_id__exact, key: 'site_id__exact')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetQueriesResponse.method(:from_hash))) .execute end |
#update_a_single_query(resource_id, body) ⇒ CreateANewQueryResponse
This route updates a query to update
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/ctd_documentation/controllers/queries_controller.rb', line 79 def update_a_single_query(resource_id, body) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/ranger/queries/{resource_id}', Server::DEFAULT) .template_param(new_parameter(resource_id, key: 'resource_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(CreateANewQueryResponse.method(:from_hash))) .execute end |