Skip to content

Commit

Permalink
Minor fixes (#164)
Browse files Browse the repository at this point in the history
* Minor fixes

- Properly reference the global AWSConfig, in each protocol function
- Remove response_dict_type from args if it's available
- Use response_dict_type in Query and JSON services

* Apply suggestions from code review

Co-authored-by: Eric Davies <[email protected]>

Co-authored-by: Eric Davies <[email protected]>
  • Loading branch information
mattBrzezinski and iamed2 authored Aug 31, 2020
1 parent fe42643 commit a2dd6fb
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/AWS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ Perform a RestXML request to AWS.
"""
function (service::RestXMLService)(
request_method::String, request_uri::String, args::AbstractDict{String, <:Any}=Dict{String, Any}();
aws_config::AWSConfig=aws_config[],
aws_config::AWSConfig=global_aws_config(),
)
request = Request(
service=service.name,
Expand All @@ -500,7 +500,7 @@ function (service::RestXMLService)(
)

if haskey(args, "response_dict_type")
request.response_dict_type = args["response_dict_type"]
request.response_dict_type = pop!(args, "response_dict_type")
end

delete!(args, "headers")
Expand Down Expand Up @@ -544,7 +544,7 @@ Perform a Query request to AWS.
"""
function (service::QueryService)(
operation::String, args::AbstractDict{String, <:Any}=Dict{String, Any}();
aws_config::AWSConfig=aws_config[],
aws_config::AWSConfig=global_aws_config(),
)
POST_RESOURCE = "/"
return_headers = _return_headers(args)
Expand All @@ -562,6 +562,10 @@ function (service::QueryService)(
return_raw=get(args, "return_raw", false),
)

if haskey(args, "response_dict_type")
request.response_dict_type = pop!(args, "response_dict_type")
end

request.headers["Content-Type"] = "application/x-www-form-urlencoded; charset=utf-8"

args["Action"] = operation
Expand Down Expand Up @@ -591,7 +595,7 @@ Perform a JSON request to AWS.
"""
function (service::JSONService)(
operation::String, args::AbstractDict{String, <:Any}=Dict{String, Any}();
aws_config::AWSConfig=aws_config[],
aws_config::AWSConfig=global_aws_config(),
)
POST_RESOURCE = "/"
return_headers = _return_headers(args)
Expand All @@ -610,6 +614,10 @@ function (service::JSONService)(
return_raw=get(args, "return_raw", false),
)

if haskey(args, "response_dict_type")
request.response_dict_type = pop!(args, "response_dict_type")
end

request.headers["Content-Type"] = "application/x-amz-json-$(service.json_version)"
request.headers["X-Amz-Target"] = "$(service.target).$(operation)"

Expand Down Expand Up @@ -637,7 +645,7 @@ Perform a RestJSON request to AWS.
"""
function (service::RestJSONService)(
request_method::String, request_uri::String, args::AbstractDict{String, <:Any}=Dict{String, String}();
aws_config::AWSConfig=aws_config[],
aws_config::AWSConfig=global_aws_config(),
)
return_headers = _return_headers(args)

Expand All @@ -654,7 +662,7 @@ function (service::RestJSONService)(
)

if haskey(args, "response_dict_type")
request.response_dict_type = args["response_dict_type"]
request.response_dict_type = pop!(args, "response_dict_type")
end

request.url = _generate_service_url(aws_config.region, request.service, request.resource)
Expand Down

2 comments on commit a2dd6fb

@mattBrzezinski
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/20506

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.0 -m "<description of version>" a2dd6fb1e9fd05d2d9ab2b5cc0826c0ea498653e
git push origin v1.0.0

Please sign in to comment.