LCOV - code coverage report
Current view: top level - port - cpl_google_cloud.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 6 6 100.0 %
Date: 2024-11-21 22:18:42 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /**********************************************************************
       2             :  * Project:  CPL - Common Portability Library
       3             :  * Purpose:  Google Cloud Storage routines
       4             :  * Author:   Even Rouault <even.rouault at spatialys.com>
       5             :  *
       6             :  **********************************************************************
       7             :  * Copyright (c) 2017, Even Rouault <even.rouault at spatialys.com>
       8             :  *
       9             :  * SPDX-License-Identifier: MIT
      10             :  ****************************************************************************/
      11             : 
      12             : #ifndef CPL_GOOGLE_CLOUD_INCLUDED_H
      13             : #define CPL_GOOGLE_CLOUD_INCLUDED_H
      14             : 
      15             : #ifndef DOXYGEN_SKIP
      16             : 
      17             : #include <cstddef>
      18             : 
      19             : #include "cpl_string.h"
      20             : 
      21             : #ifdef HAVE_CURL
      22             : 
      23             : #include <curl/curl.h>
      24             : #include "cpl_http.h"
      25             : #include "cpl_aws.h"
      26             : #include <map>
      27             : 
      28             : class VSIGSHandleHelper final : public IVSIS3LikeHandleHelper
      29             : {
      30             :     CPL_DISALLOW_COPY_ASSIGN(VSIGSHandleHelper)
      31             : 
      32             :     std::string m_osURL;
      33             :     std::string m_osEndpoint;
      34             :     std::string m_osBucketObjectKey;
      35             :     std::string m_osSecretAccessKey;
      36             :     std::string m_osAccessKeyId;
      37             :     bool m_bUseAuthenticationHeader;
      38             :     GOA2Manager m_oManager;
      39             :     std::string m_osUserProject{};
      40             : 
      41             :     static bool GetConfiguration(const std::string &osPathForOption,
      42             :                                  CSLConstList papszOptions,
      43             :                                  std::string &osSecretAccessKey,
      44             :                                  std::string &osAccessKeyId,
      45             :                                  bool &bUseAuthenticationHeader,
      46             :                                  GOA2Manager &oManager);
      47             : 
      48             :     static bool GetConfigurationFromConfigFile(
      49             :         std::string &osSecretAccessKey, std::string &osAccessKeyId,
      50             :         std::string &osOAuth2RefreshToken, std::string &osOAuth2ClientId,
      51             :         std::string &osOAuth2ClientSecret, std::string &osCredentials);
      52             : 
      53             :     void RebuildURL() override;
      54             : 
      55             :   public:
      56             :     VSIGSHandleHelper(const std::string &osEndpoint,
      57             :                       const std::string &osBucketObjectKey,
      58             :                       const std::string &osSecretAccessKey,
      59             :                       const std::string &osAccessKeyId, bool bUseHeaderFile,
      60             :                       const GOA2Manager &oManager,
      61             :                       const std::string &osUserProject);
      62             :     ~VSIGSHandleHelper();
      63             : 
      64             :     static VSIGSHandleHelper *
      65             :     BuildFromURI(const char *pszURI, const char *pszFSPrefix,
      66             :                  const char *pszURIForPathSpecificOption = nullptr,
      67             :                  CSLConstList papszOptions = nullptr);
      68             : 
      69             :     bool UsesHMACKey() const;
      70             : 
      71             :     struct curl_slist *
      72             :     GetCurlHeaders(const std::string &osVerbosVerb,
      73             :                    const struct curl_slist *psExistingHeaders,
      74             :                    const void *pabyDataContent = nullptr,
      75             :                    size_t nBytesContent = 0) const override;
      76             : 
      77          95 :     const std::string &GetURL() const override
      78             :     {
      79          95 :         return m_osURL;
      80             :     }
      81             : 
      82           2 :     std::string GetCopySourceHeader() const override
      83             :     {
      84           2 :         return "x-goog-copy-source";
      85             :     }
      86             : 
      87           1 :     const char *GetMetadataDirectiveREPLACE() const override
      88             :     {
      89           1 :         return "x-goog-metadata-directive: REPLACE";
      90             :     }
      91             : 
      92             :     std::string GetSignedURL(CSLConstList papszOptions);
      93             : 
      94             :     static void ClearCache();
      95             : };
      96             : 
      97             : #endif /* HAVE_CURL */
      98             : 
      99             : #endif /* #ifndef DOXYGEN_SKIP */
     100             : 
     101             : #endif /* CPL_GOOGLE_CLOUD_INCLUDED_H */

Generated by: LCOV version 1.14