%% WARNING: DO NOT EDIT, AUTO-GENERATED CODE! %% See https://github.com/aws-beam/aws-codegen for more details. %% @doc This is prerelease documentation for Amazon Redshift Serverless, %% which is in preview release. %% %% The documentation and the feature are both subject to change. We recommend %% that you use this feature only in test environments, and not in production %% environments. For preview terms and conditions, see Beta Service %% Participation in Amazon Web Services Service Terms. %% %% This is an interface reference for Amazon Redshift Serverless. It contains %% documentation for one of the programming or command line interfaces you %% can use to manage Amazon Redshift Serverless. %% %% Amazon Redshift Serverless automatically provisions data warehouse %% capacity and intelligently scales the underlying resources based on %% workload demands. Amazon Redshift Serverless adjusts capacity in seconds %% to deliver consistently high performance and simplified operations for %% even the most demanding and volatile workloads. Amazon Redshift Serverless %% lets you focus on using your data to acquire new insights for your %% business and customers. %% %% To learn more about Amazon Redshift Serverless, see What is Amazon %% Redshift Serverless. -module(aws_redshiftserverless). -export([convert_recovery_point_to_snapshot/2, convert_recovery_point_to_snapshot/3, create_endpoint_access/2, create_endpoint_access/3, create_namespace/2, create_namespace/3, create_snapshot/2, create_snapshot/3, create_usage_limit/2, create_usage_limit/3, create_workgroup/2, create_workgroup/3, delete_endpoint_access/2, delete_endpoint_access/3, delete_namespace/2, delete_namespace/3, delete_resource_policy/2, delete_resource_policy/3, delete_snapshot/2, delete_snapshot/3, delete_usage_limit/2, delete_usage_limit/3, delete_workgroup/2, delete_workgroup/3, get_credentials/2, get_credentials/3, get_endpoint_access/2, get_endpoint_access/3, get_namespace/2, get_namespace/3, get_recovery_point/2, get_recovery_point/3, get_resource_policy/2, get_resource_policy/3, get_snapshot/2, get_snapshot/3, get_usage_limit/2, get_usage_limit/3, get_workgroup/2, get_workgroup/3, list_endpoint_access/2, list_endpoint_access/3, list_namespaces/2, list_namespaces/3, list_recovery_points/2, list_recovery_points/3, list_snapshots/2, list_snapshots/3, list_tags_for_resource/2, list_tags_for_resource/3, list_usage_limits/2, list_usage_limits/3, list_workgroups/2, list_workgroups/3, put_resource_policy/2, put_resource_policy/3, restore_from_recovery_point/2, restore_from_recovery_point/3, restore_from_snapshot/2, restore_from_snapshot/3, tag_resource/2, tag_resource/3, untag_resource/2, untag_resource/3, update_endpoint_access/2, update_endpoint_access/3, update_namespace/2, update_namespace/3, update_snapshot/2, update_snapshot/3, update_usage_limit/2, update_usage_limit/3, update_workgroup/2, update_workgroup/3]). -include_lib("hackney/include/hackney_lib.hrl"). %%==================================================================== %% API %%==================================================================== %% @doc Converts a recovery point to a snapshot. %% %% For more information about recovery points and snapshots, see Working with %% snapshots and recovery points. convert_recovery_point_to_snapshot(Client, Input) when is_map(Client), is_map(Input) -> convert_recovery_point_to_snapshot(Client, Input, []). convert_recovery_point_to_snapshot(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"ConvertRecoveryPointToSnapshot">>, Input, Options). %% @doc Creates an Amazon Redshift Serverless managed VPC endpoint. create_endpoint_access(Client, Input) when is_map(Client), is_map(Input) -> create_endpoint_access(Client, Input, []). create_endpoint_access(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"CreateEndpointAccess">>, Input, Options). %% @doc Creates a namespace in Amazon Redshift Serverless. create_namespace(Client, Input) when is_map(Client), is_map(Input) -> create_namespace(Client, Input, []). create_namespace(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"CreateNamespace">>, Input, Options). %% @doc Creates a snapshot of all databases in a namespace. %% %% For more information about snapshots, see Working with snapshots and %% recovery points. create_snapshot(Client, Input) when is_map(Client), is_map(Input) -> create_snapshot(Client, Input, []). create_snapshot(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"CreateSnapshot">>, Input, Options). %% @doc Creates a usage limit for a specified Amazon Redshift Serverless %% usage type. %% %% The usage limit is identified by the returned usage limit identifier. create_usage_limit(Client, Input) when is_map(Client), is_map(Input) -> create_usage_limit(Client, Input, []). create_usage_limit(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"CreateUsageLimit">>, Input, Options). %% @doc Creates an workgroup in Amazon Redshift Serverless. create_workgroup(Client, Input) when is_map(Client), is_map(Input) -> create_workgroup(Client, Input, []). create_workgroup(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"CreateWorkgroup">>, Input, Options). %% @doc Deletes an Amazon Redshift Serverless managed VPC endpoint. delete_endpoint_access(Client, Input) when is_map(Client), is_map(Input) -> delete_endpoint_access(Client, Input, []). delete_endpoint_access(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"DeleteEndpointAccess">>, Input, Options). %% @doc Deletes a namespace from Amazon Redshift Serverless. %% %% Before you delete the namespace, you can create a final snapshot that has %% all of the data within the namespace. delete_namespace(Client, Input) when is_map(Client), is_map(Input) -> delete_namespace(Client, Input, []). delete_namespace(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"DeleteNamespace">>, Input, Options). %% @doc Deletes the specified resource policy. delete_resource_policy(Client, Input) when is_map(Client), is_map(Input) -> delete_resource_policy(Client, Input, []). delete_resource_policy(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"DeleteResourcePolicy">>, Input, Options). %% @doc Deletes a snapshot from Amazon Redshift Serverless. delete_snapshot(Client, Input) when is_map(Client), is_map(Input) -> delete_snapshot(Client, Input, []). delete_snapshot(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"DeleteSnapshot">>, Input, Options). %% @doc Deletes a usage limit from Amazon Redshift Serverless. delete_usage_limit(Client, Input) when is_map(Client), is_map(Input) -> delete_usage_limit(Client, Input, []). delete_usage_limit(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"DeleteUsageLimit">>, Input, Options). %% @doc Deletes a workgroup. delete_workgroup(Client, Input) when is_map(Client), is_map(Input) -> delete_workgroup(Client, Input, []). delete_workgroup(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"DeleteWorkgroup">>, Input, Options). %% @doc Returns a database user name and temporary password with temporary %% authorization to log in to Amazon Redshift Serverless. %% %% By default, the temporary credentials expire in 900 seconds. You can %% optionally specify a duration between 900 seconds (15 minutes) and 3600 %% seconds (60 minutes). %% %%

