monasca-api  4.0.0
About: OpenStack Monasca API is a RESTful API server that is designed with a layered architecture and supports Monitoring as a Service (MONaaS).
The "Ussuri" series (maintained release).
  Fossies Dox: monasca-api-4.0.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

monasca_api.v2.reference.helpers Namespace Reference

Functions

def from_json (req)
 
def to_json (data)
 
def validate_json_content_type (req)
 
def validate_authorization (http_request, authorized_rules_list)
 
def validate_payload_size (content_length)
 
def get_x_tenant_or_tenant_id (http_request, delegate_authorized_rules_list)
 
def get_query_param (req, param_name, required=False, default_val=None)
 
def get_query_name (req, name_required=False)
 
def get_query_dimensions (req, param_key='dimensions')
 
def get_query_starttime_timestamp (req, required=True)
 
def get_query_endtime_timestamp (req, required=True)
 
def validate_start_end_timestamps (start_timestamp, end_timestamp=None)
 
def _convert_time_string (date_time_string)
 
def get_query_statistics (req)
 
def get_query_period (req)
 
def get_query_group_by (req)
 
def validate_query_name (name)
 
def validate_query_dimensions (dimensions)
 
def paginate (resource, uri, limit)
 
def paginate_with_no_id (dictionary_list, uri, offset, limit)
 
def _truncate_with_offset (resource, value_list, offset)
 
def paginate_alarming (resource, uri, limit)
 
def paginate_dimension_values (dimvals, uri, offset, limit)
 
def _truncate_dimension_values (values, limit, offset)
 
def paginate_measurements (measurements, uri, limit)
 
def _get_old_query_params (parsed_uri)
 
def _get_old_query_params_except_offset (new_query_params, parsed_uri)
 
def paginate_statistics (statistics, uri, limit)
 
def create_alarms_count_next_link (uri, offset, limit)
 
def build_base_uri (parsed_uri)
 
def get_link (uri, resource_id, rel='self')
 
def add_links_to_resource (resource, uri, rel='self')
 
def add_links_to_resource_list (resourcelist, uri)
 
def raise_not_found_exception (resource_name, resource_id, tenant_id)
 
def str_2_bool (s)
 

Variables

 LOG = log.getLogger(__name__)
 
 CONF = conf.CONF
 

Function Documentation

◆ _convert_time_string()

def monasca_api.v2.reference.helpers._convert_time_string (   date_time_string)
private

◆ _get_old_query_params()

◆ _get_old_query_params_except_offset()

◆ _truncate_dimension_values()

def monasca_api.v2.reference.helpers._truncate_dimension_values (   values,
  limit,
  offset 
)
private

◆ _truncate_with_offset()

def monasca_api.v2.reference.helpers._truncate_with_offset (   resource,
  value_list,
  offset 
)
private
Truncate a list of dictionaries with a given offset.

Definition at line 442 of file helpers.py.

Referenced by monasca_api.v2.reference.helpers.paginate_with_no_id().

◆ add_links_to_resource()

def monasca_api.v2.reference.helpers.add_links_to_resource (   resource,
  uri,
  rel = 'self' 
)
Adds links to the given resource dictionary.

:param resource: the resource dictionary you wish to add links.
:param uri: the http request.uri.

Definition at line 751 of file helpers.py.

References monasca_api.v2.reference.helpers.get_link().

Referenced by monasca_api.v2.reference.helpers.add_links_to_resource_list().

◆ add_links_to_resource_list()

def monasca_api.v2.reference.helpers.add_links_to_resource_list (   resourcelist,
  uri 
)
Adds links to the given resource dictionary list.

:param resourcelist: the list of resources you wish to add links.
:param uri: the http request.uri.

Definition at line 761 of file helpers.py.

References monasca_api.v2.reference.helpers.add_links_to_resource().

◆ build_base_uri()

◆ create_alarms_count_next_link()

def monasca_api.v2.reference.helpers.create_alarms_count_next_link (   uri,
  offset,
  limit 
)

◆ from_json()

def monasca_api.v2.reference.helpers.from_json (   req)
Read the json_msg from the http request body and return them as JSON.

:param req: HTTP request object.
:return: Returns the metrics as a JSON object.
:raises falcon.HTTPBadRequest:

Definition at line 37 of file helpers.py.

◆ get_link()

def monasca_api.v2.reference.helpers.get_link (   uri,
  resource_id,
  rel = 'self' 
)
Returns a link dictionary containing href, and rel.

:param uri: the http request.uri.
:param resource_id: the id of the resource

Definition at line 733 of file helpers.py.

References monasca_api.v2.reference.helpers.build_base_uri().

Referenced by monasca_api.v2.reference.helpers.add_links_to_resource().

◆ get_query_dimensions()

def monasca_api.v2.reference.helpers.get_query_dimensions (   req,
  param_key = 'dimensions' 
)
Gets and parses the query param dimensions.

:param req: HTTP request object.
:param dimensions_param: param name for dimensions, default='dimensions'
:return: Returns the dimensions as a JSON object
:raises falcon.HTTPBadRequest: If dimensions are malformed.

Definition at line 181 of file helpers.py.

◆ get_query_endtime_timestamp()

def monasca_api.v2.reference.helpers.get_query_endtime_timestamp (   req,
  required = True 
)

◆ get_query_group_by()

def monasca_api.v2.reference.helpers.get_query_group_by (   req)

Definition at line 302 of file helpers.py.

◆ get_query_name()

def monasca_api.v2.reference.helpers.get_query_name (   req,
  name_required = False 
)
Returns the query param "name" if supplied.

:param req: HTTP request object.

Definition at line 161 of file helpers.py.

◆ get_query_param()

def monasca_api.v2.reference.helpers.get_query_param (   req,
  param_name,
  required = False,
  default_val = None 
)

Definition at line 141 of file helpers.py.

◆ get_query_period()

def monasca_api.v2.reference.helpers.get_query_period (   req)

Definition at line 283 of file helpers.py.

◆ get_query_starttime_timestamp()

def monasca_api.v2.reference.helpers.get_query_starttime_timestamp (   req,
  required = True 
)

◆ get_query_statistics()

def monasca_api.v2.reference.helpers.get_query_statistics (   req)

Definition at line 261 of file helpers.py.

◆ get_x_tenant_or_tenant_id()

def monasca_api.v2.reference.helpers.get_x_tenant_or_tenant_id (   http_request,
  delegate_authorized_rules_list 
)

Definition at line 126 of file helpers.py.

◆ paginate()

def monasca_api.v2.reference.helpers.paginate (   resource,
  uri,
  limit 
)

◆ paginate_alarming()

def monasca_api.v2.reference.helpers.paginate_alarming (   resource,
  uri,
  limit 
)

◆ paginate_dimension_values()

◆ paginate_measurements()

def monasca_api.v2.reference.helpers.paginate_measurements (   measurements,
  uri,
  limit 
)

◆ paginate_statistics()

def monasca_api.v2.reference.helpers.paginate_statistics (   statistics,
  uri,
  limit 
)

◆ paginate_with_no_id()

def monasca_api.v2.reference.helpers.paginate_with_no_id (   dictionary_list,
  uri,
  offset,
  limit 
)
This method is to paginate a list of dictionaries with no id in it.
   For example, metric name list, directory name list and directory
   value list.

Definition at line 396 of file helpers.py.

References monasca_api.v2.reference.helpers._get_old_query_params(), monasca_api.v2.reference.helpers._get_old_query_params_except_offset(), monasca_api.v2.reference.helpers._truncate_with_offset(), and monasca_api.v2.reference.helpers.build_base_uri().

◆ raise_not_found_exception()

def monasca_api.v2.reference.helpers.raise_not_found_exception (   resource_name,
  resource_id,
  tenant_id 
)
Provides exception for not found requests (update, delete, list).

:param resource_name: the name of the resource.
:param resource_id: id of the resource.
:param tenant_id: id of the tenant

Definition at line 772 of file helpers.py.

◆ str_2_bool()

def monasca_api.v2.reference.helpers.str_2_bool (   s)

Definition at line 788 of file helpers.py.

◆ to_json()

def monasca_api.v2.reference.helpers.to_json (   data)
Converts data to JSON string.

:param dict data: data to be transformed to JSON
:return: JSON string
:rtype: str
:raises: Exception

Definition at line 52 of file helpers.py.

◆ validate_authorization()

def monasca_api.v2.reference.helpers.validate_authorization (   http_request,
  authorized_rules_list 
)
Validates whether is authorized according to provided policy rules list.

If authorization fails, 401 is thrown with appropriate description.
Additionally response specifies 'WWW-Authenticate' header with 'Token'
value challenging the client to use different token (the one with
different set of roles which can access the service).

Definition at line 74 of file helpers.py.

◆ validate_json_content_type()

def monasca_api.v2.reference.helpers.validate_json_content_type (   req)

Definition at line 68 of file helpers.py.

◆ validate_payload_size()

def monasca_api.v2.reference.helpers.validate_payload_size (   content_length)
Validates payload size.

Method validates payload size, this method used req.content_length to determinate
payload size

    [service]
    max_log_size = 1048576

**max_log_size** refers to the maximum allowed content length.
If it is exceeded :py:class:`falcon.HTTPRequestEntityTooLarge` is
thrown.

:param  content_length: size of payload

:exception: :py:class:`falcon.HTTPLengthRequired`
:exception: :py:class:`falcon.HTTPRequestEntityTooLarge`

Definition at line 96 of file helpers.py.

◆ validate_query_dimensions()

def monasca_api.v2.reference.helpers.validate_query_dimensions (   dimensions)
Validates the query param dimensions.

:param dimensions: Query param dimensions.
:raises falcon.HTTPBadRequest: If dimensions are not valid.

Definition at line 332 of file helpers.py.

◆ validate_query_name()

def monasca_api.v2.reference.helpers.validate_query_name (   name)
Validates the query param name.

:param name: Query param name.
:raises falcon.HTTPBadRequest: If name is not valid.

Definition at line 317 of file helpers.py.

◆ validate_start_end_timestamps()

def monasca_api.v2.reference.helpers.validate_start_end_timestamps (   start_timestamp,
  end_timestamp = None 
)

Definition at line 247 of file helpers.py.

Variable Documentation

◆ CONF

monasca_api.v2.reference.helpers.CONF = conf.CONF

Definition at line 34 of file helpers.py.

◆ LOG

monasca_api.v2.reference.helpers.LOG = log.getLogger(__name__)

Definition at line 33 of file helpers.py.