{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Route53AutoNaming.CreateService
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a service. This action defines the configuration for the
-- following entities:
--
-- -   For public and private DNS namespaces, one of the following
--     combinations of DNS records in Amazon Route 53:
--
--     -   @A@
--
--     -   @AAAA@
--
--     -   @A@ and @AAAA@
--
--     -   @SRV@
--
--     -   @CNAME@
--
-- -   Optionally, a health check
--
-- After you create the service, you can submit a
-- <https://docs.aws.amazon.com/cloud-map/latest/api/API_RegisterInstance.html RegisterInstance>
-- request, and Cloud Map uses the values in the configuration to create
-- the specified entities.
--
-- For the current quota on the number of instances that you can register
-- using the same namespace and using the same service, see
-- <https://docs.aws.amazon.com/cloud-map/latest/dg/cloud-map-limits.html Cloud Map quotas>
-- in the /Cloud Map Developer Guide/.
module Amazonka.Route53AutoNaming.CreateService
  ( -- * Creating a Request
    CreateService (..),
    newCreateService,

    -- * Request Lenses
    createService_healthCheckConfig,
    createService_creatorRequestId,
    createService_healthCheckCustomConfig,
    createService_namespaceId,
    createService_type,
    createService_dnsConfig,
    createService_description,
    createService_tags,
    createService_name,

    -- * Destructuring the Response
    CreateServiceResponse (..),
    newCreateServiceResponse,

    -- * Response Lenses
    createServiceResponse_service,
    createServiceResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Route53AutoNaming.Types

-- | /See:/ 'newCreateService' smart constructor.
data CreateService = CreateService'
  { -- | /Public DNS and HTTP namespaces only./ A complex type that contains
    -- settings for an optional Route 53 health check. If you specify settings
    -- for a health check, Cloud Map associates the health check with all the
    -- Route 53 DNS records that you specify in @DnsConfig@.
    --
    -- If you specify a health check configuration, you can specify either
    -- @HealthCheckCustomConfig@ or @HealthCheckConfig@ but not both.
    --
    -- For information about the charges for health checks, see
    -- <http://aws.amazon.com/cloud-map/pricing/ Cloud Map Pricing>.
    CreateService -> Maybe HealthCheckConfig
healthCheckConfig :: Prelude.Maybe HealthCheckConfig,
    -- | A unique string that identifies the request and that allows failed
    -- @CreateService@ requests to be retried without the risk of running the
    -- operation twice. @CreatorRequestId@ can be any unique string (for
    -- example, a date\/timestamp).
    CreateService -> Maybe Text
creatorRequestId :: Prelude.Maybe Prelude.Text,
    -- | A complex type that contains information about an optional custom health
    -- check.
    --
    -- If you specify a health check configuration, you can specify either
    -- @HealthCheckCustomConfig@ or @HealthCheckConfig@ but not both.
    --
    -- You can\'t add, update, or delete a @HealthCheckCustomConfig@
    -- configuration from an existing service.
    CreateService -> Maybe HealthCheckCustomConfig
healthCheckCustomConfig :: Prelude.Maybe HealthCheckCustomConfig,
    -- | The ID of the namespace that you want to use to create the service. The
    -- namespace ID must be specified, but it can be specified either here or
    -- in the @DnsConfig@ object.
    CreateService -> Maybe Text
namespaceId :: Prelude.Maybe Prelude.Text,
    -- | If present, specifies that the service instances are only discoverable
    -- using the @DiscoverInstances@ API operation. No DNS records is
    -- registered for the service instances. The only valid value is @HTTP@.
    CreateService -> Maybe ServiceTypeOption
type' :: Prelude.Maybe ServiceTypeOption,
    -- | A complex type that contains information about the Amazon Route 53
    -- records that you want Cloud Map to create when you register an instance.
    CreateService -> Maybe DnsConfig
dnsConfig :: Prelude.Maybe DnsConfig,
    -- | A description for the service.
    CreateService -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The tags to add to the service. Each tag consists of a key and an
    -- optional value that you define. Tags keys can be up to 128 characters in
    -- length, and tag values can be up to 256 characters in length.
    CreateService -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The name that you want to assign to the service.
    --
    -- If you want Cloud Map to create an @SRV@ record when you register an
    -- instance and you\'re using a system that requires a specific @SRV@
    -- format, such as <http://www.haproxy.org/ HAProxy>, specify the following
    -- for @Name@:
    --
    -- -   Start the name with an underscore (_), such as @_exampleservice@.
    --
    -- -   End the name with /._protocol/, such as @._tcp@.
    --
    -- When you register an instance, Cloud Map creates an @SRV@ record and
    -- assigns a name to the record by concatenating the service name and the
    -- namespace name (for example,
    --
    -- @_exampleservice._tcp.example.com@).
    --
    -- For services that are accessible by DNS queries, you can\'t create
    -- multiple services with names that differ only by case (such as EXAMPLE
    -- and example). Otherwise, these services have the same DNS name and
    -- can\'t be distinguished. However, if you use a namespace that\'s only
    -- accessible by API calls, then you can create services that with names
    -- that differ only by case.
    CreateService -> Text
name :: Prelude.Text
  }
  deriving (CreateService -> CreateService -> Bool
(CreateService -> CreateService -> Bool)
-> (CreateService -> CreateService -> Bool) -> Eq CreateService
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateService -> CreateService -> Bool
$c/= :: CreateService -> CreateService -> Bool
== :: CreateService -> CreateService -> Bool
$c== :: CreateService -> CreateService -> Bool
Prelude.Eq, ReadPrec [CreateService]
ReadPrec CreateService
Int -> ReadS CreateService
ReadS [CreateService]
(Int -> ReadS CreateService)
-> ReadS [CreateService]
-> ReadPrec CreateService
-> ReadPrec [CreateService]
-> Read CreateService
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateService]
$creadListPrec :: ReadPrec [CreateService]
readPrec :: ReadPrec CreateService
$creadPrec :: ReadPrec CreateService
readList :: ReadS [CreateService]
$creadList :: ReadS [CreateService]
readsPrec :: Int -> ReadS CreateService
$creadsPrec :: Int -> ReadS CreateService
Prelude.Read, Int -> CreateService -> ShowS
[CreateService] -> ShowS
CreateService -> String
(Int -> CreateService -> ShowS)
-> (CreateService -> String)
-> ([CreateService] -> ShowS)
-> Show CreateService
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateService] -> ShowS
$cshowList :: [CreateService] -> ShowS
show :: CreateService -> String
$cshow :: CreateService -> String
showsPrec :: Int -> CreateService -> ShowS
$cshowsPrec :: Int -> CreateService -> ShowS
Prelude.Show, (forall x. CreateService -> Rep CreateService x)
-> (forall x. Rep CreateService x -> CreateService)
-> Generic CreateService
forall x. Rep CreateService x -> CreateService
forall x. CreateService -> Rep CreateService x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateService x -> CreateService
$cfrom :: forall x. CreateService -> Rep CreateService x
Prelude.Generic)

