Current section
Files
Jump to
Current section
Files
src/aws_sagemaker_geospatial.erl
%% WARNING: DO NOT EDIT, AUTO-GENERATED CODE!
%% See https://github.com/aws-beam/aws-codegen for more details.
%% @doc Provides APIs for creating and managing SageMaker geospatial
%% resources.
-module(aws_sagemaker_geospatial).
-export([delete_earth_observation_job/3,
delete_earth_observation_job/4,
delete_vector_enrichment_job/3,
delete_vector_enrichment_job/4,
export_earth_observation_job/2,
export_earth_observation_job/3,
export_vector_enrichment_job/2,
export_vector_enrichment_job/3,
get_earth_observation_job/2,
get_earth_observation_job/4,
get_earth_observation_job/5,
get_raster_data_collection/2,
get_raster_data_collection/4,
get_raster_data_collection/5,
get_tile/7,
get_tile/9,
get_tile/10,
get_vector_enrichment_job/2,
get_vector_enrichment_job/4,
get_vector_enrichment_job/5,
list_earth_observation_jobs/2,
list_earth_observation_jobs/3,
list_raster_data_collections/1,
list_raster_data_collections/3,
list_raster_data_collections/4,
list_tags_for_resource/2,
list_tags_for_resource/4,
list_tags_for_resource/5,
list_vector_enrichment_jobs/2,
list_vector_enrichment_jobs/3,
search_raster_data_collection/2,
search_raster_data_collection/3,
start_earth_observation_job/2,
start_earth_observation_job/3,
start_vector_enrichment_job/2,
start_vector_enrichment_job/3,
stop_earth_observation_job/2,
stop_earth_observation_job/3,
stop_vector_enrichment_job/2,
stop_vector_enrichment_job/3,
tag_resource/3,
tag_resource/4,
untag_resource/3,
untag_resource/4]).
-include_lib("hackney/include/hackney_lib.hrl").
%%====================================================================
%% API
%%====================================================================
%% @doc Use this operation to delete an Earth Observation job.
delete_earth_observation_job(Client, Arn, Input) ->
delete_earth_observation_job(Client, Arn, Input, []).
delete_earth_observation_job(Client, Arn, Input0, Options0) ->
Method = delete,
Path = ["/earth-observation-jobs/", aws_util:encode_uri(Arn), ""],
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 Use this operation to delete a Vector Enrichment job.
delete_vector_enrichment_job(Client, Arn, Input) ->
delete_vector_enrichment_job(Client, Arn, Input, []).
delete_vector_enrichment_job(Client, Arn, Input0, Options0) ->
Method = delete,
Path = ["/vector-enrichment-jobs/", aws_util:encode_uri(Arn), ""],
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 Use this operation to export results of an Earth Observation job and
%% optionally source images used as input to the EOJ to an S3 location.
export_earth_observation_job(Client, Input) ->
export_earth_observation_job(Client, Input, []).
export_earth_observation_job(Client, Input0, Options0) ->
Method = post,
Path = ["/export-earth-observation-job"],
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 Use this operation to copy results of a Vector Enrichment job to an
%% S3 location.
export_vector_enrichment_job(Client, Input) ->
export_vector_enrichment_job(Client, Input, []).
export_vector_enrichment_job(Client, Input0, Options0) ->
Method = post,
Path = ["/export-vector-enrichment-jobs"],
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 Get the details for a previously initiated Earth Observation job.
get_earth_observation_job(Client, Arn)
when is_map(Client) ->
get_earth_observation_job(Client, Arn, #{}, #{}).
get_earth_observation_job(Client, Arn, QueryMap, HeadersMap)
when is_map(Client), is_map(QueryMap), is_map(HeadersMap) ->
get_earth_observation_job(Client, Arn, QueryMap, HeadersMap, []).
get_earth_observation_job(Client, Arn, QueryMap, HeadersMap, Options0)
when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) ->
Path = ["/earth-observation-jobs/", aws_util:encode_uri(Arn), ""],
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 Use this operation to get details of a specific raster data
%% collection.
get_raster_data_collection(Client, Arn)
when is_map(Client) ->
get_raster_data_collection(Client, Arn, #{}, #{}).
get_raster_data_collection(Client, Arn, QueryMap, HeadersMap)
when is_map(Client), is_map(QueryMap), is_map(HeadersMap) ->
get_raster_data_collection(Client, Arn, QueryMap, HeadersMap, []).
get_raster_data_collection(Client, Arn, QueryMap, HeadersMap, Options0)
when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) ->
Path = ["/raster-data-collection/", aws_util:encode_uri(Arn), ""],
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 a web mercator tile for the given Earth Observation job.
get_tile(Client, X, Y, Z, Arn, ImageAssets, Target)
when is_map(Client) ->
get_tile(Client, X, Y, Z, Arn, ImageAssets, Target, #{}, #{}).
get_tile(Client, X, Y, Z, Arn, ImageAssets, Target, QueryMap, HeadersMap)
when is_map(Client), is_map(QueryMap), is_map(HeadersMap) ->
get_tile(Client, X, Y, Z, Arn, ImageAssets, Target, QueryMap, HeadersMap, []).
get_tile(Client, X, Y, Z, Arn, ImageAssets, Target, QueryMap, HeadersMap, Options0)
when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) ->
Path = ["/tile/", aws_util:encode_uri(Z), "/", aws_util:encode_uri(X), "/", aws_util:encode_uri(Y), ""],
SuccessStatusCode = 200,
Options = [{send_body_as_binary, false},
{receive_body_as_binary, false}
| Options0],
Headers = [],
Query0_ =
[
{<<"Arn">>, Arn},
{<<"ImageAssets">>, ImageAssets},
{<<"ImageMask">>, maps:get(<<"ImageMask">>, QueryMap, undefined)},
{<<"OutputDataType">>, maps:get(<<"OutputDataType">>, QueryMap, undefined)},
{<<"OutputFormat">>, maps:get(<<"OutputFormat">>, QueryMap, undefined)},
{<<"PropertyFilters">>, maps:get(<<"PropertyFilters">>, QueryMap, undefined)},
{<<"Target">>, Target},
{<<"TimeRangeFilter">>, maps:get(<<"TimeRangeFilter">>, QueryMap, undefined)}
],
Query_ = [H || {_, V} = H <- Query0_, V =/= undefined],
request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode).
%% @doc Retrieves details of a Vector Enrichment Job for a given job Amazon
%% Resource Name (ARN).
get_vector_enrichment_job(Client, Arn)
when is_map(Client) ->
get_vector_enrichment_job(Client, Arn, #{}, #{}).
get_vector_enrichment_job(Client, Arn, QueryMap, HeadersMap)
when is_map(Client), is_map(QueryMap), is_map(HeadersMap) ->
get_vector_enrichment_job(Client, Arn, QueryMap, HeadersMap, []).
get_vector_enrichment_job(Client, Arn, QueryMap, HeadersMap, Options0)
when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) ->
Path = ["/vector-enrichment-jobs/", aws_util:encode_uri(Arn), ""],
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 Use this operation to get a list of the Earth Observation jobs
%% associated with the calling Amazon Web Services account.
list_earth_observation_jobs(Client, Input) ->
list_earth_observation_jobs(Client, Input, []).
list_earth_observation_jobs(Client, Input0, Options0) ->
Method = post,
Path = ["/list-earth-observation-jobs"],
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 Use this operation to get raster data collections.
list_raster_data_collections(Client)
when is_map(Client) ->
list_raster_data_collections(Client, #{}, #{}).
list_raster_data_collections(Client, QueryMap, HeadersMap)
when is_map(Client), is_map(QueryMap), is_map(HeadersMap) ->
list_raster_data_collections(Client, QueryMap, HeadersMap, []).
list_raster_data_collections(Client, QueryMap, HeadersMap, Options0)
when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) ->
Path = ["/raster-data-collections"],
SuccessStatusCode = 200,
Options = [{send_body_as_binary, false},
{receive_body_as_binary, false}
| Options0],
Headers = [],
Query0_ =
[
{<<"MaxResults">>, maps:get(<<"MaxResults">>, QueryMap, undefined)},
{<<"NextToken">>, maps:get(<<"NextToken">>, QueryMap, undefined)}
],
Query_ = [H || {_, V} = H <- Query0_, V =/= undefined],
request(Client, get, Path, Query_, Headers, undefined, Options, SuccessStatusCode).
%% @doc Lists the tags attached to the resource.
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 Retrieves a list of vector enrichment jobs.
list_vector_enrichment_jobs(Client, Input) ->
list_vector_enrichment_jobs(Client, Input, []).
list_vector_enrichment_jobs(Client, Input0, Options0) ->
Method = post,
Path = ["/list-vector-enrichment-jobs"],
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 Allows you run image query on a specific raster data collection to
%% get a list of the satellite imagery matching the selected filters.
search_raster_data_collection(Client, Input) ->
search_raster_data_collection(Client, Input, []).
search_raster_data_collection(Client, Input0, Options0) ->
Method = post,
Path = ["/search-raster-data-collection"],
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 Use this operation to create an Earth observation job.
start_earth_observation_job(Client, Input) ->
start_earth_observation_job(Client, Input, []).
start_earth_observation_job(Client, Input0, Options0) ->
Method = post,
Path = ["/earth-observation-jobs"],
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 Vector Enrichment job for the supplied job type.
%%
%% Currently, there are two supported job types: reverse geocoding and map
%% matching.
start_vector_enrichment_job(Client, Input) ->
start_vector_enrichment_job(Client, Input, []).
start_vector_enrichment_job(Client, Input0, Options0) ->
Method = post,
Path = ["/vector-enrichment-jobs"],
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 Use this operation to stop an existing earth observation job.
stop_earth_observation_job(Client, Input) ->
stop_earth_observation_job(Client, Input, []).
stop_earth_observation_job(Client, Input0, Options0) ->
Method = post,
Path = ["/earth-observation-jobs/stop"],
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 Stops the Vector Enrichment job for a given job ARN.
stop_vector_enrichment_job(Client, Input) ->
stop_vector_enrichment_job(Client, Input, []).
stop_vector_enrichment_job(Client, Input0, Options0) ->
Method = post,
Path = ["/vector-enrichment-jobs/stop"],
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 The resource you want to tag.
tag_resource(Client, ResourceArn, Input) ->
tag_resource(Client, ResourceArn, Input, []).
tag_resource(Client, ResourceArn, Input0, Options0) ->
Method = put,
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 The resource you want to untag.
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).
%%====================================================================
%% 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 => <<"sagemaker-geospatial">>},
Host = build_host(<<"sagemaker-geospatial">>, 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).