You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by qu...@apache.org on 2017/09/27 03:12:50 UTC

[07/14] libcloud git commit: Docstrings added for public classes

Docstrings added for public classes

Signed-off-by: Quentin Pradet <qu...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/82b5c3cc
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/82b5c3cc
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/82b5c3cc

Branch: refs/heads/trunk
Commit: 82b5c3cc63e28d7a540974f7bfeb832e4c68d16c
Parents: d238e93
Author: Mika Lackman <mi...@upcloud.com>
Authored: Sun Sep 24 16:08:31 2017 +0300
Committer: Quentin Pradet <qu...@apache.org>
Committed: Wed Sep 27 07:04:33 2017 +0400

----------------------------------------------------------------------
 libcloud/common/upcloud.py | 67 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 66 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/82b5c3cc/libcloud/common/upcloud.py
----------------------------------------------------------------------
diff --git a/libcloud/common/upcloud.py b/libcloud/common/upcloud.py
index cbb2904..a63be08 100644
--- a/libcloud/common/upcloud.py
+++ b/libcloud/common/upcloud.py
@@ -27,6 +27,27 @@ class UpcloudCreateNodeRequestBody(object):
     Body of the create_node request
 
     Takes the create_node arguments (**kwargs) and constructs the request body
+
+    :param      user_id: required for authentication (required)
+    :type       user_id: ``str``
+
+    :param      name: Name of the created server (required)
+    :type       name: ``str``
+
+    :param      size: The size of resources allocated to this node.
+    :type       size: :class:`.NodeSize`
+
+    :param      image: OS Image to boot on node.
+    :type       image: :class:`.NodeImage`
+
+    :param      location: Which data center to create a node in. If empty,
+                        undefined behavior will be selected. (optional)
+    :type       location: :class:`.NodeLocation`
+
+    :param      auth: Initial authentication information for the node
+                            (optional)
+    :type       auth: :class:`.NodeAuthSSHKey`
+
     """
 
     def __init__(self, user_id, name, size, image, location, auth=None):
@@ -44,15 +65,26 @@ class UpcloudCreateNodeRequestBody(object):
     def to_json(self):
         """
         Serializes the body to json
+
+        :return: JSON string
+        :rtype: ``str``
         """
         return json.dumps(self.body)
 
 
 class UpcloudNodeDestroyer(object):
     """
-    Destroyes the node.
+    Helper class for destroying node.
     Node must be first stopped and then it can be
     destroyed
+
+    :param  upcloud_node_operations: UpcloudNodeOperations instance
+    :type   upcloud_node_operations: :class:`.UpcloudNodeOperations`
+
+    :param  sleep_func: Callable function, which sleeps.
+        Takes int argument to sleep in seconds (optional)
+    :type   sleep_func: ``function``
+
     """
 
     WAIT_AMOUNT = 2
@@ -64,6 +96,12 @@ class UpcloudNodeDestroyer(object):
         self._sleep_count = 0
 
     def destroy_node(self, node_id):
+        """
+        Destroys the given node.
+
+        :param  node_id: Id of the Node.
+        :type   node_id: ``int``
+        """
         self._stop_called = False
         self._sleep_count = 0
         return self._do_destroy_node(node_id)
@@ -99,11 +137,23 @@ class UpcloudNodeDestroyer(object):
 
 
 class UpcloudNodeOperations(object):
+    """
+    Helper class to start and stop node.
+
+    :param  conneciton: Connection instance
+    :type   connection: :class:`.UpcloudConnection`
+    """
 
     def __init__(self, connection):
         self.connection = connection
 
     def stop_node(self, node_id):
+        """
+        Stops the node
+
+        :param  node_id: Id of the Node
+        :type   node_id: ``int``
+        """
         body = {
             'stop_server': {
                 'stop_type': 'hard'
@@ -114,6 +164,15 @@ class UpcloudNodeOperations(object):
                                 data=json.dumps(body))
 
     def node_state(self, node_id):
+        """
+        Get the state of the node.
+
+        :param  node_id: Id of the Node
+        :type   node_id: ``int``
+
+        :rtype: ``str``
+        """
+
         action = '1.2/server/{0}'.format(node_id)
         try:
             response = self.connection.request(action)
@@ -124,6 +183,12 @@ class UpcloudNodeOperations(object):
             raise
 
     def destroy_node(self, node_id):
+        """
+        Destroys the node.
+
+        :param  node_id: Id of the Node
+        :type   node_id: ``int``
+        """
         self.connection.request('1.2/server/{0}'.format(node_id),
                                 method='DELETE')