Class: Raas::CatalogController
- Inherits:
-
BaseController
- Object
- BaseController
- Raas::CatalogController
- Defined in:
- lib/raas/controllers/catalog_controller.rb
Overview
CatalogController
Class Attribute Summary collapse
-
.instance ⇒ Object
Returns the value of attribute instance.
Attributes inherited from BaseController
Instance Method Summary collapse
-
#get_catalog ⇒ Object
Retrieves a platform’s catalog.
- #instance ⇒ Object
Methods inherited from BaseController
#execute_request, #initialize, #validate_parameters, #validate_response
Constructor Details
This class inherits a constructor from Raas::BaseController
Class Attribute Details
.instance ⇒ Object
Returns the value of attribute instance.
10 11 12 |
# File 'lib/raas/controllers/catalog_controller.rb', line 10 def instance @instance end |
Instance Method Details
#get_catalog ⇒ Object
Retrieves a platform’s catalog
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/raas/controllers/catalog_controller.rb', line 19 def get_catalog begin @logger.info("get_catalog called.") # Prepare query url. @logger.info("Preparing query URL for get_catalog.") _query_builder = Configuration.get_base_uri _query_builder << '/catalogs' _query_url = APIHelper.clean_url _query_builder # Prepare headers. @logger.info("Preparing headers for get_catalog.") _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. @logger.info('Preparing and executing HttpRequest for get_catalog.') _request = @http_client.get( _query_url, headers: _headers ) BasicAuth.apply(_request) _context = execute_request(_request, name: 'get_catalog') # Validate response against endpoint and global error codes. @logger.info("Validating response for get_catalog.") unless _context.response.status_code.between?(200, 208) raise RaasGenericException.new( 'API Error', _context ) end validate_response(_context) # Return appropriate response type. @logger.info("Returning response for get_catalog.") decoded = APIHelper.json_deserialize(_context.response.raw_body) CatalogModel.from_hash(decoded) rescue Exception => e @logger.error(e) raise e end end |
#instance ⇒ Object
13 14 15 |
# File 'lib/raas/controllers/catalog_controller.rb', line 13 def instance self.class.instance end |