{-# 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.DeviceFarm.ListOfferings -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Returns a list of products or offerings that the user can manage through -- the API. Each offering record indicates the recurring price per unit and -- the frequency for that offering. The API returns a @NotEligible@ error -- if the user is not permitted to invoke the operation. If you must be -- able to invoke this operation, contact -- . -- -- This operation returns paginated results. module Amazonka.DeviceFarm.ListOfferings ( -- * Creating a Request ListOfferings (..), newListOfferings, -- * Request Lenses listOfferings_nextToken, -- * Destructuring the Response ListOfferingsResponse (..), newListOfferingsResponse, -- * Response Lenses listOfferingsResponse_nextToken, listOfferingsResponse_offerings, listOfferingsResponse_httpStatus, ) where import qualified Amazonka.Core as Core import qualified Amazonka.Core.Lens.Internal as Lens import qualified Amazonka.Data as Data import Amazonka.DeviceFarm.Types import qualified Amazonka.Prelude as Prelude import qualified Amazonka.Request as Request import qualified Amazonka.Response as Response -- | Represents the request to list all offerings. -- -- /See:/ 'newListOfferings' smart constructor. data ListOfferings = ListOfferings' { -- | An identifier that was returned from the previous call to this -- operation, which can be used to return the next set of items in the -- list. nextToken :: Prelude.Maybe Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListOfferings' 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', 'listOfferings_nextToken' - An identifier that was returned from the previous call to this -- operation, which can be used to return the next set of items in the -- list. newListOfferings :: ListOfferings newListOfferings = ListOfferings' {nextToken = Prelude.Nothing} -- | An identifier that was returned from the previous call to this -- operation, which can be used to return the next set of items in the -- list. listOfferings_nextToken :: Lens.Lens' ListOfferings (Prelude.Maybe Prelude.Text) listOfferings_nextToken = Lens.lens (\ListOfferings' {nextToken} -> nextToken) (\s@ListOfferings' {} a -> s {nextToken = a} :: ListOfferings) instance Core.AWSPager ListOfferings where page rq rs | Core.stop ( rs Lens.^? listOfferingsResponse_nextToken Prelude.. Lens._Just ) = Prelude.Nothing | Core.stop ( rs Lens.^? listOfferingsResponse_offerings Prelude.. Lens._Just ) = Prelude.Nothing | Prelude.otherwise = Prelude.Just Prelude.$ rq Prelude.& listOfferings_nextToken Lens..~ rs Lens.^? listOfferingsResponse_nextToken Prelude.. Lens._Just instance Core.AWSRequest ListOfferings where type AWSResponse ListOfferings = ListOfferingsResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> ListOfferingsResponse' Prelude.<$> (x Data..?> "nextToken") Prelude.<*> (x Data..?> "offerings" Core..!@ Prelude.mempty) Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable ListOfferings where hashWithSalt _salt ListOfferings' {..} = _salt `Prelude.hashWithSalt` nextToken instance Prelude.NFData ListOfferings where rnf ListOfferings' {..} = Prelude.rnf nextToken instance Data.ToHeaders ListOfferings where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ( "DeviceFarm_20150623.ListOfferings" :: Prelude.ByteString ), "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON ListOfferings where toJSON ListOfferings' {..} = Data.object ( Prelude.catMaybes [("nextToken" Data..=) Prelude.<$> nextToken] ) instance Data.ToPath ListOfferings where toPath = Prelude.const "/" instance Data.ToQuery ListOfferings where toQuery = Prelude.const Prelude.mempty -- | Represents the return values of the list of offerings. -- -- /See:/ 'newListOfferingsResponse' smart constructor. data ListOfferingsResponse = ListOfferingsResponse' { -- | An identifier that was returned from the previous call to this -- operation, which can be used to return the next set of items in the -- list. nextToken :: Prelude.Maybe Prelude.Text, -- | A value that represents the list offering results. offerings :: Prelude.Maybe [Offering], -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListOfferingsResponse' 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', 'listOfferingsResponse_nextToken' - An identifier that was returned from the previous call to this -- operation, which can be used to return the next set of items in the -- list. -- -- 'offerings', 'listOfferingsResponse_offerings' - A value that represents the list offering results. -- -- 'httpStatus', 'listOfferingsResponse_httpStatus' - The response's http status code. newListOfferingsResponse :: -- | 'httpStatus' Prelude.Int -> ListOfferingsResponse newListOfferingsResponse pHttpStatus_ = ListOfferingsResponse' { nextToken = Prelude.Nothing, offerings = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | An identifier that was returned from the previous call to this -- operation, which can be used to return the next set of items in the -- list. listOfferingsResponse_nextToken :: Lens.Lens' ListOfferingsResponse (Prelude.Maybe Prelude.Text) listOfferingsResponse_nextToken = Lens.lens (\ListOfferingsResponse' {nextToken} -> nextToken) (\s@ListOfferingsResponse' {} a -> s {nextToken = a} :: ListOfferingsResponse) -- | A value that represents the list offering results. listOfferingsResponse_offerings :: Lens.Lens' ListOfferingsResponse (Prelude.Maybe [Offering]) listOfferingsResponse_offerings = Lens.lens (\ListOfferingsResponse' {offerings} -> offerings) (\s@ListOfferingsResponse' {} a -> s {offerings = a} :: ListOfferingsResponse) Prelude.. Lens.mapping Lens.coerced -- | The response's http status code. listOfferingsResponse_httpStatus :: Lens.Lens' ListOfferingsResponse Prelude.Int listOfferingsResponse_httpStatus = Lens.lens (\ListOfferingsResponse' {httpStatus} -> httpStatus) (\s@ListOfferingsResponse' {} a -> s {httpStatus = a} :: ListOfferingsResponse) instance Prelude.NFData ListOfferingsResponse where rnf ListOfferingsResponse' {..} = Prelude.rnf nextToken `Prelude.seq` Prelude.rnf offerings `Prelude.seq` Prelude.rnf httpStatus