{-# LANGUAGE DataKinds          #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric      #-}
{-# LANGUAGE FlexibleInstances  #-}
{-# LANGUAGE NoImplicitPrelude  #-}
{-# LANGUAGE OverloadedStrings  #-}
{-# LANGUAGE RecordWildCards    #-}
{-# LANGUAGE TypeFamilies       #-}
{-# LANGUAGE TypeOperators      #-}

{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds      #-}
{-# OPTIONS_GHC -fno-warn-unused-imports    #-}

-- |
-- Module      : Network.Google.Resource.SQL.Instances.Export
-- Copyright   : (c) 2015-2016 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Exports data from a Cloud SQL instance to a Cloud Storage bucket as a
-- SQL dump or CSV file.
--
-- /See:/ <https://cloud.google.com/sql/docs/reference/latest Cloud SQL Admin API Reference> for @sql.instances.export@.
module Network.Google.Resource.SQL.Instances.Export
    (
    -- * REST Resource
      InstancesExportResource

    -- * Creating a Request
    , instancesExport
    , InstancesExport

    -- * Request Lenses
    , ieProject
    , iePayload
    , ieInstance
    ) where

import           Network.Google.Prelude
import           Network.Google.SQLAdmin.Types

-- | A resource alias for @sql.instances.export@ method which the
-- 'InstancesExport' request conforms to.
type InstancesExportResource =
     "sql" :>
       "v1beta4" :>
         "projects" :>
           Capture "project" Text :>
             "instances" :>
               Capture "instance" Text :>
                 "export" :>
                   QueryParam "alt" AltJSON :>
                     ReqBody '[JSON] InstancesExportRequest :>
                       Post '[JSON] Operation

-- | Exports data from a Cloud SQL instance to a Cloud Storage bucket as a
-- SQL dump or CSV file.
--
-- /See:/ 'instancesExport' smart constructor.
data InstancesExport = InstancesExport'
    { _ieProject  :: !Text
    , _iePayload  :: !InstancesExportRequest
    , _ieInstance :: !Text
    } deriving (Eq,Show,Data,Typeable,Generic)

-- | Creates a value of 'InstancesExport' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'ieProject'
--
-- * 'iePayload'
--
-- * 'ieInstance'
instancesExport
    :: Text -- ^ 'ieProject'
    -> InstancesExportRequest -- ^ 'iePayload'
    -> Text -- ^ 'ieInstance'
    -> InstancesExport
instancesExport pIeProject_ pIePayload_ pIeInstance_ =
    InstancesExport'
    { _ieProject = pIeProject_
    , _iePayload = pIePayload_
    , _ieInstance = pIeInstance_
    }

-- | Project ID of the project that contains the instance to be exported.
ieProject :: Lens' InstancesExport Text
ieProject
  = lens _ieProject (\ s a -> s{_ieProject = a})

-- | Multipart request metadata.
iePayload :: Lens' InstancesExport InstancesExportRequest
iePayload
  = lens _iePayload (\ s a -> s{_iePayload = a})

-- | Cloud SQL instance ID. This does not include the project ID.
ieInstance :: Lens' InstancesExport Text
ieInstance
  = lens _ieInstance (\ s a -> s{_ieInstance = a})

instance GoogleRequest InstancesExport where
        type Rs InstancesExport = Operation
        type Scopes InstancesExport =
             '["https://www.googleapis.com/auth/cloud-platform"]
        requestClient InstancesExport'{..}
          = go _ieProject _ieInstance (Just AltJSON) _iePayload
              sQLAdminService
          where go
                  = buildClient
                      (Proxy :: Proxy InstancesExportResource)
                      mempty