-- |
-- Create a value of 'CreateService' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'healthCheckConfig', 'createService_healthCheckConfig' - /Public DNS and HTTP namespaces only./ A complex type that contains
-- settings for an optional Route 53 health check. If you specify settings
-- for a health check, Cloud Map associates the health check with all the
-- Route 53 DNS records that you specify in @DnsConfig@.
--
-- If you specify a health check configuration, you can specify either
-- @HealthCheckCustomConfig@ or @HealthCheckConfig@ but not both.
--
-- For information about the charges for health checks, see
-- <http://aws.amazon.com/cloud-map/pricing/ Cloud Map Pricing>.
--
-- 'creatorRequestId', 'createService_creatorRequestId' - A unique string that identifies the request and that allows failed
-- @CreateService@ requests to be retried without the risk of running the
-- operation twice. @CreatorRequestId@ can be any unique string (for
-- example, a date\/timestamp).
--
-- 'healthCheckCustomConfig', 'createService_healthCheckCustomConfig' - A complex type that contains information about an optional custom health
-- check.
--
-- If you specify a health check configuration, you can specify either
-- @HealthCheckCustomConfig@ or @HealthCheckConfig@ but not both.
--
-- You can\'t add, update, or delete a @HealthCheckCustomConfig@
-- configuration from an existing service.
--
-- 'namespaceId', 'createService_namespaceId' - The ID of the namespace that you want to use to create the service. The
-- namespace ID must be specified, but it can be specified either here or
-- in the @DnsConfig@ object.
--
-- 'type'', 'createService_type' - If present, specifies that the service instances are only discoverable
-- using the @DiscoverInstances@ API operation. No DNS records is
-- registered for the service instances. The only valid value is @HTTP@.
--
-- 'dnsConfig', 'createService_dnsConfig' - A complex type that contains information about the Amazon Route 53
-- records that you want Cloud Map to create when you register an instance.
--
-- 'description', 'createService_description' - A description for the service.
--
-- 'tags', 'createService_tags' - The tags to add to the service. Each tag consists of a key and an
-- optional value that you define. Tags keys can be up to 128 characters in
-- length, and tag values can be up to 256 characters in length.
--
-- 'name', 'createService_name' - The name that you want to assign to the service.
--
-- If you want Cloud Map to create an @SRV@ record when you register an
-- instance and you\'re using a system that requires a specific @SRV@
-- format, such as <http://www.haproxy.org/ HAProxy>, specify the following
-- for @Name@:
--
-- -   Start the name with an underscore (_), such as @_exampleservice@.
--
-- -   End the name with /._protocol/, such as @._tcp@.
--
-- When you register an instance, Cloud Map creates an @SRV@ record and
-- assigns a name to the record by concatenating the service name and the
-- namespace name (for example,
--
-- @_exampleservice._tcp.example.com@).
--
-- For services that are accessible by DNS queries, you can\'t create
-- multiple services with names that differ only by case (such as EXAMPLE
-- and example). Otherwise, these services have the same DNS name and
-- can\'t be distinguished. However, if you use a namespace that\'s only
-- accessible by API calls, then you can create services that with names
-- that differ only by case.
newCreateService ::
  -- | 'name'
  Prelude.Text ->
  CreateService
