{-# 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.CodePipeline.PutWebhook -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Defines a webhook and returns a unique webhook URL generated by -- CodePipeline. This URL can be supplied to third party source hosting -- providers to call every time there\'s a code change. When CodePipeline -- receives a POST request on this URL, the pipeline defined in the webhook -- is started as long as the POST request satisfied the authentication and -- filtering requirements supplied when defining the webhook. -- RegisterWebhookWithThirdParty and DeregisterWebhookWithThirdParty APIs -- can be used to automatically configure supported third parties to call -- the generated webhook URL. module Amazonka.CodePipeline.PutWebhook ( -- * Creating a Request PutWebhook (..), newPutWebhook, -- * Request Lenses putWebhook_tags, putWebhook_webhook, -- * Destructuring the Response PutWebhookResponse (..), newPutWebhookResponse, -- * Response Lenses putWebhookResponse_webhook, putWebhookResponse_httpStatus, ) where import Amazonka.CodePipeline.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:/ 'newPutWebhook' smart constructor. data PutWebhook = PutWebhook' { -- | The tags for the webhook. tags :: Prelude.Maybe [Tag], -- | The detail provided in an input file to create the webhook, such as the -- webhook name, the pipeline name, and the action name. Give the webhook a -- unique name that helps you identify it. You might name the webhook after -- the pipeline and action it targets so that you can easily recognize what -- it\'s used for later. webhook :: WebhookDefinition } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'PutWebhook' 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', 'putWebhook_tags' - The tags for the webhook. -- -- 'webhook', 'putWebhook_webhook' - The detail provided in an input file to create the webhook, such as the -- webhook name, the pipeline name, and the action name. Give the webhook a -- unique name that helps you identify it. You might name the webhook after -- the pipeline and action it targets so that you can easily recognize what -- it\'s used for later. newPutWebhook :: -- | 'webhook' WebhookDefinition -> PutWebhook newPutWebhook pWebhook_ = PutWebhook' { tags = Prelude.Nothing, webhook = pWebhook_ } -- | The tags for the webhook. putWebhook_tags :: Lens.Lens' PutWebhook (Prelude.Maybe [Tag]) putWebhook_tags = Lens.lens (\PutWebhook' {tags} -> tags) (\s@PutWebhook' {} a -> s {tags = a} :: PutWebhook) Prelude.. Lens.mapping Lens.coerced -- | The detail provided in an input file to create the webhook, such as the -- webhook name, the pipeline name, and the action name. Give the webhook a -- unique name that helps you identify it. You might name the webhook after -- the pipeline and action it targets so that you can easily recognize what -- it\'s used for later. putWebhook_webhook :: Lens.Lens' PutWebhook WebhookDefinition putWebhook_webhook = Lens.lens (\PutWebhook' {webhook} -> webhook) (\s@PutWebhook' {} a -> s {webhook = a} :: PutWebhook) instance Core.AWSRequest PutWebhook where type AWSResponse PutWebhook = PutWebhookResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> PutWebhookResponse' Prelude.<$> (x Data..?> "webhook") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable PutWebhook where hashWithSalt _salt PutWebhook' {..} = _salt `Prelude.hashWithSalt` tags `Prelude.hashWithSalt` webhook instance Prelude.NFData PutWebhook where rnf PutWebhook' {..} = Prelude.rnf tags `Prelude.seq` Prelude.rnf webhook instance Data.ToHeaders PutWebhook where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ( "CodePipeline_20150709.PutWebhook" :: Prelude.ByteString ), "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON PutWebhook where toJSON PutWebhook' {..} = Data.object ( Prelude.catMaybes [ ("tags" Data..=) Prelude.<$> tags, Prelude.Just ("webhook" Data..= webhook) ] ) instance Data.ToPath PutWebhook where toPath = Prelude.const "/" instance Data.ToQuery PutWebhook where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newPutWebhookResponse' smart constructor. data PutWebhookResponse = PutWebhookResponse' { -- | The detail returned from creating the webhook, such as the webhook name, -- webhook URL, and webhook ARN. webhook :: Prelude.Maybe ListWebhookItem, -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'PutWebhookResponse' 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: -- -- 'webhook', 'putWebhookResponse_webhook' - The detail returned from creating the webhook, such as the webhook name, -- webhook URL, and webhook ARN. -- -- 'httpStatus', 'putWebhookResponse_httpStatus' - The response's http status code. newPutWebhookResponse :: -- | 'httpStatus' Prelude.Int -> PutWebhookResponse newPutWebhookResponse pHttpStatus_ = PutWebhookResponse' { webhook = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | The detail returned from creating the webhook, such as the webhook name, -- webhook URL, and webhook ARN. putWebhookResponse_webhook :: Lens.Lens' PutWebhookResponse (Prelude.Maybe ListWebhookItem) putWebhookResponse_webhook = Lens.lens (\PutWebhookResponse' {webhook} -> webhook) (\s@PutWebhookResponse' {} a -> s {webhook = a} :: PutWebhookResponse) -- | The response's http status code. putWebhookResponse_httpStatus :: Lens.Lens' PutWebhookResponse Prelude.Int putWebhookResponse_httpStatus = Lens.lens (\PutWebhookResponse' {httpStatus} -> httpStatus) (\s@PutWebhookResponse' {} a -> s {httpStatus = a} :: PutWebhookResponse) instance Prelude.NFData PutWebhookResponse where rnf PutWebhookResponse' {..} = Prelude.rnf webhook `Prelude.seq` Prelude.rnf httpStatus