{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- |
-- Module      : Gogol.Vault.Operations.Cancel
-- Copyright   : (c) 2015-2025 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+gogol@gmail.com>
--               Toni Cebrián <toni@tonicebrian.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn\'t support this method, it returns @google.rpc.Code.UNIMPLEMENTED@. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of @1@, corresponding to @Code.CANCELLED@.
--
-- /See:/ <https://developers.google.com/vault Google Vault API Reference> for @vault.operations.cancel@.
module Gogol.Vault.Operations.Cancel
  ( -- * Resource
    VaultOperationsCancelResource,

    -- ** Constructing a Request
    VaultOperationsCancel (..),
    newVaultOperationsCancel,
  )
where

import Gogol.Prelude qualified as Core
import Gogol.Vault.Types

-- | A resource alias for @vault.operations.cancel@ method which the
-- 'VaultOperationsCancel' request conforms to.
type VaultOperationsCancelResource =
  "v1"
    Core.:> Core.CaptureMode "name" "cancel" Core.Text
    Core.:> Core.QueryParam "$.xgafv" Xgafv
    Core.:> Core.QueryParam "access_token" Core.Text
    Core.:> Core.QueryParam "callback" Core.Text
    Core.:> Core.QueryParam "uploadType" Core.Text
    Core.:> Core.QueryParam "upload_protocol" Core.Text
    Core.:> Core.QueryParam "alt" Core.AltJSON
    Core.:> Core.ReqBody '[Core.JSON] CancelOperationRequest
    Core.:> Core.Post '[Core.JSON] Empty

-- | Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn\'t support this method, it returns @google.rpc.Code.UNIMPLEMENTED@. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of @1@, corresponding to @Code.CANCELLED@.
--
-- /See:/ 'newVaultOperationsCancel' smart constructor.
data VaultOperationsCancel = VaultOperationsCancel
  { -- | V1 error format.
    VaultOperationsCancel -> Maybe Xgafv
xgafv :: (Core.Maybe Xgafv),
    -- | OAuth access token.
    VaultOperationsCancel -> Maybe Text
accessToken :: (Core.Maybe Core.Text),
    -- | JSONP
    VaultOperationsCancel -> Maybe Text
callback :: (Core.Maybe Core.Text),
    -- | The name of the operation resource to be cancelled.
    VaultOperationsCancel -> Text
name :: Core.Text,
    -- | Multipart request metadata.
    VaultOperationsCancel -> CancelOperationRequest
payload :: CancelOperationRequest,
    -- | Legacy upload protocol for media (e.g. \"media\", \"multipart\").
    VaultOperationsCancel -> Maybe Text
uploadType :: (Core.Maybe Core.Text),
    -- | Upload protocol for media (e.g. \"raw\", \"multipart\").
    VaultOperationsCancel -> Maybe Text
uploadProtocol :: (Core.Maybe Core.Text)
  }
  deriving (VaultOperationsCancel -> VaultOperationsCancel -> Bool
(VaultOperationsCancel -> VaultOperationsCancel -> Bool)
-> (VaultOperationsCancel -> VaultOperationsCancel -> Bool)
-> Eq VaultOperationsCancel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VaultOperationsCancel -> VaultOperationsCancel -> Bool
== :: VaultOperationsCancel -> VaultOperationsCancel -> Bool
$c/= :: VaultOperationsCancel -> VaultOperationsCancel -> Bool
/= :: VaultOperationsCancel -> VaultOperationsCancel -> Bool
Core.Eq, Int -> VaultOperationsCancel -> ShowS
[VaultOperationsCancel] -> ShowS
VaultOperationsCancel -> String
(Int -> VaultOperationsCancel -> ShowS)
-> (VaultOperationsCancel -> String)
-> ([VaultOperationsCancel] -> ShowS)
-> Show VaultOperationsCancel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VaultOperationsCancel -> ShowS
showsPrec :: Int -> VaultOperationsCancel -> ShowS
$cshow :: VaultOperationsCancel -> String
show :: VaultOperationsCancel -> String
$cshowList :: [VaultOperationsCancel] -> ShowS
showList :: [VaultOperationsCancel] -> ShowS
Core.Show, (forall x. VaultOperationsCancel -> Rep VaultOperationsCancel x)
-> (forall x. Rep VaultOperationsCancel x -> VaultOperationsCancel)
-> Generic VaultOperationsCancel
forall x. Rep VaultOperationsCancel x -> VaultOperationsCancel
forall x. VaultOperationsCancel -> Rep VaultOperationsCancel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. VaultOperationsCancel -> Rep VaultOperationsCancel x
from :: forall x. VaultOperationsCancel -> Rep VaultOperationsCancel x
$cto :: forall x. Rep VaultOperationsCancel x -> VaultOperationsCancel
to :: forall x. Rep VaultOperationsCancel x -> VaultOperationsCancel
Core.Generic)

-- | Creates a value of 'VaultOperationsCancel' with the minimum fields required to make a request.
newVaultOperationsCancel ::
  -- |  The name of the operation resource to be cancelled. See 'name'.
  Core.Text ->
  -- |  Multipart request metadata. See 'payload'.
  CancelOperationRequest ->
  VaultOperationsCancel
newVaultOperationsCancel :: Text -> CancelOperationRequest -> VaultOperationsCancel
newVaultOperationsCancel Text
name CancelOperationRequest
payload =
  VaultOperationsCancel
    { xgafv :: Maybe Xgafv
xgafv = Maybe Xgafv
forall a. Maybe a
Core.Nothing,
      accessToken :: Maybe Text
accessToken = Maybe Text
forall a. Maybe a
Core.Nothing,
      callback :: Maybe Text
callback = Maybe Text
forall a. Maybe a
Core.Nothing,
      name :: Text
name = Text
name,
      payload :: CancelOperationRequest
payload = CancelOperationRequest
payload,
      uploadType :: Maybe Text
uploadType = Maybe Text
forall a. Maybe a
Core.Nothing,
      uploadProtocol :: Maybe Text
uploadProtocol = Maybe Text
forall a. Maybe a
Core.Nothing
    }

instance Core.GoogleRequest VaultOperationsCancel where
  type Rs VaultOperationsCancel = Empty
  type Scopes VaultOperationsCancel = '[Ediscovery'FullControl]
  requestClient :: VaultOperationsCancel -> GClient (Rs VaultOperationsCancel)
requestClient VaultOperationsCancel {Maybe Text
Maybe Xgafv
Text
CancelOperationRequest
xgafv :: VaultOperationsCancel -> Maybe Xgafv
accessToken :: VaultOperationsCancel -> Maybe Text
callback :: VaultOperationsCancel -> Maybe Text
name :: VaultOperationsCancel -> Text
payload :: VaultOperationsCancel -> CancelOperationRequest
uploadType :: VaultOperationsCancel -> Maybe Text
uploadProtocol :: VaultOperationsCancel -> Maybe Text
xgafv :: Maybe Xgafv
accessToken :: Maybe Text
callback :: Maybe Text
name :: Text
payload :: CancelOperationRequest
uploadType :: Maybe Text
uploadProtocol :: Maybe Text
..} =
    Text
-> Maybe Xgafv
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe AltJSON
-> CancelOperationRequest
-> ServiceConfig
-> GClient Empty
go
      Text
name
      Maybe Xgafv
xgafv
      Maybe Text
accessToken
      Maybe Text
callback
      Maybe Text
uploadType
      Maybe Text
uploadProtocol
      (AltJSON -> Maybe AltJSON
forall a. a -> Maybe a
Core.Just AltJSON
Core.AltJSON)
      CancelOperationRequest
payload
      ServiceConfig
vaultService
    where
      go :: Fn VaultOperationsCancelResource
go =
        Proxy VaultOperationsCancelResource
-> Request -> Fn VaultOperationsCancelResource
forall {k} (fn :: k).
GoogleClient fn =>
Proxy fn -> Request -> Fn fn
Core.buildClient
          (Proxy VaultOperationsCancelResource
forall {k} (t :: k). Proxy t
Core.Proxy :: Core.Proxy VaultOperationsCancelResource)
          Request
forall a. Monoid a => a
Core.mempty