# 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.NetworkSecurity.V1.Model.Destination do
  @moduledoc """
  Specification of traffic destination attributes.

  ## Attributes

  *   `hosts` (*type:* `list(String.t)`, *default:* `nil`) - Required. List of host names to match. Matched against the ":authority" header in http requests. At least one host should match. Each host can be an exact match, or a prefix match (example "mydomain.*") or a suffix match (example "*.myorg.com") or a presence (any) match "*".
  *   `httpHeaderMatch` (*type:* `GoogleApi.NetworkSecurity.V1.Model.HttpHeaderMatch.t`, *default:* `nil`) - Optional. Match against key:value pair in http header. Provides a flexible match based on HTTP headers, for potentially advanced use cases. At least one header should match. Avoid using header matches to make authorization decisions unless there is a strong guarantee that requests arrive through a trusted client or proxy.
  *   `methods` (*type:* `list(String.t)`, *default:* `nil`) - Optional. A list of HTTP methods to match. At least one method should match. Should not be set for gRPC services.
  *   `ports` (*type:* `list(integer())`, *default:* `nil`) - Required. List of destination ports to match. At least one port should match.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :hosts => list(String.t()) | nil,
          :httpHeaderMatch => GoogleApi.NetworkSecurity.V1.Model.HttpHeaderMatch.t() | nil,
          :methods => list(String.t()) | nil,
          :ports => list(integer()) | nil
        }

  field(:hosts, type: :list)
  field(:httpHeaderMatch, as: GoogleApi.NetworkSecurity.V1.Model.HttpHeaderMatch)
  field(:methods, type: :list)
  field(:ports, type: :list)
end

defimpl Poison.Decoder, for: GoogleApi.NetworkSecurity.V1.Model.Destination do
  def decode(value, options) do
    GoogleApi.NetworkSecurity.V1.Model.Destination.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.NetworkSecurity.V1.Model.Destination do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