newCreateService :: Text -> CreateService
newCreateService Text
pName_ =
  CreateService' :: Maybe HealthCheckConfig
-> Maybe Text
-> Maybe HealthCheckCustomConfig
-> Maybe Text
-> Maybe ServiceTypeOption
-> Maybe DnsConfig
-> Maybe Text
-> Maybe [Tag]
-> Text
-> CreateService
CreateService'
    { $sel:healthCheckConfig:CreateService' :: Maybe HealthCheckConfig
healthCheckConfig = Maybe HealthCheckConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:creatorRequestId:CreateService' :: Maybe Text
creatorRequestId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:healthCheckCustomConfig:CreateService' :: Maybe HealthCheckCustomConfig
healthCheckCustomConfig = Maybe HealthCheckCustomConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:namespaceId:CreateService' :: Maybe Text
namespaceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':CreateService' :: Maybe ServiceTypeOption
type' = Maybe ServiceTypeOption
forall a. Maybe a
Prelude.Nothing,
      $sel:dnsConfig:CreateService' :: Maybe DnsConfig
dnsConfig = Maybe DnsConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:description:CreateService' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateService' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateService' :: Text
name = Text
pName_
    }

-- | /Public DNS and HTTP namespaces only./ A complex type that contains
-- settings for an optional Route 53 health check. If you specify settings
-- for a health check, Cloud Map associates the health check with all the
-- Route 53 DNS records that you specify in @DnsConfig@.
--
-- If you specify a health check configuration, you can specify either
-- @HealthCheckCustomConfig@ or @HealthCheckConfig@ but not both.
--
-- For information about the charges for health checks, see
-- <http://aws.amazon.com/cloud-map/pricing/ Cloud Map Pricing>.
createService_healthCheckConfig :: Lens.Lens' CreateService (Prelude.Maybe HealthCheckConfig)
createService_healthCheckConfig :: (Maybe HealthCheckConfig -> f (Maybe HealthCheckConfig))
-> CreateService -> f CreateService
createService_healthCheckConfig = (CreateService -> Maybe HealthCheckConfig)
-> (CreateService -> Maybe HealthCheckConfig -> CreateService)
-> Lens
     CreateService
     CreateService
     (Maybe HealthCheckConfig)
     (Maybe HealthCheckConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateService' {Maybe HealthCheckConfig
healthCheckConfig :: Maybe HealthCheckConfig
$sel:healthCheckConfig:CreateService' :: CreateService -> Maybe HealthCheckConfig
healthCheckConfig} -> Maybe HealthCheckConfig
healthCheckConfig) (\s :: CreateService
s@CreateService' {} Maybe HealthCheckConfig
a -> CreateService
s {$sel:healthCheckConfig:CreateService' :: Maybe HealthCheckConfig
healthCheckConfig = Maybe HealthCheckConfig
a} :: CreateService)

