Exemplo n.º 1
0
    def __init__(self,
                 configuration=None,
                 header_name=None,
                 header_value=None,
                 cookie=None,
                 pool_threads=1):
        if configuration is None:
            configuration = Configuration()
        self.configuration = configuration
        self.pool_threads = pool_threads

        self.retrying = tenacity.Retrying(
            stop=tenacity.stop_after_attempt(configuration.retry_count),
            wait=tenacity.wait_random_exponential(
                multiplier=configuration.back_off,
                max=configuration.retry_max_delay,
                min=configuration.retry_delay),
            retry=(tenacity.retry_if_result(self.is_retry_enabled) and
                   ((tenacity.retry_if_exception_type(RetryableException)) |
                    (tenacity.retry_if_exception_type(HTTPError)))))

        self.rest_client = rest.RESTClientObject(configuration,
                                                 retrying=self.retrying)
        self.default_headers = {}
        if header_name is not None:
            self.default_headers[header_name] = header_value
        self.cookie = cookie
        # Set default User-Agent.
        self.user_agent = 'opsgenie-sdk-python-2.0.2'

        # init metric publishers
        self.http_metric_publisher = self.rest_client.http_metric
        self.api_metric_publisher = metrics.ApiMetric('ApiMetricPublisher')
        self.sdk_metric_publisher = metrics.SdkMetric('SdkMetricPublisher')
Exemplo n.º 2
0
    def __init__(self, configuration=None, header_name=None, header_value=None,
                 cookie=None, pool_threads=1):
        if configuration is None:
            configuration = Configuration()
        self.configuration = configuration
        self.pool_threads = pool_threads

        self.rest_client = rest.RESTClientObject(configuration)
        self.default_headers = {}
        if header_name is not None:
            self.default_headers[header_name] = header_value
        self.cookie = cookie
        # Set default User-Agent.
        self.user_agent = 'opsgenie-sdk-python-2.0.0b3'

        # init metric publishers
        self.http_metric_publisher = self.rest_client.http_metric
        self.api_metric_publisher = metrics.ApiMetric('ApiMetricPublisher')
        self.sdk_metric_publisher = metrics.SdkMetric('SdkMetricPublisher')