{-# 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.Chime.CreateChannel
-- 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 channel to which you can add users and send messages.
--
-- __Restriction__: You can\'t change a channel\'s privacy.
--
-- The @x-amz-chime-bearer@ request header is mandatory. Use the
-- @AppInstanceUserArn@ of the user that makes the API call as the value in
-- the header.
module Amazonka.Chime.CreateChannel
  ( -- * Creating a Request
    CreateChannel (..),
    newCreateChannel,

    -- * Request Lenses
    createChannel_mode,
    createChannel_privacy,
    createChannel_chimeBearer,
    createChannel_metadata,
    createChannel_tags,
    createChannel_appInstanceArn,
    createChannel_name,
    createChannel_clientRequestToken,

    -- * Destructuring the Response
    CreateChannelResponse (..),
    newCreateChannelResponse,

    -- * Response Lenses
    createChannelResponse_channelArn,
    createChannelResponse_httpStatus,
  )
where

import Amazonka.Chime.Types
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

-- | /See:/ 'newCreateChannel' smart constructor.
data CreateChannel = CreateChannel'
  { -- | The channel mode: @UNRESTRICTED@ or @RESTRICTED@. Administrators,
    -- moderators, and channel members can add themselves and other members to
    -- unrestricted channels. Only administrators and moderators can add
    -- members to restricted channels.
    CreateChannel -> Maybe ChannelMode
mode :: Prelude.Maybe ChannelMode,
    -- | The channel\'s privacy level: @PUBLIC@ or @PRIVATE@. Private channels
    -- aren\'t discoverable by users outside the channel. Public channels are
    -- discoverable by anyone in the @AppInstance@.
    CreateChannel -> Maybe ChannelPrivacy
privacy :: Prelude.Maybe ChannelPrivacy,
    -- | The @AppInstanceUserArn@ of the user that makes the API call.
    CreateChannel -> Maybe Text
chimeBearer :: Prelude.Maybe Prelude.Text,
    -- | The metadata of the creation request. Limited to 1KB and UTF-8.
    CreateChannel -> Maybe (Sensitive Text)
metadata :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The tags for the creation request.
    CreateChannel -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
    -- | The ARN of the channel request.
    CreateChannel -> Text
appInstanceArn :: Prelude.Text,
    -- | The name of the channel.
    CreateChannel -> Sensitive Text
name :: Core.Sensitive Prelude.Text,
    -- | The client token for the request. An @Idempotency@ token.
    CreateChannel -> Sensitive Text
clientRequestToken :: Core.Sensitive Prelude.Text
  }
  deriving (CreateChannel -> CreateChannel -> Bool
(CreateChannel -> CreateChannel -> Bool)
-> (CreateChannel -> CreateChannel -> Bool) -> Eq CreateChannel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateChannel -> CreateChannel -> Bool
$c/= :: CreateChannel -> CreateChannel -> Bool
== :: CreateChannel -> CreateChannel -> Bool
$c== :: CreateChannel -> CreateChannel -> Bool
Prelude.Eq, Int -> CreateChannel -> ShowS
[CreateChannel] -> ShowS
CreateChannel -> String
(Int -> CreateChannel -> ShowS)
-> (CreateChannel -> String)
-> ([CreateChannel] -> ShowS)
-> Show CreateChannel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateChannel] -> ShowS
$cshowList :: [CreateChannel] -> ShowS
show :: CreateChannel -> String
$cshow :: CreateChannel -> String
showsPrec :: Int -> CreateChannel -> ShowS
$cshowsPrec :: Int -> CreateChannel -> ShowS
Prelude.Show, (forall x. CreateChannel -> Rep CreateChannel x)
-> (forall x. Rep CreateChannel x -> CreateChannel)
-> Generic CreateChannel
forall x. Rep CreateChannel x -> CreateChannel
forall x. CreateChannel -> Rep CreateChannel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateChannel x -> CreateChannel
$cfrom :: forall x. CreateChannel -> Rep CreateChannel x
Prelude.Generic)

-- |
-- Create a value of 'CreateChannel' 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:
--
-- 'mode', 'createChannel_mode' - The channel mode: @UNRESTRICTED@ or @RESTRICTED@. Administrators,
-- moderators, and channel members can add themselves and other members to
-- unrestricted channels. Only administrators and moderators can add
-- members to restricted channels.
--
-- 'privacy', 'createChannel_privacy' - The channel\'s privacy level: @PUBLIC@ or @PRIVATE@. Private channels
-- aren\'t discoverable by users outside the channel. Public channels are
-- discoverable by anyone in the @AppInstance@.
--
-- 'chimeBearer', 'createChannel_chimeBearer' - The @AppInstanceUserArn@ of the user that makes the API call.
--
-- 'metadata', 'createChannel_metadata' - The metadata of the creation request. Limited to 1KB and UTF-8.
--
-- 'tags', 'createChannel_tags' - The tags for the creation request.
--
-- 'appInstanceArn', 'createChannel_appInstanceArn' - The ARN of the channel request.
--
-- 'name', 'createChannel_name' - The name of the channel.
--
-- 'clientRequestToken', 'createChannel_clientRequestToken' - The client token for the request. An @Idempotency@ token.
newCreateChannel ::
  -- | 'appInstanceArn'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'clientRequestToken'
  Prelude.Text ->
  CreateChannel
newCreateChannel :: Text -> Text -> Text -> CreateChannel
newCreateChannel
  Text
pAppInstanceArn_
  Text
pName_
  Text
pClientRequestToken_ =
    CreateChannel' :: Maybe ChannelMode
-> Maybe ChannelPrivacy
-> Maybe Text
-> Maybe (Sensitive Text)
-> Maybe (NonEmpty Tag)
-> Text
-> Sensitive Text
-> Sensitive Text
-> CreateChannel
CreateChannel'
      { $sel:mode:CreateChannel' :: Maybe ChannelMode
mode = Maybe ChannelMode
forall a. Maybe a
Prelude.Nothing,
        $sel:privacy:CreateChannel' :: Maybe ChannelPrivacy
privacy = Maybe ChannelPrivacy
forall a. Maybe a
Prelude.Nothing,
        $sel:chimeBearer:CreateChannel' :: Maybe Text
chimeBearer = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:metadata:CreateChannel' :: Maybe (Sensitive Text)
metadata = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateChannel' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing,
        $sel:appInstanceArn:CreateChannel' :: Text
appInstanceArn = Text
pAppInstanceArn_,
        $sel:name:CreateChannel' :: Sensitive Text
name = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pName_,
        $sel:clientRequestToken:CreateChannel' :: Sensitive Text
clientRequestToken =
          Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pClientRequestToken_
      }

-- | The channel mode: @UNRESTRICTED@ or @RESTRICTED@. Administrators,
-- moderators, and channel members can add themselves and other members to
-- unrestricted channels. Only administrators and moderators can add
-- members to restricted channels.
createChannel_mode :: Lens.Lens' CreateChannel (Prelude.Maybe ChannelMode)
createChannel_mode :: (Maybe ChannelMode -> f (Maybe ChannelMode))
-> CreateChannel -> f CreateChannel
createChannel_mode = (CreateChannel -> Maybe ChannelMode)
-> (CreateChannel -> Maybe ChannelMode -> CreateChannel)
-> Lens
     CreateChannel CreateChannel (Maybe ChannelMode) (Maybe ChannelMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateChannel' {Maybe ChannelMode
mode :: Maybe ChannelMode
$sel:mode:CreateChannel' :: CreateChannel -> Maybe ChannelMode
mode} -> Maybe ChannelMode
mode) (\s :: CreateChannel
s@CreateChannel' {} Maybe ChannelMode
a -> CreateChannel
s {$sel:mode:CreateChannel' :: Maybe ChannelMode
mode = Maybe ChannelMode
a} :: CreateChannel)

