当前位置: 首页>>代码示例>>Python>>正文


Python boundary.ApiCli类代码示例

本文整理汇总了Python中boundary.ApiCli的典型用法代码示例。如果您正苦于以下问题:Python ApiCli类的具体用法?Python ApiCli怎么用?Python ApiCli使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ApiCli类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_arguments

    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)

        # Get the host group name
        if self.args.host_group_name is not None:
            self.host_group_name = self.args.host_group_name

        # Get the list of sources separated by commas
        if self.args.sources is not None:
            self.sources = self.args.sources

        payload = {}
        if self.host_group_name is not None:
            payload['name'] = self.host_group_name

        if self.sources is not None:
            source_list = str.split(self.sources, ',')
            if 'hostnames' not in payload:
                payload['hostnames'] = []

            for s in source_list:
                payload['hostnames'].append(s)
        self.data = json.dumps(payload, sort_keys=True)
        self.headers = {'Content-Type': 'application/json', "Accept": "application/json"}
开发者ID:boundary,项目名称:pulse-api-cli,代码行数:27,代码来源:hostgroup_modify.py

示例2: __init__

 def __init__(self):
     """
     """
     ApiCli.__init__(self)
     self.method = "GET"
     self.alarmName = None
     self.alarmId = None
开发者ID:GabrielNicolasAvellaneda,项目名称:boundary-api-cli,代码行数:7,代码来源:alarm_get.py

示例3: get_arguments

 def get_arguments(self):
     """
     Extracts the specific arguments of this CLI
     """
     ApiCli.get_arguments(self)
     if self.args.pluginName is not None:
         self.pluginName = self.args.pluginName
开发者ID:boundary,项目名称:pulse-api-cli,代码行数:7,代码来源:plugin_base.py

示例4: __init__

    def __init__(self, update):
        ApiCli.__init__(self)
        self._update = update

        # Mapping of alarm types to corresponding codes
        self._alarm_types = {"threshold": 3, "host": 4, "api": 5}

        self._aggregate = None
        self._actions = None
        self._alarm_name = None
        self._alarm_id = None
        self._host_group_id = None
        self._interval = None
        self._is_disabled = None
        self._metric = None
        self._note = None
        self._operation = None
        self._per_host_notify = None
        self._threshold = None
        self._type_id = None
        self._notify_clear = None
        self._notify_set = None
        self._payload = {}
        self._trigger_interval = None
        self._timeout_interval = None
开发者ID:boundary,项目名称:pulse-api-cli,代码行数:25,代码来源:alarm_modify.py

示例5: get_arguments

    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)
        if self.args.metricName is not None:
            self.metricName = self.args.metricName

        if self.args.measurement is not None:
            self.measurement = self.args.measurement

        if self.args.source is not None:
            self.source = self.args.source
        else:
            self.source = socket.gethostname()

        if self.args.timestamp is not None:
            self.timestamp = int(self.args.timestamp)

        m = {'metric': self.metricName,
             'measure': self.measurement}

        if self.source is not None:
            m['source'] = self.source
        if self.timestamp is not None:
            m['timestamp'] = int(self.timestamp)

        self._process_properties()

        if self._properties is not None:
            m['metadata'] = self._properties

        self.data = json.dumps(m, sort_keys=True)
        self.headers = {'Content-Type': 'application/json', "Accept": "application/json"}
开发者ID:boundary,项目名称:pulse-api-cli,代码行数:34,代码来源:measurement_create.py

示例6: add_arguments

    def add_arguments(self):
        """
        """
        ApiCli.add_arguments(self)

        self.parser.add_argument('-n', '--alarm-name', dest='alarm_name', action='store', required=True,
                                 metavar='alarm-name', help='Alarm name')
开发者ID:boundary,项目名称:pulse-api-cli,代码行数:7,代码来源:alarm_search.py

示例7: add_arguments

    def add_arguments(self):
        """
        Add specific command line arguments for this command   
        """

        # Call our parent to add the default arguments
        ApiCli.add_arguments(self)

        # Command specific arguments
        self.parser.add_argument('-f', '--format', dest='format', action='store', required=False,
                                 choices=['csv', 'json', 'raw', 'xml'], help='Output format. Default is raw')
        self.parser.add_argument('-n', '--name', dest='metric_name', action='store', required=True,
                                 metavar="metric_name", help='Metric identifier')
        self.parser.add_argument('-g', '--aggregate', dest='aggregate', action='store', required=False,
                                 choices=['sum', 'avg', 'max', 'min'], help='Metric default aggregate')
        self.parser.add_argument('-r', '--sample', dest='sample', action='store', type=int, metavar="sample",
                                 help='Down sample rate sample in seconds')
        self.parser.add_argument('-s', '--source', dest='source', action='store', metavar="source", required=True,
                                 help='Source of measurement')
        self.parser.add_argument('-b', '--start', dest='start', action='store', required=True, metavar="start",
                                 help='Start of time range as ISO 8601 string or epoch seconds')
        self.parser.add_argument('-d', '--end', dest='end', action='store', metavar="end", required=False,
                                 help='End of time range as ISO 8601 string or epoch seconds')

        self.parser.add_argument('-o', '--date-format', dest='date_format', action='store', metavar="format",
                                 required=False,
                                 help='For CSV, JSON, and XML output formats dates (see Python date.strftime). ' +
                                      'Default format is %%s')
开发者ID:boundary,项目名称:pulse-api-cli,代码行数:28,代码来源:measurement_get.py

示例8: getArguments

 def getArguments(self):
     '''
     Extracts the specific arguments of this CLI
     '''
     ApiCli.getArguments(self)
     if self.args.pluginName != None:
         self.pluginName = self.args.pluginName
开发者ID:GabrielNicolasAvellaneda,项目名称:boundary-api-cli,代码行数:7,代码来源:plugin_base.py

示例9: get_arguments

 def get_arguments(self):
     """
     Extracts the specific arguments of this CLI
     """
     ApiCli.get_arguments(self)
     if self.args.hostGroupName is not None:
         self.url_parameters = {"name": self.args.hostGroupName}
开发者ID:boundary,项目名称:pulse-api-cli,代码行数:7,代码来源:hostgroup_search.py

示例10: getArguments

    def getArguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.getArguments(self)
        if self.args.metricName is not None:
            self.metricName = self.args.metricName

        if self.args.source is not None:
            self.source = self.args.source
        else:
            self.source = ""

        if self.args.aggregate is not None:
            self.aggregate = self.args.aggregate
        else:
            self.aggregate = "avg"

        start_time = int(self.parse_time_date(self.args.start).strftime("%s"))

        # If the end time is not specified then
        # default to the current time
        if self.args.end is None:
            stop_time = int(self.now.strftime("%s"))
        else:
            stop_time = int(self.parse_time_date(self.args.end).strftime("%s"))

        # Convert to epoch time in milli-seconds
        start_time *= 1000
        stop_time *= 1000

        self.path = "v1/measurements/{0}".format(self.metricName)
        self.url_parameters = {"source": self.source, "start": str(start_time), "end": str(stop_time),
                               "agg": self.aggregate}
开发者ID:GabrielNicolasAvellaneda,项目名称:boundary-api-cli,代码行数:34,代码来源:measurement_get.py

示例11: addArguments

    def addArguments(self):
        ApiCli.addArguments(self)

        self.parser.add_argument('-n', '--host-group-name', dest='hostGroupName', action='store', required=True,
                                 metavar="host_group_name", help='Host group name')
        self.parser.add_argument('-s', '--sources', dest='sources', action='store', required=True, metavar='sources',
                                 help='Comma separated sources to add to the host group. If empty adds all hosts.')
开发者ID:GabrielNicolasAvellaneda,项目名称:boundary-api-cli,代码行数:7,代码来源:host_group_modify.py

示例12: __init__

    def __init__(self):
        ApiCli.__init__(self)
        self.method = "DELETE"
        self.path = "v1/hostgroups"

        self.hostGroupId = ""
        self.force = False
开发者ID:jdgwartney,项目名称:pulse-api-cli,代码行数:7,代码来源:hostgroup_delete.py

示例13: get_arguments

    def get_arguments(self):
        ApiCli.get_arguments(self)

        if self.args.file is not None:
            self._file = self.args.path

        self.path = 'v1/relays/{0}/config'.format(self._meter)
开发者ID:boundary,项目名称:pulse-api-cli,代码行数:7,代码来源:relay_set_config.py

示例14: add_arguments

    def add_arguments(self):
        """
        """
        ApiCli.add_arguments(self)

        self.parser.add_argument('-f', '--file', metavar='path', dest='file', action='store', required=True,
                                 help='Name of the meter to get plugin configuration information')
开发者ID:boundary,项目名称:pulse-api-cli,代码行数:7,代码来源:relay_set_config.py

示例15: __init__

    def __init__(self, update):
        ApiCli.__init__(self)
        self.update = update
        self.method = "POST"

        self.alarm_name = None
        self.metric_name = None
        self.aggregate = None
        self.operation = None
        self.threshold = None
        self.interval = None
        self.host_group_id = None
        self.note = None
        self.per_host_notify = None
        self.actions = None
        self.is_disabled = None

        self.intervals = {'1 second': 1,
                          '5 seconds': 15,
                          '1 minute': 60,
                          '5 minutes': 900,
                          '1 hour': 3600,
                          '1.5 hours': 5400,
                          '3 hours': 10800,
                          '6 hours': 21600,
                          '12 hours': 43200
                          }
开发者ID:GabrielNicolasAvellaneda,项目名称:boundary-api-cli,代码行数:27,代码来源:alarm_modify.py


注:本文中的boundary.ApiCli类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。