{-# 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.RAM.CreateResourceShare
-- 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 resource share. You must provide a list of the Amazon Resource
-- Names (ARNs) for the resources you want to share. You must also specify
-- who you want to share the resources with, and the permissions that you
-- grant them.
--
-- Sharing a resource makes it available for use by principals outside of
-- the Amazon Web Services account that created the resource. Sharing
-- doesn\'t change any permissions or quotas that apply to the resource in
-- the account that created it.
module Amazonka.RAM.CreateResourceShare
  ( -- * Creating a Request
    CreateResourceShare (..),
    newCreateResourceShare,

    -- * Request Lenses
    createResourceShare_clientToken,
    createResourceShare_allowExternalPrincipals,
    createResourceShare_principals,
    createResourceShare_resourceArns,
    createResourceShare_permissionArns,
    createResourceShare_tags,
    createResourceShare_name,

    -- * Destructuring the Response
    CreateResourceShareResponse (..),
    newCreateResourceShareResponse,

    -- * Response Lenses
    createResourceShareResponse_clientToken,
    createResourceShareResponse_resourceShare,
    createResourceShareResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateResourceShare' smart constructor.
data CreateResourceShare = CreateResourceShare'
  { -- | A unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request.
    CreateResourceShare -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether principals outside your organization in Organizations
    -- can be associated with a resource share.
    CreateResourceShare -> Maybe Bool
allowExternalPrincipals :: Prelude.Maybe Prelude.Bool,
    -- | The principals to associate with the resource share. The possible values
    -- are:
    --
    -- -   An Amazon Web Services account ID
    --
    -- -   An Amazon Resource Name (ARN) of an organization in Organizations
    --
    -- -   An ARN of an organizational unit (OU) in Organizations
    --
    -- -   An ARN of an IAM role
    --
    -- -   An ARN of an IAM user
    --
    -- Not all resource types can be shared with IAM roles and IAM users. For
    -- more information, see
    -- <https://docs.aws.amazon.com/ram/latest/userguide/permissions.html#permissions-rbp-supported-resource-types Sharing with IAM roles and IAM users>
    -- in the /Resource Access Manager User Guide/.
    CreateResourceShare -> Maybe [Text]
principals :: Prelude.Maybe [Prelude.Text],
    -- | The ARNs of the resources to associate with the resource share.
    CreateResourceShare -> Maybe [Text]
resourceArns :: Prelude.Maybe [Prelude.Text],
    -- | The Amazon Resource Names (ARNs) of the permissions to associate with
    -- the resource share. If you do not specify an ARN for the permission, RAM
    -- automatically attaches the default version of the permission for each
    -- resource type. Only one permission can be associated with each resource
    -- type in a resource share.
    CreateResourceShare -> Maybe [Text]
permissionArns :: Prelude.Maybe [Prelude.Text],
    -- | One or more tags.
    CreateResourceShare -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The name of the resource share.
    CreateResourceShare -> Text
name :: Prelude.Text
  }
  deriving (CreateResourceShare -> CreateResourceShare -> Bool
(CreateResourceShare -> CreateResourceShare -> Bool)
-> (CreateResourceShare -> CreateResourceShare -> Bool)
-> Eq CreateResourceShare
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateResourceShare -> CreateResourceShare -> Bool
$c/= :: CreateResourceShare -> CreateResourceShare -> Bool
== :: CreateResourceShare -> CreateResourceShare -> Bool
$c== :: CreateResourceShare -> CreateResourceShare -> Bool
Prelude.Eq, ReadPrec [CreateResourceShare]
ReadPrec CreateResourceShare
Int -> ReadS CreateResourceShare
ReadS [CreateResourceShare]
(Int -> ReadS CreateResourceShare)
-> ReadS [CreateResourceShare]
-> ReadPrec CreateResourceShare
-> ReadPrec [CreateResourceShare]
-> Read CreateResourceShare
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateResourceShare]
$creadListPrec :: ReadPrec [CreateResourceShare]
readPrec :: ReadPrec CreateResourceShare
$creadPrec :: ReadPrec CreateResourceShare
readList :: ReadS [CreateResourceShare]
$creadList :: ReadS [CreateResourceShare]
readsPrec :: Int -> ReadS CreateResourceShare
$creadsPrec :: Int -> ReadS CreateResourceShare
Prelude.Read, Int -> CreateResourceShare -> ShowS
[CreateResourceShare] -> ShowS
CreateResourceShare -> String
(Int -> CreateResourceShare -> ShowS)
-> (CreateResourceShare -> String)
-> ([CreateResourceShare] -> ShowS)
-> Show CreateResourceShare
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateResourceShare] -> ShowS
$cshowList :: [CreateResourceShare] -> ShowS
show :: CreateResourceShare -> String
$cshow :: CreateResourceShare -> String
showsPrec :: Int -> CreateResourceShare -> ShowS
$cshowsPrec :: Int -> CreateResourceShare -> ShowS
Prelude.Show, (forall x. CreateResourceShare -> Rep CreateResourceShare x)
-> (forall x. Rep CreateResourceShare x -> CreateResourceShare)
-> Generic CreateResourceShare
forall x. Rep CreateResourceShare x -> CreateResourceShare
forall x. CreateResourceShare -> Rep CreateResourceShare x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateResourceShare x -> CreateResourceShare
$cfrom :: forall x. CreateResourceShare -> Rep CreateResourceShare x
Prelude.Generic)

-- |
-- Create a value of 'CreateResourceShare' 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:
--
-- 'clientToken', 'createResourceShare_clientToken' - A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
--
-- 'allowExternalPrincipals', 'createResourceShare_allowExternalPrincipals' - Indicates whether principals outside your organization in Organizations
-- can be associated with a resource share.
--
-- 'principals', 'createResourceShare_principals' - The principals to associate with the resource share. The possible values
-- are:
--
-- -   An Amazon Web Services account ID
--
-- -   An Amazon Resource Name (ARN) of an organization in Organizations
--
-- -   An ARN of an organizational unit (OU) in Organizations
--
-- -   An ARN of an IAM role
--
-- -   An ARN of an IAM user
--
-- Not all resource types can be shared with IAM roles and IAM users. For
-- more information, see
-- <https://docs.aws.amazon.com/ram/latest/userguide/permissions.html#permissions-rbp-supported-resource-types Sharing with IAM roles and IAM users>
-- in the /Resource Access Manager User Guide/.
--
-- 'resourceArns', 'createResourceShare_resourceArns' - The ARNs of the resources to associate with the resource share.
--
-- 'permissionArns', 'createResourceShare_permissionArns' - The Amazon Resource Names (ARNs) of the permissions to associate with
-- the resource share. If you do not specify an ARN for the permission, RAM
-- automatically attaches the default version of the permission for each
-- resource type. Only one permission can be associated with each resource
-- type in a resource share.
--
-- 'tags', 'createResourceShare_tags' - One or more tags.
--
-- 'name', 'createResourceShare_name' - The name of the resource share.
newCreateResourceShare ::
  -- | 'name'
  Prelude.Text ->
  CreateResourceShare
newCreateResourceShare :: Text -> CreateResourceShare
newCreateResourceShare Text
pName_ =
  CreateResourceShare' :: Maybe Text
-> Maybe Bool
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Tag]
-> Text
-> CreateResourceShare
CreateResourceShare'
    { $sel:clientToken:CreateResourceShare' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:allowExternalPrincipals:CreateResourceShare' :: Maybe Bool
allowExternalPrincipals = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:principals:CreateResourceShare' :: Maybe [Text]
principals = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArns:CreateResourceShare' :: Maybe [Text]
resourceArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:permissionArns:CreateResourceShare' :: Maybe [Text]
permissionArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateResourceShare' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateResourceShare' :: Text
name = Text
pName_
    }

