@staticmethod
def build_slo(window, slo_config):
    """Get SLO JSON representation in Service Monitoring API from SLO
        configuration.

        Args:
            window (int): Window (in seconds).
            slo_config (dict): SLO Configuration.

        Returns:
            dict: SLO JSON configuration.
        """
    measurement = slo_config['backend'].get('measurement', {})
    method = slo_config['backend']['method']
    description = slo_config['slo_description']
    target = slo_config['slo_target']
    minutes, _ = divmod(window, 60)
    hours, _ = divmod(minutes, 60)
    display_name = f'{description} ({hours}h)'
    slo = {'display_name': display_name, 'goal': target, 'rolling_period':
        {'seconds': window}}
    filter_valid = measurement.get('filter_valid', '')
    if method == 'basic':
        methods = measurement.get('method', [])
        locations = measurement.get('location', [])
        versions = measurement.get('version', [])
        threshold = measurement.get('latency', {}).get('threshold')
        slo['service_level_indicator'] = {'basic_sli': {}}
        basic_sli = slo['service_level_indicator']['basic_sli']
        if methods:
            basic_sli['method'] = methods
        if locations:
            basic_sli['location'] = locations
        if versions:
            basic_sli['version'] = versions
        if threshold:
            basic_sli['latency'] = {'threshold': {'seconds': 0, 'nanos': 
                int(threshold) * 10 ** 6}}
        else:
            basic_sli['availability'] = {}
    elif method == 'good_bad_ratio':
        filter_good = measurement.get('filter_good', '')
        filter_bad = measurement.get('filter_bad', '')
        slo['service_level_indicator'] = {'request_based': {
            'good_total_ratio': {}}}
        sli = slo['service_level_indicator']
        ratio = sli['request_based']['good_total_ratio']
        if filter_good:
            ratio['good_service_filter'] = filter_good
        if filter_bad:
            ratio['bad_service_filter'] = filter_bad
        if filter_valid:
            ratio['total_service_filter'] = filter_valid
    elif method == 'distribution_cut':
        range_min = measurement.get('range_min', 0)
        range_max = measurement['range_max']
        slo['service_level_indicator'] = {'request_based': {
            'distribution_cut': {'distribution_filter': filter_valid,
            'range': {'max': float(range_max)}}}}
        sli = slo['service_level_indicator']['request_based']
        if range_min != 0:
            sli['distribution_cut']['range']['min'] = float(range_min)
    elif method == 'windows':
        filter = measurement.get('filter')
        slo['service_level_indicator'] = {'windows_based': {'window_period':
            window, 'good_bad_metric_filter': filter}}
    else:
        raise Exception(f'Method "{method}" is not supported.')
    return slo
