{-# 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.Lightsail.CreateDomain -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Creates a domain resource for the specified domain (e.g., example.com). -- -- The @create domain@ operation supports tag-based access control via -- request tags. For more information, see the -- . module Amazonka.Lightsail.CreateDomain ( -- * Creating a Request CreateDomain (..), newCreateDomain, -- * Request Lenses createDomain_tags, createDomain_domainName, -- * Destructuring the Response CreateDomainResponse (..), newCreateDomainResponse, -- * Response Lenses createDomainResponse_operation, createDomainResponse_httpStatus, ) where import qualified Amazonka.Core as Core import qualified Amazonka.Core.Lens.Internal as Lens import qualified Amazonka.Data as Data import Amazonka.Lightsail.Types import qualified Amazonka.Prelude as Prelude import qualified Amazonka.Request as Request import qualified Amazonka.Response as Response -- | /See:/ 'newCreateDomain' smart constructor. data CreateDomain = CreateDomain' { -- | The tag keys and optional values to add to the resource during create. -- -- Use the @TagResource@ action to tag a resource after it\'s created. tags :: Prelude.Maybe [Tag], -- | The domain name to manage (e.g., @example.com@). domainName :: Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'CreateDomain' 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', 'createDomain_tags' - The tag keys and optional values to add to the resource during create. -- -- Use the @TagResource@ action to tag a resource after it\'s created. -- -- 'domainName', 'createDomain_domainName' - The domain name to manage (e.g., @example.com@). newCreateDomain :: -- | 'domainName' Prelude.Text -> CreateDomain newCreateDomain pDomainName_ = CreateDomain' { tags = Prelude.Nothing, domainName = pDomainName_ } -- | The tag keys and optional values to add to the resource during create. -- -- Use the @TagResource@ action to tag a resource after it\'s created. createDomain_tags :: Lens.Lens' CreateDomain (Prelude.Maybe [Tag]) createDomain_tags = Lens.lens (\CreateDomain' {tags} -> tags) (\s@CreateDomain' {} a -> s {tags = a} :: CreateDomain) Prelude.. Lens.mapping Lens.coerced -- | The domain name to manage (e.g., @example.com@). createDomain_domainName :: Lens.Lens' CreateDomain Prelude.Text createDomain_domainName = Lens.lens (\CreateDomain' {domainName} -> domainName) (\s@CreateDomain' {} a -> s {domainName = a} :: CreateDomain) instance Core.AWSRequest CreateDomain where type AWSResponse CreateDomain = CreateDomainResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> CreateDomainResponse' Prelude.<$> (x Data..?> "operation") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable CreateDomain where hashWithSalt _salt CreateDomain' {..} = _salt `Prelude.hashWithSalt` tags `Prelude.hashWithSalt` domainName instance Prelude.NFData CreateDomain where rnf CreateDomain' {..} = Prelude.rnf tags `Prelude.seq` Prelude.rnf domainName instance Data.ToHeaders CreateDomain where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ( "Lightsail_20161128.CreateDomain" :: Prelude.ByteString ), "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON CreateDomain where toJSON CreateDomain' {..} = Data.object ( Prelude.catMaybes [ ("tags" Data..=) Prelude.<$> tags, Prelude.Just ("domainName" Data..= domainName) ] ) instance Data.ToPath CreateDomain where toPath = Prelude.const "/" instance Data.ToQuery CreateDomain where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newCreateDomainResponse' smart constructor. data CreateDomainResponse = CreateDomainResponse' { -- | An array of objects that describe the result of the action, such as the -- status of the request, the timestamp of the request, and the resources -- affected by the request. operation :: Prelude.Maybe Operation, -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'CreateDomainResponse' 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: -- -- 'operation', 'createDomainResponse_operation' - An array of objects that describe the result of the action, such as the -- status of the request, the timestamp of the request, and the resources -- affected by the request. -- -- 'httpStatus', 'createDomainResponse_httpStatus' - The response's http status code. newCreateDomainResponse :: -- | 'httpStatus' Prelude.Int -> CreateDomainResponse newCreateDomainResponse pHttpStatus_ = CreateDomainResponse' { operation = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | An array of objects that describe the result of the action, such as the -- status of the request, the timestamp of the request, and the resources -- affected by the request. createDomainResponse_operation :: Lens.Lens' CreateDomainResponse (Prelude.Maybe Operation) createDomainResponse_operation = Lens.lens (\CreateDomainResponse' {operation} -> operation) (\s@CreateDomainResponse' {} a -> s {operation = a} :: CreateDomainResponse) -- | The response's http status code. createDomainResponse_httpStatus :: Lens.Lens' CreateDomainResponse Prelude.Int createDomainResponse_httpStatus = Lens.lens (\CreateDomainResponse' {httpStatus} -> httpStatus) (\s@CreateDomainResponse' {} a -> s {httpStatus = a} :: CreateDomainResponse) instance Prelude.NFData CreateDomainResponse where rnf CreateDomainResponse' {..} = Prelude.rnf operation `Prelude.seq` Prelude.rnf httpStatus