-- | A unique string that identifies the request and that allows failed
-- @CreateService@ requests to be retried without the risk of running the
-- operation twice. @CreatorRequestId@ can be any unique string (for
-- example, a date\/timestamp).
createService_creatorRequestId :: Lens.Lens' CreateService (Prelude.Maybe Prelude.Text)
createService_creatorRequestId :: (Maybe Text -> f (Maybe Text)) -> CreateService -> f CreateService
createService_creatorRequestId = (CreateService -> Maybe Text)
-> (CreateService -> Maybe Text -> CreateService)
-> Lens CreateService CreateService (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateService' {Maybe Text
creatorRequestId :: Maybe Text
$sel:creatorRequestId:CreateService' :: CreateService -> Maybe Text
creatorRequestId} -> Maybe Text
creatorRequestId) (\s :: CreateService
s@CreateService' {} Maybe Text
a -> CreateService
s {$sel:creatorRequestId:CreateService' :: Maybe Text
creatorRequestId = Maybe Text
a} :: CreateService)

-- | A complex type that contains information about an optional custom health
-- check.
--
-- If you specify a health check configuration, you can specify either
-- @HealthCheckCustomConfig@ or @HealthCheckConfig@ but not both.
--
-- You can\'t add, update, or delete a @HealthCheckCustomConfig@
-- configuration from an existing service.
createService_healthCheckCustomConfig :: Lens.Lens' CreateService (Prelude.Maybe HealthCheckCustomConfig)
createService_healthCheckCustomConfig :: (Maybe HealthCheckCustomConfig
 -> f (Maybe HealthCheckCustomConfig))
-> CreateService -> f CreateService
createService_healthCheckCustomConfig = (CreateService -> Maybe HealthCheckCustomConfig)
-> (CreateService
    -> Maybe HealthCheckCustomConfig -> CreateService)
-> Lens
     CreateService
     CreateService
     (Maybe HealthCheckCustomConfig)
     (Maybe HealthCheckCustomConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateService' {Maybe HealthCheckCustomConfig
healthCheckCustomConfig :: Maybe HealthCheckCustomConfig
$sel:healthCheckCustomConfig:CreateService' :: CreateService -> Maybe HealthCheckCustomConfig
healthCheckCustomConfig} -> Maybe HealthCheckCustomConfig
healthCheckCustomConfig) (\s :: CreateService
s@CreateService' {} Maybe HealthCheckCustomConfig
a -> CreateService
s {$sel:healthCheckCustomConfig:CreateService' :: Maybe HealthCheckCustomConfig
healthCheckCustomConfig = Maybe HealthCheckCustomConfig
a} :: CreateService)

-- | The ID of the namespace that you want to use to create the service. The
-- namespace ID must be specified, but it can be specified either here or
-- in the @DnsConfig@ object.
createService_namespaceId :: Lens.Lens' CreateService (Prelude.Maybe Prelude.Text)
createService_namespaceId :: (Maybe Text -> f (Maybe Text)) -> CreateService -> f CreateService
createService_namespaceId = (CreateService -> Maybe Text)
-> (CreateService -> Maybe Text -> CreateService)
-> Lens CreateService CreateService (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateService' {Maybe Text
namespaceId :: Maybe Text
$sel:namespaceId:CreateService' :: CreateService -> Maybe Text
namespaceId} -> Maybe Text
namespaceId) (\s :: CreateService
s@CreateService' {} Maybe Text
a -> CreateService
s {$sel:namespaceId:CreateService' :: Maybe Text
namespaceId = Maybe Text
a} :: CreateService)

-- | If present, specifies that the service instances are only discoverable
-- using the @DiscoverInstances@ API operation. No DNS records is
-- registered for the service instances. The only valid value is @HTTP@.
createService_type :: Lens.Lens' CreateService (Prelude.Maybe ServiceTypeOption)
createService_type :: (Maybe ServiceTypeOption -> f (Maybe ServiceTypeOption))
-> CreateService -> f CreateService
createService_type = (CreateService -> Maybe ServiceTypeOption)
-> (CreateService -> Maybe ServiceTypeOption -> CreateService)
-> Lens
     CreateService
     CreateService
     (Maybe ServiceTypeOption)
     (Maybe ServiceTypeOption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateService' {Maybe ServiceTypeOption
type' :: Maybe ServiceTypeOption
$sel:type':CreateService' :: CreateService -> Maybe ServiceTypeOption
type'} -> Maybe ServiceTypeOption
type') (\s :: CreateService
s@CreateService' {} Maybe ServiceTypeOption
a -> CreateService
s {$sel:type':CreateService' :: Maybe ServiceTypeOption
type' = Maybe ServiceTypeOption
a} :: CreateService)

