{ "info": { "author": "Brent Naylor", "author_email": "brantai@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "python-rightscale\n=================\n\nA python wrapper for the Rightscale API. This supports the 1.5 API and Rightscale's OAuth token authentication.\n\n\nUsage Examples\n--------------\n\n**Setting up your auth token**\n\n```python\nimport rightscale\napi = rightscale.RightScale(refresh_token='token',api_endpoint='api-endpoint')\n```\n\n- `refreshtoken` is the refresh token issued to you when you enabled api access.\n- `api_endpoint` is the FQDN of \"Token Endpoint (API 1.5)\" from the same page.\n\nYou may pre-store these attributes in `~/.rightscalerc`. See the example file for format. When using `~/.rightscalerc`, you can instantiate `RightScale` objects without specifying credentials and it will use the credentials in your rc file:\n\n```python\nimport rightscale\napi = rightscale.RightScale()\n```\n\n**Convenience Commands**\n\nHere are some examples of some common high-level operations for which functions have been implemented in this library:\n\n- List all instances in `EC2 us-east-1`:\n\n ```python\n from rightscale import list_instances\n use1_instances = list_instances(cloud_name='EC2 us-east-1')\n ```\n\n Upon success, `use1_instances` will contain a list of dict objects representing the tiny view of each instance as returned by the RightScale API.\n\n- Run a RightScript on a specific server:\n\n ```python\n from rightscale import run_script_on_server\n inputs = {\n 'APACHE_VHOST': 'my-photo-gallery',\n }\n run_script_on_server('enable apache vhost', 'my web server', inputs=inputs)\n ```\n\n\nObject Interface to RightScale API\n----------------------------------\nThis library's object interface was modeled after the REST-ish API as documented in [the official RightScale API guide](http://support.rightscale.com/12-Guides/RightScale_API_1.5).\n\nUsers of this library should consult the [API reference](http://reference.rightscale.com/api1.5/index.html) for context-specific parameters like filters, views, GET and POST parameters.\n\n**Root API Object**\n\nIf you only need to perform a common high-level operation like `run_script_on_server`, then you can just import the necessary function from the top-level package and start calling it. The convenience commands all expect you to have working credentials in `~/.rightscalerc`. They also use an implicitly created API object (i.e. singleton instance of `rightscale.RightScale`) and perform all the API calls for you.\n\nHowever, if you need to specify different credentials than those stored in `~/.rightscalerc`, or if you need full access to the RightScale API, then you should create your own API object by instantiating `rightscale.RightScale`. E.g.\n\n```python\nfrom rightscale import RightScale\napi = RightScale()\n\n# now check rightscale's health!\napi.health_check()\n```\n\n**Resources and Actions**\n\nThe `rightscale.RightScale` class has attributes for the top-level resources documented in the API reference. The methods on each of the `RightScale` attributes map to the actions listed in the documentation. Invoking an action method is like issuing an HTTP request. Action methods return objects that always have a `response` attribute containing the HTTP `Response` objects from the [Requests library](http://python-requests.org). For example, the [Users resource](http://reference.rightscale.com/api1.5/resources/ResourceAccounts.html) has an `index` action that lists all the users available to the account. The HTTP request for this list would be:\n\n GET /api/users\n\nTo retrieve the list using this library:\n\n```python\nusers = api.users.index()\n\n# inspect http response content type\nassert 'application/vnd.rightscale.user+json' in users.response.content_type\n\n# inspect other http response headers (note: contrived example; don't really do\n# this because the library already checks status for you)\nassert '200 OK' == users.response.headers['status']\n```\n\nMost actions that act on a specific resource (as opposed to a set of resources) require a resource `id` value. For example, to get account details, the API documentation describes the [Accounts resource](http://reference.rightscale.com/api1.5/resources/ResourceAccounts.html) as having a `show` action that requires an `id` as the last part of the URL path. If the account `id` were `12345`, the associated HTTP request would be:\n\n GET /api/accounts/12345\n\nTo specify a resource identifier to action methods, assign a value to the `res_id` keyword argument like this:\n\n```python\naccount = api.accounts.show(res_id='12345')\n```\n\nRegardless of what the actual name of the resource is (e.g. `accounts`, `users`, `servers`, etc...), the special keyword argument is always called `res_id`.\n\n**Filters**\n\nThe action methods are just wrappers around HTTP `Request` objects from the [Requests library](http://python-requests.org). That means that the methods accept GET parameters and POST data as keyword arguments. For example, to find a server by name, the API reference instructs us to use the `index` method on the [Servers resource](http://reference.rightscale.com/api1.5/resources/ResourceServers.html#index) with a filter. If the name of the server were `server_foo`, the HTTP request would be:\n\n GET /api/servers?filter[]=name==server_foo\n\nAnd RightScale would return a list of matches. Using this library, to conduct the same search would look like this:\n\n```python\nparams = {\n 'filter[]': ['name==server_foo'],\n }\nfound = api.servers.index(params=params)\n```\n\n**Tags**\n\nHere's an example of how to find resources by tag:\n\n```python\nparams = {\n 'tags[]': ['rs_backup:lineage=prod_db'],\n 'resource_type': 'volume_snapshots',\n }\nsnapshots = api.tags.by_tag(params=params)\n```\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/brantai/python-rightscale", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "python-rightscale", "package_url": "https://pypi.org/project/python-rightscale/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/python-rightscale/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/brantai/python-rightscale" }, "release_url": "https://pypi.org/project/python-rightscale/0.1.3/", "requires_dist": null, "requires_python": null, "summary": "Python wrapper for the Rightscale API", "version": "0.1.3" }, "last_serial": 2317672, "releases": { "0.1.2": [ { "comment_text": "", "digests": { "md5": "8e6de3d45f28255ee686418bc101a613", "sha256": "bd6210cc2f331431dada7ebfe23d51e5ab822c26aa85ce156027776ae0f985cf" }, "downloads": -1, "filename": "python-rightscale-0.1.2.tar.gz", "has_sig": false, "md5_digest": "8e6de3d45f28255ee686418bc101a613", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11825, "upload_time": "2014-12-05T22:33:07", "url": "https://files.pythonhosted.org/packages/b1/7c/f8e2783eb4a0b02cc04cfae6bf26d72f8e38c7d6bbb09ab00e5cb3e6ce88/python-rightscale-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "a0bc33444aca5f21676db51793cd1ab0", "sha256": "8bb0338901b7b1fd8cab10651d3dec7f28582c74b57538141f9d8e6689051307" }, "downloads": -1, "filename": "python-rightscale-0.1.3.tar.gz", "has_sig": false, "md5_digest": "a0bc33444aca5f21676db51793cd1ab0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12109, "upload_time": "2015-02-20T21:27:50", "url": "https://files.pythonhosted.org/packages/69/ba/3bde5f13db2d3962e02a67be634e4c0bf08d23450894ae6aa1f40dcc8095/python-rightscale-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a0bc33444aca5f21676db51793cd1ab0", "sha256": "8bb0338901b7b1fd8cab10651d3dec7f28582c74b57538141f9d8e6689051307" }, "downloads": -1, "filename": "python-rightscale-0.1.3.tar.gz", "has_sig": false, "md5_digest": "a0bc33444aca5f21676db51793cd1ab0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12109, "upload_time": "2015-02-20T21:27:50", "url": "https://files.pythonhosted.org/packages/69/ba/3bde5f13db2d3962e02a67be634e4c0bf08d23450894ae6aa1f40dcc8095/python-rightscale-0.1.3.tar.gz" } ] }