# Path: ceagle/api/client.py
# CONF = config.CONF
# FAKE_CLIENT_MAP = {
#     "security": security.Client,
# }
# class UnknownService(Exception):
# class Client(base.Client):
#     def get(self, uri="/", **kwargs):
# def get_client(service_name):
# 
# Path: ceagle/api_fake_data/fake_status.py
# RESPONSE_TOTAL_NULL_PROBABILITY = 10
# HEALTH_NULL_PROBABILITY = 5
# PERFORMANCE_NULL_PROBABILITY = 5
# AVAILABILITY_NULL_PROBABILITY = 5
# STATUS_NULL_PROBABILITY = 20
# def validate_period(period):
# def generate_timestamps(period):
# def lucky(probability):
# def generate_values(period_or_timestamps,
#                     ratio=1, null_probability=20, integer=False):
# def generate_service_data(period, service, null_allowed):
# def generate_region_data(region, period, service, null_allowed):
# def generate_status_data(period, service):
# def get_status(period):
# def get_status_health(period):
# def get_status_performance(period):
# def get_status_availability(period):
# def get_region_status(region, period):
# def get_region_status_health(region, period):
# def get_region_status_performance(region, period):
# def get_region_status_availability(region, period):


import flask
from oss_lib import config
from ceagle.api import client
from ceagle.api_fake_data import fake_status
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.



CONF = config.CONF

bp_status = flask.Blueprint("status", __name__)
bp_region_status = flask.Blueprint("region", __name__)


def get_status_helper(period, region=None):
    result = {}
    key_map = {
        "health": {"key": "health", "arg": "fci"},
        "availability": {"key": "availability", "arg": "availability"}
    }

    for service_name in ["health", "availability"]:
        if service_name not in CONF["services"]:
            continue

        service_client = client.get_client(service_name)

        if region:
            uri = "/api/v1/region/%s/%s/%s" % (region, service_name, period)

# Path: ceagle/api/client.py
# CONF = config.CONF
# FAKE_CLIENT_MAP = {
#     "security": security.Client,
# }
# class UnknownService(Exception):
# class Client(base.Client):
#     def get(self, uri="/", **kwargs):
# def get_client(service_name):
# 
# Path: ceagle/api_fake_data/fake_status.py
# RESPONSE_TOTAL_NULL_PROBABILITY = 10
# HEALTH_NULL_PROBABILITY = 5
# PERFORMANCE_NULL_PROBABILITY = 5
# AVAILABILITY_NULL_PROBABILITY = 5
# STATUS_NULL_PROBABILITY = 20
# def validate_period(period):
# def generate_timestamps(period):
# def lucky(probability):
# def generate_values(period_or_timestamps,
#                     ratio=1, null_probability=20, integer=False):
# def generate_service_data(period, service, null_allowed):
# def generate_region_data(region, period, service, null_allowed):
# def generate_status_data(period, service):
# def get_status(period):
# def get_status_health(period):
# def get_status_performance(period):
# def get_status_availability(period):
# def get_region_status(region, period):
# def get_region_status_health(region, period):
# def get_region_status_performance(region, period):
# def get_region_status_availability(region, period):


# Path: ceagle/api/v1/status.py
import flask
from oss_lib import config
from ceagle.api import client
from ceagle.api_fake_data import fake_status

#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.



CONF = config.CONF

bp_status = flask.Blueprint("status", __name__)
bp_region_status = flask.Blueprint("region", __name__)


def get_status_helper(period, region=None):
    result = {}
    key_map = {
        "health": {"key": "health", "arg": "fci"},
        "availability": {"key": "availability", "arg": "availability"}
    }

    for service_name in ["health", "availability"]:
        if service_name not in CONF["services"]:
            continue

        service_client = client.get_client(service_name)

        if region:
            uri = "/api/v1/region/%s/%s/%s" % (region, service_name, period)

        else: