Skip to content

Commit

Permalink
Adding simple doc for Rackspace auth
Browse files Browse the repository at this point in the history
* Also fixed a misspelling
  • Loading branch information
jmvrbanac committed Feb 15, 2015
1 parent 77a4e66 commit 7a54397
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Welcome to Requests-CloudAuth's documentation!
==============================================

Requests-CloudAuth is a collection of Authenication extensions for
Requests-CloudAuth is a collection of Authentication extensions for
the Requests library. The primary purpose of this collection is to
provide an easy interface to authenticate to cloud providers with
minimal dependencies.
Expand All @@ -20,8 +20,10 @@ Documentation
--------------

.. toctree::
:maxdepth: 1

keystone_v2
rackspace

Project Links
---------------
Expand Down
33 changes: 33 additions & 0 deletions docs/source/rackspace.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Rackspace Identity Authentication Extension
===========================================

This authentication extension enables simple authentication to Rackspace
Cloud endpoints.

Sample Usage
------------
::

import requests
from requests_cloudauth import rackspace
auth = rackspace.RackspacePasswordAuth(
username='my_user',
password='my_pass'
)

# Pre-auth as we need ou project_id to list our cloud servers
auth.authenticate()
url = 'https://ord.servers.api.rackspacecloud.com/v2/{0}/servers'.format(auth.project_id)
resp = requests.get(url, auth=auth)


Extension API Documentation
---------------------------

.. autoclass:: requests_cloudauth.rackspace.RackspacePasswordAuth
:inherited-members:

.. autoclass:: requests_cloudauth.rackspace.RackspaceApiKeyAuth
:inherited-members:
22 changes: 22 additions & 0 deletions requests_cloudauth/rackspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ class RackspacePasswordAuth(KeystoneV2AuthBase):

def __init__(self, username, password, endpoint=None,
region='US'):
"""Authentication extension for Requests that supports Rackspace
password authentication.
:param username: Valid Rackspace Cloud username
:param password: Valid Rackspace Cloud password
:param endpoint: (optional) URI to override authentication endpoint
:param region: (optional) Specify the Rackspace Cloud region.
Supported values: US, UK
:return: Instance of RackspacePasswordAuth
"""
if not endpoint:
endpoint = UK_ENDPOINT if region.lower() == 'uk' else US_ENDPOINT

Expand All @@ -33,6 +44,17 @@ class RackspaceApiKeyAuth(KeystoneV2AuthBase):

def __init__(self, username, api_key, endpoint=None,
region='US'):
"""Authentication extension for Requests that supports Rackspace
API key authentication.
:param username: Valid Rackspace Cloud username
:param api_key: Valid Rackspace Cloud API key
:param endpoint: (optional) URI to override authentication endpoint
:param region: (optional) Specify the Rackspace Cloud region.
Supported values: US, UK
:return: Instance of RackspaceApiKeyAuth
"""
if not endpoint:
endpoint = UK_ENDPOINT if region.lower() == 'uk' else US_ENDPOINT

Expand Down

0 comments on commit 7a54397

Please sign in to comment.