Package cm_api :: Package endpoints :: Module dashboards
[hide private]
[frames] | no frames]

Source Code for Module cm_api.endpoints.dashboards

 1  # Licensed to Cloudera, Inc. under one 
 2  # or more contributor license agreements.  See the NOTICE file 
 3  # distributed with this work for additional information 
 4  # regarding copyright ownership.  Cloudera, Inc. licenses this file 
 5  # to you under the Apache License, Version 2.0 (the 
 6  # "License"); you may not use this file except in compliance 
 7  # with the License.  You may obtain a copy of the License at 
 8  # 
 9  #     http://www.apache.org/licenses/LICENSE-2.0 
10  # 
11  # Unless required by applicable law or agreed to in writing, software 
12  # distributed under the License is distributed on an "AS IS" BASIS, 
13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
14  # See the License for the specific language governing permissions and 
15  # limitations under the License. 
16   
17  from cm_api.endpoints.types import * 
18   
19  __docformat__ = "epytext" 
20   
21  DASHBOARDS_PATH = "/timeseries/dashboards" 
22   
23 -def _get_dashboard_path(dashboard_name):
24 return DASHBOARDS_PATH + "/%s" % (dashboard_name)
25
26 -def create_dashboards(resource_root, dashboard_list):
27 """ 28 Creates the list of dashboards. If any of the dashboards already exist 29 this whole command will fail and no dashboards will be created. 30 @since: API v6 31 @return: The list of dashboards created. 32 """ 33 return call(resource_root.post, DASHBOARDS_PATH, ApiDashboard, \ 34 ret_is_list=True, data=dashboard_list)
35
36 -def get_dashboards(resource_root):
37 """ 38 Returns the list of all dashboards. 39 @since: API v6 40 @return: A list of API dashboard objects. 41 """ 42 return call(resource_root.get, DASHBOARDS_PATH, ApiDashboard, \ 43 ret_is_list=True)
44
45 -def get_dashboard(resource_root, dashboard_name):
46 """ 47 Returns a dashboard definition for the specified name. This dashboard 48 can be imported with the createDashboards API. 49 @since: API v6 50 @return: An API dasbhboard object. 51 """ 52 return call(resource_root.get, _get_dashboard_path(dashboard_name), \ 53 ApiDashboard)
54
55 -def delete_dashboard(resource_root, dashboard_name):
56 """ 57 Deletes a dashboard. 58 @since: API v6 59 @return: The deleted dashboard. 60 """ 61 return call(resource_root.delete, _get_dashboard_path(dashboard_name), \ 62 ApiDashboard)
63
64 -class ApiDashboard(BaseApiResource):
65 _ATTRIBUTES = { 66 'name' : None, 67 'json' : None 68 } 69
70 - def __init__(self, resource_root, name=None, json=None):
71 BaseApiObject.init(self, resource_root, locals())
72
73 - def __str__(self):
74 return "<ApiDashboard>: %s" % (self.name)
75
76 - def _path(self):
77 return _get_dashboard_path(self.name)
78