Giter VIP home page Giter VIP logo

akamaiopen-edgegrid-python's Introduction

EdgeGrid for Python

This library implements an Authentication handler for requests that provides the Akamai {OPEN} Edgegrid Authentication scheme. For more information visit the Akamai {OPEN} Developer Community.

>>> import requests
>>> from akamai.edgegrid import EdgeGridAuth
>>> from urlparse import urljoin
>>> baseurl = 'https://akaa-WWWWWWWWWWWW.luna.akamaiapis.net/'
>>> s = requests.Session()
>>> s.auth = EdgeGridAuth(
    client_token='ccccccccccccccccc',
    client_secret='ssssssssssssssssss',
    access_token='aaaaaaaaaaaaaaaaaaaaa'
)

>>> result = s.get(urljoin(baseurl, '/diagnostic-tools/v1/locations'))
>>> result.status_code
200
>>> result.json()['locations'][0]
Hongkong, Hong Kong
...

Alternatively, your program can read the credentials from an .edgerc file.

>>> import requests
>>> from akamai.edgegrid import EdgeGridAuth, EdgeRc
>>> from urlparse import urljoin

>>> edgerc = EdgeRc('credentials.edgerc')
>>> section = 'default'
>>> baseurl = 'https://%s' % edgerc.get(section, 'host')

>>> s = requests.Session()
>>> s.auth = EdgeGridAuth.from_edgerc(edgerc, section)

>>> result = s.get(urljoin(baseurl, '/diagnostic-tools/v1/locations'))
>>> result.status_code
200
>>> result.json()['locations'][0]
Hongkong, Hong Kong
...

Installation

To install from pip:

$ pip install edgegrid-python

To install from sources:

$ python setup.py install

To run tests:

$ virtualenv -p python2.7 venv
$ . venv/bin/activate
$ pip install -r requirements.txt
$ python -m unittest discover

Contribute

  1. Fork the repository to start making your changes to the master branch
  2. Write a test which shows that the bug was fixed or that the feature works as expected.
  3. Send a pull request and bug the maintainer until it gets merged and published. :)

Author

Jonathan Landis

License

Copyright 2015 Akamai Technologies, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

akamaiopen-edgegrid-python's People

Contributors

jjjhhhlll avatar richreece avatar abhiomkar avatar chaoranxie avatar synedra avatar rtdean avatar kracekumar avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.