-- | A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
createResourceShare_clientToken :: Lens.Lens' CreateResourceShare (Prelude.Maybe Prelude.Text)
createResourceShare_clientToken :: (Maybe Text -> f (Maybe Text))
-> CreateResourceShare -> f CreateResourceShare
createResourceShare_clientToken = (CreateResourceShare -> Maybe Text)
-> (CreateResourceShare -> Maybe Text -> CreateResourceShare)
-> Lens
     CreateResourceShare CreateResourceShare (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceShare' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:CreateResourceShare' :: CreateResourceShare -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: CreateResourceShare
s@CreateResourceShare' {} Maybe Text
a -> CreateResourceShare
s {$sel:clientToken:CreateResourceShare' :: Maybe Text
clientToken = Maybe Text
a} :: CreateResourceShare)

-- | Indicates whether principals outside your organization in Organizations
-- can be associated with a resource share.
createResourceShare_allowExternalPrincipals :: Lens.Lens' CreateResourceShare (Prelude.Maybe Prelude.Bool)
createResourceShare_allowExternalPrincipals :: (Maybe Bool -> f (Maybe Bool))
-> CreateResourceShare -> f CreateResourceShare
createResourceShare_allowExternalPrincipals = (CreateResourceShare -> Maybe Bool)
-> (CreateResourceShare -> Maybe Bool -> CreateResourceShare)
-> Lens
     CreateResourceShare CreateResourceShare (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceShare' {Maybe Bool
allowExternalPrincipals :: Maybe Bool
$sel:allowExternalPrincipals:CreateResourceShare' :: CreateResourceShare -> Maybe Bool
allowExternalPrincipals} -> Maybe Bool
allowExternalPrincipals) (\s :: CreateResourceShare
s@CreateResourceShare' {} Maybe Bool
a -> CreateResourceShare
s {$sel:allowExternalPrincipals:CreateResourceShare' :: Maybe Bool
allowExternalPrincipals = Maybe Bool
a} :: CreateResourceShare)

-- | The principals to associate with the resource share. The possible values
-- are:
--
-- -   An Amazon Web Services account ID
--
-- -   An Amazon Resource Name (ARN) of an organization in Organizations
--
-- -   An ARN of an organizational unit (OU) in Organizations
--
-- -   An ARN of an IAM role
--
-- -   An ARN of an IAM user
--
-- Not all resource types can be shared with IAM roles and IAM users. For
-- more information, see
-- <https://docs.aws.amazon.com/ram/latest/userguide/permissions.html#permissions-rbp-supported-resource-types Sharing with IAM roles and IAM users>
-- in the /Resource Access Manager User Guide/.
createResourceShare_principals :: Lens.Lens' CreateResourceShare (Prelude.Maybe [Prelude.Text])
createResourceShare_principals :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateResourceShare -> f CreateResourceShare
createResourceShare_principals = (CreateResourceShare -> Maybe [Text])
-> (CreateResourceShare -> Maybe [Text] -> CreateResourceShare)
-> Lens
     CreateResourceShare
     CreateResourceShare
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceShare' {Maybe [Text]
principals :: Maybe [Text]
$sel:principals:CreateResourceShare' :: CreateResourceShare -> Maybe [Text]
principals} -> Maybe [Text]
principals) (\s :: CreateResourceShare
s@CreateResourceShare' {} Maybe [Text]
a -> CreateResourceShare
s {$sel:principals:CreateResourceShare' :: Maybe [Text]
principals = Maybe [Text]
a} :: CreateResourceShare) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateResourceShare -> f CreateResourceShare)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateResourceShare
-> f CreateResourceShare
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ARNs of the resources to associate with the resource share.
createResourceShare_resourceArns :: Lens.Lens' CreateResourceShare (Prelude.Maybe [Prelude.Text])
createResourceShare_resourceArns :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateResourceShare -> f CreateResourceShare
createResourceShare_resourceArns = (CreateResourceShare -> Maybe [Text])
-> (CreateResourceShare -> Maybe [Text] -> CreateResourceShare)
-> Lens
     CreateResourceShare
     CreateResourceShare
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceShare' {Maybe [Text]
resourceArns :: Maybe [Text]
$sel:resourceArns:CreateResourceShare' :: CreateResourceShare -> Maybe [Text]
resourceArns} -> Maybe [Text]
resourceArns) (\s :: CreateResourceShare
s@CreateResourceShare' {} Maybe [Text]
a -> CreateResourceShare
s {$sel:resourceArns:CreateResourceShare' :: Maybe [Text]
resourceArns = Maybe [Text]
a} :: CreateResourceShare) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateResourceShare -> f CreateResourceShare)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateResourceShare
-> f CreateResourceShare
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Names (ARNs) of the permissions to associate with
-- the resource share. If you do not specify an ARN for the permission, RAM
-- automatically attaches the default version of the permission for each
-- resource type. Only one permission can be associated with each resource
-- type in a resource share.
createResourceShare_permissionArns :: Lens.Lens' CreateResourceShare (Prelude.Maybe [Prelude.Text])
createResourceShare_permissionArns :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateResourceShare -> f CreateResourceShare
createResourceShare_permissionArns = (CreateResourceShare -> Maybe [Text])
-> (CreateResourceShare -> Maybe [Text] -> CreateResourceShare)
-> Lens
     CreateResourceShare
     CreateResourceShare
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceShare' {Maybe [Text]
permissionArns :: Maybe [Text]
$sel:permissionArns:CreateResourceShare' :: CreateResourceShare -> Maybe [Text]
permissionArns} -> Maybe [Text]
permissionArns) (\s :: CreateResourceShare
s@CreateResourceShare' {} Maybe [Text]
a -> CreateResourceShare
s {$sel:permissionArns:CreateResourceShare' :: Maybe [Text]
permissionArns = Maybe [Text]
a} :: CreateResourceShare) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateResourceShare -> f CreateResourceShare)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateResourceShare
-> f CreateResourceShare
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | One or more tags.
createResourceShare_tags :: Lens.Lens' CreateResourceShare (Prelude.Maybe [Tag])
createResourceShare_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateResourceShare -> f CreateResourceShare
createResourceShare_tags = (CreateResourceShare -> Maybe [Tag])
-> (CreateResourceShare -> Maybe [Tag] -> CreateResourceShare)
-> Lens
     CreateResourceShare CreateResourceShare (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceShare' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateResourceShare' :: CreateResourceShare -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateResourceShare
s@CreateResourceShare' {} Maybe [Tag]
a -> CreateResourceShare
s {$sel:tags:CreateResourceShare' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateResourceShare) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateResourceShare -> f CreateResourceShare)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateResourceShare
-> f CreateResourceShare
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 of the resource share.
createResourceShare_name :: Lens.Lens' CreateResourceShare Prelude.Text
createResourceShare_name :: (Text -> f Text) -> CreateResourceShare -> f CreateResourceShare
createResourceShare_name = (CreateResourceShare -> Text)
-> (CreateResourceShare -> Text -> CreateResourceShare)
-> Lens CreateResourceShare CreateResourceShare Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceShare' {Text
name :: Text
$sel:name:CreateResourceShare' :: CreateResourceShare -> Text
name} -> Text
name) (\s :: CreateResourceShare
s@CreateResourceShare' {} Text
a -> CreateResourceShare
s {$sel:name:CreateResourceShare' :: Text
name = Text
a} :: CreateResourceShare)

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

instance Prelude.NFData CreateResourceShare

instance Core.ToHeaders CreateResourceShare where
  toHeaders :: CreateResourceShare -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateResourceShare -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 CreateResourceShare where
  toJSON :: CreateResourceShare -> Value
