From cab7c803b9ade8e0f9286ce6cfe96d2ddf88fbf2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 22 Feb 2023 02:01:22 +0000 Subject: [PATCH] Update services based on v1.44.206 of AWS Go SDK Reference: https://github.com/aws/aws-sdk-go/releases/tag/v1.44.206 --- .latest-tag-aws-sdk-go | 2 +- src/aws_resiliencehub.erl | 480 +++++++++++++- src/aws_securityhub.erl | 10 +- src/aws_tnb.erl | 1276 +++++++++++++++++++++++++++++++++++++ 4 files changed, 1732 insertions(+), 36 deletions(-) create mode 100644 src/aws_tnb.erl diff --git a/.latest-tag-aws-sdk-go b/.latest-tag-aws-sdk-go index 9db889a0..48f60715 100644 --- a/.latest-tag-aws-sdk-go +++ b/.latest-tag-aws-sdk-go @@ -1 +1 @@ -v1.44.205 +v1.44.206 diff --git a/src/aws_resiliencehub.erl b/src/aws_resiliencehub.erl index c713dbd3..3154aad5 100644 --- a/src/aws_resiliencehub.erl +++ b/src/aws_resiliencehub.erl @@ -15,6 +15,10 @@ add_draft_app_version_resource_mappings/3, create_app/2, create_app/3, + create_app_version_app_component/2, + create_app_version_app_component/3, + create_app_version_resource/2, + create_app_version_resource/3, create_recommendation_template/2, create_recommendation_template/3, create_resiliency_policy/2, @@ -23,6 +27,12 @@ delete_app/3, delete_app_assessment/2, delete_app_assessment/3, + delete_app_input_source/2, + delete_app_input_source/3, + delete_app_version_app_component/2, + delete_app_version_app_component/3, + delete_app_version_resource/2, + delete_app_version_resource/3, delete_recommendation_template/2, delete_recommendation_template/3, delete_resiliency_policy/2, @@ -31,6 +41,12 @@ describe_app/3, describe_app_assessment/2, describe_app_assessment/3, + describe_app_version/2, + describe_app_version/3, + describe_app_version_app_component/2, + describe_app_version_app_component/3, + describe_app_version_resource/2, + describe_app_version_resource/3, describe_app_version_resources_resolution_status/2, describe_app_version_resources_resolution_status/3, describe_app_version_template/2, @@ -50,6 +66,10 @@ list_app_component_compliances/3, list_app_component_recommendations/2, list_app_component_recommendations/3, + list_app_input_sources/2, + list_app_input_sources/3, + list_app_version_app_components/2, + list_app_version_app_components/3, list_app_version_resource_mappings/2, list_app_version_resource_mappings/3, list_app_version_resources/2, @@ -93,6 +113,12 @@ untag_resource/4, update_app/2, update_app/3, + update_app_version/2, + update_app_version/3, + update_app_version_app_component/2, + update_app_version_app_component/3, + update_app_version_resource/2, + update_app_version_resource/3, update_resiliency_policy/2, update_resiliency_policy/3]). @@ -103,6 +129,9 @@ %%==================================================================== %% @doc Adds the resource mapping for the draft application version. +%% +%% You can also update an existing resource mapping to a new physical +%% resource. add_draft_app_version_resource_mappings(Client, Input) -> add_draft_app_version_resource_mappings(Client, Input, []). add_draft_app_version_resource_mappings(Client, Input0, Options0) -> @@ -125,20 +154,20 @@ add_draft_app_version_resource_mappings(Client, Input0, Options0) -> request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). -%% @doc Creates a Resilience Hub application. +%% @doc Creates an AWS Resilience Hub application. %% -%% A Resilience Hub application is a collection of Amazon Web Services +%% An AWS Resilience Hub application is a collection of Amazon Web Services %% resources structured to prevent and recover Amazon Web Services -%% application disruptions. To describe a Resilience Hub application, you +%% application disruptions. To describe a AWS Resilience Hub application, you %% provide an application name, resources from one or more–up to %% five–CloudFormation stacks, and an appropriate resiliency policy. %% -%% After you create a Resilience Hub application, you publish it so that you -%% can run a resiliency assessment on it. You can then use recommendations -%% from the assessment to improve resiliency by running another assessment, -%% comparing results, and then iterating the process until you achieve your -%% goals for recovery time objective (RTO) and recovery point objective -%% (RPO). +%% After you create an AWS Resilience Hub application, you publish it so that +%% you can run a resiliency assessment on it. You can then use +%% recommendations from the assessment to improve resiliency by running +%% another assessment, comparing results, and then iterating the process +%% until you achieve your goals for recovery time objective (RTO) and +%% recovery point objective (RPO). create_app(Client, Input) -> create_app(Client, Input, []). create_app(Client, Input0, Options0) -> @@ -161,7 +190,72 @@ create_app(Client, Input0, Options0) -> request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). -%% @doc Creates a new recommendation template. +%% @doc Creates a new Application Component in the AWS Resilience Hub +%% application. +%% +%% This API updates the AWS Resilience Hub application draft version. To use +%% this Application Component for running assessments, you must publish the +%% AWS Resilience Hub application using the `PublishAppVersion' API. +create_app_version_app_component(Client, Input) -> + create_app_version_app_component(Client, Input, []). +create_app_version_app_component(Client, Input0, Options0) -> + Method = post, + Path = ["/create-app-version-app-component"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Adds a resource to the AWS Resilience Hub applicationand assigns it +%% to the specified Application Components. +%% +%% If you specify a new Application Component, AWS Resilience Hub will +%% automatically create the Application Component. +%% +%% This action has no effect outside AWS Resilience Hub. +%% +%% This API updates the AWS Resilience Hub application draft version. To use +%% this resource for running resiliency assessments, you must publish the AWS +%% Resilience Hub application using the `PublishAppVersion' API. +%% +%% To update application version with new `physicalResourceID', you must +%% call `ResolveAppVersionResources' API. +create_app_version_resource(Client, Input) -> + create_app_version_resource(Client, Input, []). +create_app_version_resource(Client, Input0, Options0) -> + Method = post, + Path = ["/create-app-version-resource"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Creates a new recommendation template for the AWS Resilience Hub +%% application. create_recommendation_template(Client, Input) -> create_recommendation_template(Client, Input, []). create_recommendation_template(Client, Input0, Options0) -> @@ -257,6 +351,93 @@ delete_app_assessment(Client, Input0, Options0) -> request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). +%% @doc Deletes the input source and all of its imported resources from the +%% AWS Resilience Hub application. +delete_app_input_source(Client, Input) -> + delete_app_input_source(Client, Input, []). +delete_app_input_source(Client, Input0, Options0) -> + Method = post, + Path = ["/delete-app-input-source"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Deletes an Application Component from the AWS Resilience Hub +%% application. +%% +%% This API updates the AWS Resilience Hub application draft version. To use +%% this Application Component for running assessments, you must publish the +%% AWS Resilience Hub application using the `PublishAppVersion' API. +%% +%% You will not be able to delete an Application Component if it has +%% resources associated with it. +delete_app_version_app_component(Client, Input) -> + delete_app_version_app_component(Client, Input, []). +delete_app_version_app_component(Client, Input0, Options0) -> + Method = post, + Path = ["/delete-app-version-app-component"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Deletes a resource from the AWS Resilience Hub application. +%% +%% You can only delete a manually added resource. To exclude non-manually +%% added resources, use the `UpdateAppVersionResource' API. +%% +%% This action has no effect outside AWS Resilience Hub. +%% +%% This API updates the AWS Resilience Hub application draft version. To use +%% this resource for running resiliency assessments, you must publish the AWS +%% Resilience Hub application using the `PublishAppVersion' API. +delete_app_version_resource(Client, Input) -> + delete_app_version_resource(Client, Input, []). +delete_app_version_resource(Client, Input0, Options0) -> + Method = post, + Path = ["/delete-app-version-resource"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + %% @doc Deletes a recommendation template. %% %% This is a destructive action that can't be undone. @@ -353,6 +534,86 @@ describe_app_assessment(Client, Input0, Options0) -> request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). +%% @doc Describes the AWS Resilience Hub application version. +describe_app_version(Client, Input) -> + describe_app_version(Client, Input, []). +describe_app_version(Client, Input0, Options0) -> + Method = post, + Path = ["/describe-app-version"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Describes an Application Component in the AWS Resilience Hub +%% application. +describe_app_version_app_component(Client, Input) -> + describe_app_version_app_component(Client, Input, []). +describe_app_version_app_component(Client, Input0, Options0) -> + Method = post, + Path = ["/describe-app-version-app-component"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Describes a resource of the AWS Resilience Hub application. +%% +%% This API accepts only one of the following parameters to descibe the +%% resource: +%% +%% `resourceName' +%% +%% `logicalResourceId' +%% +%% `physicalResourceId' (Along with `physicalResourceId', you can +%% also provide `awsAccountId', and `awsRegion') +describe_app_version_resource(Client, Input) -> + describe_app_version_resource(Client, Input, []). +describe_app_version_resource(Client, Input0, Options0) -> + Method = post, + Path = ["/describe-app-version-resource"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + %% @doc Returns the resolution status for the specified resolution identifier %% for an application version. %% @@ -380,7 +641,7 @@ describe_app_version_resources_resolution_status(Client, Input0, Options0) -> request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). -%% @doc Describes details about an AWS Resilience Hub +%% @doc Describes details about an AWS Resilience Hub application. describe_app_version_template(Client, Input) -> describe_app_version_template(Client, Input, []). describe_app_version_template(Client, Input0, Options0) -> @@ -405,6 +666,12 @@ describe_app_version_template(Client, Input0, Options0) -> %% @doc Describes the status of importing resources to an application %% version. +%% +%% If you get a 404 error with +%% `ResourceImportStatusNotFoundAppMetadataException', you must call +%% `importResourcesToDraftAppVersion' after creating the application and +%% before calling `describeDraftAppVersionResourcesImportStatus' to +%% obtain the status. describe_draft_app_version_resources_import_status(Client, Input) -> describe_draft_app_version_resources_import_status(Client, Input, []). describe_draft_app_version_resources_import_status(Client, Input0, Options0) -> @@ -455,9 +722,12 @@ describe_resiliency_policy(Client, Input0, Options0) -> request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). -%% @doc Imports resources from sources such as a CloudFormation stack, -%% resource-groups, or application registry app to a draft application -%% version. +%% @doc Imports resources to AWS Resilience Hub application draft version +%% from different input sources. +%% +%% For more information about the input sources supported by AWS Resilience +%% Hub, see Discover the structure and describe your Resilience Hub +%% application. import_resources_to_draft_app_version(Client, Input) -> import_resources_to_draft_app_version(Client, Input, []). import_resources_to_draft_app_version(Client, Input0, Options0) -> @@ -480,7 +750,8 @@ import_resources_to_draft_app_version(Client, Input0, Options0) -> request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). -%% @doc Lists the alarm recommendations for a AWS Resilience Hub application. +%% @doc Lists the alarm recommendations for an AWS Resilience Hub +%% application. list_alarm_recommendations(Client, Input) -> list_alarm_recommendations(Client, Input, []). list_alarm_recommendations(Client, Input0, Options0) -> @@ -540,7 +811,8 @@ list_app_assessments(Client, QueryMap, HeadersMap, Options0) request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode). -%% @doc Lists the compliances for an AWS Resilience Hub component. +%% @doc Lists the compliances for an AWS Resilience Hub Application +%% Component. list_app_component_compliances(Client, Input) -> list_app_component_compliances(Client, Input, []). list_app_component_compliances(Client, Input0, Options0) -> @@ -563,7 +835,8 @@ list_app_component_compliances(Client, Input0, Options0) -> request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). -%% @doc Lists the recommendations for an AWS Resilience Hub component. +%% @doc Lists the recommendations for an AWS Resilience Hub Application +%% Component. list_app_component_recommendations(Client, Input) -> list_app_component_recommendations(Client, Input, []). list_app_component_recommendations(Client, Input0, Options0) -> @@ -586,6 +859,57 @@ list_app_component_recommendations(Client, Input0, Options0) -> request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). +%% @doc Lists all the input sources of the AWS Resilience Hub application. +%% +%% For more information about the input sources supported by AWS Resilience +%% Hub, see Discover the structure and describe your Resilience Hub +%% application. +list_app_input_sources(Client, Input) -> + list_app_input_sources(Client, Input, []). +list_app_input_sources(Client, Input0, Options0) -> + Method = post, + Path = ["/list-app-input-sources"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Lists all the Application Components in the AWS Resilience Hub +%% application. +list_app_version_app_components(Client, Input) -> + list_app_version_app_components(Client, Input, []). +list_app_version_app_components(Client, Input0, Options0) -> + Method = post, + Path = ["/list-app-version-app-components"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + %% @doc Lists how the resources in an application version are mapped/sourced %% from. %% @@ -613,7 +937,7 @@ list_app_version_resource_mappings(Client, Input0, Options0) -> request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). -%% @doc Lists all the resources in an application version. +%% @doc Lists all the resources in an AWS Resilience Hub application. list_app_version_resources(Client, Input) -> list_app_version_resources(Client, Input, []). list_app_version_resources(Client, Input0, Options0) -> @@ -636,7 +960,7 @@ list_app_version_resources(Client, Input0, Options0) -> request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). -%% @doc Lists the different versions for the Resilience Hub applications. +%% @doc Lists the different versions for the AWS Resilience Hub applications. list_app_versions(Client, Input) -> list_app_versions(Client, Input, []). list_app_versions(Client, Input0, Options0) -> @@ -659,7 +983,14 @@ list_app_versions(Client, Input0, Options0) -> request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). -%% @doc Lists your Resilience Hub applications. +%% @doc Lists your AWS Resilience Hub applications. +%% +%% You can filter applications using only one filter at a time or without +%% using any filter. If you try to filter applications using multiple +%% filters, you will get the following error: +%% +%% `An error occurred (ValidationException) when calling the ListApps +%% operation: Only one filter is supported for this operation.' list_apps(Client) when is_map(Client) -> list_apps(Client, #{}, #{}). @@ -689,7 +1020,7 @@ list_apps(Client, QueryMap, HeadersMap, Options0) request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode). -%% @doc Lists the recommendation templates for the Resilience Hub +%% @doc Lists the recommendation templates for the AWS Resilience Hub %% applications. list_recommendation_templates(Client, AssessmentArn) when is_map(Client) -> @@ -723,7 +1054,8 @@ list_recommendation_templates(Client, AssessmentArn, QueryMap, HeadersMap, Optio request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode). -%% @doc Lists the resiliency policies for the Resilience Hub applications. +%% @doc Lists the resiliency policies for the AWS Resilience Hub +%% applications. list_resiliency_policies(Client) when is_map(Client) -> list_resiliency_policies(Client, #{}, #{}). @@ -753,7 +1085,7 @@ list_resiliency_policies(Client, QueryMap, HeadersMap, Options0) request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode). %% @doc Lists the standard operating procedure (SOP) recommendations for the -%% Resilience Hub applications. +%% AWS Resilience Hub applications. list_sop_recommendations(Client, Input) -> list_sop_recommendations(Client, Input, []). list_sop_recommendations(Client, Input0, Options0) -> @@ -776,7 +1108,7 @@ list_sop_recommendations(Client, Input0, Options0) -> request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). -%% @doc Lists the suggested resiliency policies for the Resilience Hub +%% @doc Lists the suggested resiliency policies for the AWS Resilience Hub %% applications. list_suggested_resiliency_policies(Client) when is_map(Client) -> @@ -805,7 +1137,7 @@ list_suggested_resiliency_policies(Client, QueryMap, HeadersMap, Options0) request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode). -%% @doc Lists the tags for your resources in your Resilience Hub +%% @doc Lists the tags for your resources in your AWS Resilience Hub %% applications. list_tags_for_resource(Client, ResourceArn) when is_map(Client) -> @@ -829,7 +1161,8 @@ list_tags_for_resource(Client, ResourceArn, QueryMap, HeadersMap, Options0) request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode). -%% @doc Lists the test recommendations for the Resilience Hub application. +%% @doc Lists the test recommendations for the AWS Resilience Hub +%% application. list_test_recommendations(Client, Input) -> list_test_recommendations(Client, Input, []). list_test_recommendations(Client, Input0, Options0) -> @@ -856,7 +1189,7 @@ list_test_recommendations(Client, Input0, Options0) -> %% Resilience Hub. %% %% An unsupported resource is a resource that exists in the object that was -%% used to create an app, but is not supported by Resilience Hub. +%% used to create an app, but is not supported by AWS Resilience Hub. list_unsupported_app_version_resources(Client, Input) -> list_unsupported_app_version_resources(Client, Input, []). list_unsupported_app_version_resources(Client, Input0, Options0) -> @@ -879,7 +1212,7 @@ list_unsupported_app_version_resources(Client, Input0, Options0) -> request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). -%% @doc Publishes a new version of a specific Resilience Hub application. +%% @doc Publishes a new version of a specific AWS Resilience Hub application. publish_app_version(Client, Input) -> publish_app_version(Client, Input, []). publish_app_version(Client, Input0, Options0) -> @@ -902,8 +1235,8 @@ publish_app_version(Client, Input0, Options0) -> request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). -%% @doc Adds or updates the app template for a draft version of a Resilience -%% Hub app. +%% @doc Adds or updates the app template for an AWS Resilience Hub +%% application draft version. put_draft_app_version_template(Client, Input) -> put_draft_app_version_template(Client, Input, []). put_draft_app_version_template(Client, Input0, Options0) -> @@ -1065,6 +1398,93 @@ update_app(Client, Input0, Options0) -> request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). +%% @doc Updates the AWS Resilience Hub application version. +%% +%% This API updates the AWS Resilience Hub application draft version. To use +%% this information for running resiliency assessments, you must publish the +%% AWS Resilience Hub application using the `PublishAppVersion' API. +update_app_version(Client, Input) -> + update_app_version(Client, Input, []). +update_app_version(Client, Input0, Options0) -> + Method = post, + Path = ["/update-app-version"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Updates an existing Application Component in the AWS Resilience Hub +%% application. +%% +%% This API updates the AWS Resilience Hub application draft version. To use +%% this Application Component for running assessments, you must publish the +%% AWS Resilience Hub application using the `PublishAppVersion' API. +update_app_version_app_component(Client, Input) -> + update_app_version_app_component(Client, Input, []). +update_app_version_app_component(Client, Input0, Options0) -> + Method = post, + Path = ["/update-app-version-app-component"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Updates the resource details in the AWS Resilience Hub application. +%% +%% This action has no effect outside AWS Resilience Hub. +%% +%% This API updates the AWS Resilience Hub application draft version. To use +%% this resource for running resiliency assessments, you must publish the AWS +%% Resilience Hub application using the `PublishAppVersion' API. +%% +%% To update application version with new `physicalResourceID', you must +%% call `ResolveAppVersionResources' API. +update_app_version_resource(Client, Input) -> + update_app_version_resource(Client, Input, []). +update_app_version_resource(Client, Input0, Options0) -> + Method = post, + Path = ["/update-app-version-resource"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + %% @doc Updates a resiliency policy. update_resiliency_policy(Client, Input) -> update_resiliency_policy(Client, Input, []). diff --git a/src/aws_securityhub.erl b/src/aws_securityhub.erl index c33fc78e..dd08a100 100644 --- a/src/aws_securityhub.erl +++ b/src/aws_securityhub.erl @@ -1175,16 +1175,16 @@ enable_organization_admin_account(Client, Input0, Options0) -> %% Security Hub. %% %% When you use the `EnableSecurityHub' operation to enable Security Hub, -%% you also automatically enable the following standards. +%% you also automatically enable the following standards: %% -%% Other standards are not automatically enabled. %% -%% To not enable the automatically enabled standards, set +%% To opt out of automatically enabled standards, set %% `EnableDefaultStandards' to `false'. %% %% After you enable Security Hub, to enable a standard, use the diff --git a/src/aws_tnb.erl b/src/aws_tnb.erl new file mode 100644 index 00000000..eb9ce780 --- /dev/null +++ b/src/aws_tnb.erl @@ -0,0 +1,1276 @@ +%% WARNING: DO NOT EDIT, AUTO-GENERATED CODE! +%% See https://github.com/aws-beam/aws-codegen for more details. + +%% @doc Amazon Web Services Telco Network Builder (TNB) is a network +%% automation service that helps you deploy and manage telecom networks. +%% +%% AWS TNB helps you with the lifecycle management of your telecommunication +%% network functions throughout planning, deployment, and post-deployment +%% activities. +-module(aws_tnb). + +-export([cancel_sol_network_operation/3, + cancel_sol_network_operation/4, + create_sol_function_package/2, + create_sol_function_package/3, + create_sol_network_instance/2, + create_sol_network_instance/3, + create_sol_network_package/2, + create_sol_network_package/3, + delete_sol_function_package/3, + delete_sol_function_package/4, + delete_sol_network_instance/3, + delete_sol_network_instance/4, + delete_sol_network_package/3, + delete_sol_network_package/4, + get_sol_function_instance/2, + get_sol_function_instance/4, + get_sol_function_instance/5, + get_sol_function_package/2, + get_sol_function_package/4, + get_sol_function_package/5, + get_sol_function_package_content/3, + get_sol_function_package_content/5, + get_sol_function_package_content/6, + get_sol_function_package_descriptor/3, + get_sol_function_package_descriptor/5, + get_sol_function_package_descriptor/6, + get_sol_network_instance/2, + get_sol_network_instance/4, + get_sol_network_instance/5, + get_sol_network_operation/2, + get_sol_network_operation/4, + get_sol_network_operation/5, + get_sol_network_package/2, + get_sol_network_package/4, + get_sol_network_package/5, + get_sol_network_package_content/3, + get_sol_network_package_content/5, + get_sol_network_package_content/6, + get_sol_network_package_descriptor/2, + get_sol_network_package_descriptor/4, + get_sol_network_package_descriptor/5, + instantiate_sol_network_instance/3, + instantiate_sol_network_instance/4, + list_sol_function_instances/1, + list_sol_function_instances/3, + list_sol_function_instances/4, + list_sol_function_packages/1, + list_sol_function_packages/3, + list_sol_function_packages/4, + list_sol_network_instances/1, + list_sol_network_instances/3, + list_sol_network_instances/4, + list_sol_network_operations/1, + list_sol_network_operations/3, + list_sol_network_operations/4, + list_sol_network_packages/1, + list_sol_network_packages/3, + list_sol_network_packages/4, + list_tags_for_resource/2, + list_tags_for_resource/4, + list_tags_for_resource/5, + put_sol_function_package_content/3, + put_sol_function_package_content/4, + put_sol_network_package_content/3, + put_sol_network_package_content/4, + tag_resource/3, + tag_resource/4, + terminate_sol_network_instance/3, + terminate_sol_network_instance/4, + untag_resource/3, + untag_resource/4, + update_sol_function_package/3, + update_sol_function_package/4, + update_sol_network_instance/3, + update_sol_network_instance/4, + update_sol_network_package/3, + update_sol_network_package/4, + validate_sol_function_package_content/3, + validate_sol_function_package_content/4, + validate_sol_network_package_content/3, + validate_sol_network_package_content/4]). + +-include_lib("hackney/include/hackney_lib.hrl"). + +%%==================================================================== +%% API +%%==================================================================== + +%% @doc Cancels a network operation. +%% +%% A network operation is any operation that is done to your network, such as +%% network instance instantiation or termination. +cancel_sol_network_operation(Client, NsLcmOpOccId, Input) -> + cancel_sol_network_operation(Client, NsLcmOpOccId, Input, []). +cancel_sol_network_operation(Client, NsLcmOpOccId, Input0, Options0) -> + Method = post, + Path = ["/sol/nslcm/v1/ns_lcm_op_occs/", aws_util:encode_uri(NsLcmOpOccId), "/cancel"], + SuccessStatusCode = 202, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Creates a function package. +%% +%% A function package is a .zip file in CSAR (Cloud Service Archive) format +%% that contains a network function (an ETSI standard telecommunication +%% application) and function package descriptor that uses the TOSCA standard +%% to describe how the network functions should run on your network. For more +%% information, see Function packages in the Amazon Web Services Telco +%% Network Builder User Guide. +%% +%% Creating a function package is the first step for creating a network in +%% AWS TNB. This request creates an empty container with an ID. The next step +%% is to upload the actual CSAR zip file into that empty container. To upload +%% function package content, see PutSolFunctionPackageContent. +create_sol_function_package(Client, Input) -> + create_sol_function_package(Client, Input, []). +create_sol_function_package(Client, Input0, Options0) -> + Method = post, + Path = ["/sol/vnfpkgm/v1/vnf_packages"], + SuccessStatusCode = 201, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Creates a network instance. +%% +%% A network instance is a single network created in Amazon Web Services TNB +%% that can be deployed and on which life-cycle operations (like terminate, +%% update, and delete) can be performed. Creating a network instance is the +%% third step after creating a network package. For more information about +%% network instances, Network instances in the Amazon Web Services Telco +%% Network Builder User Guide. +%% +%% Once you create a network instance, you can instantiate it. To instantiate +%% a network, see InstantiateSolNetworkInstance. +create_sol_network_instance(Client, Input) -> + create_sol_network_instance(Client, Input, []). +create_sol_network_instance(Client, Input0, Options0) -> + Method = post, + Path = ["/sol/nslcm/v1/ns_instances"], + SuccessStatusCode = 201, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Creates a network package. +%% +%% A network package is a .zip file in CSAR (Cloud Service Archive) format +%% defines the function packages you want to deploy and the Amazon Web +%% Services infrastructure you want to deploy them on. For more information, +%% see Network instances in the Amazon Web Services Telco Network Builder +%% User Guide. +%% +%% A network package consists of a network service descriptor (NSD) file +%% (required) and any additional files (optional), such as scripts specific +%% to your needs. For example, if you have multiple function packages in your +%% network package, you can use the NSD to define which network functions +%% should run in certain VPCs, subnets, or EKS clusters. +%% +%% This request creates an empty network package container with an ID. Once +%% you create a network package, you can upload the network package content +%% using PutSolNetworkPackageContent. +create_sol_network_package(Client, Input) -> + create_sol_network_package(Client, Input, []). +create_sol_network_package(Client, Input0, Options0) -> + Method = post, + Path = ["/sol/nsd/v1/ns_descriptors"], + SuccessStatusCode = 201, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Deletes a function package. +%% +%% A function package is a .zip file in CSAR (Cloud Service Archive) format +%% that contains a network function (an ETSI standard telecommunication +%% application) and function package descriptor that uses the TOSCA standard +%% to describe how the network functions should run on your network. +%% +%% To delete a function package, the package must be in a disabled state. To +%% disable a function package, see UpdateSolFunctionPackage. +delete_sol_function_package(Client, VnfPkgId, Input) -> + delete_sol_function_package(Client, VnfPkgId, Input, []). +delete_sol_function_package(Client, VnfPkgId, Input0, Options0) -> + Method = delete, + Path = ["/sol/vnfpkgm/v1/vnf_packages/", aws_util:encode_uri(VnfPkgId), ""], + SuccessStatusCode = 204, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Deletes a network instance. +%% +%% A network instance is a single network created in Amazon Web Services TNB +%% that can be deployed and on which life-cycle operations (like terminate, +%% update, and delete) can be performed. +%% +%% To delete a network instance, the instance must be in a stopped or +%% terminated state. To terminate a network instance, see +%% TerminateSolNetworkInstance. +delete_sol_network_instance(Client, NsInstanceId, Input) -> + delete_sol_network_instance(Client, NsInstanceId, Input, []). +delete_sol_network_instance(Client, NsInstanceId, Input0, Options0) -> + Method = delete, + Path = ["/sol/nslcm/v1/ns_instances/", aws_util:encode_uri(NsInstanceId), ""], + SuccessStatusCode = 204, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Deletes network package. +%% +%% A network package is a .zip file in CSAR (Cloud Service Archive) format +%% defines the function packages you want to deploy and the Amazon Web +%% Services infrastructure you want to deploy them on. +%% +%% To delete a network package, the package must be in a disable state. To +%% disable a network package, see UpdateSolNetworkPackage. +delete_sol_network_package(Client, NsdInfoId, Input) -> + delete_sol_network_package(Client, NsdInfoId, Input, []). +delete_sol_network_package(Client, NsdInfoId, Input0, Options0) -> + Method = delete, + Path = ["/sol/nsd/v1/ns_descriptors/", aws_util:encode_uri(NsdInfoId), ""], + SuccessStatusCode = 204, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Gets the details of a network function instance, including the +%% instantation state and metadata from the function package descriptor in +%% the network function package. +%% +%% A network function instance is a function in a function package . +get_sol_function_instance(Client, VnfInstanceId) + when is_map(Client) -> + get_sol_function_instance(Client, VnfInstanceId, #{}, #{}). + +get_sol_function_instance(Client, VnfInstanceId, QueryMap, HeadersMap) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> + get_sol_function_instance(Client, VnfInstanceId, QueryMap, HeadersMap, []). + +get_sol_function_instance(Client, VnfInstanceId, QueryMap, HeadersMap, Options0) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> + Path = ["/sol/vnflcm/v1/vnf_instances/", aws_util:encode_uri(VnfInstanceId), ""], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false} + | Options0], + + Headers = [], + + Query_ = [], + + request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode). + +%% @doc Gets the details of an individual function package, such as the +%% operational state and whether the package is in use. +%% +%% A function package is a .zip file in CSAR (Cloud Service Archive) format +%% that contains a network function (an ETSI standard telecommunication +%% application) and function package descriptor that uses the TOSCA standard +%% to describe how the network functions should run on your network.. +get_sol_function_package(Client, VnfPkgId) + when is_map(Client) -> + get_sol_function_package(Client, VnfPkgId, #{}, #{}). + +get_sol_function_package(Client, VnfPkgId, QueryMap, HeadersMap) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> + get_sol_function_package(Client, VnfPkgId, QueryMap, HeadersMap, []). + +get_sol_function_package(Client, VnfPkgId, QueryMap, HeadersMap, Options0) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> + Path = ["/sol/vnfpkgm/v1/vnf_packages/", aws_util:encode_uri(VnfPkgId), ""], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false} + | Options0], + + Headers = [], + + Query_ = [], + + request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode). + +%% @doc Gets the contents of a function package. +%% +%% A function package is a .zip file in CSAR (Cloud Service Archive) format +%% that contains a network function (an ETSI standard telecommunication +%% application) and function package descriptor that uses the TOSCA standard +%% to describe how the network functions should run on your network. +get_sol_function_package_content(Client, VnfPkgId, Accept) + when is_map(Client) -> + get_sol_function_package_content(Client, VnfPkgId, Accept, #{}, #{}). + +get_sol_function_package_content(Client, VnfPkgId, Accept, QueryMap, HeadersMap) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> + get_sol_function_package_content(Client, VnfPkgId, Accept, QueryMap, HeadersMap, []). + +get_sol_function_package_content(Client, VnfPkgId, Accept, QueryMap, HeadersMap, Options0) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> + Path = ["/sol/vnfpkgm/v1/vnf_packages/", aws_util:encode_uri(VnfPkgId), "/package_content"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false} + | Options0], + + Headers0 = + [ + {<<"Accept">>, Accept} + ], + Headers = [H || {_, V} = H <- Headers0, V =/= undefined], + + Query_ = [], + + case request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode) of + {ok, Body0, {_, ResponseHeaders, _} = Response} -> + ResponseHeadersParams = + [ + {<<"Content-Type">>, <<"contentType">>} + ], + FoldFun = fun({Name_, Key_}, Acc_) -> + case lists:keyfind(Name_, 1, ResponseHeaders) of + false -> Acc_; + {_, Value_} -> Acc_#{Key_ => Value_} + end + end, + Body = lists:foldl(FoldFun, Body0, ResponseHeadersParams), + {ok, Body, Response}; + Result -> + Result + end. + +%% @doc Gets a function package descriptor in a function package. +%% +%% A function package descriptor is a .yaml file in a function package that +%% uses the TOSCA standard to describe how the network function in the +%% function package should run on your network. +%% +%% A function package is a .zip file in CSAR (Cloud Service Archive) format +%% that contains a network function (an ETSI standard telecommunication +%% application) and function package descriptor that uses the TOSCA standard +%% to describe how the network functions should run on your network. +get_sol_function_package_descriptor(Client, VnfPkgId, Accept) + when is_map(Client) -> + get_sol_function_package_descriptor(Client, VnfPkgId, Accept, #{}, #{}). + +get_sol_function_package_descriptor(Client, VnfPkgId, Accept, QueryMap, HeadersMap) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> + get_sol_function_package_descriptor(Client, VnfPkgId, Accept, QueryMap, HeadersMap, []). + +get_sol_function_package_descriptor(Client, VnfPkgId, Accept, QueryMap, HeadersMap, Options0) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> + Path = ["/sol/vnfpkgm/v1/vnf_packages/", aws_util:encode_uri(VnfPkgId), "/vnfd"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false} + | Options0], + + Headers0 = + [ + {<<"Accept">>, Accept} + ], + Headers = [H || {_, V} = H <- Headers0, V =/= undefined], + + Query_ = [], + + case request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode) of + {ok, Body0, {_, ResponseHeaders, _} = Response} -> + ResponseHeadersParams = + [ + {<<"Content-Type">>, <<"contentType">>} + ], + FoldFun = fun({Name_, Key_}, Acc_) -> + case lists:keyfind(Name_, 1, ResponseHeaders) of + false -> Acc_; + {_, Value_} -> Acc_#{Key_ => Value_} + end + end, + Body = lists:foldl(FoldFun, Body0, ResponseHeadersParams), + {ok, Body, Response}; + Result -> + Result + end. + +%% @doc Gets the details of the network instance. +%% +%% A network instance is a single network created in Amazon Web Services TNB +%% that can be deployed and on which life-cycle operations (like terminate, +%% update, and delete) can be performed. +get_sol_network_instance(Client, NsInstanceId) + when is_map(Client) -> + get_sol_network_instance(Client, NsInstanceId, #{}, #{}). + +get_sol_network_instance(Client, NsInstanceId, QueryMap, HeadersMap) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> + get_sol_network_instance(Client, NsInstanceId, QueryMap, HeadersMap, []). + +get_sol_network_instance(Client, NsInstanceId, QueryMap, HeadersMap, Options0) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> + Path = ["/sol/nslcm/v1/ns_instances/", aws_util:encode_uri(NsInstanceId), ""], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false} + | Options0], + + Headers = [], + + Query_ = [], + + request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode). + +%% @doc Gets the details of a network operation, including the tasks involved +%% in the network operation and the status of the tasks. +%% +%% A network operation is any operation that is done to your network, such as +%% network instance instantiation or termination. +get_sol_network_operation(Client, NsLcmOpOccId) + when is_map(Client) -> + get_sol_network_operation(Client, NsLcmOpOccId, #{}, #{}). + +get_sol_network_operation(Client, NsLcmOpOccId, QueryMap, HeadersMap) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> + get_sol_network_operation(Client, NsLcmOpOccId, QueryMap, HeadersMap, []). + +get_sol_network_operation(Client, NsLcmOpOccId, QueryMap, HeadersMap, Options0) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> + Path = ["/sol/nslcm/v1/ns_lcm_op_occs/", aws_util:encode_uri(NsLcmOpOccId), ""], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false} + | Options0], + + Headers = [], + + Query_ = [], + + request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode). + +%% @doc Gets the details of a network package. +%% +%% A network package is a .zip file in CSAR (Cloud Service Archive) format +%% defines the function packages you want to deploy and the Amazon Web +%% Services infrastructure you want to deploy them on. +get_sol_network_package(Client, NsdInfoId) + when is_map(Client) -> + get_sol_network_package(Client, NsdInfoId, #{}, #{}). + +get_sol_network_package(Client, NsdInfoId, QueryMap, HeadersMap) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> + get_sol_network_package(Client, NsdInfoId, QueryMap, HeadersMap, []). + +get_sol_network_package(Client, NsdInfoId, QueryMap, HeadersMap, Options0) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> + Path = ["/sol/nsd/v1/ns_descriptors/", aws_util:encode_uri(NsdInfoId), ""], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false} + | Options0], + + Headers = [], + + Query_ = [], + + request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode). + +%% @doc Gets the contents of a network package. +%% +%% A network package is a .zip file in CSAR (Cloud Service Archive) format +%% defines the function packages you want to deploy and the Amazon Web +%% Services infrastructure you want to deploy them on. +get_sol_network_package_content(Client, NsdInfoId, Accept) + when is_map(Client) -> + get_sol_network_package_content(Client, NsdInfoId, Accept, #{}, #{}). + +get_sol_network_package_content(Client, NsdInfoId, Accept, QueryMap, HeadersMap) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> + get_sol_network_package_content(Client, NsdInfoId, Accept, QueryMap, HeadersMap, []). + +get_sol_network_package_content(Client, NsdInfoId, Accept, QueryMap, HeadersMap, Options0) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> + Path = ["/sol/nsd/v1/ns_descriptors/", aws_util:encode_uri(NsdInfoId), "/nsd_content"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false} + | Options0], + + Headers0 = + [ + {<<"Accept">>, Accept} + ], + Headers = [H || {_, V} = H <- Headers0, V =/= undefined], + + Query_ = [], + + case request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode) of + {ok, Body0, {_, ResponseHeaders, _} = Response} -> + ResponseHeadersParams = + [ + {<<"Content-Type">>, <<"contentType">>} + ], + FoldFun = fun({Name_, Key_}, Acc_) -> + case lists:keyfind(Name_, 1, ResponseHeaders) of + false -> Acc_; + {_, Value_} -> Acc_#{Key_ => Value_} + end + end, + Body = lists:foldl(FoldFun, Body0, ResponseHeadersParams), + {ok, Body, Response}; + Result -> + Result + end. + +%% @doc Gets the content of the network service descriptor. +%% +%% A network service descriptor is a .yaml file in a network package that +%% uses the TOSCA standard to describe the network functions you want to +%% deploy and the Amazon Web Services infrastructure you want to deploy the +%% network functions on. +get_sol_network_package_descriptor(Client, NsdInfoId) + when is_map(Client) -> + get_sol_network_package_descriptor(Client, NsdInfoId, #{}, #{}). + +get_sol_network_package_descriptor(Client, NsdInfoId, QueryMap, HeadersMap) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> + get_sol_network_package_descriptor(Client, NsdInfoId, QueryMap, HeadersMap, []). + +get_sol_network_package_descriptor(Client, NsdInfoId, QueryMap, HeadersMap, Options0) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> + Path = ["/sol/nsd/v1/ns_descriptors/", aws_util:encode_uri(NsdInfoId), "/nsd"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false} + | Options0], + + Headers = [], + + Query_ = [], + + case request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode) of + {ok, Body0, {_, ResponseHeaders, _} = Response} -> + ResponseHeadersParams = + [ + {<<"Content-Type">>, <<"contentType">>} + ], + FoldFun = fun({Name_, Key_}, Acc_) -> + case lists:keyfind(Name_, 1, ResponseHeaders) of + false -> Acc_; + {_, Value_} -> Acc_#{Key_ => Value_} + end + end, + Body = lists:foldl(FoldFun, Body0, ResponseHeadersParams), + {ok, Body, Response}; + Result -> + Result + end. + +%% @doc Instantiates a network instance. +%% +%% A network instance is a single network created in Amazon Web Services TNB +%% that can be deployed and on which life-cycle operations (like terminate, +%% update, and delete) can be performed. +%% +%% Before you can instantiate a network instance, you have to create a +%% network instance. For more information, see CreateSolNetworkInstance. +instantiate_sol_network_instance(Client, NsInstanceId, Input) -> + instantiate_sol_network_instance(Client, NsInstanceId, Input, []). +instantiate_sol_network_instance(Client, NsInstanceId, Input0, Options0) -> + Method = post, + Path = ["/sol/nslcm/v1/ns_instances/", aws_util:encode_uri(NsInstanceId), "/instantiate"], + SuccessStatusCode = 201, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + QueryMapping = [ + {<<"dry_run">>, <<"dryRun">>} + ], + {Query_, Input} = aws_request:build_headers(QueryMapping, Input2), + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Lists network function instances. +%% +%% A network function instance is a function in a function package . +list_sol_function_instances(Client) + when is_map(Client) -> + list_sol_function_instances(Client, #{}, #{}). + +list_sol_function_instances(Client, QueryMap, HeadersMap) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> + list_sol_function_instances(Client, QueryMap, HeadersMap, []). + +list_sol_function_instances(Client, QueryMap, HeadersMap, Options0) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> + Path = ["/sol/vnflcm/v1/vnf_instances"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false} + | Options0], + + Headers = [], + + Query0_ = + [ + {<<"max_results">>, maps:get(<<"max_results">>, QueryMap, undefined)}, + {<<"nextpage_opaque_marker">>, maps:get(<<"nextpage_opaque_marker">>, QueryMap, undefined)} + ], + Query_ = [H || {_, V} = H <- Query0_, V =/= undefined], + + request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode). + +%% @doc Lists information about function packages. +%% +%% A function package is a .zip file in CSAR (Cloud Service Archive) format +%% that contains a network function (an ETSI standard telecommunication +%% application) and function package descriptor that uses the TOSCA standard +%% to describe how the network functions should run on your network. +list_sol_function_packages(Client) + when is_map(Client) -> + list_sol_function_packages(Client, #{}, #{}). + +list_sol_function_packages(Client, QueryMap, HeadersMap) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> + list_sol_function_packages(Client, QueryMap, HeadersMap, []). + +list_sol_function_packages(Client, QueryMap, HeadersMap, Options0) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> + Path = ["/sol/vnfpkgm/v1/vnf_packages"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false} + | Options0], + + Headers = [], + + Query0_ = + [ + {<<"max_results">>, maps:get(<<"max_results">>, QueryMap, undefined)}, + {<<"nextpage_opaque_marker">>, maps:get(<<"nextpage_opaque_marker">>, QueryMap, undefined)} + ], + Query_ = [H || {_, V} = H <- Query0_, V =/= undefined], + + request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode). + +%% @doc Lists your network instances. +%% +%% A network instance is a single network created in Amazon Web Services TNB +%% that can be deployed and on which life-cycle operations (like terminate, +%% update, and delete) can be performed. +list_sol_network_instances(Client) + when is_map(Client) -> + list_sol_network_instances(Client, #{}, #{}). + +list_sol_network_instances(Client, QueryMap, HeadersMap) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> + list_sol_network_instances(Client, QueryMap, HeadersMap, []). + +list_sol_network_instances(Client, QueryMap, HeadersMap, Options0) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> + Path = ["/sol/nslcm/v1/ns_instances"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false} + | Options0], + + Headers = [], + + Query0_ = + [ + {<<"max_results">>, maps:get(<<"max_results">>, QueryMap, undefined)}, + {<<"nextpage_opaque_marker">>, maps:get(<<"nextpage_opaque_marker">>, QueryMap, undefined)} + ], + Query_ = [H || {_, V} = H <- Query0_, V =/= undefined], + + request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode). + +%% @doc Lists details for a network operation, including when the operation +%% started and the status of the operation. +%% +%% A network operation is any operation that is done to your network, such as +%% network instance instantiation or termination. +list_sol_network_operations(Client) + when is_map(Client) -> + list_sol_network_operations(Client, #{}, #{}). + +list_sol_network_operations(Client, QueryMap, HeadersMap) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> + list_sol_network_operations(Client, QueryMap, HeadersMap, []). + +list_sol_network_operations(Client, QueryMap, HeadersMap, Options0) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> + Path = ["/sol/nslcm/v1/ns_lcm_op_occs"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false} + | Options0], + + Headers = [], + + Query0_ = + [ + {<<"max_results">>, maps:get(<<"max_results">>, QueryMap, undefined)}, + {<<"nextpage_opaque_marker">>, maps:get(<<"nextpage_opaque_marker">>, QueryMap, undefined)} + ], + Query_ = [H || {_, V} = H <- Query0_, V =/= undefined], + + request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode). + +%% @doc Lists network packages. +%% +%% A network package is a .zip file in CSAR (Cloud Service Archive) format +%% defines the function packages you want to deploy and the Amazon Web +%% Services infrastructure you want to deploy them on. +list_sol_network_packages(Client) + when is_map(Client) -> + list_sol_network_packages(Client, #{}, #{}). + +list_sol_network_packages(Client, QueryMap, HeadersMap) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> + list_sol_network_packages(Client, QueryMap, HeadersMap, []). + +list_sol_network_packages(Client, QueryMap, HeadersMap, Options0) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> + Path = ["/sol/nsd/v1/ns_descriptors"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false} + | Options0], + + Headers = [], + + Query0_ = + [ + {<<"max_results">>, maps:get(<<"max_results">>, QueryMap, undefined)}, + {<<"nextpage_opaque_marker">>, maps:get(<<"nextpage_opaque_marker">>, QueryMap, undefined)} + ], + Query_ = [H || {_, V} = H <- Query0_, V =/= undefined], + + request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode). + +%% @doc Lists tags for AWS TNB resources. +list_tags_for_resource(Client, ResourceArn) + when is_map(Client) -> + list_tags_for_resource(Client, ResourceArn, #{}, #{}). + +list_tags_for_resource(Client, ResourceArn, QueryMap, HeadersMap) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> + list_tags_for_resource(Client, ResourceArn, QueryMap, HeadersMap, []). + +list_tags_for_resource(Client, ResourceArn, QueryMap, HeadersMap, Options0) + when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> + Path = ["/tags/", aws_util:encode_uri(ResourceArn), ""], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false} + | Options0], + + Headers = [], + + Query_ = [], + + request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode). + +%% @doc Uploads the contents of a function package. +%% +%% A function package is a .zip file in CSAR (Cloud Service Archive) format +%% that contains a network function (an ETSI standard telecommunication +%% application) and function package descriptor that uses the TOSCA standard +%% to describe how the network functions should run on your network. +put_sol_function_package_content(Client, VnfPkgId, Input) -> + put_sol_function_package_content(Client, VnfPkgId, Input, []). +put_sol_function_package_content(Client, VnfPkgId, Input0, Options0) -> + Method = put, + Path = ["/sol/vnfpkgm/v1/vnf_packages/", aws_util:encode_uri(VnfPkgId), "/package_content"], + SuccessStatusCode = 202, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + HeadersMapping = [ + {<<"Content-Type">>, <<"contentType">>} + ], + {Headers, Input1} = aws_request:build_headers(HeadersMapping, Input0), + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Uploads the contents of a network package. +%% +%% A network package is a .zip file in CSAR (Cloud Service Archive) format +%% defines the function packages you want to deploy and the Amazon Web +%% Services infrastructure you want to deploy them on. +put_sol_network_package_content(Client, NsdInfoId, Input) -> + put_sol_network_package_content(Client, NsdInfoId, Input, []). +put_sol_network_package_content(Client, NsdInfoId, Input0, Options0) -> + Method = put, + Path = ["/sol/nsd/v1/ns_descriptors/", aws_util:encode_uri(NsdInfoId), "/nsd_content"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + HeadersMapping = [ + {<<"Content-Type">>, <<"contentType">>} + ], + {Headers, Input1} = aws_request:build_headers(HeadersMapping, Input0), + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Tags an AWS TNB resource. +%% +%% A tag is a label that you assign to an Amazon Web Services resource. Each +%% tag consists of a key and an optional value. You can use tags to search +%% and filter your resources or track your Amazon Web Services costs. +tag_resource(Client, ResourceArn, Input) -> + tag_resource(Client, ResourceArn, Input, []). +tag_resource(Client, ResourceArn, Input0, Options0) -> + Method = post, + Path = ["/tags/", aws_util:encode_uri(ResourceArn), ""], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Terminates a network instance. +%% +%% A network instance is a single network created in Amazon Web Services TNB +%% that can be deployed and on which life-cycle operations (like terminate, +%% update, and delete) can be performed. +%% +%% You must terminate a network instance before you can delete it. +terminate_sol_network_instance(Client, NsInstanceId, Input) -> + terminate_sol_network_instance(Client, NsInstanceId, Input, []). +terminate_sol_network_instance(Client, NsInstanceId, Input0, Options0) -> + Method = post, + Path = ["/sol/nslcm/v1/ns_instances/", aws_util:encode_uri(NsInstanceId), "/terminate"], + SuccessStatusCode = 201, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Untags an AWS TNB resource. +%% +%% A tag is a label that you assign to an Amazon Web Services resource. Each +%% tag consists of a key and an optional value. You can use tags to search +%% and filter your resources or track your Amazon Web Services costs. +untag_resource(Client, ResourceArn, Input) -> + untag_resource(Client, ResourceArn, Input, []). +untag_resource(Client, ResourceArn, Input0, Options0) -> + Method = delete, + Path = ["/tags/", aws_util:encode_uri(ResourceArn), ""], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + QueryMapping = [ + {<<"tagKeys">>, <<"tagKeys">>} + ], + {Query_, Input} = aws_request:build_headers(QueryMapping, Input2), + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Updates the operational state of function package. +%% +%% A function package is a .zip file in CSAR (Cloud Service Archive) format +%% that contains a network function (an ETSI standard telecommunication +%% application) and function package descriptor that uses the TOSCA standard +%% to describe how the network functions should run on your network. +update_sol_function_package(Client, VnfPkgId, Input) -> + update_sol_function_package(Client, VnfPkgId, Input, []). +update_sol_function_package(Client, VnfPkgId, Input0, Options0) -> + Method = patch, + Path = ["/sol/vnfpkgm/v1/vnf_packages/", aws_util:encode_uri(VnfPkgId), ""], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Update a network instance. +%% +%% A network instance is a single network created in Amazon Web Services TNB +%% that can be deployed and on which life-cycle operations (like terminate, +%% update, and delete) can be performed. +update_sol_network_instance(Client, NsInstanceId, Input) -> + update_sol_network_instance(Client, NsInstanceId, Input, []). +update_sol_network_instance(Client, NsInstanceId, Input0, Options0) -> + Method = post, + Path = ["/sol/nslcm/v1/ns_instances/", aws_util:encode_uri(NsInstanceId), "/update"], + SuccessStatusCode = 201, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Updates the operational state of a network package. +%% +%% A network package is a .zip file in CSAR (Cloud Service Archive) format +%% defines the function packages you want to deploy and the Amazon Web +%% Services infrastructure you want to deploy them on. +%% +%% A network service descriptor is a .yaml file in a network package that +%% uses the TOSCA standard to describe the network functions you want to +%% deploy and the Amazon Web Services infrastructure you want to deploy the +%% network functions on. +update_sol_network_package(Client, NsdInfoId, Input) -> + update_sol_network_package(Client, NsdInfoId, Input, []). +update_sol_network_package(Client, NsdInfoId, Input0, Options0) -> + Method = patch, + Path = ["/sol/nsd/v1/ns_descriptors/", aws_util:encode_uri(NsdInfoId), ""], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + Headers = [], + Input1 = Input0, + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Validates function package content. +%% +%% This can be used as a dry run before uploading function package content +%% with PutSolFunctionPackageContent. +%% +%% A function package is a .zip file in CSAR (Cloud Service Archive) format +%% that contains a network function (an ETSI standard telecommunication +%% application) and function package descriptor that uses the TOSCA standard +%% to describe how the network functions should run on your network. +validate_sol_function_package_content(Client, VnfPkgId, Input) -> + validate_sol_function_package_content(Client, VnfPkgId, Input, []). +validate_sol_function_package_content(Client, VnfPkgId, Input0, Options0) -> + Method = put, + Path = ["/sol/vnfpkgm/v1/vnf_packages/", aws_util:encode_uri(VnfPkgId), "/package_content/validate"], + SuccessStatusCode = 202, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + HeadersMapping = [ + {<<"Content-Type">>, <<"contentType">>} + ], + {Headers, Input1} = aws_request:build_headers(HeadersMapping, Input0), + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%% @doc Validates network package content. +%% +%% This can be used as a dry run before uploading network package content +%% with PutSolNetworkPackageContent. +%% +%% A network package is a .zip file in CSAR (Cloud Service Archive) format +%% defines the function packages you want to deploy and the Amazon Web +%% Services infrastructure you want to deploy them on. +validate_sol_network_package_content(Client, NsdInfoId, Input) -> + validate_sol_network_package_content(Client, NsdInfoId, Input, []). +validate_sol_network_package_content(Client, NsdInfoId, Input0, Options0) -> + Method = put, + Path = ["/sol/nsd/v1/ns_descriptors/", aws_util:encode_uri(NsdInfoId), "/nsd_content/validate"], + SuccessStatusCode = 200, + Options = [{send_body_as_binary, false}, + {receive_body_as_binary, false}, + {append_sha256_content_hash, false} + | Options0], + + HeadersMapping = [ + {<<"Content-Type">>, <<"contentType">>} + ], + {Headers, Input1} = aws_request:build_headers(HeadersMapping, Input0), + + CustomHeaders = [], + Input2 = Input1, + + Query_ = [], + Input = Input2, + + request(Client, Method, Path, Query_, CustomHeaders ++ Headers, Input, Options, SuccessStatusCode). + +%%==================================================================== +%% Internal functions +%%==================================================================== + +-spec request(aws_client:aws_client(), atom(), iolist(), list(), + list(), map() | undefined, list(), pos_integer() | undefined) -> + {ok, {integer(), list()}} | + {ok, Result, {integer(), list(), hackney:client()}} | + {error, Error, {integer(), list(), hackney:client()}} | + {error, term()} when + Result :: map(), + Error :: map(). +request(Client, Method, Path, Query, Headers0, Input, Options, SuccessStatusCode) -> + RequestFun = fun() -> do_request(Client, Method, Path, Query, Headers0, Input, Options, SuccessStatusCode) end, + aws_request:request(RequestFun, Options). + +do_request(Client, Method, Path, Query, Headers0, Input, Options, SuccessStatusCode) -> + Client1 = Client#{service => <<"tnb">>}, + Host = build_host(<<"tnb">>, Client1), + URL0 = build_url(Host, Path, Client1), + URL = aws_request:add_query(URL0, Query), + AdditionalHeaders1 = [ {<<"Host">>, Host} + , {<<"Content-Type">>, <<"application/x-amz-json-1.1">>} + ], + Payload = + case proplists:get_value(send_body_as_binary, Options) of + true -> + maps:get(<<"Body">>, Input, <<"">>); + false -> + encode_payload(Input) + end, + AdditionalHeaders = case proplists:get_value(append_sha256_content_hash, Options, false) of + true -> + add_checksum_hash_header(AdditionalHeaders1, Payload); + false -> + AdditionalHeaders1 + end, + Headers1 = aws_request:add_headers(AdditionalHeaders, Headers0), + + MethodBin = aws_request:method_to_binary(Method), + SignedHeaders = aws_request:sign_request(Client1, MethodBin, URL, Headers1, Payload), + Response = hackney:request(Method, URL, SignedHeaders, Payload, Options), + DecodeBody = not proplists:get_value(receive_body_as_binary, Options), + handle_response(Response, SuccessStatusCode, DecodeBody). + +add_checksum_hash_header(Headers, Body) -> + [ {<<"X-Amz-CheckSum-SHA256">>, base64:encode(crypto:hash(sha256, Body))} + | Headers + ]. + +handle_response({ok, StatusCode, ResponseHeaders}, SuccessStatusCode, _DecodeBody) + when StatusCode =:= 200; + StatusCode =:= 202; + StatusCode =:= 204; + StatusCode =:= 206; + StatusCode =:= SuccessStatusCode -> + {ok, {StatusCode, ResponseHeaders}}; +handle_response({ok, StatusCode, ResponseHeaders}, _, _DecodeBody) -> + {error, {StatusCode, ResponseHeaders}}; +handle_response({ok, StatusCode, ResponseHeaders, Client}, SuccessStatusCode, DecodeBody) + when StatusCode =:= 200; + StatusCode =:= 202; + StatusCode =:= 204; + StatusCode =:= 206; + StatusCode =:= SuccessStatusCode -> + case hackney:body(Client) of + {ok, <<>>} when StatusCode =:= 200; + StatusCode =:= SuccessStatusCode -> + {ok, #{}, {StatusCode, ResponseHeaders, Client}}; + {ok, Body} -> + Result = case DecodeBody of + true -> + try + jsx:decode(Body) + catch + Error:Reason:Stack -> + erlang:raise(error, {body_decode_failed, Error, Reason, StatusCode, Body}, Stack) + end; + false -> #{<<"Body">> => Body} + end, + {ok, Result, {StatusCode, ResponseHeaders, Client}} + end; +handle_response({ok, StatusCode, _ResponseHeaders, _Client}, _, _DecodeBody) + when StatusCode =:= 503 -> + %% Retriable error if retries are enabled + {error, service_unavailable}; +handle_response({ok, StatusCode, ResponseHeaders, Client}, _, _DecodeBody) -> + {ok, Body} = hackney:body(Client), + try + DecodedError = jsx:decode(Body), + {error, DecodedError, {StatusCode, ResponseHeaders, Client}} + catch + Error:Reason:Stack -> + erlang:raise(error, {body_decode_failed, Error, Reason, StatusCode, Body}, Stack) + end; +handle_response({error, Reason}, _, _DecodeBody) -> + {error, Reason}. + +build_host(_EndpointPrefix, #{region := <<"local">>, endpoint := Endpoint}) -> + Endpoint; +build_host(_EndpointPrefix, #{region := <<"local">>}) -> + <<"localhost">>; +build_host(EndpointPrefix, #{region := Region, endpoint := Endpoint}) -> + aws_util:binary_join([EndpointPrefix, Region, Endpoint], <<".">>). + +build_url(Host, Path0, Client) -> + Proto = maps:get(proto, Client), + Path = erlang:iolist_to_binary(Path0), + Port = maps:get(port, Client), + aws_util:binary_join([Proto, <<"://">>, Host, <<":">>, Port, Path], <<"">>). + +-spec encode_payload(undefined | map()) -> binary(). +encode_payload(undefined) -> + <<>>; +encode_payload(Input) -> + jsx:encode(Input).