{-# 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.KMS.ListAliases -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Gets a list of aliases in the caller\'s Amazon Web Services account and -- region. For more information about aliases, see CreateAlias. -- -- By default, the @ListAliases@ operation returns all aliases in the -- account and region. To get only the aliases associated with a particular -- KMS key, use the @KeyId@ parameter. -- -- The @ListAliases@ response can include aliases that you created and -- associated with your customer managed keys, and aliases that Amazon Web -- Services created and associated with Amazon Web Services managed keys in -- your account. You can recognize Amazon Web Services aliases because -- their names have the format @aws\/\@, such as -- @aws\/dynamodb@. -- -- The response might also include aliases that have no @TargetKeyId@ -- field. These are predefined aliases that Amazon Web Services has created -- but has not yet associated with a KMS key. Aliases that Amazon Web -- Services creates in your account, including predefined aliases, do not -- count against your -- . -- -- __Cross-account use__: No. @ListAliases@ does not return aliases in -- other Amazon Web Services accounts. -- -- __Required permissions__: -- -- (IAM policy) -- -- For details, see -- -- in the /Key Management Service Developer Guide/. -- -- __Related operations:__ -- -- - CreateAlias -- -- - DeleteAlias -- -- - UpdateAlias -- -- This operation returns paginated results. module Amazonka.KMS.ListAliases ( -- * Creating a Request ListAliases (..), newListAliases, -- * Request Lenses listAliases_keyId, listAliases_limit, listAliases_marker, -- * Destructuring the Response ListAliasesResponse (..), newListAliasesResponse, -- * Response Lenses listAliasesResponse_aliases, listAliasesResponse_nextMarker, listAliasesResponse_truncated, listAliasesResponse_httpStatus, ) where import qualified Amazonka.Core as Core import qualified Amazonka.Core.Lens.Internal as Lens import qualified Amazonka.Data as Data import Amazonka.KMS.Types import qualified Amazonka.Prelude as Prelude import qualified Amazonka.Request as Request import qualified Amazonka.Response as Response -- | /See:/ 'newListAliases' smart constructor. data ListAliases = ListAliases' { -- | Lists only aliases that are associated with the specified KMS key. Enter -- a KMS key in your Amazon Web Services account. -- -- This parameter is optional. If you omit it, @ListAliases@ returns all -- aliases in the account and Region. -- -- Specify the key ID or key ARN of the KMS key. -- -- For example: -- -- - Key ID: @1234abcd-12ab-34cd-56ef-1234567890ab@ -- -- - Key ARN: -- @arn:aws:kms:us-east-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@ -- -- To get the key ID and key ARN for a KMS key, use ListKeys or -- DescribeKey. keyId :: Prelude.Maybe Prelude.Text, -- | Use this parameter to specify the maximum number of items to return. -- When this value is present, KMS does not return more than the specified -- number of items, but it might return fewer. -- -- This value is optional. If you include a value, it must be between 1 and -- 100, inclusive. If you do not include a value, it defaults to 50. limit :: Prelude.Maybe Prelude.Natural, -- | Use this parameter in a subsequent request after you receive a response -- with truncated results. Set it to the value of @NextMarker@ from the -- truncated response you just received. marker :: Prelude.Maybe Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListAliases' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'keyId', 'listAliases_keyId' - Lists only aliases that are associated with the specified KMS key. Enter -- a KMS key in your Amazon Web Services account. -- -- This parameter is optional. If you omit it, @ListAliases@ returns all -- aliases in the account and Region. -- -- Specify the key ID or key ARN of the KMS key. -- -- For example: -- -- - Key ID: @1234abcd-12ab-34cd-56ef-1234567890ab@ -- -- - Key ARN: -- @arn:aws:kms:us-east-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@ -- -- To get the key ID and key ARN for a KMS key, use ListKeys or -- DescribeKey. -- -- 'limit', 'listAliases_limit' - Use this parameter to specify the maximum number of items to return. -- When this value is present, KMS does not return more than the specified -- number of items, but it might return fewer. -- -- This value is optional. If you include a value, it must be between 1 and -- 100, inclusive. If you do not include a value, it defaults to 50. -- -- 'marker', 'listAliases_marker' - Use this parameter in a subsequent request after you receive a response -- with truncated results. Set it to the value of @NextMarker@ from the -- truncated response you just received. newListAliases :: ListAliases newListAliases = ListAliases' { keyId = Prelude.Nothing, limit = Prelude.Nothing, marker = Prelude.Nothing } -- | Lists only aliases that are associated with the specified KMS key. Enter -- a KMS key in your Amazon Web Services account. -- -- This parameter is optional. If you omit it, @ListAliases@ returns all -- aliases in the account and Region. -- -- Specify the key ID or key ARN of the KMS key. -- -- For example: -- -- - Key ID: @1234abcd-12ab-34cd-56ef-1234567890ab@ -- -- - Key ARN: -- @arn:aws:kms:us-east-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@ -- -- To get the key ID and key ARN for a KMS key, use ListKeys or -- DescribeKey. listAliases_keyId :: Lens.Lens' ListAliases (Prelude.Maybe Prelude.Text) listAliases_keyId = Lens.lens (\ListAliases' {keyId} -> keyId) (\s@ListAliases' {} a -> s {keyId = a} :: ListAliases) -- | Use this parameter to specify the maximum number of items to return. -- When this value is present, KMS does not return more than the specified -- number of items, but it might return fewer. -- -- This value is optional. If you include a value, it must be between 1 and -- 100, inclusive. If you do not include a value, it defaults to 50. listAliases_limit :: Lens.Lens' ListAliases (Prelude.Maybe Prelude.Natural) listAliases_limit = Lens.lens (\ListAliases' {limit} -> limit) (\s@ListAliases' {} a -> s {limit = a} :: ListAliases) -- | Use this parameter in a subsequent request after you receive a response -- with truncated results. Set it to the value of @NextMarker@ from the -- truncated response you just received. listAliases_marker :: Lens.Lens' ListAliases (Prelude.Maybe Prelude.Text) listAliases_marker = Lens.lens (\ListAliases' {marker} -> marker) (\s@ListAliases' {} a -> s {marker = a} :: ListAliases) instance Core.AWSPager ListAliases where page rq rs | Core.stop ( rs Lens.^? listAliasesResponse_truncated Prelude.. Lens._Just ) = Prelude.Nothing | Prelude.isNothing ( rs Lens.^? listAliasesResponse_nextMarker Prelude.. Lens._Just ) = Prelude.Nothing | Prelude.otherwise = Prelude.Just Prelude.$ rq Prelude.& listAliases_marker Lens..~ rs Lens.^? listAliasesResponse_nextMarker Prelude.. Lens._Just instance Core.AWSRequest ListAliases where type AWSResponse ListAliases = ListAliasesResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> ListAliasesResponse' Prelude.<$> (x Data..?> "Aliases" Core..!@ Prelude.mempty) Prelude.<*> (x Data..?> "NextMarker") Prelude.<*> (x Data..?> "Truncated") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable ListAliases where hashWithSalt _salt ListAliases' {..} = _salt `Prelude.hashWithSalt` keyId `Prelude.hashWithSalt` limit `Prelude.hashWithSalt` marker instance Prelude.NFData ListAliases where rnf ListAliases' {..} = Prelude.rnf keyId `Prelude.seq` Prelude.rnf limit `Prelude.seq` Prelude.rnf marker instance Data.ToHeaders ListAliases where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ("TrentService.ListAliases" :: Prelude.ByteString), "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON ListAliases where toJSON ListAliases' {..} = Data.object ( Prelude.catMaybes [ ("KeyId" Data..=) Prelude.<$> keyId, ("Limit" Data..=) Prelude.<$> limit, ("Marker" Data..=) Prelude.<$> marker ] ) instance Data.ToPath ListAliases where toPath = Prelude.const "/" instance Data.ToQuery ListAliases where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newListAliasesResponse' smart constructor. data ListAliasesResponse = ListAliasesResponse' { -- | A list of aliases. aliases :: Prelude.Maybe [AliasListEntry], -- | When @Truncated@ is true, this element is present and contains the value -- to use for the @Marker@ parameter in a subsequent request. nextMarker :: Prelude.Maybe Prelude.Text, -- | A flag that indicates whether there are more items in the list. When -- this value is true, the list in this response is truncated. To get more -- items, pass the value of the @NextMarker@ element in thisresponse to the -- @Marker@ parameter in a subsequent request. truncated :: Prelude.Maybe Prelude.Bool, -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListAliasesResponse' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'aliases', 'listAliasesResponse_aliases' - A list of aliases. -- -- 'nextMarker', 'listAliasesResponse_nextMarker' - When @Truncated@ is true, this element is present and contains the value -- to use for the @Marker@ parameter in a subsequent request. -- -- 'truncated', 'listAliasesResponse_truncated' - A flag that indicates whether there are more items in the list. When -- this value is true, the list in this response is truncated. To get more -- items, pass the value of the @NextMarker@ element in thisresponse to the -- @Marker@ parameter in a subsequent request. -- -- 'httpStatus', 'listAliasesResponse_httpStatus' - The response's http status code. newListAliasesResponse :: -- | 'httpStatus' Prelude.Int -> ListAliasesResponse newListAliasesResponse pHttpStatus_ = ListAliasesResponse' { aliases = Prelude.Nothing, nextMarker = Prelude.Nothing, truncated = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | A list of aliases. listAliasesResponse_aliases :: Lens.Lens' ListAliasesResponse (Prelude.Maybe [AliasListEntry]) listAliasesResponse_aliases = Lens.lens (\ListAliasesResponse' {aliases} -> aliases) (\s@ListAliasesResponse' {} a -> s {aliases = a} :: ListAliasesResponse) Prelude.. Lens.mapping Lens.coerced -- | When @Truncated@ is true, this element is present and contains the value -- to use for the @Marker@ parameter in a subsequent request. listAliasesResponse_nextMarker :: Lens.Lens' ListAliasesResponse (Prelude.Maybe Prelude.Text) listAliasesResponse_nextMarker = Lens.lens (\ListAliasesResponse' {nextMarker} -> nextMarker) (\s@ListAliasesResponse' {} a -> s {nextMarker = a} :: ListAliasesResponse) -- | A flag that indicates whether there are more items in the list. When -- this value is true, the list in this response is truncated. To get more -- items, pass the value of the @NextMarker@ element in thisresponse to the -- @Marker@ parameter in a subsequent request. listAliasesResponse_truncated :: Lens.Lens' ListAliasesResponse (Prelude.Maybe Prelude.Bool) listAliasesResponse_truncated = Lens.lens (\ListAliasesResponse' {truncated} -> truncated) (\s@ListAliasesResponse' {} a -> s {truncated = a} :: ListAliasesResponse) -- | The response's http status code. listAliasesResponse_httpStatus :: Lens.Lens' ListAliasesResponse Prelude.Int listAliasesResponse_httpStatus = Lens.lens (\ListAliasesResponse' {httpStatus} -> httpStatus) (\s@ListAliasesResponse' {} a -> s {httpStatus = a} :: ListAliasesResponse) instance Prelude.NFData ListAliasesResponse where rnf ListAliasesResponse' {..} = Prelude.rnf aliases `Prelude.seq` Prelude.rnf nextMarker `Prelude.seq` Prelude.rnf truncated `Prelude.seq` Prelude.rnf httpStatus