Python Wrapper for DigitalOcean's v2 API
This project is not actively maintained in sync with v2 API changes; if something changes (and therefore breaks the library), open an issue, please.
python
pip install skiff
python
import skiff
s = skiff.rig("my_token")
droplets = s.Droplet.all()
#>>> [<cond.in (#267357) nyc1 - Ubuntu 12.10 x64 - 512mb>,
#>>> <hey.github (#2012972) nyc1 - Ubuntu 13.10 x32 - 512mb>,
#>>> <hello.world (#2012974) nyc1 - Ubuntu 13.10 x32 - 512mb>]
Creation calls can be made with keyword args or a single dictionary argument.
Calls to s.<resource>.all()
can also be passed query parameters. The v2 API currently responds to per_page
. For example, s.Image.all(per_page=200)
will return all of the images up to the 200th (200 is max). By default, s.<resource>.all()
will page through all responses. Pass page=False
to stop skiff from automatically retriving all of the possible values.
Each object has a property _json
, which contains the json response as a dictionary. If you make local changes to the skiff objects (via update()
or similar), be sure to refresh the local json with my_object = my_object.reload()
.
python
my_droplet = s.Droplet.create(name='hello.world',
region='nyc1',
size='512mb',
image=5141286)
#>>> <hello.world (#2012974) nyc1 - Ubuntu 14.04 x64 - 512mb>
# wait until droplet is created
my_droplet.wait_till_done()
# refresh network information
my_droplet = my_droplet.refresh()
Alternatively, you can pass a dictionary containing those values.
python
# Get droplet by ID
my_droplet = s.Droplet.get(id)
# Get droplet by Name (not intelligent)
my_droplet = s.Droplet.get('hello.world')
python
my_droplet.destroy()
python
my_droplet.rename('new.name')
python
my_droplet.reboot()
my_droplet.restart()
python
my_droplet.shutdown()
python
my_droplet.power_off()
python
my_droplet.power_on()
python
my_droplet.power_cycle()
python
# Get size via search
some_size = s.Size.get('512')
#>>> <512mb>
my_droplet.resize(some_size)
Alternatively, simply pass in the string '512mb'
.
python
ubuntu_image = s.Image.get('Ubuntu 13.10')
my_droplet.rebuild(ubuntu_image)
python
# Default to current Image
my_droplet.restore()
# Specify Image
ubuntu_image = s.Image.get('Ubuntu 13.10')
my_droplet.restore(ubuntu_image)
python
my_droplet.password_reset()
my_droplet.reset_password()
python
new_kernel = my_droplet.kernels()[10]
my_droplet.change_kernel(new_kernel)
Alternatively, simply pass the kernel's ID.
python
my_droplet.enable_ipv6()
Note: Droplet must be powered off before you perform this.
python
my_droplet.snapshot()
python
my_droplet.disable_backups()
python
my_droplet.enable_private_networking()
python
my_droplet.snapshots()
python
my_droplet.backups()
python
my_droplet.actions()
python
my_droplet.kernels()
When the droplet's status changes remotely, call this function to manually update your local representation.
This is particularly useful after creating a new droplet because the network info is blank at request time.
python
my_droplet = my_droplet.refresh()
my_droplet = my_droplet.reload()
Returns a boolean regarding whether or not the droplet is processing an action.
python
my_droplet.has_action_in_progress()
#>>> False
Blocks until the droplet has no more pending actions.
python
# waits until the droplet is ready to use, polling every 5 seconds
my_droplet.wait_till_done(5)
Returns all actions for a token.
python
s.Action.all()
python
action_id = 28012139
s.Action.get(action_id)
#>>> <destroy (#28012139) completed>
python
s.Domain.all()
#>>> [<blog.cond.in>,
#>>> <matt.cond.in>,
#>>> <example.com>,
#>>> <example2.com>]
```python # easy, defaulting to fist ipv4 network's public ip my_domain = my_droplet.create_domain('example.com')
# or more manually
my_domain = s.Domain.create(name='example.com', ip_address=my_droplet.v4[0].ip_address)
```
python
my_domain = s.Domain.get('example.com')
my_domain = s.Domain.get(domain_id)
These are aliases for the same method.
python
my_domain.delete()
my_domain.destroy()
python
my_domain.records()
#>>>[<example.com - A (#348736) @ -> 123.456.789.123>,
#>>> <example.com - CNAME (#348740) www -> @>,
#>>> <example.com - NS (#348737) -> NS1.DIGITALOCEAN.COM.>,
#>>> <example.com - NS (#348738) -> NS2.DIGITALOCEAN.COM.>,
#>>> <example.com - NS (#348739) -> NS3.DIGITALOCEAN.COM.>]
python
my_domain.create_record(type='CNAME', name='www', data='@')
See the DigitalOcean v2 API Docs for more options.
python
my_record_id = 1234
my_record = my_domain.get_record(my_record_id)
python
my_record = my_record.update('new_name')
See the DigitalOcean v2 API Docs for information on what new_name
should be.
These are aliases for the same method.
python
my_record.delete()
my_record.destroy()
python
s.Image.all(per_page=100)
#>>> [<CentOS 5.8 x64 (#1601) CentOS>,
#>>> <CentOS 5.8 x32 (#1602) CentOS>,
#>>> ...........
#>>> <Ghost 0.5 on Ubuntu 14.04 (#5610254) Ubuntu>,
#>>> <Redmine on Ubuntu 14.04 (#4869208) Ubuntu>,
#>>> <WordPress on Ubuntu 14.04 (#4991187) Ubuntu>]
python
# Get by ID
my_image_id = 3101580
my_image = s.Image.get(my_image_id)
# Or by slug
ubuntu_slug = 'ubuntu1404'
ubuntu_image = s.Image.get(ubuntu_slug)
# Or by search (not very intelligent; useful for REPL use)
ubuntu_image = s.Image.get('Ubuntu 13.10')
These are aliases for the same method.
python
my_image.delete()
my_image.destroy()
python
name = 'my_new_image'
my_image = my_image.update(name)
python
new_region = s.Region.get('nyc1')
my_image.transfer(new_region)
Alternatively, simply pass the string 'nyc1'.
python
my_image.actions()
python
action_id = 1234
my_image.get_action(action_id)
python
s.Key.all()
python
# ID
my_key = s.Key.get(1234)
# Name
my_key = s.Key.get('my public key')
# Fingerprint
my_key = s.Key.get('my:fi:ng:er:pr:in:t!')
python
with open('~/.ssh/id_rsa.pub', 'r') as f:
pub_key = f.read()
my_key = s.Key.create(name='my public key', public_key=pub_key)
python
my_key = my_key.update('new public key name')
These are aliases for the same method.
python
my_key.delete()
my_key.destroy()
python
s.Region.all()
#>>> [<New York 1 (nyc1)>,
#>>> <San Francisco 1 (sfo1)>,
#>>> <New York 2 (nyc2)>,
#>>> <Amsterdam 2 (ams2)>,
#>>> <Singapore 1 (sgp1)>]
There's probably not much benefit in getting a SkiffRegion instance rather than just passing the region slug string as a parameter.
python
nyc1_region = s.Region.get('nyc1')
python
s.Size.all()
#>>> [<512mb>, <1gb>, <2gb>, <4gb>, <8gb>, <16gb>, <32gb>, <48gb>, <64gb>]
python
# search, not intelligent
small_size = s.Size.get('512')
Suggestions accepted via Issues and Pull-Requests :)
run py.test
Note: Takes a while.
py.test
MIT
Bumps ipython from 2.1.0 to 7.16.3.
Sourced from ipython's releases.
7.9.0
No release notes provided.
7.8.0
No release notes provided.
7.7.0
No release notes provided.
7.6.1
No release notes provided.
7.6.0
No release notes provided.
7.5.0
No release notes provided.
7.4.0
No release notes provided.
7.3.0
No release notes provided.
7.2.0
No release notes provided.
7.1.1
No release notes provided.
7.1.0
No release notes provided.
7.0.1
No release notes provided.
7.0.0
No release notes provided.
7.0.0-doc
No release notes provided.
7.0.0rc1
No release notes provided.
7.0.0b1
No release notes provided.
6.2.1
No release notes provided.
... (truncated)
d43c7c7
release 7.16.35fa1e40
Merge pull request from GHSA-pq7m-3gw7-gq5x8df8971
back to dev9f477b7
release 7.16.2138f266
bring back release helper from master branch5aa3634
Merge pull request #13341 from meeseeksmachine/auto-backport-of-pr-13335-on-7...bcae8e0
Backport PR #13335: What's new 7.16.28fcdcd3
Pin Jedi to <0.17.2.2486838
release 7.16.120bdc6f
fix conda buildDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase
.
Bumps py from 1.4.20 to 1.10.0.
Sourced from py's changelog.
1.10.0 (2020-12-12)
- Fix a regular expression DoS vulnerability in the py.path.svnwc SVN blame functionality (CVE-2020-29651)
- Update vendored apipkg: 1.4 => 1.5
- Update vendored iniconfig: 1.0.0 => 1.1.1
1.9.0 (2020-06-24)
Add type annotation stubs for the following modules:
py.error
py.iniconfig
py.path
(not including SVN paths)py.io
py.xml
There are no plans to type other modules at this time.
The type annotations are provided in external .pyi files, not inline in the code, and may therefore contain small errors or omissions. If you use
py
in conjunction with a type checker, and encounter any type errors you believe should be accepted, please report it in an issue.1.8.2 (2020-06-15)
- On Windows,
py.path.local
s which differ only in case now have the same Python hash value. Previously, such paths were considered equal but had different hashes, which is not allowed and breaks the assumptions made by dicts, sets and other users of hashes.1.8.1 (2019-12-27)
Handle
FileNotFoundError
when trying to import pathlib inpath.common
on Python 3.4 (#207).
py.path.local.samefile
now works correctly in Python 3 on Windows when dealing with symlinks.1.8.0 (2019-02-21)
add
"importlib"
pyimport mode for python3.5+, allowing unimportable test suites to contain identically named modules.fix
LocalPath.as_cwd()
not callingos.chdir()
withNone
, when being invoked from a non-existing directory.
... (truncated)
e5ff378
Update CHANGELOG for 1.10.094cf44f
Update vendored libs5e8ded5
testing: comment out an assert which fails on Python 3.9 for nowafdffcc
Rename HOWTORELEASE.rst to RELEASING.rst2de53a6
Merge pull request #266 from nicoddemus/gh-actionsfa1b32e
Merge pull request #264 from hugovk/patch-2887d6b8
Skip test_samefile_symlink on pypy3 on Windowse94e670
Fix test_comments() in test_sourcefef9a32
Adapt test4a694b0
Add GitHub Actions badge to READMEDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase
.
Bumps pygments from 1.6 to 2.7.4.
Sourced from pygments's releases.
2.7.4
Updated lexers:
Fix infinite loop in SML lexer (#1625)
Fix backtracking string regexes in JavaScript/TypeScript, Modula2 and many other lexers (#1637)
Limit recursion with nesting Ruby heredocs (#1638)
Fix a few inefficient regexes for guessing lexers
Fix the raw token lexer handling of Unicode (#1616)
Revert a private API change in the HTML formatter (#1655) -- please note that private APIs remain subject to change!
Fix several exponential/cubic-complexity regexes found by Ben Caller/Doyensec (#1675)
Fix incorrect MATLAB example (#1582)
Thanks to Google's OSS-Fuzz project for finding many of these bugs.
2.7.3
... (truncated)
Sourced from pygments's changelog.
Version 2.7.4
(released January 12, 2021)
Updated lexers:
Fix infinite loop in SML lexer (#1625)
Fix backtracking string regexes in JavaScript/TypeScript, Modula2 and many other lexers (#1637)
Limit recursion with nesting Ruby heredocs (#1638)
Fix a few inefficient regexes for guessing lexers
Fix the raw token lexer handling of Unicode (#1616)
Revert a private API change in the HTML formatter (#1655) -- please note that private APIs remain subject to change!
Fix several exponential/cubic-complexity regexes found by Ben Caller/Doyensec (#1675)
Fix incorrect MATLAB example (#1582)
Thanks to Google's OSS-Fuzz project for finding many of these bugs.
Version 2.7.3
(released December 6, 2020)
... (truncated)
4d555d0
Bump version to 2.7.4.fc3b05d
Update CHANGES.ad21935
Revert "Added dracula theme style (#1636)"e411506
Prepare for 2.7.4 release.275e34d
doc: remove Perl 6 ref2e7e8c4
Fix several exponential/cubic complexity regexes found by Ben Caller/Doyenseceb39c43
xquery: fix pop from empty stack2738778
fix coding style in test_analyzer_lexer02e0f09
Added 'ERROR STOP' to fortran.py keywords. (#1665)c83fe48
support added for css variables (#1633)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase
.
Bumps pyyaml from 3.11 to 5.4.
Sourced from pyyaml's changelog.
5.4 (2021-01-19)
- yaml/pyyaml#407 -- Build modernization, remove distutils, fix metadata, build wheels, CI to GHA
- yaml/pyyaml#472 -- Fix for CVE-2020-14343, moves arbitrary python tags to UnsafeLoader
- yaml/pyyaml#441 -- Fix memory leak in implicit resolver setup
- yaml/pyyaml#392 -- Fix py2 copy support for timezone objects
- yaml/pyyaml#378 -- Fix compatibility with Jython
5.3.1 (2020-03-18)
- yaml/pyyaml#386 -- Prevents arbitrary code execution during python/object/new constructor
5.3 (2020-01-06)
- yaml/pyyaml#290 -- Use
is
instead of equality for comparing withNone
- yaml/pyyaml#270 -- Fix typos and stylistic nit
- yaml/pyyaml#309 -- Fix up small typo
- yaml/pyyaml#161 -- Fix handling of slots
- yaml/pyyaml#358 -- Allow calling add_multi_constructor with None
- yaml/pyyaml#285 -- Add use of safe_load() function in README
- yaml/pyyaml#351 -- Fix reader for Unicode code points over 0xFFFF
- yaml/pyyaml#360 -- Enable certain unicode tests when maxunicode not > 0xffff
- yaml/pyyaml#359 -- Use full_load in yaml-highlight example
- yaml/pyyaml#244 -- Document that PyYAML is implemented with Cython
- yaml/pyyaml#329 -- Fix for Python 3.10
- yaml/pyyaml#310 -- Increase size of index, line, and column fields
- yaml/pyyaml#260 -- Remove some unused imports
- yaml/pyyaml#163 -- Create timezone-aware datetimes when parsed as such
- yaml/pyyaml#363 -- Add tests for timezone
5.2 (2019-12-02)
- Repair incompatibilities introduced with 5.1. The default Loader was changed, but several methods like add_constructor still used the old default yaml/pyyaml#279 -- A more flexible fix for custom tag constructors yaml/pyyaml#287 -- Change default loader for yaml.add_constructor yaml/pyyaml#305 -- Change default loader for add_implicit_resolver, add_path_resolver
- Make FullLoader safer by removing python/object/apply from the default FullLoader yaml/pyyaml#347 -- Move constructor for object/apply to UnsafeConstructor
- Fix bug introduced in 5.1 where quoting went wrong on systems with sys.maxunicode <= 0xffff yaml/pyyaml#276 -- Fix logic for quoting special characters
- Other PRs: yaml/pyyaml#280 -- Update CHANGES for 5.1
5.1.2 (2019-07-30)
- Re-release of 5.1 with regenerated Cython sources to build properly for Python 3.8b2+
... (truncated)
58d0cb7
5.4 releasea60f7a1
Fix compatibility with Jythonee98abd
Run CI on PR base branch changesddf2033
constructor.timezone: _copy & deepcopyfc914d5
Avoid repeatedly appending to yaml_implicit_resolversa001f27
Fix for CVE-2020-14343fe15062
Add 3.9 to appveyor file for completeness sake1e1c7fb
Add a newline character to end of pyproject.toml0b6b7d6
Start sentences and phrases for capital lettersc976915
Shell code improvementsDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase
.
Bumps jinja2 from 2.7.3 to 2.11.3.
Sourced from jinja2's releases.
2.11.3
This contains a fix for a speed issue with the
urlize
filter.urlize
is likely to be called on untrusted user input. For certain inputs some of the regular expressions used to parse the text could take a very long time due to backtracking. As part of the fix, the email matching became slightly stricter. The various speedups apply tourlize
in general, not just the specific input cases.
- PyPI: https://pypi.org/project/Jinja2/2.11.3/
- Changes: https://jinja.palletsprojects.com/en/2.11.x/changelog/#version-2-11-3
2.11.2
2.11.1
This fixes an issue in async environment when indexing the result of an attribute lookup, like
{{ data.items[1:] }}
.2.11.0
- Changes: https://jinja.palletsprojects.com/en/2.11.x/changelog/#version-2-11-0
- Blog: https://palletsprojects.com/blog/jinja-2-11-0-released/
- Twitter: https://twitter.com/PalletsTeam/status/1221883554537230336
This is the last version to support Python 2.7 and 3.5. The next version will be Jinja 3.0 and will support Python 3.6 and newer.
2.10.3
2.10.2
2.10.1
- Changes: https://jinja.palletsprojects.com/en/2.10.x/changelog/#version-2-10-1
- Blog: https://palletsprojects.com/blog/jinja-2-10-1-released/
- Twitter: https://twitter.com/PalletsTeam/status/1114605127308992513
2.10
Primary changes
- A
NativeEnvironment
that renders Python types instead of strings. http://jinja.pocoo.org/docs/2.10/nativetypes/- A
namespace
object that works with{% set %}
. This replaces previous hacks for storing state across iterations or scopes. http://jinja.pocoo.org/docs/2.10/templates/#assignments- The
loop
object now hasnextitem
andprevitem
attributes, as well as achanged
method, for the common case of outputting something as a value in the loop changes. More complicated cases can use thenamespace
object. http://jinja.pocoo.org/docs/2.10/templates/#forInstall or upgrade
Install from PyPI with pip:
... (truncated)
Sourced from jinja2's changelog.
Version 2.11.3
Released 2021-01-31
- Improve the speed of the
urlize
filter by reducing regex backtracking. Email matching requires a word character at the start of the domain part, and only word characters in the TLD. :pr:1343
Version 2.11.2
Released 2020-04-13
- Fix a bug that caused callable objects with
__getattr__
, like :class:~unittest.mock.Mock
to be treated as a :func:contextfunction
. :issue:1145
- Update
wordcount
filter to trigger :class:Undefined
methods by wrapping the input in :func:soft_str
. :pr:1160
- Fix a hang when displaying tracebacks on Python 32-bit. :issue:
1162
- Showing an undefined error for an object that raises
AttributeError
on access doesn't cause a recursion error. :issue:1177
- Revert changes to :class:
~loaders.PackageLoader
from 2.10 which removed the dependency on setuptools and pkg_resources, and added limited support for namespace packages. The changes caused issues when using Pytest. Due to the difficulty in supporting Python 2 and :pep:451
simultaneously, the changes are reverted until 3.0. :pr:1182
- Fix line numbers in error messages when newlines are stripped. :pr:
1178
- The special
namespace()
assignment object in templates works in async environments. :issue:1180
- Fix whitespace being removed before tags in the middle of lines when
lstrip_blocks
is enabled. :issue:1138
- :class:
~nativetypes.NativeEnvironment
doesn't evaluate intermediate strings during rendering. This prevents early evaluation which could change the value of an expression. :issue:1186
Version 2.11.1
Released 2020-01-30
- Fix a bug that prevented looking up a key after an attribute (
{{ data.items[1:] }}
) in an async template. :issue:1141
... (truncated)
cf21539
release version 2.11.315ef8f0
Merge pull request #1343 from pallets/urlize-speedupef658dc
speed up urlize matchingeeca0fe
Merge pull request #1207 from mhansen/patch-12dd7691
Merge pull request #1209 from mhansen/patch-34892940
do_dictsort: update example ready to copy/paste7db7d33
api.rst: bugfix in docs, import PackageLoader9ec465b
fix changelog header737a4cd
release version 2.11.2179df6b
Merge pull request #1190 from pallets/native-evalDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase
.
SkiffImage.transfer() fails due to "global name 'SkiffRegion' is not defined"
SkiffImage.do_action() fails due to "global name 'SkiffAction' is not defined"
The referred objects should be imported.
iykyk @PleasrDAO — @hackNY alum '14, mentorNY '15. Previously @Skillshare, @IFTTT, @Google, @Grooveshark. he/him
GitHub Repository