Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying endpoint_url should not require metadata dict #163

Merged
merged 2 commits into from Oct 23, 2013

Conversation

jamesls
Copy link
Member

@jamesls jamesls commented Oct 22, 2013

If a service has no metadata dict that contains
regions/endpoint/protocol info, we should still be able to
construct endpoints by passing endpoint_url. I've also
updated the code to not require region_name unless it's a sigv4
service (which is the only reason we need to require a region name
if we're given an explicit endpoint_url).

With this commit, we can consume the unprocessed model as it
exists in services/*.json.

So basically:

>>> botocore.session.get_session()
<botocore.session.Session object at 0x1017b1c50>
>>> s = _
>>> s.get_service('iam')
Service(iam)
>>> service = _
>>> service.get_endpoint()
iam(https://iam.amazonaws.com/)
>>> service.get_endpoint(region_name='us-east-1')
iam(https://iam.amazonaws.com/)
>>> service.get_endpoint(region_name='us-east-1', endpoint_url='https://example.com')
iam(https://example.com)
>>> service.get_endpoint(endpoint_url='https://example.com')  # sigv4 services requires explicit region_name when using endpoint_url
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "botocore/service.py", line 124, in get_endpoint
    return get_endpoint(self, region_name, endpoint_url)
  File "botocore/endpoint.py", line 257, in get_endpoint
    service_object=service)
  File "botocore/endpoint.py", line 272, in _get_auth
    raise botocore.exceptions.NoRegionError(env_var=envvar_name)
botocore.exceptions.NoRegionError: You must specify a region or set the BOTO_DEFAULT_REGION environment variable.
>>> s.get_service('ec2').get_endpoint(endpoint_url='http://complete.override.com') # sigv2 service doesn't require region_name when using endpoint_url
ec2(http://complete.override.com)

If a service has not metadata dict that contains
regions/endpoint/protocol info, we should still be able to
construct endpoints by passing endpoint_url.  I've also
updated the code to not require region_name unless it's a sigv4
service (which is the only reason we need to require a region name
if we're given an explicit endpoint_url).

With this commit, we can consume the unprocessed model as it
exists in services/*.json.
# logic, if an endpoint_url is explicitly
# provided, just use what's been explicitly passed in.
return get_endpoint(self, region_name, endpoint_url)
if region_name is None and not self.global_endpoint:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a test that covers this exception? Everything else seems well covered but this case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like there is not. I'll go ahead and add a test.

@toastdriven
Copy link
Contributor

Outside of that feedback, LGTM.

@jamesls
Copy link
Member Author

jamesls commented Oct 22, 2013

@toastdriven Test added in jamesls@87f6d44.

@toastdriven
Copy link
Contributor

Thanks. 🚢 it!

@jamesls jamesls merged commit 87f6d44 into boto:develop Oct 23, 2013
@jamesls jamesls deleted the regions-not-required branch June 23, 2014 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants