Lesson 35 - Get Compute Auth Token Working
This commit is contained in:
@@ -0,0 +1,221 @@
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
|
||||
#ifndef AWS_SDKUTILS_AWS_PROFILE_H
|
||||
#define AWS_SDKUTILS_AWS_PROFILE_H
|
||||
#include <aws/sdkutils/sdkutils.h>
|
||||
|
||||
AWS_PUSH_SANE_WARNING_LEVEL
|
||||
|
||||
struct aws_allocator;
|
||||
struct aws_string;
|
||||
struct aws_byte_buf;
|
||||
struct aws_byte_cursor;
|
||||
|
||||
/*
|
||||
* A set of data types that model the aws profile specification
|
||||
*
|
||||
* A profile collection is a collection of zero or more named profiles
|
||||
* Each profile is a set of properties (named key-value pairs)
|
||||
* Empty-valued properties may have sub properties (named key-value pairs)
|
||||
*
|
||||
* Resolution rules exist to determine what profile to use, what files to
|
||||
* read profile collections from, and what types of credentials have priority.
|
||||
*
|
||||
* The profile specification is informally defined as "what the aws cli does" and
|
||||
* formally defined in internal aws documents.
|
||||
*/
|
||||
struct aws_profile_property;
|
||||
struct aws_profile;
|
||||
struct aws_profile_collection;
|
||||
|
||||
/**
|
||||
* The profile specification has rule exceptions based on what file
|
||||
* the profile collection comes from.
|
||||
*/
|
||||
enum aws_profile_source_type { AWS_PST_NONE, AWS_PST_CONFIG, AWS_PST_CREDENTIALS };
|
||||
|
||||
/*
|
||||
* The collection can hold different types of sections.
|
||||
*/
|
||||
enum aws_profile_section_type {
|
||||
AWS_PROFILE_SECTION_TYPE_PROFILE,
|
||||
AWS_PROFILE_SECTION_TYPE_SSO_SESSION,
|
||||
|
||||
AWS_PROFILE_SECTION_TYPE_COUNT,
|
||||
};
|
||||
|
||||
AWS_EXTERN_C_BEGIN
|
||||
|
||||
/*************************
|
||||
* Profile collection APIs
|
||||
*************************/
|
||||
|
||||
/**
|
||||
* Increments the reference count on the profile collection, allowing the caller to take a reference to it.
|
||||
*
|
||||
* Returns the same profile collection passed in.
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
struct aws_profile_collection *aws_profile_collection_acquire(struct aws_profile_collection *collection);
|
||||
|
||||
/**
|
||||
* Decrements a profile collection's ref count. When the ref count drops to zero, the collection will be destroyed.
|
||||
* Returns NULL.
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
struct aws_profile_collection *aws_profile_collection_release(struct aws_profile_collection *collection);
|
||||
|
||||
/**
|
||||
* @Deprecated This is equivalent to aws_profile_collection_release.
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
void aws_profile_collection_destroy(struct aws_profile_collection *profile_collection);
|
||||
|
||||
/**
|
||||
* Create a new profile collection by parsing a file with the specified path
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
struct aws_profile_collection *aws_profile_collection_new_from_file(
|
||||
struct aws_allocator *allocator,
|
||||
const struct aws_string *file_path,
|
||||
enum aws_profile_source_type source);
|
||||
|
||||
/**
|
||||
* Create a new profile collection by merging a config-file-based profile
|
||||
* collection and a credentials-file-based profile collection
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
struct aws_profile_collection *aws_profile_collection_new_from_merge(
|
||||
struct aws_allocator *allocator,
|
||||
const struct aws_profile_collection *config_profiles,
|
||||
const struct aws_profile_collection *credentials_profiles);
|
||||
|
||||
/**
|
||||
* Create a new profile collection by parsing text in a buffer. Primarily
|
||||
* for testing.
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
struct aws_profile_collection *aws_profile_collection_new_from_buffer(
|
||||
struct aws_allocator *allocator,
|
||||
const struct aws_byte_buf *buffer,
|
||||
enum aws_profile_source_type source);
|
||||
|
||||
/**
|
||||
* Retrieves a reference to a profile with the specified name, if it exists, from the profile collection
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
const struct aws_profile *aws_profile_collection_get_profile(
|
||||
const struct aws_profile_collection *profile_collection,
|
||||
const struct aws_string *profile_name);
|
||||
|
||||
/*
|
||||
* Retrieves a reference to a section with the specified name and type, if it exists, from the profile collection.
|
||||
* You can get the "default" profile or credentials file sections by passing `AWS_PROFILE_SECTION_TYPE_PROFILE`
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
const struct aws_profile *aws_profile_collection_get_section(
|
||||
const struct aws_profile_collection *profile_collection,
|
||||
const enum aws_profile_section_type section_type,
|
||||
const struct aws_string *section_name);
|
||||
|
||||
/**
|
||||
* Returns the number of profiles in a collection
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
size_t aws_profile_collection_get_profile_count(const struct aws_profile_collection *profile_collection);
|
||||
|
||||
/**
|
||||
* Returns the number of elements of the specified section in a collection.
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
size_t aws_profile_collection_get_section_count(
|
||||
const struct aws_profile_collection *profile_collection,
|
||||
const enum aws_profile_section_type section_type);
|
||||
|
||||
/**
|
||||
* Returns a reference to the name of the provided profile
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
const struct aws_string *aws_profile_get_name(const struct aws_profile *profile);
|
||||
|
||||
/**************
|
||||
* profile APIs
|
||||
**************/
|
||||
|
||||
/**
|
||||
* Retrieves a reference to a property with the specified name, if it exists, from a profile
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
const struct aws_profile_property *aws_profile_get_property(
|
||||
const struct aws_profile *profile,
|
||||
const struct aws_string *property_name);
|
||||
|
||||
/**
|
||||
* Returns how many properties a profile holds
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
size_t aws_profile_get_property_count(const struct aws_profile *profile);
|
||||
|
||||
/**
|
||||
* Returns a reference to the property's string value
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
const struct aws_string *aws_profile_property_get_value(const struct aws_profile_property *property);
|
||||
|
||||
/***********************
|
||||
* profile property APIs
|
||||
***********************/
|
||||
|
||||
/**
|
||||
* Returns a reference to the value of a sub property with the given name, if it exists, in the property
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
const struct aws_string *aws_profile_property_get_sub_property(
|
||||
const struct aws_profile_property *property,
|
||||
const struct aws_string *sub_property_name);
|
||||
|
||||
/**
|
||||
* Returns how many sub properties the property holds
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
size_t aws_profile_property_get_sub_property_count(const struct aws_profile_property *property);
|
||||
|
||||
/***********
|
||||
* Misc APIs
|
||||
***********/
|
||||
|
||||
/**
|
||||
* Computes the final platform-specific path for the profile credentials file. Does limited home directory
|
||||
* expansion/resolution.
|
||||
*
|
||||
* override_path, if not null, will be searched first instead of using the standard home directory config path
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
struct aws_string *aws_get_credentials_file_path(
|
||||
struct aws_allocator *allocator,
|
||||
const struct aws_byte_cursor *override_path);
|
||||
|
||||
/**
|
||||
* Computes the final platform-specific path for the profile config file. Does limited home directory
|
||||
* expansion/resolution.
|
||||
*
|
||||
* override_path, if not null, will be searched first instead of using the standard home directory config path
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
struct aws_string *aws_get_config_file_path(
|
||||
struct aws_allocator *allocator,
|
||||
const struct aws_byte_cursor *override_path);
|
||||
|
||||
/**
|
||||
* Computes the profile to use for credentials lookups based on profile resolution rules
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
struct aws_string *aws_get_profile_name(struct aws_allocator *allocator, const struct aws_byte_cursor *override_name);
|
||||
|
||||
AWS_EXTERN_C_END
|
||||
AWS_POP_SANE_WARNING_LEVEL
|
||||
|
||||
#endif /* AWS_SDKUTILS_AWS_PROFILE_H */
|
||||
@@ -0,0 +1,322 @@
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
|
||||
#ifndef AWS_SDKUTILS_ENDPOINTS_RULESET_H
|
||||
#define AWS_SDKUTILS_ENDPOINTS_RULESET_H
|
||||
|
||||
#include <aws/common/byte_buf.h>
|
||||
#include <aws/sdkutils/sdkutils.h>
|
||||
|
||||
AWS_PUSH_SANE_WARNING_LEVEL
|
||||
|
||||
struct aws_endpoints_ruleset;
|
||||
struct aws_partitions_config;
|
||||
struct aws_endpoints_parameter;
|
||||
struct aws_endpoints_rule_engine;
|
||||
struct aws_endpoints_resolved_endpoint;
|
||||
struct aws_endpoints_request_context;
|
||||
struct aws_hash_table;
|
||||
|
||||
enum aws_endpoints_parameter_type {
|
||||
AWS_ENDPOINTS_PARAMETER_STRING,
|
||||
AWS_ENDPOINTS_PARAMETER_BOOLEAN,
|
||||
AWS_ENDPOINTS_PARAMETER_STRING_ARRAY,
|
||||
};
|
||||
enum aws_endpoints_resolved_endpoint_type { AWS_ENDPOINTS_RESOLVED_ENDPOINT, AWS_ENDPOINTS_RESOLVED_ERROR };
|
||||
|
||||
AWS_EXTERN_C_BEGIN
|
||||
|
||||
AWS_SDKUTILS_API struct aws_byte_cursor aws_endpoints_get_supported_ruleset_version(void);
|
||||
|
||||
/*
|
||||
******************************
|
||||
* Parameter
|
||||
******************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Value type of parameter.
|
||||
*/
|
||||
AWS_SDKUTILS_API enum aws_endpoints_parameter_type aws_endpoints_parameter_get_type(
|
||||
const struct aws_endpoints_parameter *parameter);
|
||||
|
||||
/*
|
||||
* Specifies whether parameter maps to one of SDK built ins (ex. "AWS::Region").
|
||||
* Return is a cursor specifying the name of associated built in.
|
||||
* If there is no mapping, cursor will be empty.
|
||||
* Cursor is guaranteed to be valid for lifetime of paramater.
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_byte_cursor aws_endpoints_parameter_get_built_in(
|
||||
const struct aws_endpoints_parameter *parameter);
|
||||
|
||||
/*
|
||||
* Default string value.
|
||||
* out_cursor will point to default string value if one exist and will be empty
|
||||
* otherwise.
|
||||
* Cursor is guaranteed to be valid for lifetime of paramater.
|
||||
* Returns AWS_OP_ERR if parameter is not a string.
|
||||
*/
|
||||
AWS_SDKUTILS_API int aws_endpoints_parameter_get_default_string(
|
||||
const struct aws_endpoints_parameter *parameter,
|
||||
struct aws_byte_cursor *out_cursor);
|
||||
|
||||
/*
|
||||
* Default boolean value.
|
||||
* out_bool will have pointer to value if default is specified, NULL otherwise.
|
||||
* Owned by parameter.
|
||||
* Returns AWS_OP_ERR if parameter is not a boolean.
|
||||
*/
|
||||
AWS_SDKUTILS_API int aws_endpoints_parameter_get_default_boolean(
|
||||
const struct aws_endpoints_parameter *parameter,
|
||||
const bool **out_bool);
|
||||
|
||||
/*
|
||||
* Whether parameter is required.
|
||||
*/
|
||||
AWS_SDKUTILS_API bool aws_endpoints_parameter_get_is_required(const struct aws_endpoints_parameter *parameter);
|
||||
|
||||
/*
|
||||
* Returns cursor to parameter documentation.
|
||||
* Cursor is guaranteed to be valid for lifetime of paramater.
|
||||
* Will not be empty as doc is required.
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_byte_cursor aws_endpoints_parameter_get_documentation(
|
||||
const struct aws_endpoints_parameter *parameter);
|
||||
|
||||
/*
|
||||
* Whether parameter is deprecated.
|
||||
*/
|
||||
AWS_SDKUTILS_API bool aws_endpoints_parameters_get_is_deprecated(const struct aws_endpoints_parameter *parameter);
|
||||
|
||||
/*
|
||||
* Deprecation message. Cursor is empty if parameter is not deprecated.
|
||||
* Cursor is guaranteed to be valid for lifetime of paramater.
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_byte_cursor aws_endpoints_parameter_get_deprecated_message(
|
||||
const struct aws_endpoints_parameter *parameter);
|
||||
|
||||
/*
|
||||
* Deprecated since. Cursor is empty if parameter is not deprecated.
|
||||
* Cursor is guaranteed to be valid for lifetime of paramater.
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_byte_cursor aws_endpoints_parameter_get_deprecated_since(
|
||||
const struct aws_endpoints_parameter *parameter);
|
||||
|
||||
/*
|
||||
******************************
|
||||
* Ruleset
|
||||
******************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Create new ruleset from a json string.
|
||||
* In cases of failure NULL is returned and last error is set.
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_endpoints_ruleset *aws_endpoints_ruleset_new_from_string(
|
||||
struct aws_allocator *allocator,
|
||||
struct aws_byte_cursor ruleset_json);
|
||||
|
||||
/*
|
||||
* Increment ref count
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_endpoints_ruleset *aws_endpoints_ruleset_acquire(struct aws_endpoints_ruleset *ruleset);
|
||||
|
||||
/*
|
||||
* Decrement ref count
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_endpoints_ruleset *aws_endpoints_ruleset_release(struct aws_endpoints_ruleset *ruleset);
|
||||
|
||||
/*
|
||||
* Get ruleset parameters.
|
||||
* Return is a hashtable with paramater name as a key (aws_byte_cursor *) and parameter
|
||||
* (aws_endpoints_parameter *) as a value. Ruleset owns the owns the hashtable and
|
||||
* pointer is valid during ruleset lifetime. Will never return a NULL. In case
|
||||
* there are no parameters in the ruleset, hash table will contain 0 elements.
|
||||
*
|
||||
* Note on usage in bindings:
|
||||
* - this is basically a map from a parameter name to a structure describing parameter
|
||||
* - deep copy all the fields and let language take ownership of data
|
||||
* Consider transforming this into language specific map (dict for python, Map
|
||||
* in Java, std::map in C++, etc...) instead of wrapping it into a custom class.
|
||||
*/
|
||||
AWS_SDKUTILS_API const struct aws_hash_table *aws_endpoints_ruleset_get_parameters(
|
||||
struct aws_endpoints_ruleset *ruleset);
|
||||
|
||||
/*
|
||||
* Ruleset version.
|
||||
* Returned pointer is owned by ruleset.
|
||||
* Will not return NULL as version is a required field for ruleset.
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_byte_cursor aws_endpoints_ruleset_get_version(const struct aws_endpoints_ruleset *ruleset);
|
||||
|
||||
/*
|
||||
* Ruleset service id.
|
||||
* Returned pointer is owned by ruleset.
|
||||
* Can be NULL if not specified in ruleset.
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_byte_cursor aws_endpoints_ruleset_get_service_id(
|
||||
const struct aws_endpoints_ruleset *ruleset);
|
||||
|
||||
/*
|
||||
******************************
|
||||
* Rule engine
|
||||
******************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create new rule engine for a given ruleset.
|
||||
* In cases of failure NULL is returned and last error is set.
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_endpoints_rule_engine *aws_endpoints_rule_engine_new(
|
||||
struct aws_allocator *allocator,
|
||||
struct aws_endpoints_ruleset *ruleset,
|
||||
struct aws_partitions_config *partitions_config);
|
||||
|
||||
/*
|
||||
* Increment rule engine ref count.
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_endpoints_rule_engine *aws_endpoints_rule_engine_acquire(
|
||||
struct aws_endpoints_rule_engine *rule_engine);
|
||||
|
||||
/*
|
||||
* Decrement rule engine ref count.
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_endpoints_rule_engine *aws_endpoints_rule_engine_release(
|
||||
struct aws_endpoints_rule_engine *rule_engine);
|
||||
|
||||
/*
|
||||
* Creates new request context.
|
||||
* This is basically a property bag containing all request parameter values needed to
|
||||
* resolve endpoint. Parameter value names must match parameter names specified
|
||||
* in ruleset.
|
||||
* Caller is responsible for releasing request context.
|
||||
* Note on usage in bindings:
|
||||
* - Consider exposing it as a custom property bag or a standard map and then
|
||||
* transform it into request context.
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_endpoints_request_context *aws_endpoints_request_context_new(
|
||||
struct aws_allocator *allocator);
|
||||
|
||||
/*
|
||||
* Increment resolved endpoint ref count.
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_endpoints_request_context *aws_endpoints_request_context_acquire(
|
||||
struct aws_endpoints_request_context *request_context);
|
||||
|
||||
/*
|
||||
* Decrement resolved endpoint ref count.
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_endpoints_request_context *aws_endpoints_request_context_release(
|
||||
struct aws_endpoints_request_context *request_context);
|
||||
|
||||
/*
|
||||
* Add string value to request context.
|
||||
* Note: this function will make a copy of the memory backing the cursors.
|
||||
* The function will override any previous value stored in the context with the
|
||||
* same name.
|
||||
*/
|
||||
AWS_SDKUTILS_API int aws_endpoints_request_context_add_string(
|
||||
struct aws_allocator *allocator,
|
||||
struct aws_endpoints_request_context *context,
|
||||
struct aws_byte_cursor name,
|
||||
struct aws_byte_cursor value);
|
||||
|
||||
/*
|
||||
* Add boolean value to request context.
|
||||
* The function will override any previous value stored in the context with the
|
||||
* same name.
|
||||
*/
|
||||
AWS_SDKUTILS_API int aws_endpoints_request_context_add_boolean(
|
||||
struct aws_allocator *allocator,
|
||||
struct aws_endpoints_request_context *context,
|
||||
struct aws_byte_cursor name,
|
||||
bool value);
|
||||
|
||||
/*
|
||||
* Add string array value to request context.
|
||||
* Note: this function will make a copy of the memory backing the cursors.
|
||||
* The function will override any previous value stored in the context with the
|
||||
* same name.
|
||||
*/
|
||||
AWS_SDKUTILS_API int aws_endpoints_request_context_add_string_array(
|
||||
struct aws_allocator *allocator,
|
||||
struct aws_endpoints_request_context *context,
|
||||
struct aws_byte_cursor name,
|
||||
const struct aws_byte_cursor *value_array,
|
||||
size_t len);
|
||||
|
||||
/*
|
||||
* Resolve an endpoint given request context.
|
||||
* Resolved endpoint is returned through out_resolved_endpoint.
|
||||
* In cases of error out_resolved_endpoint is set to NULL and error is returned.
|
||||
* Resolved endpoint is ref counter and caller is responsible for releasing it.
|
||||
*/
|
||||
AWS_SDKUTILS_API int aws_endpoints_rule_engine_resolve(
|
||||
struct aws_endpoints_rule_engine *engine,
|
||||
const struct aws_endpoints_request_context *context,
|
||||
struct aws_endpoints_resolved_endpoint **out_resolved_endpoint);
|
||||
|
||||
/*
|
||||
* Increment resolved endpoint ref count.
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_endpoints_resolved_endpoint *aws_endpoints_resolved_endpoint_acquire(
|
||||
struct aws_endpoints_resolved_endpoint *resolved_endpoint);
|
||||
|
||||
/*
|
||||
* Decrement resolved endpoint ref count.
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_endpoints_resolved_endpoint *aws_endpoints_resolved_endpoint_release(
|
||||
struct aws_endpoints_resolved_endpoint *resolved_endpoint);
|
||||
|
||||
/*
|
||||
* Get type of resolved endpoint.
|
||||
*/
|
||||
AWS_SDKUTILS_API enum aws_endpoints_resolved_endpoint_type aws_endpoints_resolved_endpoint_get_type(
|
||||
const struct aws_endpoints_resolved_endpoint *resolved_endpoint);
|
||||
|
||||
/*
|
||||
* Get url for the resolved endpoint.
|
||||
* Valid only if resolved endpoint has endpoint type and will error otherwise.
|
||||
*/
|
||||
AWS_SDKUTILS_API int aws_endpoints_resolved_endpoint_get_url(
|
||||
const struct aws_endpoints_resolved_endpoint *resolved_endpoint,
|
||||
struct aws_byte_cursor *out_url);
|
||||
|
||||
/*
|
||||
* Get properties for the resolved endpoint.
|
||||
* Note: properties is a json string containing additional data for a given
|
||||
* endpoint. Data is not typed and is not guaranteed to change in the future.
|
||||
* For use at callers discretion.
|
||||
* Valid only if resolved endpoint has endpoint type and will error otherwise.
|
||||
*/
|
||||
AWS_SDKUTILS_API int aws_endpoints_resolved_endpoint_get_properties(
|
||||
const struct aws_endpoints_resolved_endpoint *resolved_endpoint,
|
||||
struct aws_byte_cursor *out_properties);
|
||||
|
||||
/*
|
||||
* Get headers for the resolved endpoint.
|
||||
* out_headers type is aws_hash_table with (aws_string *) as key
|
||||
* and (aws_array_list * of aws_string *) as value.
|
||||
* Note on usage in bindings:
|
||||
* - this is a map to a list of strings and can be implemented as such in the
|
||||
* target language with deep copy of all underlying strings.
|
||||
* Valid only if resolved endpoint has endpoint type and will error otherwise.
|
||||
*/
|
||||
AWS_SDKUTILS_API int aws_endpoints_resolved_endpoint_get_headers(
|
||||
const struct aws_endpoints_resolved_endpoint *resolved_endpoint,
|
||||
const struct aws_hash_table **out_headers);
|
||||
|
||||
/*
|
||||
* Get error for the resolved endpoint.
|
||||
* Valid only if resolved endpoint has error type and will error otherwise.
|
||||
*/
|
||||
AWS_SDKUTILS_API int aws_endpoints_resolved_endpoint_get_error(
|
||||
const struct aws_endpoints_resolved_endpoint *resolved_endpoint,
|
||||
struct aws_byte_cursor *out_error);
|
||||
|
||||
AWS_EXTERN_C_END
|
||||
AWS_POP_SANE_WARNING_LEVEL
|
||||
|
||||
#endif /* AWS_SDKUTILS_ENDPOINTS_RULESET_H */
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef AWS_SDKUTILS_EXPORTS_H
|
||||
#define AWS_SDKUTILS_EXPORTS_H
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
|
||||
#if defined(USE_WINDOWS_DLL_SEMANTICS) || defined(WIN32)
|
||||
# ifdef AWS_SDKUTILS_USE_IMPORT_EXPORT
|
||||
# ifdef AWS_SDKUTILS_EXPORTS
|
||||
# define AWS_SDKUTILS_API __declspec(dllexport)
|
||||
# else
|
||||
# define AWS_SDKUTILS_API __declspec(dllimport)
|
||||
# endif /* AWS_SDKUTILS_EXPORTS */
|
||||
# else
|
||||
# define AWS_SDKUTILS_API
|
||||
# endif /*USE_IMPORT_EXPORT */
|
||||
|
||||
#else
|
||||
# if ((__GNUC__ >= 4) || defined(__clang__)) && defined(AWS_SDKUTILS_USE_IMPORT_EXPORT) && \
|
||||
defined(AWS_SDKUTILS_EXPORTS)
|
||||
# define AWS_SDKUTILS_API __attribute__((visibility("default")))
|
||||
# else
|
||||
# define AWS_SDKUTILS_API
|
||||
# endif /* __GNUC__ >= 4 || defined(__clang__) */
|
||||
|
||||
#endif /* defined(USE_WINDOWS_DLL_SEMANTICS) || defined(WIN32) */
|
||||
|
||||
#endif /* AWS_SDKUTILS_EXPORTS_H */
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
|
||||
#ifndef AWS_SDKUTILS_PARTITIONS_H
|
||||
#define AWS_SDKUTILS_PARTITIONS_H
|
||||
|
||||
#include <aws/common/byte_buf.h>
|
||||
#include <aws/sdkutils/sdkutils.h>
|
||||
|
||||
AWS_PUSH_SANE_WARNING_LEVEL
|
||||
|
||||
struct aws_partitions_config;
|
||||
|
||||
AWS_EXTERN_C_BEGIN
|
||||
|
||||
AWS_SDKUTILS_API struct aws_byte_cursor aws_partitions_get_supported_version(void);
|
||||
|
||||
/*
|
||||
* Create new partitions config from a json string.
|
||||
* In cases of failure NULL is returned and last error is set.
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_partitions_config *aws_partitions_config_new_from_string(
|
||||
struct aws_allocator *allocator,
|
||||
struct aws_byte_cursor json);
|
||||
|
||||
/*
|
||||
* Increment ref count
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_partitions_config *aws_partitions_config_acquire(struct aws_partitions_config *partitions);
|
||||
|
||||
/*
|
||||
* Decrement ref count
|
||||
*/
|
||||
AWS_SDKUTILS_API struct aws_partitions_config *aws_partitions_config_release(struct aws_partitions_config *partitions);
|
||||
|
||||
AWS_EXTERN_C_END
|
||||
AWS_POP_SANE_WARNING_LEVEL
|
||||
|
||||
#endif /* AWS_SDKUTILS_PARTITIONS_H */
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
#ifndef AWS_SDKUTILS_RESOURCE_NAME_H
|
||||
#define AWS_SDKUTILS_RESOURCE_NAME_H
|
||||
#pragma once
|
||||
|
||||
#include <aws/sdkutils/sdkutils.h>
|
||||
|
||||
#include <aws/common/byte_buf.h>
|
||||
|
||||
AWS_PUSH_SANE_WARNING_LEVEL
|
||||
|
||||
struct aws_resource_name {
|
||||
struct aws_byte_cursor partition;
|
||||
struct aws_byte_cursor service;
|
||||
struct aws_byte_cursor region;
|
||||
struct aws_byte_cursor account_id;
|
||||
struct aws_byte_cursor resource_id;
|
||||
};
|
||||
|
||||
AWS_EXTERN_C_BEGIN
|
||||
|
||||
/**
|
||||
Given an ARN "Amazon Resource Name" represented as an in memory a
|
||||
structure representing the parts
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
int aws_resource_name_init_from_cur(struct aws_resource_name *arn, const struct aws_byte_cursor *input);
|
||||
|
||||
/**
|
||||
Calculates the space needed to write an ARN to a byte buf
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
int aws_resource_name_length(const struct aws_resource_name *arn, size_t *size);
|
||||
|
||||
/**
|
||||
Serializes an ARN structure into the lexical string format
|
||||
*/
|
||||
AWS_SDKUTILS_API
|
||||
int aws_byte_buf_append_resource_name(struct aws_byte_buf *buf, const struct aws_resource_name *arn);
|
||||
|
||||
AWS_EXTERN_C_END
|
||||
AWS_POP_SANE_WARNING_LEVEL
|
||||
|
||||
#endif /* AWS_SDKUTILS_RESOURCE_NAME_H */
|
||||
@@ -0,0 +1,57 @@
|
||||
#ifndef AWS_SDKUTILS_SDKUTILS_H
|
||||
#define AWS_SDKUTILS_SDKUTILS_H
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
|
||||
#include <aws/common/common.h>
|
||||
#include <aws/common/logging.h>
|
||||
|
||||
#include <aws/sdkutils/exports.h>
|
||||
|
||||
AWS_PUSH_SANE_WARNING_LEVEL
|
||||
|
||||
struct aws_allocator;
|
||||
|
||||
#define AWS_C_SDKUTILS_PACKAGE_ID 15
|
||||
|
||||
enum aws_sdkutils_errors {
|
||||
AWS_ERROR_SDKUTILS_GENERAL = AWS_ERROR_ENUM_BEGIN_RANGE(AWS_C_SDKUTILS_PACKAGE_ID),
|
||||
AWS_ERROR_SDKUTILS_PARSE_FATAL,
|
||||
AWS_ERROR_SDKUTILS_PARSE_RECOVERABLE,
|
||||
AWS_ERROR_SDKUTILS_ENDPOINTS_UNSUPPORTED_RULESET,
|
||||
AWS_ERROR_SDKUTILS_ENDPOINTS_PARSE_FAILED,
|
||||
AWS_ERROR_SDKUTILS_ENDPOINTS_RESOLVE_INIT_FAILED,
|
||||
AWS_ERROR_SDKUTILS_ENDPOINTS_RESOLVE_FAILED,
|
||||
AWS_ERROR_SDKUTILS_ENDPOINTS_EMPTY_RULESET,
|
||||
AWS_ERROR_SDKUTILS_ENDPOINTS_RULESET_EXHAUSTED,
|
||||
AWS_ERROR_SDKUTILS_PARTITIONS_UNSUPPORTED,
|
||||
AWS_ERROR_SDKUTILS_PARTITIONS_PARSE_FAILED,
|
||||
AWS_ERROR_SDKUTILS_ENDPOINTS_UNSUPPORTED_REGEX,
|
||||
AWS_ERROR_SDKUTILS_ENDPOINTS_REGEX_NO_MATCH,
|
||||
|
||||
AWS_ERROR_SDKUTILS_END_RANGE = AWS_ERROR_ENUM_END_RANGE(AWS_C_SDKUTILS_PACKAGE_ID)
|
||||
};
|
||||
|
||||
enum aws_sdkutils_log_subject {
|
||||
AWS_LS_SDKUTILS_GENERAL = AWS_LOG_SUBJECT_BEGIN_RANGE(AWS_C_SDKUTILS_PACKAGE_ID),
|
||||
AWS_LS_SDKUTILS_PROFILE,
|
||||
AWS_LS_SDKUTILS_ENDPOINTS_PARSING,
|
||||
AWS_LS_SDKUTILS_ENDPOINTS_RESOLVE,
|
||||
AWS_LS_SDKUTILS_ENDPOINTS_GENERAL,
|
||||
AWS_LS_SDKUTILS_PARTITIONS_PARSING,
|
||||
AWS_LS_SDKUTILS_ENDPOINTS_REGEX,
|
||||
|
||||
AWS_LS_SDKUTILS_LAST = AWS_LOG_SUBJECT_END_RANGE(AWS_C_SDKUTILS_PACKAGE_ID)
|
||||
};
|
||||
|
||||
AWS_EXTERN_C_BEGIN
|
||||
|
||||
AWS_SDKUTILS_API void aws_sdkutils_library_init(struct aws_allocator *allocator);
|
||||
AWS_SDKUTILS_API void aws_sdkutils_library_clean_up(void);
|
||||
|
||||
AWS_EXTERN_C_END
|
||||
AWS_POP_SANE_WARNING_LEVEL
|
||||
|
||||
#endif /* AWS_SDKUTILS_SDKUTILS_H */
|
||||
Reference in New Issue
Block a user