Tags¶
Tag¶
-
class
doapi.Tag[source]¶ New in version 0.2.0.
A tag resource, representing a label that can be applied to other resources.
New tags are created via the
doapi.create_tag()method and can be retrieved with thedoapi.fetch_tag()anddoapi.fetch_all_tags()methods.The DigitalOcean API specifies the following fields for tag objects:
Variables: -
url¶ The endpoint for general operations on the individual tag
-
fetch()[source]¶ Fetch & return a new
Tagobject representing the tag’s current stateReturn type: Tag Raises: DOAPIError – if the API endpoint replies with an error (e.g., if the tag no longer exists)
-
update_tag(name)[source]¶ Update (i.e., rename) the tag
Parameters: name (str) – the new name for the tag Returns: an updated TagobjectReturn type: Tag Raises: DOAPIError – if the API endpoint replies with an error
-
delete()[source]¶ Delete the tag
Returns: NoneRaises: DOAPIError – if the API endpoint replies with an error
-
add(*resources)[source]¶ Apply the tag to one or more resources
Parameters: resources – one or more Resourceobjects to which tags can be appliedReturns: NoneRaises: DOAPIError – if the API endpoint replies with an error
-
remove(*resources)[source]¶ Remove the tag from one or more resources
Parameters: resources – one or more Resourceobjects to which tags can be appliedReturns: NoneRaises: DOAPIError – if the API endpoint replies with an error
-
fetch_all_droplets()[source]¶ Returns a generator that yields all of the droplets to which the tag is currently applied
Return type: generator of DropletsRaises: DOAPIError – if the API endpoint replies with an error
-
delete_all_droplets()[source]¶ Delete all of the droplets to which the tag is applied
Returns: NoneRaises: DOAPIError – if the API endpoint replies with an error
-
act_on_droplets(**data)[source]¶ Perform an arbitrary action on all of the droplets to which the tag is applied.
datawill be serialized as JSON and POSTed to the proper API endpoint. All currently-documented actions require the POST body to be a JSON object containing, at a minimum, a"type"field.Returns: a generator of Actions representing the in-progress operations on the dropletsReturn type: generator of ActionsRaises: DOAPIError – if the API endpoint replies with an error
-
power_cycle()[source]¶ Power cycle all of the droplets to which the tag is applied
Returns: a generator of Actions representing the in-progress operations on the dropletsReturn type: generator of ActionsRaises: DOAPIError – if the API endpoint replies with an error
-
power_on()[source]¶ Power on all of the droplets to which the tag is applied
Returns: a generator of Actions representing the in-progress operations on the dropletsReturn type: generator of ActionsRaises: DOAPIError – if the API endpoint replies with an error
-
power_off()[source]¶ Power off all of the droplets to which the tag is applied
Returns: a generator of Actions representing the in-progress operations on the dropletsReturn type: generator of ActionsRaises: DOAPIError – if the API endpoint replies with an error
-
shutdown()[source]¶ Shut down all of the droplets to which the tag is applied
Returns: a generator of Actions representing the in-progress operations on the dropletsReturn type: generator of ActionsRaises: DOAPIError – if the API endpoint replies with an error
-
enable_private_networking()[source]¶ Enable private networking on all of the droplets to which the tag is applied
Returns: a generator of Actions representing the in-progress operations on the dropletsReturn type: generator of ActionsRaises: DOAPIError – if the API endpoint replies with an error
-
enable_ipv6()[source]¶ Enable IPv6 networking on all of the droplets to which the tag is applied
Returns: a generator of Actions representing the in-progress operations on the dropletsReturn type: generator of ActionsRaises: DOAPIError – if the API endpoint replies with an error
-
enable_backups()[source]¶ Enable backups on all of the droplets to which the tag is applied
Returns: a generator of Actions representing the in-progress operations on the dropletsReturn type: generator of ActionsRaises: DOAPIError – if the API endpoint replies with an error
-
disable_backups()[source]¶ Disable backups on all of the droplets to which the tag is applied
Returns: a generator of Actions representing the in-progress operations on the dropletsReturn type: generator of ActionsRaises: DOAPIError – if the API endpoint replies with an error
-
snapshot(name)[source]¶ Create snapshot images of all of the droplets to which the tag is applied
Parameters: name (str) – the name for the new snapshots Returns: a generator of Actions representing the in-progress operations on the dropletsReturn type: generator of ActionsRaises: DOAPIError – if the API endpoint replies with an error
-