Best Python code snippet using robotframework-androidlibrary_python
Droplet.py
Source:Droplet.py  
...139        if self.networks['v6']:140            self.ip_v6_address = self.networks['v6'][0]['ip_address']141        return self142143    def _perform_action(self, params, return_dict=True):144        """145            Perform a droplet action.146147            Args:148                params - dict : parameters of the action149150            Optional Args:151                return_dict - bool : Return a dict when True (default),152                    otherwise return an Action.153154            Returns dict or Action155        """156        action = self.get_data(157            "droplets/%s/actions/" % self.id,158            type=POST,159            params=params160        )161        if return_dict:162            return action163        else:164            action = action[u'action']165            return_action = Action()166            # Loading attributes167            for attr in action.keys():168                setattr(return_action, attr, action[attr])169            return return_action170171    def power_on(self, return_dict=True):172        """173            Boot up the droplet174175            Optional Args:176                return_dict - bool : Return a dict when True (default),177                    otherwise return an Action.178179            Returns dict or Action180        """181        return self._perform_action({'type': 'power_on'}, return_dict)182183    def shutdown(self, return_dict=True):184        """185            shutdown the droplet186187            Optional Args:188                return_dict - bool : Return a dict when True (default),189                    otherwise return an Action.190191            Returns dict or Action192        """193        return self._perform_action({'type': 'shutdown'}, return_dict)194195    def reboot(self, return_dict=True):196        """197            restart the droplet198199            Optional Args:200                return_dict - bool : Return a dict when True (default),201                    otherwise return an Action.202203            Returns dict or Action204        """205        return self._perform_action({'type': 'reboot'}, return_dict)206207    def power_cycle(self, return_dict=True):208        """209            restart the droplet210211            Optional Args:212                return_dict - bool : Return a dict when True (default),213                    otherwise return an Action.214215            Returns dict or Action216        """217        return self._perform_action({'type': 'power_cycle'}, return_dict)218219    def power_off(self, return_dict=True):220        """221            restart the droplet222223            Optional Args:224                return_dict - bool : Return a dict when True (default),225                    otherwise return an Action.226227            Returns dict or Action228        """229        return self._perform_action({'type': 'power_off'}, return_dict)230231    def reset_root_password(self, return_dict=True):232        """233            reset the root password234235            Optional Args:236                return_dict - bool : Return a dict when True (default),237                    otherwise return an Action.238239            Returns dict or Action240        """241        return self._perform_action({'type': 'password_reset'}, return_dict)242243    def resize(self, new_size_slug, return_dict=True):244        """Resize the droplet to a new size slug.245246        Args:247            new_size_slug: str - name of new size248249        Optional Args:250            return_dict - bool : Return a dict when True (default),251                otherwise return an Action.252253        Returns dict or Action254        """255        return self._perform_action(256            {"type": "resize", "size": new_size_slug},257            return_dict258        )259260    def take_snapshot(self, snapshot_name, return_dict=True):261        """Take a snapshot!262263        Args:264            snapshot_name: str - name of snapshot265266        Optional Args:267            return_dict - bool : Return a dict when True (default),268                otherwise return an Action.269270        Returns dict or Action271        """272        return self._perform_action(273            {"type": "snapshot", "name": snapshot_name},274            return_dict275        )276277    def restore(self, image_id, return_dict=True):278        """Restore the droplet to an image ( snapshot or backup )279280        Args:281            image_id : int - id of image282283        Optional Args:284            return_dict - bool : Return a dict when True (default),285                otherwise return an Action.286287        Returns dict or Action288        """289        return self._perform_action(290            {"type": "restore", "image": image_id},291            return_dict292        )293294    def rebuild(self, image_id=None, return_dict=True):295        """Restore the droplet to an image ( snapshot or backup )296297        Args:298            image_id : int - id of image299300        Optional Args:301            return_dict - bool : Return a dict when True (default),302                otherwise return an Action.303304        Returns dict or Action305        """306        if not image_id:307            image_id = self.image['id']308309        return self._perform_action(310            {"type": "rebuild", "image": image_id},311            return_dict312        )313314    def enable_backups(self):315        """316            Enable automatic backups (Not yet implemented in APIv2)317        """318        print("Not yet implemented in APIv2")319320    def disable_backups(self, return_dict=True):321        """322            Disable automatic backups323324            Optional Args:325                return_dict - bool : Return a dict when True (default),326                    otherwise return an Action.327328            Returns dict or Action329        """330        return self._perform_action({'type': 'disable_backups'}, return_dict)331332    def destroy(self):333        """334            Destroy the droplet335336            Optional Args:337                return_dict - bool : Return a dict when True (default),338                    otherwise return an Action.339340            Returns dict or Action341        """342        return self.get_data("droplets/%s" % self.id, type=DELETE)343344    def rename(self, name, return_dict=True):345        """Rename the droplet346347        Args:348            name : str - new name349350        Optional Args:351            return_dict - bool : Return a dict when True (default),352                otherwise return an Action.353354        Returns dict or Action355        """356        return self._perform_action(357            {'type': 'rename', 'name': name},358            return_dict359        )360361    def enable_private_networking(self, return_dict=True):362        """363           Enable private networking on an existing Droplet where available.364365           Optional Args:366               return_dict - bool : Return a dict when True (default),367                   otherwise return an Action.368369           Returns dict or Action370        """371        return self._perform_action({'type': 'enable_private_networking'}, return_dict)372373    def enable_ipv6(self, return_dict=True):374        """375            Enable IPv6 on an existing Droplet where available.376377            Optional Args:378                return_dict - bool : Return a dict when True (default),379                    otherwise return an Action.380381            Returns dict or Action382        """383        return self._perform_action({'type': 'enable_ipv6'}, return_dict)384385    def change_kernel(self, kernel, return_dict=True):386        """Change the kernel to a new one387388        Args:389            kernel : instance of digitalocean.Kernel.Kernel390391        Optional Args:392            return_dict - bool : Return a dict when True (default),393                otherwise return an Action.394395        Returns dict or Action396        """397        if type(kernel) != Kernel:398            raise BadKernelObject("Use Kernel object")399400        return self._perform_action(401            {'type': 'change_kernel', 'kernel': kernel.id},402            return_dict403        )404405    def __get_ssh_keys_id_or_fingerprint(self):406        """407            Check and return a list of SSH key IDs or fingerprints according408            to DigitalOcean's API. This method is used to check and create a409            droplet with the correct SSH keys.410        """411        ssh_keys_id = list()412        for ssh_key in self.ssh_keys:413            if type(ssh_key) in [int, type(2**64)]:414                ssh_keys_id.append(int(ssh_key))
...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
