{-# 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.Config.PutStoredQuery -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Saves a new query or updates an existing saved query. The @QueryName@ -- must be unique for a single Amazon Web Services account and a single -- Amazon Web Services Region. You can create upto 300 queries in a single -- Amazon Web Services account and a single Amazon Web Services Region. module Amazonka.Config.PutStoredQuery ( -- * Creating a Request PutStoredQuery (..), newPutStoredQuery, -- * Request Lenses putStoredQuery_tags, putStoredQuery_storedQuery, -- * Destructuring the Response PutStoredQueryResponse (..), newPutStoredQueryResponse, -- * Response Lenses putStoredQueryResponse_queryArn, putStoredQueryResponse_httpStatus, ) where import Amazonka.Config.Types 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 qualified Amazonka.Request as Request import qualified Amazonka.Response as Response -- | /See:/ 'newPutStoredQuery' smart constructor. data PutStoredQuery = PutStoredQuery' { -- | A list of @Tags@ object. tags :: Prelude.Maybe [Tag], -- | A list of @StoredQuery@ objects. The mandatory fields are @QueryName@ -- and @Expression@. -- -- When you are creating a query, you must provide a query name and an -- expression. When you are updating a query, you must provide a query name -- but updating the description is optional. storedQuery :: StoredQuery } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'PutStoredQuery' 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: -- -- 'tags', 'putStoredQuery_tags' - A list of @Tags@ object. -- -- 'storedQuery', 'putStoredQuery_storedQuery' - A list of @StoredQuery@ objects. The mandatory fields are @QueryName@ -- and @Expression@. -- -- When you are creating a query, you must provide a query name and an -- expression. When you are updating a query, you must provide a query name -- but updating the description is optional. newPutStoredQuery :: -- | 'storedQuery' StoredQuery -> PutStoredQuery newPutStoredQuery pStoredQuery_ = PutStoredQuery' { tags = Prelude.Nothing, storedQuery = pStoredQuery_ } -- | A list of @Tags@ object. putStoredQuery_tags :: Lens.Lens' PutStoredQuery (Prelude.Maybe [Tag]) putStoredQuery_tags = Lens.lens (\PutStoredQuery' {tags} -> tags) (\s@PutStoredQuery' {} a -> s {tags = a} :: PutStoredQuery) Prelude.. Lens.mapping Lens.coerced -- | A list of @StoredQuery@ objects. The mandatory fields are @QueryName@ -- and @Expression@. -- -- When you are creating a query, you must provide a query name and an -- expression. When you are updating a query, you must provide a query name -- but updating the description is optional. putStoredQuery_storedQuery :: Lens.Lens' PutStoredQuery StoredQuery putStoredQuery_storedQuery = Lens.lens (\PutStoredQuery' {storedQuery} -> storedQuery) (\s@PutStoredQuery' {} a -> s {storedQuery = a} :: PutStoredQuery) instance Core.AWSRequest PutStoredQuery where type AWSResponse PutStoredQuery = PutStoredQueryResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> PutStoredQueryResponse' Prelude.<$> (x Data..?> "QueryArn") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable PutStoredQuery where hashWithSalt _salt PutStoredQuery' {..} = _salt `Prelude.hashWithSalt` tags `Prelude.hashWithSalt` storedQuery instance Prelude.NFData PutStoredQuery where rnf PutStoredQuery' {..} = Prelude.rnf tags `Prelude.seq` Prelude.rnf storedQuery instance Data.ToHeaders PutStoredQuery where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ( "StarlingDoveService.PutStoredQuery" :: Prelude.ByteString ), "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON PutStoredQuery where toJSON PutStoredQuery' {..} = Data.object ( Prelude.catMaybes [ ("Tags" Data..=) Prelude.<$> tags, Prelude.Just ("StoredQuery" Data..= storedQuery) ] ) instance Data.ToPath PutStoredQuery where toPath = Prelude.const "/" instance Data.ToQuery PutStoredQuery where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newPutStoredQueryResponse' smart constructor. data PutStoredQueryResponse = PutStoredQueryResponse' { -- | Amazon Resource Name (ARN) of the query. For example, -- arn:partition:service:region:account-id:resource-type\/resource-name\/resource-id. queryArn :: Prelude.Maybe Prelude.Text, -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'PutStoredQueryResponse' 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: -- -- 'queryArn', 'putStoredQueryResponse_queryArn' - Amazon Resource Name (ARN) of the query. For example, -- arn:partition:service:region:account-id:resource-type\/resource-name\/resource-id. -- -- 'httpStatus', 'putStoredQueryResponse_httpStatus' - The response's http status code. newPutStoredQueryResponse :: -- | 'httpStatus' Prelude.Int -> PutStoredQueryResponse newPutStoredQueryResponse pHttpStatus_ = PutStoredQueryResponse' { queryArn = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | Amazon Resource Name (ARN) of the query. For example, -- arn:partition:service:region:account-id:resource-type\/resource-name\/resource-id. putStoredQueryResponse_queryArn :: Lens.Lens' PutStoredQueryResponse (Prelude.Maybe Prelude.Text) putStoredQueryResponse_queryArn = Lens.lens (\PutStoredQueryResponse' {queryArn} -> queryArn) (\s@PutStoredQueryResponse' {} a -> s {queryArn = a} :: PutStoredQueryResponse) -- | The response's http status code. putStoredQueryResponse_httpStatus :: Lens.Lens' PutStoredQueryResponse Prelude.Int putStoredQueryResponse_httpStatus = Lens.lens (\PutStoredQueryResponse' {httpStatus} -> httpStatus) (\s@PutStoredQueryResponse' {} a -> s {httpStatus = a} :: PutStoredQueryResponse) instance Prelude.NFData PutStoredQueryResponse where rnf PutStoredQueryResponse' {..} = Prelude.rnf queryArn `Prelude.seq` Prelude.rnf httpStatus