%% WARNING: DO NOT EDIT, AUTO-GENERATED CODE!
%% See https://github.com/aws-beam/aws-codegen for more details.
%% @doc
PENDING. When it is
%% ready, the state is RUNNING.
create_image_builder(Client, Input)
when is_map(Client), is_map(Input) ->
create_image_builder(Client, Input, []).
create_image_builder(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"CreateImageBuilder">>, Input, Options).
%% @doc Creates a URL to start an image builder streaming session.
create_image_builder_streaming_u_r_l(Client, Input)
when is_map(Client), is_map(Input) ->
create_image_builder_streaming_u_r_l(Client, Input, []).
create_image_builder_streaming_u_r_l(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"CreateImageBuilderStreamingURL">>, Input, Options).
%% @doc Creates a stack to start streaming applications to users. A stack
%% consists of an associated fleet, user access policies, and storage
%% configurations.
create_stack(Client, Input)
when is_map(Client), is_map(Input) ->
create_stack(Client, Input, []).
create_stack(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"CreateStack">>, Input, Options).
%% @doc Creates a temporary URL to start an AppStream 2.0 streaming session
%% for the specified user. A streaming URL enables application streaming to
%% be tested without user setup.
create_streaming_u_r_l(Client, Input)
when is_map(Client), is_map(Input) ->
create_streaming_u_r_l(Client, Input, []).
create_streaming_u_r_l(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"CreateStreamingURL">>, Input, Options).
%% @doc Creates a usage report subscription. Usage reports are generated
%% daily.
create_usage_report_subscription(Client, Input)
when is_map(Client), is_map(Input) ->
create_usage_report_subscription(Client, Input, []).
create_usage_report_subscription(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"CreateUsageReportSubscription">>, Input, Options).
%% @doc Creates a new user in the user pool.
create_user(Client, Input)
when is_map(Client), is_map(Input) ->
create_user(Client, Input, []).
create_user(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"CreateUser">>, Input, Options).
%% @doc Deletes the specified Directory Config object from AppStream 2.0.
%% This object includes the information required to join streaming instances
%% to an Active Directory domain.
delete_directory_config(Client, Input)
when is_map(Client), is_map(Input) ->
delete_directory_config(Client, Input, []).
delete_directory_config(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"DeleteDirectoryConfig">>, Input, Options).
%% @doc Deletes the specified fleet.
delete_fleet(Client, Input)
when is_map(Client), is_map(Input) ->
delete_fleet(Client, Input, []).
delete_fleet(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"DeleteFleet">>, Input, Options).
%% @doc Deletes the specified image. You cannot delete an image when it is in
%% use. After you delete an image, you cannot provision new capacity using
%% the image.
delete_image(Client, Input)
when is_map(Client), is_map(Input) ->
delete_image(Client, Input, []).
delete_image(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"DeleteImage">>, Input, Options).
%% @doc Deletes the specified image builder and releases the capacity.
delete_image_builder(Client, Input)
when is_map(Client), is_map(Input) ->
delete_image_builder(Client, Input, []).
delete_image_builder(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"DeleteImageBuilder">>, Input, Options).
%% @doc Deletes permissions for the specified private image. After you delete
%% permissions for an image, AWS accounts to which you previously granted
%% these permissions can no longer use the image.
delete_image_permissions(Client, Input)
when is_map(Client), is_map(Input) ->
delete_image_permissions(Client, Input, []).
delete_image_permissions(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"DeleteImagePermissions">>, Input, Options).
%% @doc Deletes the specified stack. After the stack is deleted, the
%% application streaming environment provided by the stack is no longer
%% available to users. Also, any reservations made for application streaming
%% sessions for the stack are released.
delete_stack(Client, Input)
when is_map(Client), is_map(Input) ->
delete_stack(Client, Input, []).
delete_stack(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"DeleteStack">>, Input, Options).
%% @doc Disables usage report generation.
delete_usage_report_subscription(Client, Input)
when is_map(Client), is_map(Input) ->
delete_usage_report_subscription(Client, Input, []).
delete_usage_report_subscription(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"DeleteUsageReportSubscription">>, Input, Options).
%% @doc Deletes a user from the user pool.
delete_user(Client, Input)
when is_map(Client), is_map(Input) ->
delete_user(Client, Input, []).
delete_user(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"DeleteUser">>, Input, Options).
%% @doc Retrieves a list that describes one or more specified Directory
%% Config objects for AppStream 2.0, if the names for these objects are
%% provided. Otherwise, all Directory Config objects in the account are
%% described. These objects include the configuration information required to
%% join fleets and image builders to Microsoft Active Directory domains.
%%
%% Although the response syntax in this topic includes the account password,
%% this password is not returned in the actual response.
describe_directory_configs(Client, Input)
when is_map(Client), is_map(Input) ->
describe_directory_configs(Client, Input, []).
describe_directory_configs(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"DescribeDirectoryConfigs">>, Input, Options).
%% @doc Retrieves a list that describes one or more specified fleets, if the
%% fleet names are provided. Otherwise, all fleets in the account are
%% described.
describe_fleets(Client, Input)
when is_map(Client), is_map(Input) ->
describe_fleets(Client, Input, []).
describe_fleets(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"DescribeFleets">>, Input, Options).
%% @doc Retrieves a list that describes one or more specified image builders,
%% if the image builder names are provided. Otherwise, all image builders in
%% the account are described.
describe_image_builders(Client, Input)
when is_map(Client), is_map(Input) ->
describe_image_builders(Client, Input, []).
describe_image_builders(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"DescribeImageBuilders">>, Input, Options).
%% @doc Retrieves a list that describes the permissions for shared AWS
%% account IDs on a private image that you own.
describe_image_permissions(Client, Input)
when is_map(Client), is_map(Input) ->
describe_image_permissions(Client, Input, []).
describe_image_permissions(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"DescribeImagePermissions">>, Input, Options).
%% @doc Retrieves a list that describes one or more specified images, if the
%% image names or image ARNs are provided. Otherwise, all images in the
%% account are described.
describe_images(Client, Input)
when is_map(Client), is_map(Input) ->
describe_images(Client, Input, []).
describe_images(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"DescribeImages">>, Input, Options).
%% @doc Retrieves a list that describes the streaming sessions for a
%% specified stack and fleet. If a UserId is provided for the stack and
%% fleet, only streaming sessions for that user are described. If an
%% authentication type is not provided, the default is to authenticate users
%% using a streaming URL.
describe_sessions(Client, Input)
when is_map(Client), is_map(Input) ->
describe_sessions(Client, Input, []).
describe_sessions(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"DescribeSessions">>, Input, Options).
%% @doc Retrieves a list that describes one or more specified stacks, if the
%% stack names are provided. Otherwise, all stacks in the account are
%% described.
describe_stacks(Client, Input)
when is_map(Client), is_map(Input) ->
describe_stacks(Client, Input, []).
describe_stacks(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"DescribeStacks">>, Input, Options).
%% @doc Retrieves a list that describes one or more usage report
%% subscriptions.
describe_usage_report_subscriptions(Client, Input)
when is_map(Client), is_map(Input) ->
describe_usage_report_subscriptions(Client, Input, []).
describe_usage_report_subscriptions(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"DescribeUsageReportSubscriptions">>, Input, Options).
%% @doc Retrieves a list that describes the UserStackAssociation objects. You
%% must specify either or both of the following:
%%
%% STOPPED state, you can update any
%% attribute except the fleet name. If the fleet is in the
%% RUNNING state, you can update the DisplayName,
%% ComputeCapacity, ImageARN,
%% ImageName, IdleDisconnectTimeoutInSeconds, and
%% DisconnectTimeoutInSeconds attributes. If the fleet is in the
%% STARTING or STOPPING state, you can't update it.
update_fleet(Client, Input)
when is_map(Client), is_map(Input) ->
update_fleet(Client, Input, []).
update_fleet(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"UpdateFleet">>, Input, Options).
%% @doc Adds or updates permissions for the specified private image.
update_image_permissions(Client, Input)
when is_map(Client), is_map(Input) ->
update_image_permissions(Client, Input, []).
update_image_permissions(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"UpdateImagePermissions">>, Input, Options).
%% @doc Updates the specified fields for the specified stack.
update_stack(Client, Input)
when is_map(Client), is_map(Input) ->
update_stack(Client, Input, []).
update_stack(Client, Input, Options)
when is_map(Client), is_map(Input), is_list(Options) ->
request(Client, <<"UpdateStack">>, 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 :: {binary(), binary()}.
request(Client, Action, Input, Options) ->
Client1 = Client#{service => <<"appstream">>},
Host = get_host(<<"appstream2">>, Client1),
URL = get_url(Host, Client1),
Headers = [
{<<"Host">>, Host},
{<<"Content-Type">>, <<"application/x-amz-json-1.1">>},
{<<"X-Amz-Target">>, << <<"PhotonAdminProxyService.">>/binary, Action/binary>>}
],
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, [return_maps]),
{ok, Result, {200, ResponseHeaders, Client}}
end;
handle_response({ok, StatusCode, ResponseHeaders, Client}) ->
{ok, Body} = hackney:body(Client),
Error = jsx:decode(Body, [return_maps]),
Exception = maps:get(<<"__type">>, Error, undefined),
Reason = maps:get(<<"message">>, Error, undefined),
{error, {Exception, Reason}, {StatusCode, ResponseHeaders, Client}};
handle_response({error, Reason}) ->
{error, Reason}.
get_host(_EndpointPrefix, #{region := <<"local">>}) ->
<<"localhost">>;
get_host(EndpointPrefix, #{region := Region, endpoint := Endpoint}) ->
aws_util:binary_join([EndpointPrefix, <<".">>, Region, <<".">>, Endpoint], <<"">>).
get_url(Host, Client) ->
Proto = maps:get(proto, Client),
Port = maps:get(port, Client),
aws_util:binary_join([Proto, <<"://">>, Host, <<":">>, Port, <<"/">>], <<"">>).