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-04-28 21:03:45 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             :  * Permission is hereby granted, free of charge, to any person obtaining a
      10             :  * copy of this software and associated documentation files (the "Software"),
      11             :  * to deal in the Software without restriction, including without limitation
      12             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      13             :  * and/or sell copies of the Software, and to permit persons to whom the
      14             :  * Software is furnished to do so, subject to the following conditions:
      15             :  *
      16             :  * The above copyright notice and this permission notice shall be included
      17             :  * in all copies or substantial portions of the Software.
      18             :  *
      19             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      20             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      21             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      22             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      23             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      24             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      25             :  * DEALINGS IN THE SOFTWARE.
      26             :  ****************************************************************************/
      27             : 
      28             : #ifndef CPL_GOOGLE_CLOUD_INCLUDED_H
      29             : #define CPL_GOOGLE_CLOUD_INCLUDED_H
      30             : 
      31             : #ifndef DOXYGEN_SKIP
      32             : 
      33             : #include <cstddef>
      34             : 
      35             : #include "cpl_string.h"
      36             : 
      37             : #ifdef HAVE_CURL
      38             : 
      39             : #include <curl/curl.h>
      40             : #include "cpl_http.h"
      41             : #include "cpl_aws.h"
      42             : #include <map>
      43             : 
      44             : class VSIGSHandleHelper final : public IVSIS3LikeHandleHelper
      45             : {
      46             :     CPL_DISALLOW_COPY_ASSIGN(VSIGSHandleHelper)
      47             : 
      48             :     std::string m_osURL;
      49             :     std::string m_osEndpoint;
      50             :     std::string m_osBucketObjectKey;
      51             :     std::string m_osSecretAccessKey;
      52             :     std::string m_osAccessKeyId;
      53             :     bool m_bUseAuthenticationHeader;
      54             :     GOA2Manager m_oManager;
      55             :     std::string m_osUserProject{};
      56             : 
      57             :     static bool GetConfiguration(const std::string &osPathForOption,
      58             :                                  CSLConstList papszOptions,
      59             :                                  std::string &osSecretAccessKey,
      60             :                                  std::string &osAccessKeyId,
      61             :                                  bool &bUseAuthenticationHeader,
      62             :                                  GOA2Manager &oManager);
      63             : 
      64             :     static bool GetConfigurationFromConfigFile(
      65             :         std::string &osSecretAccessKey, std::string &osAccessKeyId,
      66             :         std::string &osOAuth2RefreshToken, std::string &osOAuth2ClientId,
      67             :         std::string &osOAuth2ClientSecret, std::string &osCredentials);
      68             : 
      69             :     void RebuildURL() override;
      70             : 
      71             :   public:
      72             :     VSIGSHandleHelper(const std::string &osEndpoint,
      73             :                       const std::string &osBucketObjectKey,
      74             :                       const std::string &osSecretAccessKey,
      75             :                       const std::string &osAccessKeyId, bool bUseHeaderFile,
      76             :                       const GOA2Manager &oManager,
      77             :                       const std::string &osUserProject);
      78             :     ~VSIGSHandleHelper();
      79             : 
      80             :     static VSIGSHandleHelper *BuildFromURI(const char *pszURI,
      81             :                                            const char *pszFSPrefix,
      82             :                                            CSLConstList papszOptions = nullptr);
      83             : 
      84             :     bool UsesHMACKey() const;
      85             : 
      86             :     struct curl_slist *
      87             :     GetCurlHeaders(const std::string &osVerbosVerb,
      88             :                    const struct curl_slist *psExistingHeaders,
      89             :                    const void *pabyDataContent = nullptr,
      90             :                    size_t nBytesContent = 0) const override;
      91             : 
      92          85 :     const std::string &GetURL() const override
      93             :     {
      94          85 :         return m_osURL;
      95             :     }
      96             : 
      97           2 :     std::string GetCopySourceHeader() const override
      98             :     {
      99           2 :         return "x-goog-copy-source";
     100             :     }
     101             : 
     102           1 :     const char *GetMetadataDirectiveREPLACE() const override
     103             :     {
     104           1 :         return "x-goog-metadata-directive: REPLACE";
     105             :     }
     106             : 
     107             :     std::string GetSignedURL(CSLConstList papszOptions);
     108             : 
     109             :     static void CleanMutex();
     110             :     static void ClearCache();
     111             : };
     112             : 
     113             : #endif /* HAVE_CURL */
     114             : 
     115             : #endif /* #ifndef DOXYGEN_SKIP */
     116             : 
     117             : #endif /* CPL_GOOGLE_CLOUD_INCLUDED_H */

Generated by: LCOV version 1.14