-- | A complex type that contains information about the Amazon Route 53
-- records that you want Cloud Map to create when you register an instance.
createService_dnsConfig :: Lens.Lens' CreateService (Prelude.Maybe DnsConfig)
createService_dnsConfig :: (Maybe DnsConfig -> f (Maybe DnsConfig))
-> CreateService -> f CreateService
createService_dnsConfig = (CreateService -> Maybe DnsConfig)
-> (CreateService -> Maybe DnsConfig -> CreateService)
-> Lens
     CreateService CreateService (Maybe DnsConfig) (Maybe DnsConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateService' {Maybe DnsConfig
dnsConfig :: Maybe DnsConfig
$sel:dnsConfig:CreateService' :: CreateService -> Maybe DnsConfig
dnsConfig} -> Maybe DnsConfig
dnsConfig) (\s :: CreateService
s@CreateService' {} Maybe DnsConfig
a -> CreateService
s {$sel:dnsConfig:CreateService' :: Maybe DnsConfig
dnsConfig = Maybe DnsConfig
a} :: CreateService)

-- | A description for the service.
createService_description :: Lens.Lens' CreateService (Prelude.Maybe Prelude.Text)
createService_description :: (Maybe Text -> f (Maybe Text)) -> CreateService -> f CreateService
createService_description = (CreateService -> Maybe Text)
-> (CreateService -> Maybe Text -> CreateService)
-> Lens CreateService CreateService (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateService' {Maybe Text
description :: Maybe Text
$sel:description:CreateService' :: CreateService -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateService
s@CreateService' {} Maybe Text
a -> CreateService
s {$sel:description:CreateService' :: Maybe Text
description = Maybe Text
a} :: CreateService)

-- | The tags to add to the service. Each tag consists of a key and an
-- optional value that you define. Tags keys can be up to 128 characters in
-- length, and tag values can be up to 256 characters in length.
createService_tags :: Lens.Lens' CreateService (Prelude.Maybe [Tag])
createService_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateService -> f CreateService
createService_tags = (CreateService -> Maybe [Tag])
-> (CreateService -> Maybe [Tag] -> CreateService)
-> Lens CreateService CreateService (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateService' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateService' :: CreateService -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateService
s@CreateService' {} Maybe [Tag]
a -> CreateService
s {$sel:tags:CreateService' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateService) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateService -> f CreateService)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateService
-> f CreateService
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name that you want to assign to the service.
--
-- If you want Cloud Map to create an @SRV@ record when you register an
-- instance and you\'re using a system that requires a specific @SRV@
-- format, such as <http://www.haproxy.org/ HAProxy>, specify the following
-- for @Name@:
--
-- -   Start the name with an underscore (_), such as @_exampleservice@.
--
-- -   End the name with /._protocol/, such as @._tcp@.
--
-- When you register an instance, Cloud Map creates an @SRV@ record and
-- assigns a name to the record by concatenating the service name and the
-- namespace name (for example,
--
-- @_exampleservice._tcp.example.com@).
--
-- For services that are accessible by DNS queries, you can\'t create
-- multiple services with names that differ only by case (such as EXAMPLE
-- and example). Otherwise, these services have the same DNS name and
-- can\'t be distinguished. However, if you use a namespace that\'s only
-- accessible by API calls, then you can create services that with names
-- that differ only by case.
createService_name :: Lens.Lens' CreateService Prelude.Text
createService_name :: (Text -> f Text) -> CreateService -> f CreateService
createService_name = (CreateService -> Text)
-> (CreateService -> Text -> CreateService)
-> Lens CreateService CreateService Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateService' {Text
name :: Text
$sel:name:CreateService' :: CreateService -> Text
name} -> Text
name) (\s :: CreateService
s@CreateService' {} Text
a -> CreateService
s {$sel:name:CreateService' :: Text
name = Text
a} :: CreateService)

instance Core.AWSRequest CreateService where
  type
    AWSResponse CreateService =
      CreateServiceResponse
  request :: CreateService -> Request CreateService
