Class RESTUtil
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final org.apache.iceberg.relocated.com.google.common.base.JoinerDeprecated.static final org.apache.iceberg.relocated.com.google.common.base.SplitterDeprecated.since 1.11.0, will be removed in 1.12.0; usenamespaceFromQueryParam(String)instead. -
Method Summary
Modifier and TypeMethodDescriptionconfigHeaders(Map<String, String> properties) decodeFormData(String formString) Decodes a map of form data from application/x-www-form-urlencoded.static NamespacedecodeNamespace(String encodedNs) Deprecated.since 1.11.0, will be removed in 1.12.0; usedecodeNamespace(String, String)instead.static NamespacedecodeNamespace(String encodedNamespace, String separator) Takes in a string representation of a namespace as used for a URL parameter and returns the corresponding namespace.static StringdecodeString(String encoded) Decodes a URL-encoded string.static StringencodeFormData(Map<?, ?> formData) Encodes a map of form data as application/x-www-form-urlencoded.static StringDeprecated.since 1.11.0, will be removed in 1.12.0; useencodeNamespace(Namespace, String)instead.static StringencodeNamespace(Namespace namespace, String separator) Returns a String representation of a namespace that is suitable for use in a URL / URI.static StringencodeString(String toEncode) Encodes a string using URL encodingextractPrefixMap(Map<String, String> properties, String prefix) Takes in a map, and returns a copy filtered on the entries with keys beginning with the designated prefix.Returns a single-use headers map containing a freshly generated idempotency key.Merge updates into a target string map.static NamespacenamespaceFromQueryParam(String namespace) This converts a namespace where each part in a multipart namespace has been separated using '' to its originalNamespaceinstance.static NamespacenamespaceFromQueryParam(String namespace, String unicodeNamespaceSeparator) This converts a namespace where each part in a multipart namespace has been separated using the provided unicode separator to its originalNamespaceinstance.static StringnamespaceToQueryParam(Namespace namespace) This converts the given namespace to a string and separates each part in a multipart namespace using the unicode character ''.static StringnamespaceToQueryParam(Namespace namespace, String unicodeNamespaceSeparator) This converts the given namespace to a string and separates each part in a multipart namespace using the provided unicode separator.static StringresolveEndpoint(String catalogUri, String endpointPath) Returns the catalog URI suffixed by the relative endpoint path.static StringstripTrailingSlash(String path)
-
Field Details
-
NAMESPACE_JOINER
@Deprecated public static final org.apache.iceberg.relocated.com.google.common.base.Joiner NAMESPACE_JOINERDeprecated.since 1.11.0, will be removed in 1.12.0; usenamespaceToQueryParam(Namespace)} instead. -
NAMESPACE_SPLITTER
@Deprecated public static final org.apache.iceberg.relocated.com.google.common.base.Splitter NAMESPACE_SPLITTERDeprecated.since 1.11.0, will be removed in 1.12.0; usenamespaceFromQueryParam(String)instead. -
IDEMPOTENCY_KEY_HEADER
- See Also:
-
-
Method Details
-
stripTrailingSlash
-
merge
Merge updates into a target string map.- Parameters:
target- a map to updateupdates- a map of updates- Returns:
- an immutable result map built from target and updates
-
extractPrefixMap
Takes in a map, and returns a copy filtered on the entries with keys beginning with the designated prefix. The keys are returned with the prefix removed.Any entries whose keys don't begin with the prefix are not returned.
This can be used to get a subset of the configuration related to the REST catalog, such as all properties from a prefix of `spark.sql.catalog.my_catalog.rest.` to get REST catalog specific properties from the spark configuration.
-
encodeFormData
Encodes a map of form data as application/x-www-form-urlencoded.This encodes the form with pairs separated by & and keys separated from values by =.
- Parameters:
formData- a map of form data- Returns:
- a String of encoded form data
-
decodeFormData
Decodes a map of form data from application/x-www-form-urlencoded.This decodes the form with pairs separated by & and keys separated from values by =.
- Parameters:
formString- a map of form data- Returns:
- a map of key/value form data
-
encodeString
Encodes a string using URL encodingdecodeString(String)should be used to decode.- Parameters:
toEncode- string to encode- Returns:
- UTF-8 encoded string, suitable for use as a URL parameter
-
decodeString
Decodes a URL-encoded string.See also
encodeString(String)for URL encoding.- Parameters:
encoded- a string to decode- Returns:
- a decoded string
-
namespaceToQueryParam
This converts the given namespace to a string and separates each part in a multipart namespace using the unicode character ''. Note that this method is different fromencodeNamespace(Namespace), which uses the UTF-8 escaped version of '', which is '0x1F'.namespaceFromQueryParam(String)should be used to convert the namespace string back to aNamespaceinstance.- Parameters:
namespace- The namespace to convert- Returns:
- The namespace converted to a string where each part in a multipart namespace is separated using the unicode character ''
-
namespaceToQueryParam
This converts the given namespace to a string and separates each part in a multipart namespace using the provided unicode separator. Note that this method is different fromencodeNamespace(Namespace), which uses a UTF-8 escaped separator.namespaceFromQueryParam(String, String)should be used to convert the namespace string back to aNamespaceinstance.- Parameters:
namespace- The namespace to convertunicodeNamespaceSeparator- The unicode namespace separator to use, such as '.'- Returns:
- The namespace converted to a string where each part in a multipart namespace is separated using the given unicode separator
-
namespaceFromQueryParam
This converts a namespace where each part in a multipart namespace has been separated using '' to its originalNamespaceinstance.namespaceToQueryParam(Namespace)should be used to convert theNamespaceto a string.- Parameters:
namespace- The namespace to convert- Returns:
- The namespace instance from the given namespace string, where each part in a multipart namespace is converted using the unicode separator ''
-
namespaceFromQueryParam
This converts a namespace where each part in a multipart namespace has been separated using the provided unicode separator to its originalNamespaceinstance.namespaceToQueryParam(Namespace, String)should be used to convert theNamespaceto a string.- Parameters:
namespace- The namespace to convertunicodeNamespaceSeparator- The unicode namespace separator to use, such as '.'- Returns:
- The namespace instance from the given namespace string, where each part in a multipart namespace is converted using the given unicode namespace separator
-
encodeNamespace
Deprecated.since 1.11.0, will be removed in 1.12.0; useencodeNamespace(Namespace, String)instead.Returns a String representation of a namespace that is suitable for use in a URL / URI.This function needs to be called when a namespace is used as a path variable (or query parameter etc.), to format the namespace per the spec.
decodeNamespace(java.lang.String)should be used to parse the namespace from a URL parameter.- Parameters:
ns- namespace to encode- Returns:
- UTF-8 encoded string representing the namespace, suitable for use as a URL parameter
-
encodeNamespace
Returns a String representation of a namespace that is suitable for use in a URL / URI.This function needs to be called when a namespace is used as a path variable (or query parameter etc.), to format the namespace per the spec.
decodeNamespace(String, String)should be used to parse the namespace from a URL parameter.- Parameters:
namespace- namespace to encodeseparator- The namespace separator to be used for encoding. The separator will be used as-is and won't be UTF-8 encoded.- Returns:
- UTF-8 encoded string representing the namespace, suitable for use as a URL parameter
-
decodeNamespace
Deprecated.since 1.11.0, will be removed in 1.12.0; usedecodeNamespace(String, String)instead.Takes in a string representation of a namespace as used for a URL parameter and returns the corresponding namespace.See also
encodeNamespace(org.apache.iceberg.catalog.Namespace)for generating correctly formatted URLs.- Parameters:
encodedNs- a namespace to decode- Returns:
- a namespace
-
decodeNamespace
Takes in a string representation of a namespace as used for a URL parameter and returns the corresponding namespace.See also
encodeNamespace(org.apache.iceberg.catalog.Namespace)for generating correctly formatted URLs.- Parameters:
encodedNamespace- a namespace to decodeseparator- The namespace separator to be used as-is for decoding. This should be the same separator that was used when callingencodeNamespace(Namespace, String)- Returns:
- a namespace
-
resolveEndpoint
Returns the catalog URI suffixed by the relative endpoint path. If the endpoint path is an absolute path, then the absolute endpoint path is returned without using the catalog URI.- Parameters:
catalogUri- The catalog URI that is typically passed throughCatalogProperties.URIendpointPath- Either an absolute or relative endpoint path- Returns:
- The actual endpoint path if it's an absolute path or the catalog uri suffixed by the endpoint path if the path is relative.
-
configHeaders
-
idempotencyHeaders
Returns a single-use headers map containing a freshly generated idempotency key. The key is a UUIDv7 string suitable for use in the Idempotency-Key header.
-
namespaceToQueryParam(Namespace)} instead.