spotinst-sdk2


Namespotinst-sdk2 JSON
Version 3.20.0 PyPI version JSON
download
home_pagehttps://github.com/spotinst/spotinst-sdk-python
SummaryA Python SDK for Spotinst
upload_time2024-11-20 07:29:21
maintainerNone
docs_urlNone
authorSpotinst
requires_python>=3.7.0
licenseMIT
keywords spotinst spot instances aws azure ec2 cloud infrastructure development elastigroup
VCS
bugtrack_url
requirements PyYaml requests pydoc-markdown mock pytest
Travis-CI
coveralls test coverage No coveralls.
            [![Build Status](https://travis-ci.org/spotinst/spotinst-sdk-python.svg?branch=v2)](https://travis-ci.org/spotinst/spotinst-sdk-python)
[![Coverage Status](https://coveralls.io/repos/github/spotinst/spotinst-sdk-python/badge.svg?branch=v2)](https://coveralls.io/github/spotinst/spotinst-sdk-python?branch=master)
[![Python 2.7](https://img.shields.io/badge/python-2.7-blue.svg)](https://www.python.org/downloads/release/python-270/)
[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/)

# Spotinst SDK Python

The official Spotinst SDK for the Python programming language.

## Version 2

The new Spotinst Python SDK comes with a few breaking changes but do not fear, here we will explain all you need to know to make sure you can go right back in buisness in no time. 

- There is no longer the `SpotinstClient()` class which was used to validate your credentials and make requests all in one
- Now there is the `SpotinstSession()` class which is used to validate credentials. [Configure Session Docs](#Configuring-Session)
- From the session object you can create client objects which correlate to specific Spotinst Services and are used to make requests. [Setup Clients Docs](#Setup-Clients)
- Some methods required you to pass in a Model object

Here is a basic example of how to create an Ocean cluster using the Ocean Client and the Ocean Models

```python
from spotinst_sdk2 import SpotinstSession
from spotinst_sdk2.models.ocean.aws import *

session = SpotinstSession()
client = session.client("ocean_aws")

################ Compute ################
launch_specification = LaunchSpecifications(security_group_ids=["sg-12345"],
 image_id="ami-12345", key_pair="Noam-key")

instance_types = InstanceTypes(whitelist=["c4.8xlarge"])

compute = Compute(instance_types=instance_types, 
  subnet_ids=["subnet-1234"], launch_specification=launch_specification)

################ Strategy ################

strategy = Strategy(utilize_reserved_instances=False, fallback_to_od=True, spot_percentage=100)

################ Capacity ################

capacity = Capacity(minimum=0, maximum=0, target=0)

################# Ocean #################

ocean = Ocean(name="Ocean SDK Test", controller_cluster_id="ocean.k8s", 
  region="us-west-2", capacity=capacity, strategy=strategy, compute=compute)

client.create_ocean_cluster(ocean=ocean)
```

In the [SDK Client documentation](./docs/clients/) you can view what methods are supported by each client. <br>
For information on what models are supported checkout the [SDK Model documentation](./docs/models/). <br>
More examples can be found in the [SDK Examples Documentation](./docs/examples/). <br>

## Table of Contents

- [Installation](#installation)
- [Authentication](#authentication)
- [Setup Clients](#setup-clients)
- [Documentation](#documentation)
- [Getting Help](#getting-help)
- [Community](#community)
- [License](#license)

## Installation

```bash
pip install --upgrade spotinst-sdk2
```

## Authentication

The mechanism in which the SDK looks for credentials is to search through a list of possible locations and stop as soon as it finds credentials. The order in which the SDK searches for credentials is:

1. Passing credentials as parameters when creating a `SpotinstSession` object:

```python
session = SpotinstSession(auth_token='foo', account_id='bar')
```

2. Environment variables:

```sh
export SPOTINST_TOKEN=foo
export SPOTINST_ACCOUNT=bar
```

3. Shared credentials file:

- The shared credentials file has a default location of `~/.spotinst/credentials`. This file is an INI formatted file with section names corresponding to profiles. With each section, two configuration variables can be specified: `token`, `account`. These are the only supported values in the shared credential file.

- Below is a minimal example of the shared credentials file:

```ini
[default]
token   = foo
account = bar
```

- The shared credentials file also supports the concept of profiles. Profiles represent logical groups of configuration. The shared credential file can have multiple profiles:

```ini
[default]
token   = foo
account = bar

[dev]
token   = foo2
account = bar2

[prod]
token   = foo3
account = bar3
```

- You can configure your Spot credentials using the `spotctl configure` command. For more information, see the `spotctl` [Getting Started](https://github.com/spotinst/spotctl#getting-started).

- To maintain compatibility with previous SDK versions, the file can also be in YAML format:

```yaml
default:
  token: foo
  account: bar
  
dev:
  token: foo2
  account: bar2
  
prod:
  token: foo3
  account: bar3
```

- You can change the location of the credentials file and the profile used by setting the `SPOTINST_SHARED_CREDENTIALS_FILE` and/or `SPOTINST_PROFILE` environment variables:

```sh
export SPOTINST_SHARED_CREDENTIALS_FILE=/path/to/credentials_file
export SPOTINST_PROFILE=dev
```

- Passing the credentials file location and the profile used as parameters when creating a `SpotinstSession` object:

```python
session = SpotinstSession(credentials_file='/path/to/credentials_file', profile='dev')
```
  
## Setup Clients

After a session is created you can use the session object to create clients. Clients are used to make request to the different services that Spotinsts has to offer. To create a client simply use the method `client` from the session object and pass in the string of the client you wish to create. Here is an example:

```python
session = SpotinstSession()

eg_client = session.client("elastigroup_aws")
ocean_client = session.client("ocean")
```

Take note you can create more than one client with the session. The currently supported clients are

### Client Options

- `session.client("admin")`
- `session.client("setup_aws")`
- `session.client("setup_azure")`
- `session.client("setup_gcp")`
- `session.client("elastigroup_aws")`
- `session.client("elastigroup_azure_v3")`
- `session.client("elastigroup_gcp")`
- `session.client("mcs")`
- `session.client("mrScaler_aws")`
- `session.client("ocean_aws")`
- `session.client("ocean_azure")`
- `session.client("ocean_gcp")`
- `session.client("ocean_ecs")`
- `session.client("ocean_rightsizing")`
- `session.client("subscription")`
- `session.client("managed_instance_aws")`
- `session.client("stateful_node_azure")`
- `session.client("functions")`

A full list of endpoints and clients can be found in the documentation [here](./docs/clients/).

## Documentation

For a comprehensive documentation, check out the [API documentation](https://help.spot.io/).

## Getting Help

We use GitHub issues for tracking bugs and feature requests. Please use these community resources for getting help:

- Ask a question on [Stack Overflow](https://stackoverflow.com/) and tag it with [spotinst-sdk-python](https://stackoverflow.com/questions/tagged/spotinst-sdk-python/).
- Join our Spotinst community on [Slack](http://slack.spot.io/).
- Open an [issue](https://github.com/spotinst/spotinst-sdk-python/issues/new/).

## Community

- [Slack](http://slack.spot.io/)
- [Twitter](https://twitter.com/spot_hq/)

## License

Code is licensed under the [Apache License 2.0](LICENSE). See [NOTICE.md](NOTICE.md) for complete details, including software and third-party licenses and permissions.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/spotinst/spotinst-sdk-python",
    "name": "spotinst-sdk2",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7.0",
    "maintainer_email": null,
    "keywords": "spotinst spot instances aws azure ec2 cloud infrastructure development elastigroup",
    "author": "Spotinst",
    "author_email": "service@spotinst.com",
    "download_url": "https://files.pythonhosted.org/packages/d8/79/255afa39302ec45bb3d7ef4e20900df94e09d74292525477c72a41402a10/spotinst-sdk2-3.20.0.tar.gz",
    "platform": null,
    "description": "[![Build Status](https://travis-ci.org/spotinst/spotinst-sdk-python.svg?branch=v2)](https://travis-ci.org/spotinst/spotinst-sdk-python)\n[![Coverage Status](https://coveralls.io/repos/github/spotinst/spotinst-sdk-python/badge.svg?branch=v2)](https://coveralls.io/github/spotinst/spotinst-sdk-python?branch=master)\n[![Python 2.7](https://img.shields.io/badge/python-2.7-blue.svg)](https://www.python.org/downloads/release/python-270/)\n[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/)\n\n# Spotinst SDK Python\n\nThe official Spotinst SDK for the Python programming language.\n\n## Version 2\n\nThe new Spotinst Python SDK comes with a few breaking changes but do not fear, here we will explain all you need to know to make sure you can go right back in buisness in no time. \n\n- There is no longer the `SpotinstClient()` class which was used to validate your credentials and make requests all in one\n- Now there is the `SpotinstSession()` class which is used to validate credentials. [Configure Session Docs](#Configuring-Session)\n- From the session object you can create client objects which correlate to specific Spotinst Services and are used to make requests. [Setup Clients Docs](#Setup-Clients)\n- Some methods required you to pass in a Model object\n\nHere is a basic example of how to create an Ocean cluster using the Ocean Client and the Ocean Models\n\n```python\nfrom spotinst_sdk2 import SpotinstSession\nfrom spotinst_sdk2.models.ocean.aws import *\n\nsession = SpotinstSession()\nclient = session.client(\"ocean_aws\")\n\n################ Compute ################\nlaunch_specification = LaunchSpecifications(security_group_ids=[\"sg-12345\"],\n image_id=\"ami-12345\", key_pair=\"Noam-key\")\n\ninstance_types = InstanceTypes(whitelist=[\"c4.8xlarge\"])\n\ncompute = Compute(instance_types=instance_types, \n  subnet_ids=[\"subnet-1234\"], launch_specification=launch_specification)\n\n################ Strategy ################\n\nstrategy = Strategy(utilize_reserved_instances=False, fallback_to_od=True, spot_percentage=100)\n\n################ Capacity ################\n\ncapacity = Capacity(minimum=0, maximum=0, target=0)\n\n################# Ocean #################\n\nocean = Ocean(name=\"Ocean SDK Test\", controller_cluster_id=\"ocean.k8s\", \n  region=\"us-west-2\", capacity=capacity, strategy=strategy, compute=compute)\n\nclient.create_ocean_cluster(ocean=ocean)\n```\n\nIn the [SDK Client documentation](./docs/clients/) you can view what methods are supported by each client. <br>\nFor information on what models are supported checkout the [SDK Model documentation](./docs/models/). <br>\nMore examples can be found in the [SDK Examples Documentation](./docs/examples/). <br>\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Authentication](#authentication)\n- [Setup Clients](#setup-clients)\n- [Documentation](#documentation)\n- [Getting Help](#getting-help)\n- [Community](#community)\n- [License](#license)\n\n## Installation\n\n```bash\npip install --upgrade spotinst-sdk2\n```\n\n## Authentication\n\nThe mechanism in which the SDK looks for credentials is to search through a list of possible locations and stop as soon as it finds credentials. The order in which the SDK searches for credentials is:\n\n1. Passing credentials as parameters when creating a `SpotinstSession` object:\n\n```python\nsession = SpotinstSession(auth_token='foo', account_id='bar')\n```\n\n2. Environment variables:\n\n```sh\nexport SPOTINST_TOKEN=foo\nexport SPOTINST_ACCOUNT=bar\n```\n\n3. Shared credentials file:\n\n- The shared credentials file has a default location of `~/.spotinst/credentials`. This file is an INI formatted file with section names corresponding to profiles. With each section, two configuration variables can be specified: `token`, `account`. These are the only supported values in the shared credential file.\n\n- Below is a minimal example of the shared credentials file:\n\n```ini\n[default]\ntoken   = foo\naccount = bar\n```\n\n- The shared credentials file also supports the concept of profiles. Profiles represent logical groups of configuration. The shared credential file can have multiple profiles:\n\n```ini\n[default]\ntoken   = foo\naccount = bar\n\n[dev]\ntoken   = foo2\naccount = bar2\n\n[prod]\ntoken   = foo3\naccount = bar3\n```\n\n- You can configure your Spot credentials using the `spotctl configure` command. For more information, see the `spotctl` [Getting Started](https://github.com/spotinst/spotctl#getting-started).\n\n- To maintain compatibility with previous SDK versions, the file can also be in YAML format:\n\n```yaml\ndefault:\n  token: foo\n  account: bar\n  \ndev:\n  token: foo2\n  account: bar2\n  \nprod:\n  token: foo3\n  account: bar3\n```\n\n- You can change the location of the credentials file and the profile used by setting the `SPOTINST_SHARED_CREDENTIALS_FILE` and/or `SPOTINST_PROFILE` environment variables:\n\n```sh\nexport SPOTINST_SHARED_CREDENTIALS_FILE=/path/to/credentials_file\nexport SPOTINST_PROFILE=dev\n```\n\n- Passing the credentials file location and the profile used as parameters when creating a `SpotinstSession` object:\n\n```python\nsession = SpotinstSession(credentials_file='/path/to/credentials_file', profile='dev')\n```\n  \n## Setup Clients\n\nAfter a session is created you can use the session object to create clients. Clients are used to make request to the different services that Spotinsts has to offer. To create a client simply use the method `client` from the session object and pass in the string of the client you wish to create. Here is an example:\n\n```python\nsession = SpotinstSession()\n\neg_client = session.client(\"elastigroup_aws\")\nocean_client = session.client(\"ocean\")\n```\n\nTake note you can create more than one client with the session. The currently supported clients are\n\n### Client Options\n\n- `session.client(\"admin\")`\n- `session.client(\"setup_aws\")`\n- `session.client(\"setup_azure\")`\n- `session.client(\"setup_gcp\")`\n- `session.client(\"elastigroup_aws\")`\n- `session.client(\"elastigroup_azure_v3\")`\n- `session.client(\"elastigroup_gcp\")`\n- `session.client(\"mcs\")`\n- `session.client(\"mrScaler_aws\")`\n- `session.client(\"ocean_aws\")`\n- `session.client(\"ocean_azure\")`\n- `session.client(\"ocean_gcp\")`\n- `session.client(\"ocean_ecs\")`\n- `session.client(\"ocean_rightsizing\")`\n- `session.client(\"subscription\")`\n- `session.client(\"managed_instance_aws\")`\n- `session.client(\"stateful_node_azure\")`\n- `session.client(\"functions\")`\n\nA full list of endpoints and clients can be found in the documentation [here](./docs/clients/).\n\n## Documentation\n\nFor a comprehensive documentation, check out the [API documentation](https://help.spot.io/).\n\n## Getting Help\n\nWe use GitHub issues for tracking bugs and feature requests. Please use these community resources for getting help:\n\n- Ask a question on [Stack Overflow](https://stackoverflow.com/) and tag it with [spotinst-sdk-python](https://stackoverflow.com/questions/tagged/spotinst-sdk-python/).\n- Join our Spotinst community on [Slack](http://slack.spot.io/).\n- Open an [issue](https://github.com/spotinst/spotinst-sdk-python/issues/new/).\n\n## Community\n\n- [Slack](http://slack.spot.io/)\n- [Twitter](https://twitter.com/spot_hq/)\n\n## License\n\nCode is licensed under the [Apache License 2.0](LICENSE). See [NOTICE.md](NOTICE.md) for complete details, including software and third-party licenses and permissions.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python SDK for Spotinst",
    "version": "3.20.0",
    "project_urls": {
        "Homepage": "https://github.com/spotinst/spotinst-sdk-python"
    },
    "split_keywords": [
        "spotinst",
        "spot",
        "instances",
        "aws",
        "azure",
        "ec2",
        "cloud",
        "infrastructure",
        "development",
        "elastigroup"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d879255afa39302ec45bb3d7ef4e20900df94e09d74292525477c72a41402a10",
                "md5": "14609d80ce32acc4ed9c53a71de6e7e8",
                "sha256": "69e70e60c7106facffa58d081abcea47634c413e732a4f6fbccfbdc85132160f"
            },
            "downloads": -1,
            "filename": "spotinst-sdk2-3.20.0.tar.gz",
            "has_sig": false,
            "md5_digest": "14609d80ce32acc4ed9c53a71de6e7e8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7.0",
            "size": 92263,
            "upload_time": "2024-11-20T07:29:21",
            "upload_time_iso_8601": "2024-11-20T07:29:21.505243Z",
            "url": "https://files.pythonhosted.org/packages/d8/79/255afa39302ec45bb3d7ef4e20900df94e09d74292525477c72a41402a10/spotinst-sdk2-3.20.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-20 07:29:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "spotinst",
    "github_project": "spotinst-sdk-python",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "PyYaml",
            "specs": [
                [
                    "==",
                    "6.0.2"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.32.3"
                ]
            ]
        },
        {
            "name": "pydoc-markdown",
            "specs": [
                [
                    "==",
                    "4.8.2"
                ]
            ]
        },
        {
            "name": "mock",
            "specs": [
                [
                    "==",
                    "5.1.0"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "==",
                    "8.3.2"
                ]
            ]
        }
    ],
    "lcname": "spotinst-sdk2"
}
        
Elapsed time: 0.84722s