request = Service -> CreateService -> Request CreateService
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateService
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateService)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateService))
-> Logger
-> Service
-> Proxy CreateService
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateService)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ServiceInfo -> Int -> CreateServiceResponse
CreateServiceResponse'
            (Maybe ServiceInfo -> Int -> CreateServiceResponse)
-> Either String (Maybe ServiceInfo)
-> Either String (Int -> CreateServiceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ServiceInfo)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Service")
            Either String (Int -> CreateServiceResponse)
-> Either String Int -> Either String CreateServiceResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateService

instance Prelude.NFData CreateService

instance Core.ToHeaders CreateService where
  toHeaders :: CreateService -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateService -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Route53AutoNaming_v20170314.CreateService" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON CreateService where
  toJSON :: CreateService -> Value
toJSON CreateService' {Maybe [Tag]
Maybe Text
Maybe HealthCheckCustomConfig
Maybe HealthCheckConfig
Maybe DnsConfig
Maybe ServiceTypeOption
Text
name :: Text
tags :: Maybe [Tag]
description :: Maybe Text
dnsConfig :: Maybe DnsConfig
type' :: Maybe ServiceTypeOption
namespaceId :: Maybe Text
healthCheckCustomConfig :: Maybe HealthCheckCustomConfig
creatorRequestId :: Maybe Text
healthCheckConfig :: Maybe HealthCheckConfig
$sel:name:CreateService' :: CreateService -> Text
$sel:tags:CreateService' :: CreateService -> Maybe [Tag]
$sel:description:CreateService' :: CreateService -> Maybe Text
$sel:dnsConfig:CreateService' :: CreateService -> Maybe DnsConfig
$sel:type':CreateService' :: CreateService -> Maybe ServiceTypeOption
$sel:namespaceId:CreateService' :: CreateService -> Maybe Text
$sel:healthCheckCustomConfig:CreateService' :: CreateService -> Maybe HealthCheckCustomConfig
$sel:creatorRequestId:CreateService' :: CreateService -> Maybe Text
$sel:healthCheckConfig:CreateService' :: CreateService -> Maybe HealthCheckConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"HealthCheckConfig" Text -> HealthCheckConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HealthCheckConfig -> Pair)
-> Maybe HealthCheckConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HealthCheckConfig
healthCheckConfig,
            (Text
"CreatorRequestId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
creatorRequestId,
            (Text
"HealthCheckCustomConfig" Text -> HealthCheckCustomConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HealthCheckCustomConfig -> Pair)
-> Maybe HealthCheckCustomConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HealthCheckCustomConfig
healthCheckCustomConfig,
            (Text
"NamespaceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
namespaceId,
            (Text
"Type" Text -> ServiceTypeOption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ServiceTypeOption -> Pair)
-> Maybe ServiceTypeOption -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ServiceTypeOption
type',
            (Text
"DnsConfig" Text -> DnsConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DnsConfig -> Pair) -> Maybe DnsConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DnsConfig
dnsConfig,
            (Text
"Description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )

instance Core.ToPath CreateService where
  toPath :: CreateService -> ByteString
toPath = ByteString -> CreateService -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery CreateService where
  toQuery :: CreateService -> QueryString
toQuery = QueryString -> CreateService -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newCreateServiceResponse' smart constructor.
data CreateServiceResponse = CreateServiceResponse'
  { -- | A complex type that contains information about the new service.
    CreateServiceResponse -> Maybe ServiceInfo
service :: Prelude.Maybe ServiceInfo,
    -- | The response's http status code.
    CreateServiceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateServiceResponse -> CreateServiceResponse -> Bool
(CreateServiceResponse -> CreateServiceResponse -> Bool)
-> (CreateServiceResponse -> CreateServiceResponse -> Bool)
-> Eq CreateServiceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateServiceResponse -> CreateServiceResponse -> Bool
$c/= :: CreateServiceResponse -> CreateServiceResponse -> Bool
== :: CreateServiceResponse -> CreateServiceResponse -> Bool
$c== :: CreateServiceResponse -> CreateServiceResponse -> Bool
Prelude.Eq, ReadPrec [CreateServiceResponse]
ReadPrec CreateServiceResponse
Int -> ReadS CreateServiceResponse
ReadS [CreateServiceResponse]
(Int -> ReadS CreateServiceResponse)
-> ReadS [CreateServiceResponse]
-> ReadPrec CreateServiceResponse
-> ReadPrec [CreateServiceResponse]
-> Read CreateServiceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateServiceResponse]
$creadListPrec :: ReadPrec [CreateServiceResponse]
readPrec :: ReadPrec CreateServiceResponse
$creadPrec :: ReadPrec CreateServiceResponse
readList :: ReadS [CreateServiceResponse]
$creadList :: ReadS [CreateServiceResponse]
readsPrec :: Int -> ReadS CreateServiceResponse
$creadsPrec :: Int -> ReadS CreateServiceResponse
Prelude.Read, Int -> CreateServiceResponse -> ShowS
[CreateServiceResponse] -> ShowS
CreateServiceResponse -> String
(Int -> CreateServiceResponse -> ShowS)
-> (CreateServiceResponse -> String)
-> ([CreateServiceResponse] -> ShowS)
-> Show CreateServiceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateServiceResponse] -> ShowS
$cshowList :: [CreateServiceResponse] -> ShowS
show :: CreateServiceResponse -> String
$cshow :: CreateServiceResponse -> String
showsPrec :: Int -> CreateServiceResponse -> ShowS
$cshowsPrec :: Int -> CreateServiceResponse -> ShowS
Prelude.Show, (forall x. CreateServiceResponse -> Rep CreateServiceResponse x)
-> (forall x. Rep CreateServiceResponse x -> CreateServiceResponse)
-> Generic CreateServiceResponse
forall x. Rep CreateServiceResponse x -> CreateServiceResponse
forall x. CreateServiceResponse -> Rep CreateServiceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateServiceResponse x -> CreateServiceResponse
$cfrom :: forall x. CreateServiceResponse -> Rep CreateServiceResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateServiceResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'service', 'createServiceResponse_service' - A complex type that contains information about the new service.
--
-- 'httpStatus', 'createServiceResponse_httpStatus' - The response's http status code.
newCreateServiceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateServiceResponse
newCreateServiceResponse :: Int -> CreateServiceResponse
newCreateServiceResponse Int
pHttpStatus_ =
  CreateServiceResponse' :: Maybe ServiceInfo -> Int -> CreateServiceResponse
CreateServiceResponse'
    { $sel:service:CreateServiceResponse' :: Maybe ServiceInfo
service = Maybe ServiceInfo
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateServiceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A complex type that contains information about the new service.
createServiceResponse_service :: Lens.Lens' CreateServiceResponse (Prelude.Maybe ServiceInfo)
createServiceResponse_service :: (Maybe ServiceInfo -> f (Maybe ServiceInfo))
-> CreateServiceResponse -> f CreateServiceResponse
createServiceResponse_service = (CreateServiceResponse -> Maybe ServiceInfo)
-> (CreateServiceResponse
    -> Maybe ServiceInfo -> CreateServiceResponse)
-> Lens
     CreateServiceResponse
     CreateServiceResponse
     (Maybe ServiceInfo)
     (Maybe ServiceInfo)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateServiceResponse' {Maybe ServiceInfo
service :: Maybe ServiceInfo
$sel:service:CreateServiceResponse' :: CreateServiceResponse -> Maybe ServiceInfo
service} -> Maybe ServiceInfo
service) (\s :: CreateServiceResponse
s@CreateServiceResponse' {} Maybe ServiceInfo
a -> CreateServiceResponse
s {$sel:service:CreateServiceResponse' :: Maybe ServiceInfo
service = Maybe ServiceInfo
a} :: CreateServiceResponse)

-- | The response's http status code.
createServiceResponse_httpStatus :: Lens.Lens' CreateServiceResponse Prelude.Int
createServiceResponse_httpStatus :: (Int -> f Int) -> CreateServiceResponse -> f CreateServiceResponse
createServiceResponse_httpStatus = (CreateServiceResponse -> Int)
-> (CreateServiceResponse -> Int -> CreateServiceResponse)
-> Lens CreateServiceResponse CreateServiceResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateServiceResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateServiceResponse' :: CreateServiceResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateServiceResponse
s@CreateServiceResponse' {} Int
a -> CreateServiceResponse
s {$sel:httpStatus:CreateServiceResponse' :: Int
httpStatus = Int
a} :: CreateServiceResponse)

instance Prelude.NFData CreateServiceResponse