LCOV - code coverage report
Current view: top level - source/common/config - xds_resource.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 0 6 0.0 %
Date: 2024-01-05 06:35:25 Functions: 0 2 0.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "envoy/common/exception.h"
       4             : 
       5             : #include "absl/strings/string_view.h"
       6             : #include "xds/core/v3/resource_locator.pb.h"
       7             : #include "xds/core/v3/resource_name.pb.h"
       8             : 
       9             : namespace Envoy {
      10             : namespace Config {
      11             : 
      12             : // Utilities for URI encoding/decoding of xds::core::v3::Resource{Name,Locator}.
      13             : class XdsResourceIdentifier {
      14             : public:
      15             :   // Options for encoded URIs.
      16             :   struct EncodeOptions {
      17             :     // Should the context params be sorted by key? This provides deterministic encoding.
      18             :     bool sort_context_params_{};
      19             :   };
      20             : 
      21             :   /**
      22             :    * Encode a xds::core::v3::ResourceName message as a xdstp:// URN string.
      23             :    *
      24             :    * @param resource_name resource name message.
      25             :    * @param options encoding options.
      26             :    * @return std::string xdstp:// URN for resource_name.
      27             :    */
      28             :   static std::string encodeUrn(const xds::core::v3::ResourceName& resource_name,
      29             :                                const EncodeOptions& options);
      30           0 :   static std::string encodeUrn(const xds::core::v3::ResourceName& resource_name) {
      31           0 :     return encodeUrn(resource_name, {});
      32           0 :   }
      33             : 
      34             :   /**
      35             :    * Encode a xds::core::v3::ResourceLocator message as a xdstp:// URL string.
      36             :    *
      37             :    * @param resource_name resource name message.
      38             :    * @param options encoding options.
      39             :    * @return std::string xdstp:// URL for resource_name.
      40             :    */
      41             :   static std::string encodeUrl(const xds::core::v3::ResourceLocator& resource_locator,
      42             :                                const EncodeOptions& options);
      43           0 :   static std::string encodeUrl(const xds::core::v3::ResourceLocator& resource_locator) {
      44           0 :     return encodeUrl(resource_locator, {});
      45           0 :   }
      46             : 
      47             :   /**
      48             :    * Decode a xdstp:// URN string to a xds::core::v3::ResourceName.
      49             :    *
      50             :    * @param resource_urn xdstp:// resource URN.
      51             :    * @return xds::core::v3::ResourceName resource name message for resource_urn.
      52             :    * @throws EnvoyException when parsing fails.
      53             :    */
      54             :   static absl::StatusOr<xds::core::v3::ResourceName> decodeUrn(absl::string_view resource_urn);
      55             : 
      56             :   /**
      57             :    * Decode a xdstp:// URL string to a xds::core::v3::ResourceLocator.
      58             :    *
      59             :    * @param resource_url xdstp:// resource URL.
      60             :    * @return xds::core::v3::ResourceLocator resource name message for resource_url.
      61             :    * @throws EnvoyException when parsing fails.
      62             :    */
      63             :   static xds::core::v3::ResourceLocator decodeUrl(absl::string_view resource_url);
      64             : 
      65             :   /**
      66             :    * @param resource_name resource name.
      67             :    * @return bool does resource_name have a xdstp: scheme?
      68             :    */
      69             :   static bool hasXdsTpScheme(absl::string_view resource_name);
      70             : };
      71             : 
      72             : } // namespace Config
      73             : } // namespace Envoy

Generated by: LCOV version 1.15