# Copyright 2024 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# 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.

---
name: 'Slo'
api_resource_type_kind: ServiceLevelObjective
description: |
  A Service-Level Objective (SLO) describes the level of desired good
  service. It consists of a service-level indicator (SLI), a performance
  goal, and a period over which the objective is to be evaluated against
  that goal. The SLO can use SLIs defined in a number of different manners.
  Typical SLOs might include "99% of requests in each rolling week have
  latency below 200 milliseconds" or "99.5% of requests in each calendar
  month return successfully."
references:
  guides:
    'Service Monitoring': 'https://cloud.google.com/monitoring/service-monitoring'
    'Monitoring API Documentation': 'https://cloud.google.com/monitoring/api/v3/'
  api: 'https://cloud.google.com/monitoring/api/ref_v3/rest/v3/services.serviceLevelObjectives'
docs:
id_format: '{{name}}'
base_url: 'v3/projects/{{project}}/services/{{service}}/serviceLevelObjectives'
# name = projects/{{project}}/services/{{service}}/serviceLevelObjectives/{{slo_id}}
self_link: 'v3/{{name}}'
create_url: 'v3/projects/{{project}}/services/{{service}}/serviceLevelObjectives?serviceLevelObjectiveId={{slo_id}}'
update_verb: 'PATCH'
update_mask: true
mutex: 'monitoring/project/{{project}}/service/{{service}}'
import_format:
  - '{{project}} {{name}}'
  - '{{name}}'
timeouts:
  insert_minutes: 20
  update_minutes: 20
  delete_minutes: 20
custom_code:
  constants: 'templates/terraform/constants/monitoring_slo.go.tmpl'
  encoder: 'templates/terraform/encoders/monitoring_slo.go.tmpl'
  custom_import: 'templates/terraform/custom_import/self_link_as_name.tmpl'
examples:
  - name: 'monitoring_slo_appengine'
    primary_resource_id: 'appeng_slo'
    vars:
      slo_id: 'ae-slo'
  - name: 'monitoring_slo_request_based'
    primary_resource_id: 'request_based_slo'
    vars:
      service_id: 'custom-srv-request-slos'
      slo_id: 'consumed-api-slo'
    test_env_vars:
      project: 'PROJECT_NAME'
  - name: 'monitoring_slo_windows_based_good_bad_metric_filter'
    primary_resource_id: 'windows_based'
    vars:
      service_id: 'custom-srv-windows-slos'
      slo_id: 'good-bad-metric-filter'
  - name: 'monitoring_slo_windows_based_metric_mean'
    primary_resource_id: 'windows_based'
    vars:
      service_id: 'custom-srv-windows-slos'
      slo_id: 'metric-mean-range'
  - name: 'monitoring_slo_windows_based_metric_sum'
    primary_resource_id: 'windows_based'
    vars:
      service_id: 'custom-srv-windows-slos'
      slo_id: 'metric-sum-range'
  - name: 'monitoring_slo_windows_based_ratio_threshold'
    primary_resource_id: 'windows_based'
    vars:
      service_id: 'custom-srv-windows-slos'
      slo_id: 'ratio-threshold'
parameters:
  - name: 'service'
    type: String
    description: |
      ID of the service to which this SLO belongs.
    url_param_only: true
    required: true
    immutable: true
  - name: 'sloId'
    type: String
    description: |
      The id to use for this ServiceLevelObjective. If omitted, an id will be generated instead.
    api_name: name
    immutable: true
    default_from_api: true
    custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.tmpl'
    validation:
      regex: '^[a-zA-Z0-9\-_:.]+$'
