# Copyright 2019 Google LLC
#
# 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.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.AnalyticsAdmin.V1alpha.Model.GoogleAnalyticsAdminV1alphaCalculatedMetric do
  @moduledoc """
  A definition for a calculated metric.

  ## Attributes

  *   `calculatedMetricId` (*type:* `String.t`, *default:* `nil`) - Output only. The ID to use for the calculated metric. In the UI, this is referred to as the "API name." The calculated_metric_id is used when referencing this calculated metric from external APIs. For example, "calcMetric:{calculated_metric_id}".
  *   `description` (*type:* `String.t`, *default:* `nil`) - Optional. Description for this calculated metric. Max length of 4096 characters.
  *   `displayName` (*type:* `String.t`, *default:* `nil`) - Required. Display name for this calculated metric as shown in the Google Analytics UI. Max length 82 characters.
  *   `formula` (*type:* `String.t`, *default:* `nil`) - Required. The calculated metric's definition. Maximum number of unique referenced custom metrics is 5. Formulas supports the following operations: + (addition), - (subtraction), - (negative), * (multiplication), / (division), () (parenthesis). Any valid real numbers are acceptable that fit in a Long (64bit integer) or a Double (64 bit floating point number). Example formula: "( customEvent:parameter_name + cartPurchaseQuantity ) / 2.0"
  *   `invalidMetricReference` (*type:* `boolean()`, *default:* `nil`) - Output only. If true, this calculated metric has a invalid metric reference. Anything using a calculated metric with invalid_metric_reference set to true may fail, produce warnings, or produce unexpected results.
  *   `metricUnit` (*type:* `String.t`, *default:* `nil`) - Required. The type for the calculated metric's value.
  *   `name` (*type:* `String.t`, *default:* `nil`) - Output only. Resource name for this CalculatedMetric. Format: 'properties/{property_id}/calculatedMetrics/{calculated_metric_id}'
  *   `restrictedMetricType` (*type:* `list(String.t)`, *default:* `nil`) - Output only. Types of restricted data that this metric contains.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :calculatedMetricId => String.t() | nil,
          :description => String.t() | nil,
          :displayName => String.t() | nil,
          :formula => String.t() | nil,
          :invalidMetricReference => boolean() | nil,
          :metricUnit => String.t() | nil,
          :name => String.t() | nil,
          :restrictedMetricType => list(String.t()) | nil
        }

  field(:calculatedMetricId)
  field(:description)
  field(:displayName)
  field(:formula)
  field(:invalidMetricReference)
  field(:metricUnit)
  field(:name)
  field(:restrictedMetricType, type: :list)
end

defimpl Poison.Decoder,
  for: GoogleApi.AnalyticsAdmin.V1alpha.Model.GoogleAnalyticsAdminV1alphaCalculatedMetric do
  def decode(value, options) do
    GoogleApi.AnalyticsAdmin.V1alpha.Model.GoogleAnalyticsAdminV1alphaCalculatedMetric.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for: GoogleApi.AnalyticsAdmin.V1alpha.Model.GoogleAnalyticsAdminV1alphaCalculatedMetric do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