-- | The channel\'s privacy level: @PUBLIC@ or @PRIVATE@. Private channels
-- aren\'t discoverable by users outside the channel. Public channels are
-- discoverable by anyone in the @AppInstance@.
createChannel_privacy :: Lens.Lens' CreateChannel (Prelude.Maybe ChannelPrivacy)
createChannel_privacy :: (Maybe ChannelPrivacy -> f (Maybe ChannelPrivacy))
-> CreateChannel -> f CreateChannel
createChannel_privacy = (CreateChannel -> Maybe ChannelPrivacy)
-> (CreateChannel -> Maybe ChannelPrivacy -> CreateChannel)
-> Lens
     CreateChannel
     CreateChannel
     (Maybe ChannelPrivacy)
     (Maybe ChannelPrivacy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateChannel' {Maybe ChannelPrivacy
privacy :: Maybe ChannelPrivacy
$sel:privacy:CreateChannel' :: CreateChannel -> Maybe ChannelPrivacy
privacy} -> Maybe ChannelPrivacy
privacy) (\s :: CreateChannel
s@CreateChannel' {} Maybe ChannelPrivacy
a -> CreateChannel
s {$sel:privacy:CreateChannel' :: Maybe ChannelPrivacy
privacy = Maybe ChannelPrivacy
a} :: CreateChannel)

-- | The @AppInstanceUserArn@ of the user that makes the API call.
createChannel_chimeBearer :: Lens.Lens' CreateChannel (Prelude.Maybe Prelude.Text)
createChannel_chimeBearer :: (Maybe Text -> f (Maybe Text)) -> CreateChannel -> f CreateChannel
createChannel_chimeBearer = (CreateChannel -> Maybe Text)
-> (CreateChannel -> Maybe Text -> CreateChannel)
-> Lens CreateChannel CreateChannel (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateChannel' {Maybe Text
chimeBearer :: Maybe Text
$sel:chimeBearer:CreateChannel' :: CreateChannel -> Maybe Text
chimeBearer} -> Maybe Text
chimeBearer) (\s :: CreateChannel
s@CreateChannel' {} Maybe Text
a -> CreateChannel
s {$sel:chimeBearer:CreateChannel' :: Maybe Text
chimeBearer = Maybe Text
a} :: CreateChannel)

-- | The metadata of the creation request. Limited to 1KB and UTF-8.
createChannel_metadata :: Lens.Lens' CreateChannel (Prelude.Maybe Prelude.Text)
createChannel_metadata :: (Maybe Text -> f (Maybe Text)) -> CreateChannel -> f CreateChannel
createChannel_metadata = (CreateChannel -> Maybe (Sensitive Text))
-> (CreateChannel -> Maybe (Sensitive Text) -> CreateChannel)
-> Lens
     CreateChannel
     CreateChannel
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateChannel' {Maybe (Sensitive Text)
metadata :: Maybe (Sensitive Text)
$sel:metadata:CreateChannel' :: CreateChannel -> Maybe (Sensitive Text)
metadata} -> Maybe (Sensitive Text)
metadata) (\s :: CreateChannel
s@CreateChannel' {} Maybe (Sensitive Text)
a -> CreateChannel
s {$sel:metadata:CreateChannel' :: Maybe (Sensitive Text)
metadata = Maybe (Sensitive Text)
a} :: CreateChannel) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> CreateChannel -> f CreateChannel)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> CreateChannel
-> f CreateChannel
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The tags for the creation request.
createChannel_tags :: Lens.Lens' CreateChannel (Prelude.Maybe (Prelude.NonEmpty Tag))
createChannel_tags :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateChannel -> f CreateChannel
createChannel_tags = (CreateChannel -> Maybe (NonEmpty Tag))
-> (CreateChannel -> Maybe (NonEmpty Tag) -> CreateChannel)
-> Lens
     CreateChannel
     CreateChannel
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateChannel' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:CreateChannel' :: CreateChannel -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: CreateChannel
s@CreateChannel' {} Maybe (NonEmpty Tag)
a -> CreateChannel
s {$sel:tags:CreateChannel' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: CreateChannel) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
 -> CreateChannel -> f CreateChannel)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
    -> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateChannel
-> f CreateChannel
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
-> Iso
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty 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 (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ARN of the channel request.
createChannel_appInstanceArn :: Lens.Lens' CreateChannel Prelude.Text
createChannel_appInstanceArn :: (Text -> f Text) -> CreateChannel -> f CreateChannel
createChannel_appInstanceArn = (CreateChannel -> Text)
-> (CreateChannel -> Text -> CreateChannel)
-> Lens CreateChannel CreateChannel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateChannel' {Text
appInstanceArn :: Text
$sel:appInstanceArn:CreateChannel' :: CreateChannel -> Text
appInstanceArn} -> Text
appInstanceArn) (\s :: CreateChannel
s@CreateChannel' {} Text
a -> CreateChannel
s {$sel:appInstanceArn:CreateChannel' :: Text
appInstanceArn = Text
a} :: CreateChannel)

-- | The name of the channel.
createChannel_name :: Lens.Lens' CreateChannel Prelude.Text
createChannel_name :: (Text -> f Text) -> CreateChannel -> f CreateChannel
createChannel_name = (CreateChannel -> Sensitive Text)
-> (CreateChannel -> Sensitive Text -> CreateChannel)
-> Lens
     CreateChannel CreateChannel (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateChannel' {Sensitive Text
name :: Sensitive Text
$sel:name:CreateChannel' :: CreateChannel -> Sensitive Text
name} -> Sensitive Text
name) (\s :: CreateChannel
s@CreateChannel' {} Sensitive Text
a -> CreateChannel
s {$sel:name:CreateChannel' :: Sensitive Text
name = Sensitive Text
a} :: CreateChannel) ((Sensitive Text -> f (Sensitive Text))
 -> CreateChannel -> f CreateChannel)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> CreateChannel
-> f CreateChannel
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The client token for the request. An @Idempotency@ token.
createChannel_clientRequestToken :: Lens.Lens' CreateChannel Prelude.Text
createChannel_clientRequestToken :: (Text -> f Text) -> CreateChannel -> f CreateChannel
createChannel_clientRequestToken = (CreateChannel -> Sensitive Text)
-> (CreateChannel -> Sensitive Text -> CreateChannel)
-> Lens
     CreateChannel CreateChannel (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateChannel' {Sensitive Text
clientRequestToken :: Sensitive Text
$sel:clientRequestToken:CreateChannel' :: CreateChannel -> Sensitive Text
clientRequestToken} -> Sensitive Text
clientRequestToken) (\s :: CreateChannel
s@CreateChannel' {} Sensitive Text
a -> CreateChannel
s {$sel:clientRequestToken:CreateChannel' :: Sensitive Text
clientRequestToken = Sensitive Text
a} :: CreateChannel) ((Sensitive Text -> f (Sensitive Text))
 -> CreateChannel -> f CreateChannel)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> CreateChannel
-> f CreateChannel
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

instance Core.AWSRequest CreateChannel where
  type
    AWSResponse CreateChannel =
      CreateChannelResponse
  request :: CreateChannel -> Request CreateChannel
request = Service -> CreateChannel -> Request CreateChannel
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateChannel)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateChannel))
-> Logger
-> Service
-> Proxy CreateChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateChannel)))
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 Text -> Int -> CreateChannelResponse
CreateChannelResponse'
            (Maybe Text -> Int -> CreateChannelResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateChannelResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ChannelArn")
            Either String (Int -> CreateChannelResponse)
-> Either String Int -> Either String CreateChannelResponse
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 CreateChannel

instance Prelude.NFData CreateChannel

instance Core.ToHeaders CreateChannel where
  toHeaders :: CreateChannel -> ResponseHeaders
toHeaders CreateChannel' {Maybe (NonEmpty Tag)
Maybe Text
Maybe (Sensitive Text)
Maybe ChannelMode
Maybe ChannelPrivacy
Text
Sensitive Text
clientRequestToken :: Sensitive Text
name :: Sensitive Text
appInstanceArn :: Text
tags :: Maybe (NonEmpty Tag)
metadata :: Maybe (Sensitive Text)
chimeBearer :: Maybe Text
privacy :: Maybe ChannelPrivacy
mode :: Maybe ChannelMode
$sel:clientRequestToken:CreateChannel' :: CreateChannel -> Sensitive Text
$sel:name:CreateChannel' :: CreateChannel -> Sensitive Text
$sel:appInstanceArn:CreateChannel' :: CreateChannel -> Text
$sel:tags:CreateChannel' :: CreateChannel -> Maybe (NonEmpty Tag)
$sel:metadata:CreateChannel' :: CreateChannel -> Maybe (Sensitive Text)
$sel:chimeBearer:CreateChannel' :: CreateChannel -> Maybe Text
$sel:privacy:CreateChannel' :: CreateChannel -> Maybe ChannelPrivacy
$sel:mode:CreateChannel' :: CreateChannel -> Maybe ChannelMode
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [HeaderName
"x-amz-chime-bearer" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
chimeBearer]

instance Core.ToJSON CreateChannel where
  toJSON :: CreateChannel -> Value
toJSON CreateChannel' {Maybe (NonEmpty Tag)
Maybe Text
Maybe (Sensitive Text)
Maybe ChannelMode
Maybe ChannelPrivacy
Text
Sensitive Text
clientRequestToken :: Sensitive Text
name :: Sensitive Text
appInstanceArn :: Text
tags :: Maybe (NonEmpty Tag)
metadata :: Maybe (Sensitive Text)
chimeBearer :: Maybe Text
privacy :: Maybe ChannelPrivacy
mode :: Maybe ChannelMode
$sel:clientRequestToken:CreateChannel' :: CreateChannel -> Sensitive Text
$sel:name:CreateChannel' :: CreateChannel -> Sensitive Text
$sel:appInstanceArn:CreateChannel' :: CreateChannel -> Text
$sel:tags:CreateChannel' :: CreateChannel -> Maybe (NonEmpty Tag)
$sel:metadata:CreateChannel' :: CreateChannel -> Maybe (Sensitive Text)
$sel:chimeBearer:CreateChannel' :: CreateChannel -> Maybe Text
$sel:privacy:CreateChannel' :: CreateChannel -> Maybe ChannelPrivacy
$sel:mode:CreateChannel' :: CreateChannel -> Maybe ChannelMode
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Mode" Text -> ChannelMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ChannelMode -> Pair) -> Maybe ChannelMode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ChannelMode
mode,
            (Text
"Privacy" Text -> ChannelPrivacy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ChannelPrivacy -> Pair) -> Maybe ChannelPrivacy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ChannelPrivacy
privacy,
            (Text
"Metadata" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
metadata,
            (Text
"Tags" Text -> NonEmpty Tag -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Tag -> Pair) -> Maybe (NonEmpty Tag) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Tag)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AppInstanceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
appInstanceArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ClientRequestToken" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
clientRequestToken)
          ]
      )

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

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

-- | /See:/ 'newCreateChannelResponse' smart constructor.
data CreateChannelResponse = CreateChannelResponse'
  { -- | The ARN of the channel.
    CreateChannelResponse -> Maybe Text
channelArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateChannelResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateChannelResponse -> CreateChannelResponse -> Bool
(CreateChannelResponse -> CreateChannelResponse -> Bool)
-> (CreateChannelResponse -> CreateChannelResponse -> Bool)
-> Eq CreateChannelResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateChannelResponse -> CreateChannelResponse -> Bool
$c/= :: CreateChannelResponse -> CreateChannelResponse -> Bool
== :: CreateChannelResponse -> CreateChannelResponse -> Bool
$c== :: CreateChannelResponse -> CreateChannelResponse -> Bool
Prelude.Eq, ReadPrec [CreateChannelResponse]
ReadPrec CreateChannelResponse
Int -> ReadS CreateChannelResponse
ReadS [CreateChannelResponse]
(Int -> ReadS CreateChannelResponse)
-> ReadS [CreateChannelResponse]
-> ReadPrec CreateChannelResponse
-> ReadPrec [CreateChannelResponse]
-> Read CreateChannelResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateChannelResponse]
$creadListPrec :: ReadPrec [CreateChannelResponse]
readPrec :: ReadPrec CreateChannelResponse
$creadPrec :: ReadPrec CreateChannelResponse
readList :: ReadS [CreateChannelResponse]
$creadList :: ReadS [CreateChannelResponse]
readsPrec :: Int -> ReadS CreateChannelResponse
$creadsPrec :: Int -> ReadS CreateChannelResponse
Prelude.Read, Int -> CreateChannelResponse -> ShowS
[CreateChannelResponse] -> ShowS
CreateChannelResponse -> String
(Int -> CreateChannelResponse -> ShowS)
-> (CreateChannelResponse -> String)
-> ([CreateChannelResponse] -> ShowS)
-> Show CreateChannelResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateChannelResponse] -> ShowS
$cshowList :: [CreateChannelResponse] -> ShowS
show :: CreateChannelResponse -> String
$cshow :: CreateChannelResponse -> String
showsPrec :: Int -> CreateChannelResponse -> ShowS
$cshowsPrec :: Int -> CreateChannelResponse -> ShowS
Prelude.Show, (forall x. CreateChannelResponse -> Rep CreateChannelResponse x)
-> (forall x. Rep CreateChannelResponse x -> CreateChannelResponse)
-> Generic CreateChannelResponse
forall x. Rep CreateChannelResponse x -> CreateChannelResponse
forall x. CreateChannelResponse -> Rep CreateChannelResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateChannelResponse x -> CreateChannelResponse
$cfrom :: forall x. CreateChannelResponse -> Rep CreateChannelResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateChannelResponse' 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:
--
-- 'channelArn', 'createChannelResponse_channelArn' - The ARN of the channel.
--
-- 'httpStatus', 'createChannelResponse_httpStatus' - The response's http status code.
newCreateChannelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateChannelResponse
newCreateChannelResponse :: Int -> CreateChannelResponse
newCreateChannelResponse Int
pHttpStatus_ =
  CreateChannelResponse' :: Maybe Text -> Int -> CreateChannelResponse
CreateChannelResponse'
    { $sel:channelArn:CreateChannelResponse' :: Maybe Text
channelArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateChannelResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the channel.
createChannelResponse_channelArn :: Lens.Lens' CreateChannelResponse (Prelude.Maybe Prelude.Text)
createChannelResponse_channelArn :: (Maybe Text -> f (Maybe Text))
-> CreateChannelResponse -> f CreateChannelResponse
createChannelResponse_channelArn = (CreateChannelResponse -> Maybe Text)
-> (CreateChannelResponse -> Maybe Text -> CreateChannelResponse)
-> Lens
     CreateChannelResponse
     CreateChannelResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateChannelResponse' {Maybe Text
channelArn :: Maybe Text
$sel:channelArn:CreateChannelResponse' :: CreateChannelResponse -> Maybe Text
channelArn} -> Maybe Text
channelArn) (\s :: CreateChannelResponse
s@CreateChannelResponse' {} Maybe Text
a -> CreateChannelResponse
s {$sel:channelArn:CreateChannelResponse' :: Maybe Text
channelArn = Maybe Text
a} :: CreateChannelResponse)

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

instance Prelude.NFData CreateChannelResponse