%% WARNING: DO NOT EDIT, AUTO-GENERATED CODE! %% See https://github.com/aws-beam/aws-codegen for more details. %% @doc Welcome to the AWS Entity Resolution API Reference. %% %% AWS Entity Resolution is an AWS service that provides pre-configured %% entity resolution capabilities that enable developers and analysts at %% advertising and marketing companies to build an accurate and complete view %% of their consumers. %% %% With AWS Entity Resolution, you have the ability to match source records %% containing consumer identifiers, such as name, email address, and phone %% number. This holds true even when these records have incomplete or %% conflicting identifiers. For example, AWS Entity Resolution can %% effectively match a source record from a customer relationship management %% (CRM) system, which includes account information like first name, last %% name, postal address, phone number, and email address, with a source %% record from a marketing system containing campaign information, such as %% username and email address. %% %% To learn more about AWS Entity Resolution concepts, procedures, and best %% practices, see the AWS Entity Resolution User Guide. -module(aws_entityresolution). -export([create_matching_workflow/2, create_matching_workflow/3, create_schema_mapping/2, create_schema_mapping/3, delete_matching_workflow/3, delete_matching_workflow/4, delete_schema_mapping/3, delete_schema_mapping/4, get_match_id/3, get_match_id/4, get_matching_job/3, get_matching_job/5, get_matching_job/6, get_matching_workflow/2, get_matching_workflow/4, get_matching_workflow/5, get_schema_mapping/2, get_schema_mapping/4, get_schema_mapping/5, list_matching_jobs/2, list_matching_jobs/4, list_matching_jobs/5, list_matching_workflows/1, list_matching_workflows/3, list_matching_workflows/4, list_schema_mappings/1, list_schema_mappings/3, list_schema_mappings/4, list_tags_for_resource/2, list_tags_for_resource/4, list_tags_for_resource/5, start_matching_job/3, start_matching_job/4, tag_resource/3, tag_resource/4, untag_resource/3, untag_resource/4, update_matching_workflow/3, update_matching_workflow/4]). -include_lib("hackney/include/hackney_lib.hrl"). %%==================================================================== %% API %%==================================================================== %% @doc Creates a `MatchingWorkflow' object which stores the %% configuration of the data processing job to be run. %% %% It is important to note that there should not be a pre-existing %% `MatchingWorkflow' with the same name. To modify an existing workflow, %% utilize the `UpdateMatchingWorkflow' API. create_matching_workflow(Client, Input) -> create_matching_workflow(Client, Input, []). create_matching_workflow(Client, Input0, Options0) -> Method = post, Path = ["/matchingworkflows"], 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 schema mapping, which defines the schema of the input %% customer records table. %% %% The `SchemaMapping' also provides Entity Resolution with some metadata %% about the table, such as the attribute types of the columns and which %% columns to match on. create_schema_mapping(Client, Input) -> create_schema_mapping(Client, Input, []). create_schema_mapping(Client, Input0, Options0) -> Method = post, Path = ["/schemas"], 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 the `MatchingWorkflow' with a given name. %% %% This operation will succeed even if a workflow with the given name does %% not exist. delete_matching_workflow(Client, WorkflowName, Input) -> delete_matching_workflow(Client, WorkflowName, Input, []). delete_matching_workflow(Client, WorkflowName, Input0, Options0) -> Method = delete, Path = ["/matchingworkflows/", aws_util:encode_uri(WorkflowName), ""], 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 the `SchemaMapping' with a given name. %% %% This operation will succeed even if a schema with the given name does not %% exist. This operation will fail if there is a %% `DataIntegrationWorkflow' object that references the %% `SchemaMapping' in the workflow's `InputSourceConfig'. delete_schema_mapping(Client, SchemaName, Input) -> delete_schema_mapping(Client, SchemaName, Input, []). delete_schema_mapping(Client, SchemaName, Input0, Options0) -> Method = delete, Path = ["/schemas/", aws_util:encode_uri(SchemaName), ""], 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 corresponding Match ID of a customer record if the record %% has been processed. get_match_id(Client, WorkflowName, Input) -> get_match_id(Client, WorkflowName, Input, []). get_match_id(Client, WorkflowName, Input0, Options0) -> Method = post, Path = ["/matchingworkflows/", aws_util:encode_uri(WorkflowName), "/matches"], 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 Gets the status, metrics, and errors (if there are any) that are %% associated with a job. get_matching_job(Client, JobId, WorkflowName) when is_map(Client) -> get_matching_job(Client, JobId, WorkflowName, #{}, #{}). get_matching_job(Client, JobId, WorkflowName, QueryMap, HeadersMap) when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> get_matching_job(Client, JobId, WorkflowName, QueryMap, HeadersMap, []). get_matching_job(Client, JobId, WorkflowName, QueryMap, HeadersMap, Options0) when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> Path = ["/matchingworkflows/", aws_util:encode_uri(WorkflowName), "/jobs/", aws_util:encode_uri(JobId), ""], 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 Returns the `MatchingWorkflow' with a given name, if it exists. get_matching_workflow(Client, WorkflowName) when is_map(Client) -> get_matching_workflow(Client, WorkflowName, #{}, #{}). get_matching_workflow(Client, WorkflowName, QueryMap, HeadersMap) when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> get_matching_workflow(Client, WorkflowName, QueryMap, HeadersMap, []). get_matching_workflow(Client, WorkflowName, QueryMap, HeadersMap, Options0) when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> Path = ["/matchingworkflows/", aws_util:encode_uri(WorkflowName), ""], 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 Returns the SchemaMapping of a given name. get_schema_mapping(Client, SchemaName) when is_map(Client) -> get_schema_mapping(Client, SchemaName, #{}, #{}). get_schema_mapping(Client, SchemaName, QueryMap, HeadersMap) when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> get_schema_mapping(Client, SchemaName, QueryMap, HeadersMap, []). get_schema_mapping(Client, SchemaName, QueryMap, HeadersMap, Options0) when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> Path = ["/schemas/", aws_util:encode_uri(SchemaName), ""], 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 Lists all jobs for a given workflow. list_matching_jobs(Client, WorkflowName) when is_map(Client) -> list_matching_jobs(Client, WorkflowName, #{}, #{}). list_matching_jobs(Client, WorkflowName, QueryMap, HeadersMap) when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> list_matching_jobs(Client, WorkflowName, QueryMap, HeadersMap, []). list_matching_jobs(Client, WorkflowName, QueryMap, HeadersMap, Options0) when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> Path = ["/matchingworkflows/", aws_util:encode_uri(WorkflowName), "/jobs"], 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 Returns a list of all the `MatchingWorkflows' that have been %% created for an AWS account. list_matching_workflows(Client) when is_map(Client) -> list_matching_workflows(Client, #{}, #{}). list_matching_workflows(Client, QueryMap, HeadersMap) when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> list_matching_workflows(Client, QueryMap, HeadersMap, []). list_matching_workflows(Client, QueryMap, HeadersMap, Options0) when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> Path = ["/matchingworkflows"], 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 Returns a list of all the `SchemaMappings' that have been created %% for an AWS account. list_schema_mappings(Client) when is_map(Client) -> list_schema_mappings(Client, #{}, #{}). list_schema_mappings(Client, QueryMap, HeadersMap) when is_map(Client), is_map(QueryMap), is_map(HeadersMap) -> list_schema_mappings(Client, QueryMap, HeadersMap, []). list_schema_mappings(Client, QueryMap, HeadersMap, Options0) when is_map(Client), is_map(QueryMap), is_map(HeadersMap), is_list(Options0) -> Path = ["/schemas"], 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 Displays the tags associated with an AWS Entity Resolution resource. %% %% In Entity Resolution, `SchemaMapping', and `MatchingWorkflow' can %% be tagged. 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 Starts the `MatchingJob' of a workflow. %% %% The workflow must have previously been created using the %% `CreateMatchingWorkflow' endpoint. start_matching_job(Client, WorkflowName, Input) -> start_matching_job(Client, WorkflowName, Input, []). start_matching_job(Client, WorkflowName, Input0, Options0) -> Method = post, Path = ["/matchingworkflows/", aws_util:encode_uri(WorkflowName), "/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 Assigns one or more tags (key-value pairs) to the specified AWS %% Entity Resolution resource. %% %% Tags can help you organize and categorize your resources. You can also use %% them to scope user permissions by granting a user permission to access or %% change only resources with certain tag values. In Entity Resolution, %% `SchemaMapping', and `MatchingWorkflow' can be tagged. Tags %% don't have any semantic meaning to AWS and are interpreted strictly as %% strings of characters. You can use the `TagResource' action with a %% resource that already has tags. If you specify a new tag key, this tag is %% appended to the list of tags associated with the resource. If you specify %% a tag key that is already associated with the resource, the new tag value %% that you specify replaces the previous value for that tag. 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 Removes one or more tags from the specified AWS Entity Resolution %% resource. %% %% In Entity Resolution, `SchemaMapping', and `MatchingWorkflow' can %% be tagged. 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 an existing `MatchingWorkflow'. %% %% This method is identical to `CreateMatchingWorkflow', except it uses %% an HTTP `PUT' request instead of a `POST' request, and the %% `MatchingWorkflow' must already exist for the method to succeed. update_matching_workflow(Client, WorkflowName, Input) -> update_matching_workflow(Client, WorkflowName, Input, []). update_matching_workflow(Client, WorkflowName, Input0, Options0) -> Method = put, Path = ["/matchingworkflows/", aws_util:encode_uri(WorkflowName), ""], 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). %%==================================================================== %% 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 => <<"entityresolution">>}, Host = build_host(<<"entityresolution">>, 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 = aws_client:proto(Client), Path = erlang:iolist_to_binary(Path0), Port = aws_client: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).