# 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.TrafficDirector.V3.Model.SocketAddress do
  @moduledoc """
  [#next-free-field: 7]

  ## Attributes

  *   `address` (*type:* `String.t`, *default:* `nil`) - The address for this socket. :ref:`Listeners ` will bind to the address. An empty address is not allowed. Specify ``0.0.0.0`` or ``::`` to bind to any address. [#comment:TODO(zuercher) reinstate when implemented: It is possible to distinguish a Listener address via the prefix/suffix matching in :ref:`FilterChainMatch `.] When used within an upstream :ref:`BindConfig `, the address controls the source address of outbound connections. For :ref:`clusters `, the cluster type determines whether the address must be an IP (``STATIC`` or ``EDS`` clusters) or a hostname resolved by DNS (``STRICT_DNS`` or ``LOGICAL_DNS`` clusters). Address resolution can be customized via :ref:`resolver_name `.
  *   `ipv4Compat` (*type:* `boolean()`, *default:* `nil`) - When binding to an IPv6 address above, this enables `IPv4 compatibility `_. Binding to ``::`` will allow both IPv4 and IPv6 connections, with peer IPv4 addresses mapped into IPv6 space as ``::FFFF:``.
  *   `namedPort` (*type:* `String.t`, *default:* `nil`) - This is only valid if :ref:`resolver_name ` is specified below and the named resolver is capable of named port resolution.
  *   `portValue` (*type:* `integer()`, *default:* `nil`) - 
  *   `protocol` (*type:* `String.t`, *default:* `nil`) - 
  *   `resolverName` (*type:* `String.t`, *default:* `nil`) - The name of the custom resolver. This must have been registered with Envoy. If this is empty, a context dependent default applies. If the address is a concrete IP address, no resolution will occur. If address is a hostname this should be set for resolution other than DNS. Specifying a custom resolver with ``STRICT_DNS`` or ``LOGICAL_DNS`` will generate an error at runtime.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :address => String.t() | nil,
          :ipv4Compat => boolean() | nil,
          :namedPort => String.t() | nil,
          :portValue => integer() | nil,
          :protocol => String.t() | nil,
          :resolverName => String.t() | nil
        }

  field(:address)
  field(:ipv4Compat)
  field(:namedPort)
  field(:portValue)
  field(:protocol)
  field(:resolverName)
end

defimpl Poison.Decoder, for: GoogleApi.TrafficDirector.V3.Model.SocketAddress do
  def decode(value, options) do
    GoogleApi.TrafficDirector.V3.Model.SocketAddress.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.TrafficDirector.V3.Model.SocketAddress do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
