{-# 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.ListPermissions -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Retrieves a list of available RAM permissions that you can use for the -- supported resource types. module Amazonka.RAM.ListPermissions ( -- * Creating a Request ListPermissions (..), newListPermissions, -- * Request Lenses listPermissions_maxResults, listPermissions_nextToken, listPermissions_resourceType, -- * Destructuring the Response ListPermissionsResponse (..), newListPermissionsResponse, -- * Response Lenses listPermissionsResponse_nextToken, listPermissionsResponse_permissions, listPermissionsResponse_httpStatus, ) where import qualified Amazonka.Core as Core import qualified Amazonka.Core.Lens.Internal as Lens import qualified Amazonka.Data as Data import qualified Amazonka.Prelude as Prelude import Amazonka.RAM.Types import qualified Amazonka.Request as Request import qualified Amazonka.Response as Response -- | /See:/ 'newListPermissions' smart constructor. data ListPermissions = ListPermissions' { -- | Specifies the total number of results that you want included on each -- page of the response. If you do not include this parameter, it defaults -- to a value that is specific to the operation. If additional items exist -- beyond the number you specify, the @NextToken@ response element is -- returned with a value (not null). Include the specified value as the -- @NextToken@ request parameter in the next call to the operation to get -- the next part of the results. Note that the service might return fewer -- results than the maximum even when there are more results available. You -- should check @NextToken@ after every operation to ensure that you -- receive all of the results. maxResults :: Prelude.Maybe Prelude.Natural, -- | Specifies that you want to receive the next page of results. Valid only -- if you received a @NextToken@ response in the previous request. If you -- did, it indicates that more output is available. Set this parameter to -- the value provided by the previous call\'s @NextToken@ response to -- request the next page of results. nextToken :: Prelude.Maybe Prelude.Text, -- | Specifies that you want to list permissions for only the specified -- resource type. For example, to list only permissions that apply to EC2 -- subnets, specify @ec2:Subnet@. You can use the ListResourceTypes -- operation to get the specific string required. resourceType :: Prelude.Maybe Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListPermissions' 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', 'listPermissions_maxResults' - Specifies the total number of results that you want included on each -- page of the response. If you do not include this parameter, it defaults -- to a value that is specific to the operation. If additional items exist -- beyond the number you specify, the @NextToken@ response element is -- returned with a value (not null). Include the specified value as the -- @NextToken@ request parameter in the next call to the operation to get -- the next part of the results. Note that the service might return fewer -- results than the maximum even when there are more results available. You -- should check @NextToken@ after every operation to ensure that you -- receive all of the results. -- -- 'nextToken', 'listPermissions_nextToken' - Specifies that you want to receive the next page of results. Valid only -- if you received a @NextToken@ response in the previous request. If you -- did, it indicates that more output is available. Set this parameter to -- the value provided by the previous call\'s @NextToken@ response to -- request the next page of results. -- -- 'resourceType', 'listPermissions_resourceType' - Specifies that you want to list permissions for only the specified -- resource type. For example, to list only permissions that apply to EC2 -- subnets, specify @ec2:Subnet@. You can use the ListResourceTypes -- operation to get the specific string required. newListPermissions :: ListPermissions newListPermissions = ListPermissions' { maxResults = Prelude.Nothing, nextToken = Prelude.Nothing, resourceType = Prelude.Nothing } -- | Specifies the total number of results that you want included on each -- page of the response. If you do not include this parameter, it defaults -- to a value that is specific to the operation. If additional items exist -- beyond the number you specify, the @NextToken@ response element is -- returned with a value (not null). Include the specified value as the -- @NextToken@ request parameter in the next call to the operation to get -- the next part of the results. Note that the service might return fewer -- results than the maximum even when there are more results available. You -- should check @NextToken@ after every operation to ensure that you -- receive all of the results. listPermissions_maxResults :: Lens.Lens' ListPermissions (Prelude.Maybe Prelude.Natural) listPermissions_maxResults = Lens.lens (\ListPermissions' {maxResults} -> maxResults) (\s@ListPermissions' {} a -> s {maxResults = a} :: ListPermissions) -- | Specifies that you want to receive the next page of results. Valid only -- if you received a @NextToken@ response in the previous request. If you -- did, it indicates that more output is available. Set this parameter to -- the value provided by the previous call\'s @NextToken@ response to -- request the next page of results. listPermissions_nextToken :: Lens.Lens' ListPermissions (Prelude.Maybe Prelude.Text) listPermissions_nextToken = Lens.lens (\ListPermissions' {nextToken} -> nextToken) (\s@ListPermissions' {} a -> s {nextToken = a} :: ListPermissions) -- | Specifies that you want to list permissions for only the specified -- resource type. For example, to list only permissions that apply to EC2 -- subnets, specify @ec2:Subnet@. You can use the ListResourceTypes -- operation to get the specific string required. listPermissions_resourceType :: Lens.Lens' ListPermissions (Prelude.Maybe Prelude.Text) listPermissions_resourceType = Lens.lens (\ListPermissions' {resourceType} -> resourceType) (\s@ListPermissions' {} a -> s {resourceType = a} :: ListPermissions) instance Core.AWSRequest ListPermissions where type AWSResponse ListPermissions = ListPermissionsResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> ListPermissionsResponse' Prelude.<$> (x Data..?> "nextToken") Prelude.<*> (x Data..?> "permissions" Core..!@ Prelude.mempty) Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable ListPermissions where hashWithSalt _salt ListPermissions' {..} = _salt `Prelude.hashWithSalt` maxResults `Prelude.hashWithSalt` nextToken `Prelude.hashWithSalt` resourceType instance Prelude.NFData ListPermissions where rnf ListPermissions' {..} = Prelude.rnf maxResults `Prelude.seq` Prelude.rnf nextToken `Prelude.seq` Prelude.rnf resourceType instance Data.ToHeaders ListPermissions where toHeaders = Prelude.const ( Prelude.mconcat [ "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON ListPermissions where toJSON ListPermissions' {..} = Data.object ( Prelude.catMaybes [ ("maxResults" Data..=) Prelude.<$> maxResults, ("nextToken" Data..=) Prelude.<$> nextToken, ("resourceType" Data..=) Prelude.<$> resourceType ] ) instance Data.ToPath ListPermissions where toPath = Prelude.const "/listpermissions" instance Data.ToQuery ListPermissions where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newListPermissionsResponse' smart constructor. data ListPermissionsResponse = ListPermissionsResponse' { -- | If present, this value indicates that more output is available than is -- included in the current response. Use this value in the @NextToken@ -- request parameter in a subsequent call to the operation to get the next -- part of the output. You should repeat this until the @NextToken@ -- response element comes back as @null@. This indicates that this is the -- last page of results. nextToken :: Prelude.Maybe Prelude.Text, -- | An array of objects with information about the permissions. permissions :: Prelude.Maybe [ResourceSharePermissionSummary], -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListPermissionsResponse' 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', 'listPermissionsResponse_nextToken' - If present, this value indicates that more output is available than is -- included in the current response. Use this value in the @NextToken@ -- request parameter in a subsequent call to the operation to get the next -- part of the output. You should repeat this until the @NextToken@ -- response element comes back as @null@. This indicates that this is the -- last page of results. -- -- 'permissions', 'listPermissionsResponse_permissions' - An array of objects with information about the permissions. -- -- 'httpStatus', 'listPermissionsResponse_httpStatus' - The response's http status code. newListPermissionsResponse :: -- | 'httpStatus' Prelude.Int -> ListPermissionsResponse newListPermissionsResponse pHttpStatus_ = ListPermissionsResponse' { nextToken = Prelude.Nothing, permissions = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | If present, this value indicates that more output is available than is -- included in the current response. Use this value in the @NextToken@ -- request parameter in a subsequent call to the operation to get the next -- part of the output. You should repeat this until the @NextToken@ -- response element comes back as @null@. This indicates that this is the -- last page of results. listPermissionsResponse_nextToken :: Lens.Lens' ListPermissionsResponse (Prelude.Maybe Prelude.Text) listPermissionsResponse_nextToken = Lens.lens (\ListPermissionsResponse' {nextToken} -> nextToken) (\s@ListPermissionsResponse' {} a -> s {nextToken = a} :: ListPermissionsResponse) -- | An array of objects with information about the permissions. listPermissionsResponse_permissions :: Lens.Lens' ListPermissionsResponse (Prelude.Maybe [ResourceSharePermissionSummary]) listPermissionsResponse_permissions = Lens.lens (\ListPermissionsResponse' {permissions} -> permissions) (\s@ListPermissionsResponse' {} a -> s {permissions = a} :: ListPermissionsResponse) Prelude.. Lens.mapping Lens.coerced -- | The response's http status code. listPermissionsResponse_httpStatus :: Lens.Lens' ListPermissionsResponse Prelude.Int listPermissionsResponse_httpStatus = Lens.lens (\ListPermissionsResponse' {httpStatus} -> httpStatus) (\s@ListPermissionsResponse' {} a -> s {httpStatus = a} :: ListPermissionsResponse) instance Prelude.NFData ListPermissionsResponse where rnf ListPermissionsResponse' {..} = Prelude.rnf nextToken `Prelude.seq` Prelude.rnf permissions `Prelude.seq` Prelude.rnf httpStatus