toJSON CreateResourceShare' {Maybe Bool
Maybe [Text]
Maybe [Tag]
Maybe Text
Text
name :: Text
tags :: Maybe [Tag]
permissionArns :: Maybe [Text]
resourceArns :: Maybe [Text]
principals :: Maybe [Text]
allowExternalPrincipals :: Maybe Bool
clientToken :: Maybe Text
$sel:name:CreateResourceShare' :: CreateResourceShare -> Text
$sel:tags:CreateResourceShare' :: CreateResourceShare -> Maybe [Tag]
$sel:permissionArns:CreateResourceShare' :: CreateResourceShare -> Maybe [Text]
$sel:resourceArns:CreateResourceShare' :: CreateResourceShare -> Maybe [Text]
$sel:principals:CreateResourceShare' :: CreateResourceShare -> Maybe [Text]
$sel:allowExternalPrincipals:CreateResourceShare' :: CreateResourceShare -> Maybe Bool
$sel:clientToken:CreateResourceShare' :: CreateResourceShare -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"clientToken" 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
clientToken,
            (Text
"allowExternalPrincipals" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
allowExternalPrincipals,
            (Text
"principals" 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]
principals,
            (Text
"resourceArns" 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]
resourceArns,
            (Text
"permissionArns" 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]
permissionArns,
            (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 CreateResourceShare where
  toPath :: CreateResourceShare -> ByteString
toPath = ByteString -> CreateResourceShare -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/createresourceshare"

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

-- | /See:/ 'newCreateResourceShareResponse' smart constructor.
data CreateResourceShareResponse = CreateResourceShareResponse'
  { -- | A unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request.
    CreateResourceShareResponse -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | Information about the resource share.
    CreateResourceShareResponse -> Maybe ResourceShare
resourceShare :: Prelude.Maybe ResourceShare,
    -- | The response's http status code.
    CreateResourceShareResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateResourceShareResponse -> CreateResourceShareResponse -> Bool
(CreateResourceShareResponse
 -> CreateResourceShareResponse -> Bool)
-> (CreateResourceShareResponse
    -> CreateResourceShareResponse -> Bool)
-> Eq CreateResourceShareResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateResourceShareResponse -> CreateResourceShareResponse -> Bool
$c/= :: CreateResourceShareResponse -> CreateResourceShareResponse -> Bool
== :: CreateResourceShareResponse -> CreateResourceShareResponse -> Bool
$c== :: CreateResourceShareResponse -> CreateResourceShareResponse -> Bool
Prelude.Eq, ReadPrec [CreateResourceShareResponse]
ReadPrec CreateResourceShareResponse
Int -> ReadS CreateResourceShareResponse
ReadS [CreateResourceShareResponse]
(Int -> ReadS CreateResourceShareResponse)
-> ReadS [CreateResourceShareResponse]
-> ReadPrec CreateResourceShareResponse
-> ReadPrec [CreateResourceShareResponse]
-> Read CreateResourceShareResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateResourceShareResponse]
$creadListPrec :: ReadPrec [CreateResourceShareResponse]
readPrec :: ReadPrec CreateResourceShareResponse
$creadPrec :: ReadPrec CreateResourceShareResponse
readList :: ReadS [CreateResourceShareResponse]
$creadList :: ReadS [CreateResourceShareResponse]
readsPrec :: Int -> ReadS CreateResourceShareResponse
$creadsPrec :: Int -> ReadS CreateResourceShareResponse
Prelude.Read, Int -> CreateResourceShareResponse -> ShowS
[CreateResourceShareResponse] -> ShowS
CreateResourceShareResponse -> String
(Int -> CreateResourceShareResponse -> ShowS)
-> (CreateResourceShareResponse -> String)
-> ([CreateResourceShareResponse] -> ShowS)
-> Show CreateResourceShareResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateResourceShareResponse] -> ShowS
$cshowList :: [CreateResourceShareResponse] -> ShowS
show :: CreateResourceShareResponse -> String
$cshow :: CreateResourceShareResponse -> String
showsPrec :: Int -> CreateResourceShareResponse -> ShowS
$cshowsPrec :: Int -> CreateResourceShareResponse -> ShowS
Prelude.Show, (forall x.
 CreateResourceShareResponse -> Rep CreateResourceShareResponse x)
-> (forall x.
    Rep CreateResourceShareResponse x -> CreateResourceShareResponse)
-> Generic CreateResourceShareResponse
forall x.
Rep CreateResourceShareResponse x -> CreateResourceShareResponse
forall x.
CreateResourceShareResponse -> Rep CreateResourceShareResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateResourceShareResponse x -> CreateResourceShareResponse
$cfrom :: forall x.
CreateResourceShareResponse -> Rep CreateResourceShareResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateResourceShareResponse' 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:
--
-- 'clientToken', 'createResourceShareResponse_clientToken' - A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
--
-- 'resourceShare', 'createResourceShareResponse_resourceShare' - Information about the resource share.
--
-- 'httpStatus', 'createResourceShareResponse_httpStatus' - The response's http status code.
newCreateResourceShareResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateResourceShareResponse
newCreateResourceShareResponse :: Int -> CreateResourceShareResponse
newCreateResourceShareResponse Int
pHttpStatus_ =
  CreateResourceShareResponse' :: Maybe Text
-> Maybe ResourceShare -> Int -> CreateResourceShareResponse
CreateResourceShareResponse'
    { $sel:clientToken:CreateResourceShareResponse' :: Maybe Text
clientToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceShare:CreateResourceShareResponse' :: Maybe ResourceShare
resourceShare = Maybe ResourceShare
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateResourceShareResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
createResourceShareResponse_clientToken :: Lens.Lens' CreateResourceShareResponse (Prelude.Maybe Prelude.Text)
createResourceShareResponse_clientToken :: (Maybe Text -> f (Maybe Text))
-> CreateResourceShareResponse -> f CreateResourceShareResponse
createResourceShareResponse_clientToken = (CreateResourceShareResponse -> Maybe Text)
-> (CreateResourceShareResponse
    -> Maybe Text -> CreateResourceShareResponse)
-> Lens
     CreateResourceShareResponse
     CreateResourceShareResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceShareResponse' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:CreateResourceShareResponse' :: CreateResourceShareResponse -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: CreateResourceShareResponse
s@CreateResourceShareResponse' {} Maybe Text
a -> CreateResourceShareResponse
s {$sel:clientToken:CreateResourceShareResponse' :: Maybe Text
clientToken = Maybe Text
a} :: CreateResourceShareResponse)

-- | Information about the resource share.
createResourceShareResponse_resourceShare :: Lens.Lens' CreateResourceShareResponse (Prelude.Maybe ResourceShare)
createResourceShareResponse_resourceShare :: (Maybe ResourceShare -> f (Maybe ResourceShare))
-> CreateResourceShareResponse -> f CreateResourceShareResponse
createResourceShareResponse_resourceShare = (CreateResourceShareResponse -> Maybe ResourceShare)
-> (CreateResourceShareResponse
    -> Maybe ResourceShare -> CreateResourceShareResponse)
-> Lens
     CreateResourceShareResponse
     CreateResourceShareResponse
     (Maybe ResourceShare)
     (Maybe ResourceShare)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceShareResponse' {Maybe ResourceShare
resourceShare :: Maybe ResourceShare
$sel:resourceShare:CreateResourceShareResponse' :: CreateResourceShareResponse -> Maybe ResourceShare
resourceShare} -> Maybe ResourceShare
resourceShare) (\s :: CreateResourceShareResponse
s@CreateResourceShareResponse' {} Maybe ResourceShare
a -> CreateResourceShareResponse
s {$sel:resourceShare:CreateResourceShareResponse' :: Maybe ResourceShare
resourceShare = Maybe ResourceShare
a} :: CreateResourceShareResponse)

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

instance Prelude.NFData CreateResourceShareResponse