properties:
  - name: 'name'
    type: String
    description: |
      The full resource name for this service. The syntax is:
      projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
    output: true
  - name: 'displayName'
    type: String
    description: |
      Name used for UI elements listing this SLO.
  - name: 'goal'
    type: Double
    description: |
      The fraction of service that must be good in order for this objective
      to be met. 0 < goal <= 0.999
    required: true
    validation:
      function: 'validateMonitoringSloGoal'
  - name: 'rollingPeriodDays'
    type: Integer
    description: |
      A rolling time period, semantically "in the past X days".
      Must be between 1 to 30 days, inclusive.
    api_name: rollingPeriod
    exactly_one_of:
      - 'rolling_period_days'
      - 'calendar_period'
    custom_flatten: 'templates/terraform/custom_expand/days_to_duration_string.go.tmpl'
    custom_expand: 'templates/terraform/custom_flatten/duration_string_to_days.go.tmpl'
    validation:
      function: 'validation.IntBetween(1, 30)'
  - name: 'calendarPeriod'
    type: Enum
    description: |
      A calendar period, semantically "since the start of the current
      <calendarPeriod>".
    exactly_one_of:
      - 'rolling_period_days'
      - 'calendar_period'
    enum_values:
      - 'DAY'
      - 'WEEK'
      - 'FORTNIGHT'
      - 'MONTH'
  - name: 'userLabels'
    type: KeyValuePairs
    description: |
      This field is intended to be used for organizing and identifying the AlertPolicy
      objects.The field can contain up to 64 entries. Each key and value is limited
      to 63 Unicode characters or 128 bytes, whichever is smaller. Labels and values
      can contain only lowercase letters, numerals, underscores, and dashes. Keys
      must begin with a letter.
    send_empty_value: true
  - name: 'serviceLevelIndicator'
    type: NestedObject
    description: |
      serviceLevelIndicator (SLI) describes a good service.
      It is used to measure and calculate the quality of the Service's
      performance with respect to a single aspect of service quality.
    flatten_object: true
    properties:
      - name: 'basicSli'
        type: NestedObject
        description: |
          Basic Service-Level Indicator (SLI) on a well-known service type.
          Performance will be computed on the basis of pre-defined metrics.

          SLIs are used to measure and calculate the quality of the Service's
          performance with respect to a single aspect of service quality.

          Exactly one of the following must be set:
          `basic_sli`, `request_based_sli`, `windows_based_sli`
        exactly_one_of:
          - 'service_level_indicator.0.basic_sli'
          - 'service_level_indicator.0.request_based_sli'
          - 'service_level_indicator.0.windows_based_sli'
        properties:
          - name: 'method'
            type: Array
            description: |
              An optional set of RPCs to which this SLI is relevant.
              Telemetry from other methods will not be used to calculate
              performance for this SLI. If omitted, this SLI applies to all
              the Service's methods. For service types that don't support
              breaking down by method, setting this field will result in an
              error.
            is_set: true
            item_type:
              type: String
          - name: 'location'
            type: Array
            description: |
              An optional set of locations to which this SLI is relevant.
              Telemetry from other locations will not be used to calculate
              performance for this SLI. If omitted, this SLI applies to all
              locations in which the Service has activity. For service types
              that don't support breaking down by location, setting this
              field will result in an error.
            is_set: true
            item_type:
              type: String
          - name: 'version'
            type: Array
            description: |
              The set of API versions to which this SLI is relevant.
              Telemetry from other API versions will not be used to
              calculate performance for this SLI. If omitted,
              this SLI applies to all API versions. For service types
              that don't support breaking down by version, setting this
              field will result in an error.
            is_set: true
            item_type:
              type: String
          - name: 'latency'
            type: NestedObject
            description: |
              Parameters for a latency threshold SLI.
            exactly_one_of:
              - 'service_level_indicator.0.basic_sli.0.latency'
              - 'service_level_indicator.0.basic_sli.0.availability'
            properties:
              - name: 'threshold'
                type: String
                description: |
                  A duration string, e.g. 10s.
                  Good service is defined to be the count of requests made to
                  this service that return in no more than threshold.
                required: true
          - name: 'availability'
            type: NestedObject
            description: |
              Availability based SLI, dervied from count of requests made to this service that return successfully.
            exactly_one_of:
              - 'service_level_indicator.0.basic_sli.0.latency'
              - 'service_level_indicator.0.basic_sli.0.availability'
            custom_flatten: 'templates/terraform/custom_flatten/monitoring_slo_availability_sli.go.tmpl'
            properties:
              - name: 'enabled'
                type: Boolean
                description: |
                  Whether an availability SLI is enabled or not. Must be set to true. Defaults to `true`.
                validation:
                  function: 'validateAvailabilitySli'
                default_value: true
      - name: 'requestBasedSli'
        type: NestedObject
        description: |
          A request-based SLI defines a SLI for which atomic units of
          service are counted directly.

          A SLI describes a good service.
          It is used to measure and calculate the quality of the Service's
          performance with respect to a single aspect of service quality.
          Exactly one of the following must be set:
          `basic_sli`, `request_based_sli`, `windows_based_sli`
        api_name: requestBased
        update_mask_fields:
          - 'serviceLevelIndicator.requestBased.goodTotalRatio.badServiceFilter'
          - 'serviceLevelIndicator.requestBased.goodTotalRatio.goodServiceFilter'
          - 'serviceLevelIndicator.requestBased.goodTotalRatio.totalServiceFilter'
          - 'serviceLevelIndicator.requestBased.distributionCut.range'
          - 'serviceLevelIndicator.requestBased.distributionCut.distributionFilter'
        exactly_one_of:
          - 'service_level_indicator.0.basic_sli'
          - 'service_level_indicator.0.request_based_sli'
          - 'service_level_indicator.0.windows_based_sli'
        properties:
          - name: 'goodTotalRatio'
            type: NestedObject
            description: |
              A means to compute a ratio of `good_service` to `total_service`.
              Defines computing this ratio with two TimeSeries [monitoring filters](https://cloud.google.com/monitoring/api/v3/filters)
              Must specify exactly two of good, bad, and total service filters.
              The relationship good_service + bad_service = total_service
              will be assumed.

              Exactly one of `distribution_cut` or `good_total_ratio` can be set.
            exactly_one_of:
              - 'service_level_indicator.0.request_based_sli.0.good_total_ratio'
              - 'service_level_indicator.0.request_based_sli.0.distribution_cut'
            properties:
              - name: 'goodServiceFilter'
                type: String
                description: |
                  A TimeSeries [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters)
                  quantifying good service provided.
                  Must have ValueType = DOUBLE or ValueType = INT64 and
                  must have MetricKind = DELTA or MetricKind = CUMULATIVE.

                  Exactly two of `good_service_filter`,`bad_service_filter`,`total_service_filter`
                  must be set (good + bad = total is assumed).
                at_least_one_of:
                  - 'service_level_indicator.0.request_based_sli.0.good_total_ratio.0.good_service_filter'
                  - 'service_level_indicator.0.request_based_sli.0.good_total_ratio.0.bad_service_filter'
                  - 'service_level_indicator.0.request_based_sli.0.good_total_ratio.0.total_service_filter'
              - name: 'badServiceFilter'
                type: String
                description: |
                  A TimeSeries [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters)
                  quantifying bad service provided, either demanded service that
                  was not provided or demanded service that was of inadequate
                  quality.

                  Must have ValueType = DOUBLE or ValueType = INT64 and
                  must have MetricKind = DELTA or MetricKind = CUMULATIVE.

                  Exactly two of `good_service_filter`,`bad_service_filter`,`total_service_filter`
                  must be set (good + bad = total is assumed).
                at_least_one_of:
                  - 'service_level_indicator.0.request_based_sli.0.good_total_ratio.0.good_service_filter'
                  - 'service_level_indicator.0.request_based_sli.0.good_total_ratio.0.bad_service_filter'
                  - 'service_level_indicator.0.request_based_sli.0.good_total_ratio.0.total_service_filter'
              - name: 'totalServiceFilter'
                type: String
                description: |
                  A TimeSeries [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters)
                  quantifying total demanded service.

                  Must have ValueType = DOUBLE or ValueType = INT64 and
                  must have MetricKind = DELTA or MetricKind = CUMULATIVE.

                  Exactly two of `good_service_filter`,`bad_service_filter`,`total_service_filter`
                  must be set (good + bad = total is assumed).
                at_least_one_of:
                  - 'service_level_indicator.0.request_based_sli.0.good_total_ratio.0.good_service_filter'
                  - 'service_level_indicator.0.request_based_sli.0.good_total_ratio.0.bad_service_filter'
                  - 'service_level_indicator.0.request_based_sli.0.good_total_ratio.0.total_service_filter'
          - name: 'distributionCut'
            type: NestedObject
            description: |
              Used when good_service is defined by a count of values aggregated in a
              Distribution that fall into a good range. The total_service is the
              total count of all values aggregated in the Distribution.
              Defines a distribution TimeSeries filter and thresholds used for
              measuring good service and total service.

              Exactly one of `distribution_cut` or `good_total_ratio` can be set.
            exactly_one_of:
              - 'service_level_indicator.0.request_based_sli.0.good_total_ratio'
              - 'service_level_indicator.0.request_based_sli.0.distribution_cut'
            properties:
              - name: 'distributionFilter'
                type: String
                description: |
                  A TimeSeries [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters)
                  aggregating values to quantify the good service provided.

                  Must have ValueType = DISTRIBUTION and
                  MetricKind = DELTA or MetricKind = CUMULATIVE.
                required: true
              - name: 'range'
                type: NestedObject
                description: |
                  Range of numerical values. The computed good_service
                  will be the count of values x in the Distribution such
                  that range.min <= x <= range.max. inclusive of min and
                  max. Open ranges can be defined by setting
                  just one of min or max.
                required: true
                properties:
                  - name: 'min'
                    type: Double
                    description: |
                      Min value for the range (inclusive). If not given,
                      will be set to 0
                    at_least_one_of:
                      - 'service_level_indicator.0.request_based_sli.0.distribution_cut.0.range.0.min'
                      - 'service_level_indicator.0.request_based_sli.0.distribution_cut.0.range.0.max'
                  - name: 'max'
                    type: Double
                    description: |
                      max value for the range (inclusive). If not given,
                      will be set to 0
                    at_least_one_of:
                      - 'service_level_indicator.0.request_based_sli.0.distribution_cut.0.range.0.min'
                      - 'service_level_indicator.0.request_based_sli.0.distribution_cut.0.range.0.max'
      - name: 'windowsBasedSli'
        type: NestedObject
        description: |
          A windows-based SLI defines the criteria for time windows.
          good_service is defined based off the count of these time windows
          for which the provided service was of good quality.

          A SLI describes a good service. It is used to measure and calculate
          the quality of the Service's performance with respect to a single
          aspect of service quality.

          Exactly one of the following must be set:
          `basic_sli`, `request_based_sli`, `windows_based_sli`
        api_name: windowsBased
        update_mask_fields:
          - 'serviceLevelIndicator.windowsBased.windowPeriod'
          - 'serviceLevelIndicator.windowsBased.goodBadMetricFilter'
          - 'serviceLevelIndicator.windowsBased.goodTotalRatioThreshold.threshold'
          - 'serviceLevelIndicator.windowsBased.goodTotalRatioThreshold.performance.goodTotalRatio.badServiceFilter'
          - 'serviceLevelIndicator.windowsBased.goodTotalRatioThreshold.performance.goodTotalRatio.goodServiceFilter'
          - 'serviceLevelIndicator.windowsBased.goodTotalRatioThreshold.performance.goodTotalRatio.totalServiceFilter'
          - 'serviceLevelIndicator.windowsBased.goodTotalRatioThreshold.performance.distributionCut.range'
          - 'serviceLevelIndicator.windowsBased.goodTotalRatioThreshold.performance.distributionCut.distributionFilter'
          - 'serviceLevelIndicator.windowsBased.goodTotalRatioThreshold.basicSliPerformance'
          - 'serviceLevelIndicator.windowsBased.metricMeanInRange.timeSeries'
          - 'serviceLevelIndicator.windowsBased.metricMeanInRange.range'
          - 'serviceLevelIndicator.windowsBased.metricSumInRange.timeSeries'
          - 'serviceLevelIndicator.windowsBased.metricSumInRange.range'
        exactly_one_of:
          - 'service_level_indicator.0.basic_sli'
          - 'service_level_indicator.0.request_based_sli'
          - 'service_level_indicator.0.windows_based_sli'
        properties:
          # NOTE: If adding properties to windowsBasedSli, remember to add to the
          # custom updateMask fields in property overrides.
          - name: 'windowPeriod'
            type: String
            description: |
              Duration over which window quality is evaluated, given as a
              duration string "{X}s" representing X seconds. Must be an
              integer fraction of a day and at least 60s.
          # START window_criterion FIELDS
          - name: 'goodBadMetricFilter'
            type: String
            description: |
              A TimeSeries [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters)
              with ValueType = BOOL. The window is good if any true values
              appear in the window. One of `good_bad_metric_filter`,
              `good_total_ratio_threshold`, `metric_mean_in_range`,
              `metric_sum_in_range` must be set for `windows_based_sli`.
            exactly_one_of:
              - 'service_level_indicator.0.windows_based_sli.0.good_bad_metric_filter'
              - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold'
              - 'service_level_indicator.0.windows_based_sli.0.metric_mean_in_range'
              - 'service_level_indicator.0.windows_based_sli.0.metric_sum_in_range'
          - name: 'goodTotalRatioThreshold'
            type: NestedObject
            description: |
              Criterion that describes a window as good if its performance is
              high enough. One of `good_bad_metric_filter`,
              `good_total_ratio_threshold`, `metric_mean_in_range`,
              `metric_sum_in_range` must be set for `windows_based_sli`.
            exactly_one_of:
              - 'service_level_indicator.0.windows_based_sli.0.good_bad_metric_filter'
              - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold'
              - 'service_level_indicator.0.windows_based_sli.0.metric_mean_in_range'
              - 'service_level_indicator.0.windows_based_sli.0.metric_sum_in_range'
            properties:
              - name: 'threshold'
                type: Double
                description: |
                  If window performance >= threshold, the window is counted
                  as good.
              - name: 'performance'
                type: NestedObject
                description: |
                  Request-based SLI to evaluate to judge window quality.
                exactly_one_of:
                  - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance'
                  - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.basic_sli_performance'
                properties:
                  - name: 'goodTotalRatio'
                    type: NestedObject
                    description: |
                      A means to compute a ratio of `good_service` to `total_service`.
                      Defines computing this ratio with two TimeSeries [monitoring filters](https://cloud.google.com/monitoring/api/v3/filters)
                      Must specify exactly two of good, bad, and total service filters.
                      The relationship good_service + bad_service = total_service
                      will be assumed.
                    exactly_one_of:
                      - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance.0.good_total_ratio'
                      - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance.0.distribution_cut'
                    properties:
                      - name: 'goodServiceFilter'
                        type: String
                        description: |
                          A TimeSeries [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters)
                          quantifying good service provided. Exactly two of
                          good, bad, or total service filter must be defined (where
                          good + bad = total is assumed)

                          Must have ValueType = DOUBLE or ValueType = INT64 and
                          must have MetricKind = DELTA or MetricKind = CUMULATIVE.
                        at_least_one_of:
                          - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance.0.good_total_ratio.0.good_service_filter'
                          - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance.0.good_total_ratio.0.bad_service_filter'
                          - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance.0.good_total_ratio.0.total_service_filter'
                      - name: 'badServiceFilter'
                        type: String
                        description: |
                          A TimeSeries [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters)
                          quantifying bad service provided, either demanded service that
                          was not provided or demanded service that was of inadequate
                          quality. Exactly two of
                          good, bad, or total service filter must be defined (where
                          good + bad = total is assumed)

                          Must have ValueType = DOUBLE or ValueType = INT64 and
                          must have MetricKind = DELTA or MetricKind = CUMULATIVE.
                        at_least_one_of:
                          - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance.0.good_total_ratio.0.good_service_filter'
                          - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance.0.good_total_ratio.0.bad_service_filter'
                          - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance.0.good_total_ratio.0.total_service_filter'
                      - name: 'totalServiceFilter'
                        type: String
                        description: |
                          A TimeSeries [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters)
                          quantifying total demanded service. Exactly two of
                          good, bad, or total service filter must be defined (where
                          good + bad = total is assumed)

                          Must have ValueType = DOUBLE or ValueType = INT64 and
                          must have MetricKind = DELTA or MetricKind = CUMULATIVE.
                        at_least_one_of:
                          - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance.0.good_total_ratio.0.good_service_filter'
                          - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance.0.good_total_ratio.0.bad_service_filter'
                          - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance.0.good_total_ratio.0.total_service_filter'
                  - name: 'distributionCut'
                    type: NestedObject
                    description: |
                      Used when good_service is defined by a count of values aggregated in a
                      Distribution that fall into a good range. The total_service is the
                      total count of all values aggregated in the Distribution.
                      Defines a distribution TimeSeries filter and thresholds used for
                      measuring good service and total service.
                    exactly_one_of:
                      - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance.0.good_total_ratio'
                      - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance.0.distribution_cut'
                    properties:
                      - name: 'distributionFilter'
                        type: String
                        description: |
                          A TimeSeries [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters)
                          aggregating values to quantify the good service provided.

                          Must have ValueType = DISTRIBUTION and
                          MetricKind = DELTA or MetricKind = CUMULATIVE.
                        required: true
                      - name: 'range'
                        type: NestedObject
                        description: |
                          Range of numerical values. The computed good_service
                          will be the count of values x in the Distribution such
                          that range.min <= x <= range.max. inclusive of min and
                          max. Open ranges can be defined by setting
                          just one of min or max.
                        required: true
                        properties:
                          - name: 'min'
                            type: Double
                            description: |
                              Min value for the range (inclusive). If not given,
                              will be set to 0
                            at_least_one_of:
                              - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance.0.distribution_cut.0.range.0.min'
                              - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance.0.distribution_cut.0.range.0.max'
                          - name: 'max'
                            type: Double
                            description: |
                              max value for the range (inclusive). If not given,
                              will be set to 0
                            at_least_one_of:
                              - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance.0.distribution_cut.0.range.0.min'
                              - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance.0.distribution_cut.0.range.0.max'
              - name: 'basicSliPerformance'
                type: NestedObject
                description: |
                  Basic SLI to evaluate to judge window quality.
                exactly_one_of:
                  - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.performance'
                  - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.basic_sli_performance'
                properties:
                  - name: 'method'
                    type: Array
                    description: |
                      An optional set of RPCs to which this SLI is relevant.
                      Telemetry from other methods will not be used to calculate
                      performance for this SLI. If omitted, this SLI applies to all
                      the Service's methods. For service types that don't support
                      breaking down by method, setting this field will result in an
                      error.
                    is_set: true
                    item_type:
                      type: String
                  - name: 'location'
                    type: Array
                    description: |
                      An optional set of locations to which this SLI is relevant.
                      Telemetry from other locations will not be used to calculate
                      performance for this SLI. If omitted, this SLI applies to all
                      locations in which the Service has activity. For service types
                      that don't support breaking down by location, setting this
                      field will result in an error.
                    is_set: true
                    item_type:
                      type: String
                  - name: 'version'
                    type: Array
                    description: |
                      The set of API versions to which this SLI is relevant.
                      Telemetry from other API versions will not be used to
                      calculate performance for this SLI. If omitted,
                      this SLI applies to all API versions. For service types
                      that don't support breaking down by version, setting this
                      field will result in an error.
                    is_set: true
                    item_type:
                      type: String
                  - name: 'latency'
                    type: NestedObject
                    description: |
                      Parameters for a latency threshold SLI.
                    exactly_one_of:
                      - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.basic_sli_performance.0.latency'
                      - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.basic_sli_performance.0.availability'
                    properties:
                      - name: 'threshold'
                        type: String
                        description: |
                          A duration string, e.g. 10s.
                          Good service is defined to be the count of requests made to
                          this service that return in no more than threshold.
                        required: true
                  - name: 'availability'
                    type: NestedObject
                    description: |
                      Availability based SLI, dervied from count of requests made to this service that return successfully.
                    exactly_one_of:
                      - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.basic_sli_performance.0.latency'
                      - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold.0.basic_sli_performance.0.availability'
                    custom_flatten: 'templates/terraform/custom_flatten/monitoring_slo_availability_sli.go.tmpl'
                    properties:
                      - name: 'enabled'
                        type: Boolean
                        description: |
                          Whether an availability SLI is enabled or not. Must be set to `true. Defaults to `true`.
                        validation:
                          function: 'validateAvailabilitySli'
                        default_value: true
          - name: 'metricMeanInRange'
            type: NestedObject
            description: |
              Criterion that describes a window as good if the metric's value
              is in a good range, *averaged* across returned streams.
              One of `good_bad_metric_filter`,

              `good_total_ratio_threshold`, `metric_mean_in_range`,
              `metric_sum_in_range` must be set for `windows_based_sli`.
              Average value X of `time_series` should satisfy
              `range.min <= X <= range.max` for a good window.
            exactly_one_of:
              - 'service_level_indicator.0.windows_based_sli.0.good_bad_metric_filter'
              - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold'
              - 'service_level_indicator.0.windows_based_sli.0.metric_mean_in_range'
              - 'service_level_indicator.0.windows_based_sli.0.metric_sum_in_range'
            properties:
              - name: 'timeSeries'
                type: String
                description: |
                  A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters)
                  specifying the TimeSeries to use for evaluating window
                  The provided TimeSeries must have ValueType = INT64 or
                  ValueType = DOUBLE and MetricKind = GAUGE. Mean value `X`
                  should satisfy `range.min <= X <= range.max`
                  under good service.
                required: true
              - name: 'range'
                type: NestedObject
                description: |
                  Range of numerical values. The computed good_service
                  will be the count of values x in the Distribution such
                  that range.min <= x <= range.max. inclusive of min and
                  max. Open ranges can be defined by setting
                  just one of min or max. Mean value `X` of `time_series`
                  values should satisfy `range.min <= X <= range.max` for a
                  good service.
                required: true
                properties:
                  - name: 'min'
                    type: Double
                    description: |
                      Min value for the range (inclusive). If not given,
                      will be set to "-infinity", defining an open range
                      "< range.max"
                    at_least_one_of:
                      - 'service_level_indicator.0.windows_based_sli.0.metric_mean_in_range.0.range.0.min'
                      - 'service_level_indicator.0.windows_based_sli.0.metric_mean_in_range.0.range.0.max'
                  - name: 'max'
                    type: Double
                    description: |
                      max value for the range (inclusive). If not given,
                      will be set to "infinity", defining an open range
                      ">= range.min"
                    at_least_one_of:
                      - 'service_level_indicator.0.windows_based_sli.0.metric_mean_in_range.0.range.0.min'
                      - 'service_level_indicator.0.windows_based_sli.0.metric_mean_in_range.0.range.0.max'
          - name: 'metricSumInRange'
            type: NestedObject
            description: |
              Criterion that describes a window as good if the metric's value
              is in a good range, *summed* across returned streams.
              Summed value `X` of `time_series` should satisfy
              `range.min <= X <= range.max` for a good window.

              One of `good_bad_metric_filter`,
              `good_total_ratio_threshold`, `metric_mean_in_range`,
              `metric_sum_in_range` must be set for `windows_based_sli`.
            exactly_one_of:
              - 'service_level_indicator.0.windows_based_sli.0.good_bad_metric_filter'
              - 'service_level_indicator.0.windows_based_sli.0.good_total_ratio_threshold'
              - 'service_level_indicator.0.windows_based_sli.0.metric_mean_in_range'
              - 'service_level_indicator.0.windows_based_sli.0.metric_sum_in_range'
            properties:
              - name: 'timeSeries'
                type: String
                description: |
                  A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters)
                  specifying the TimeSeries to use for evaluating window
                  quality. The provided TimeSeries must have
                  ValueType = INT64 or ValueType = DOUBLE and
                  MetricKind = GAUGE.

                  Summed value `X` should satisfy
                  `range.min <= X <= range.max` for a good window.
                required: true
              - name: 'range'
                type: NestedObject
                description: |
                  Range of numerical values. The computed good_service
                  will be the count of values x in the Distribution such
                  that range.min <= x <= range.max. inclusive of min and
                  max. Open ranges can be defined by setting
                  just one of min or max. Summed value `X` should satisfy
                  `range.min <= X <= range.max` for a good window.
                required: true
                properties:
                  - name: 'min'
                    type: Double
                    description: |
                      Min value for the range (inclusive). If not given,
                      will be set to "-infinity", defining an open range
                      "< range.max"
                    at_least_one_of:
                      - 'service_level_indicator.0.windows_based_sli.0.metric_sum_in_range.0.range.0.min'
                      - 'service_level_indicator.0.windows_based_sli.0.metric_sum_in_range.0.range.0.max'
                  - name: 'max'
                    type: Double
                    description: |
                      max value for the range (inclusive). If not given,
                      will be set to "infinity", defining an open range
                      ">= range.min"
                    at_least_one_of:
                      - 'service_level_indicator.0.windows_based_sli.0.metric_sum_in_range.0.range.0.min'
                      - 'service_level_indicator.0.windows_based_sli.0.metric_sum_in_range.0.range.0.max'
