{-# 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.FSx.ListTagsForResource -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Lists tags for Amazon FSx resources. -- -- When retrieving all tags, you can optionally specify the @MaxResults@ -- parameter to limit the number of tags in a response. If more tags -- remain, Amazon FSx returns a @NextToken@ value in the response. In this -- case, send a later request with the @NextToken@ request parameter set to -- the value of @NextToken@ from the last response. -- -- This action is used in an iterative process to retrieve a list of your -- tags. @ListTagsForResource@ is called first without a @NextToken@value. -- Then the action continues to be called with the @NextToken@ parameter -- set to the value of the last @NextToken@ value until a response has no -- @NextToken@. -- -- When using this action, keep the following in mind: -- -- - The implementation might return fewer than @MaxResults@ file system -- descriptions while still including a @NextToken@ value. -- -- - The order of tags returned in the response of one -- @ListTagsForResource@ call and the order of tags returned across the -- responses of a multi-call iteration is unspecified. -- -- This operation returns paginated results. module Amazonka.FSx.ListTagsForResource ( -- * Creating a Request ListTagsForResource (..), newListTagsForResource, -- * Request Lenses listTagsForResource_maxResults, listTagsForResource_nextToken, listTagsForResource_resourceARN, -- * Destructuring the Response ListTagsForResourceResponse (..), newListTagsForResourceResponse, -- * Response Lenses listTagsForResourceResponse_nextToken, listTagsForResourceResponse_tags, listTagsForResourceResponse_httpStatus, ) where import qualified Amazonka.Core as Core import qualified Amazonka.Core.Lens.Internal as Lens import qualified Amazonka.Data as Data import Amazonka.FSx.Types import qualified Amazonka.Prelude as Prelude import qualified Amazonka.Request as Request import qualified Amazonka.Response as Response -- | The request object for @ListTagsForResource@ operation. -- -- /See:/ 'newListTagsForResource' smart constructor. data ListTagsForResource = ListTagsForResource' { -- | Maximum number of tags to return in the response (integer). This -- parameter value must be greater than 0. The number of items that Amazon -- FSx returns is the minimum of the @MaxResults@ parameter specified in -- the request and the service\'s internal maximum number of items per -- page. maxResults :: Prelude.Maybe Prelude.Natural, -- | Opaque pagination token returned from a previous @ListTagsForResource@ -- operation (String). If a token present, the action continues the list -- from where the returning call left off. nextToken :: Prelude.Maybe Prelude.Text, -- | The ARN of the Amazon FSx resource that will have its tags listed. resourceARN :: Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListTagsForResource' 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: -- -- 'maxResults', 'listTagsForResource_maxResults' - Maximum number of tags to return in the response (integer). This -- parameter value must be greater than 0. The number of items that Amazon -- FSx returns is the minimum of the @MaxResults@ parameter specified in -- the request and the service\'s internal maximum number of items per -- page. -- -- 'nextToken', 'listTagsForResource_nextToken' - Opaque pagination token returned from a previous @ListTagsForResource@ -- operation (String). If a token present, the action continues the list -- from where the returning call left off. -- -- 'resourceARN', 'listTagsForResource_resourceARN' - The ARN of the Amazon FSx resource that will have its tags listed. newListTagsForResource :: -- | 'resourceARN' Prelude.Text -> ListTagsForResource newListTagsForResource pResourceARN_ = ListTagsForResource' { maxResults = Prelude.Nothing, nextToken = Prelude.Nothing, resourceARN = pResourceARN_ } -- | Maximum number of tags to return in the response (integer). This -- parameter value must be greater than 0. The number of items that Amazon -- FSx returns is the minimum of the @MaxResults@ parameter specified in -- the request and the service\'s internal maximum number of items per -- page. listTagsForResource_maxResults :: Lens.Lens' ListTagsForResource (Prelude.Maybe Prelude.Natural) listTagsForResource_maxResults = Lens.lens (\ListTagsForResource' {maxResults} -> maxResults) (\s@ListTagsForResource' {} a -> s {maxResults = a} :: ListTagsForResource) -- | Opaque pagination token returned from a previous @ListTagsForResource@ -- operation (String). If a token present, the action continues the list -- from where the returning call left off. listTagsForResource_nextToken :: Lens.Lens' ListTagsForResource (Prelude.Maybe Prelude.Text) listTagsForResource_nextToken = Lens.lens (\ListTagsForResource' {nextToken} -> nextToken) (\s@ListTagsForResource' {} a -> s {nextToken = a} :: ListTagsForResource) -- | The ARN of the Amazon FSx resource that will have its tags listed. listTagsForResource_resourceARN :: Lens.Lens' ListTagsForResource Prelude.Text listTagsForResource_resourceARN = Lens.lens (\ListTagsForResource' {resourceARN} -> resourceARN) (\s@ListTagsForResource' {} a -> s {resourceARN = a} :: ListTagsForResource) instance Core.AWSPager ListTagsForResource where page rq rs | Core.stop ( rs Lens.^? listTagsForResourceResponse_nextToken Prelude.. Lens._Just ) = Prelude.Nothing | Core.stop ( rs Lens.^? listTagsForResourceResponse_tags Prelude.. Lens._Just Prelude.. Lens.to Prelude.toList ) = Prelude.Nothing | Prelude.otherwise = Prelude.Just Prelude.$ rq Prelude.& listTagsForResource_nextToken Lens..~ rs Lens.^? listTagsForResourceResponse_nextToken Prelude.. Lens._Just instance Core.AWSRequest ListTagsForResource where type AWSResponse ListTagsForResource = ListTagsForResourceResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> ListTagsForResourceResponse' Prelude.<$> (x Data..?> "NextToken") Prelude.<*> (x Data..?> "Tags") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable ListTagsForResource where hashWithSalt _salt ListTagsForResource' {..} = _salt `Prelude.hashWithSalt` maxResults `Prelude.hashWithSalt` nextToken `Prelude.hashWithSalt` resourceARN instance Prelude.NFData ListTagsForResource where rnf ListTagsForResource' {..} = Prelude.rnf maxResults `Prelude.seq` Prelude.rnf nextToken `Prelude.seq` Prelude.rnf resourceARN instance Data.ToHeaders ListTagsForResource where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ( "AWSSimbaAPIService_v20180301.ListTagsForResource" :: Prelude.ByteString ), "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON ListTagsForResource where toJSON ListTagsForResource' {..} = Data.object ( Prelude.catMaybes [ ("MaxResults" Data..=) Prelude.<$> maxResults, ("NextToken" Data..=) Prelude.<$> nextToken, Prelude.Just ("ResourceARN" Data..= resourceARN) ] ) instance Data.ToPath ListTagsForResource where toPath = Prelude.const "/" instance Data.ToQuery ListTagsForResource where toQuery = Prelude.const Prelude.mempty -- | The response object for @ListTagsForResource@ operation. -- -- /See:/ 'newListTagsForResourceResponse' smart constructor. data ListTagsForResourceResponse = ListTagsForResourceResponse' { -- | This is present if there are more tags than returned in the response -- (String). You can use the @NextToken@ value in the later request to -- fetch the tags. nextToken :: Prelude.Maybe Prelude.Text, -- | A list of tags on the resource. tags :: Prelude.Maybe (Prelude.NonEmpty Tag), -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListTagsForResourceResponse' 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: -- -- 'nextToken', 'listTagsForResourceResponse_nextToken' - This is present if there are more tags than returned in the response -- (String). You can use the @NextToken@ value in the later request to -- fetch the tags. -- -- 'tags', 'listTagsForResourceResponse_tags' - A list of tags on the resource. -- -- 'httpStatus', 'listTagsForResourceResponse_httpStatus' - The response's http status code. newListTagsForResourceResponse :: -- | 'httpStatus' Prelude.Int -> ListTagsForResourceResponse newListTagsForResourceResponse pHttpStatus_ = ListTagsForResourceResponse' { nextToken = Prelude.Nothing, tags = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | This is present if there are more tags than returned in the response -- (String). You can use the @NextToken@ value in the later request to -- fetch the tags. listTagsForResourceResponse_nextToken :: Lens.Lens' ListTagsForResourceResponse (Prelude.Maybe Prelude.Text) listTagsForResourceResponse_nextToken = Lens.lens (\ListTagsForResourceResponse' {nextToken} -> nextToken) (\s@ListTagsForResourceResponse' {} a -> s {nextToken = a} :: ListTagsForResourceResponse) -- | A list of tags on the resource. listTagsForResourceResponse_tags :: Lens.Lens' ListTagsForResourceResponse (Prelude.Maybe (Prelude.NonEmpty Tag)) listTagsForResourceResponse_tags = Lens.lens (\ListTagsForResourceResponse' {tags} -> tags) (\s@ListTagsForResourceResponse' {} a -> s {tags = a} :: ListTagsForResourceResponse) Prelude.. Lens.mapping Lens.coerced -- | The response's http status code. listTagsForResourceResponse_httpStatus :: Lens.Lens' ListTagsForResourceResponse Prelude.Int listTagsForResourceResponse_httpStatus = Lens.lens (\ListTagsForResourceResponse' {httpStatus} -> httpStatus) (\s@ListTagsForResourceResponse' {} a -> s {httpStatus = a} :: ListTagsForResourceResponse) instance Prelude.NFData ListTagsForResourceResponse where rnf ListTagsForResourceResponse' {..} = Prelude.rnf nextToken `Prelude.seq` Prelude.rnf tags `Prelude.seq` Prelude.rnf httpStatus