The Identity and Access Management (IAM) user or role that runs %% GetCredentials must have an IAM policy attached that allows access to all %% necessary actions and resources.

If the DbName %% parameter is specified, the IAM policy must allow access to the resource %% dbname for the specified database name.

get_credentials(Client, Input) when is_map(Client), is_map(Input) -> get_credentials(Client, Input, []). get_credentials(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"GetCredentials">>, Input, Options). %% @doc Returns information, such as the name, about a VPC endpoint. get_endpoint_access(Client, Input) when is_map(Client), is_map(Input) -> get_endpoint_access(Client, Input, []). get_endpoint_access(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"GetEndpointAccess">>, Input, Options). %% @doc Returns information about a namespace in Amazon Redshift Serverless. get_namespace(Client, Input) when is_map(Client), is_map(Input) -> get_namespace(Client, Input, []). get_namespace(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"GetNamespace">>, Input, Options). %% @doc Returns information about a recovery point. get_recovery_point(Client, Input) when is_map(Client), is_map(Input) -> get_recovery_point(Client, Input, []). get_recovery_point(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"GetRecoveryPoint">>, Input, Options). %% @doc Returns a resource policy. get_resource_policy(Client, Input) when is_map(Client), is_map(Input) -> get_resource_policy(Client, Input, []). get_resource_policy(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"GetResourcePolicy">>, Input, Options). %% @doc Returns information about a specific snapshot. get_snapshot(Client, Input) when is_map(Client), is_map(Input) -> get_snapshot(Client, Input, []). get_snapshot(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"GetSnapshot">>, Input, Options). %% @doc Returns information about a usage limit. get_usage_limit(Client, Input) when is_map(Client), is_map(Input) -> get_usage_limit(Client, Input, []). get_usage_limit(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"GetUsageLimit">>, Input, Options). %% @doc Returns information about a specific workgroup. get_workgroup(Client, Input) when is_map(Client), is_map(Input) -> get_workgroup(Client, Input, []). get_workgroup(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"GetWorkgroup">>, Input, Options). %% @doc Returns an array of `EndpointAccess' objects and relevant %% information. list_endpoint_access(Client, Input) when is_map(Client), is_map(Input) -> list_endpoint_access(Client, Input, []). list_endpoint_access(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"ListEndpointAccess">>, Input, Options). %% @doc Returns information about a list of specified namespaces. list_namespaces(Client, Input) when is_map(Client), is_map(Input) -> list_namespaces(Client, Input, []). list_namespaces(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"ListNamespaces">>, Input, Options). %% @doc Returns an array of recovery points. list_recovery_points(Client, Input) when is_map(Client), is_map(Input) -> list_recovery_points(Client, Input, []). list_recovery_points(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"ListRecoveryPoints">>, Input, Options). %% @doc Returns a list of snapshots. list_snapshots(Client, Input) when is_map(Client), is_map(Input) -> list_snapshots(Client, Input, []). list_snapshots(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"ListSnapshots">>, Input, Options). %% @doc Lists the tags assigned to a resource. list_tags_for_resource(Client, Input) when is_map(Client), is_map(Input) -> list_tags_for_resource(Client, Input, []). list_tags_for_resource(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"ListTagsForResource">>, Input, Options). %% @doc Lists all usage limits within Amazon Redshift Serverless. list_usage_limits(Client, Input) when is_map(Client), is_map(Input) -> list_usage_limits(Client, Input, []). list_usage_limits(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"ListUsageLimits">>, Input, Options). %% @doc Returns information about a list of specified workgroups. list_workgroups(Client, Input) when is_map(Client), is_map(Input) -> list_workgroups(Client, Input, []). list_workgroups(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"ListWorkgroups">>, Input, Options). %% @doc Creates or updates a resource policy. %% %% Currently, you can use policies to share snapshots across Amazon Web %% Services accounts. put_resource_policy(Client, Input) when is_map(Client), is_map(Input) -> put_resource_policy(Client, Input, []). put_resource_policy(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"PutResourcePolicy">>, Input, Options). %% @doc Restore the data from a recovery point. restore_from_recovery_point(Client, Input) when is_map(Client), is_map(Input) -> restore_from_recovery_point(Client, Input, []). restore_from_recovery_point(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"RestoreFromRecoveryPoint">>, Input, Options). %% @doc Restores a namespace from a snapshot. restore_from_snapshot(Client, Input) when is_map(Client), is_map(Input) -> restore_from_snapshot(Client, Input, []). restore_from_snapshot(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"RestoreFromSnapshot">>, Input, Options). %% @doc Assigns one or more tags to a resource. tag_resource(Client, Input) when is_map(Client), is_map(Input) -> tag_resource(Client, Input, []). tag_resource(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"TagResource">>, Input, Options). %% @doc Removes a tag or set of tags from a resource. untag_resource(Client, Input) when is_map(Client), is_map(Input) -> untag_resource(Client, Input, []). untag_resource(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"UntagResource">>, Input, Options). %% @doc Updates an Amazon Redshift Serverless managed endpoint. update_endpoint_access(Client, Input) when is_map(Client), is_map(Input) -> update_endpoint_access(Client, Input, []). update_endpoint_access(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"UpdateEndpointAccess">>, Input, Options). %% @doc Updates a namespace with the specified settings. update_namespace(Client, Input) when is_map(Client), is_map(Input) -> update_namespace(Client, Input, []). update_namespace(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"UpdateNamespace">>, Input, Options). %% @doc Updates a snapshot. update_snapshot(Client, Input) when is_map(Client), is_map(Input) -> update_snapshot(Client, Input, []). update_snapshot(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"UpdateSnapshot">>, Input, Options). %% @doc Update a usage limit in Amazon Redshift Serverless. %% %% You can't update the usage type or period of a usage limit. update_usage_limit(Client, Input) when is_map(Client), is_map(Input) -> update_usage_limit(Client, Input, []). update_usage_limit(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"UpdateUsageLimit">>, Input, Options). %% @doc Updates a workgroup with the specified configuration settings. update_workgroup(Client, Input) when is_map(Client), is_map(Input) -> update_workgroup(Client, Input, []). update_workgroup(Client, Input, Options) when is_map(Client), is_map(Input), is_list(Options) -> request(Client, <<"UpdateWorkgroup">>, Input, Options). %%==================================================================== %% Internal functions %%==================================================================== -spec request(aws_client:aws_client(), binary(), map(), list()) -> {ok, Result, {integer(), list(), hackney:client()}} | {error, Error, {integer(), list(), hackney:client()}} | {error, term()} when Result :: map() | undefined, Error :: map(). request(Client, Action, Input, Options) -> RequestFun = fun() -> do_request(Client, Action, Input, Options) end, aws_request:request(RequestFun, Options). do_request(Client, Action, Input0, Options) -> Client1 = Client#{service => <<"redshift-serverless">>}, Host = build_host(<<"redshift-serverless">>, Client1), URL = build_url(Host, Client1), Headers = [ {<<"Host">>, Host}, {<<"Content-Type">>, <<"application/x-amz-json-1.1">>}, {<<"X-Amz-Target">>, <<"RedshiftServerless.", Action/binary>>} ], Input = Input0, Payload = jsx:encode(Input), SignedHeaders = aws_request:sign_request(Client1, <<"POST">>, URL, Headers, Payload), Response = hackney:request(post, URL, SignedHeaders, Payload, Options), handle_response(Response). handle_response({ok, 200, ResponseHeaders, Client}) -> case hackney:body(Client) of {ok, <<>>} -> {ok, undefined, {200, ResponseHeaders, Client}}; {ok, Body} -> Result = jsx:decode(Body), {ok, Result, {200, ResponseHeaders, Client}} end; handle_response({ok, StatusCode, ResponseHeaders, Client}) -> {ok, Body} = hackney:body(Client), Error = jsx:decode(Body), {error, Error, {StatusCode, ResponseHeaders, Client}}; handle_response({error, Reason}) -> {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, Client) -> Proto = maps:get(proto, Client), Port = maps:get(port, Client), aws_util:binary_join([Proto, <<"://">>, Host, <<":">>, Port, <<"/">>], <<"">>).