<commit_before># Python API Wrapper for cloudatcost.com

import requests

BASE_URL = "https://panel.cloudatcost.com/api/"
API_VERSION = "v1"

LIST_SERVERS_URL = "/listservers.php"
LIST_TEMPLATES_URL = "/listtemplates.php"
LIST_TASKS_URL = "/listtasks.php"
POWER_OPERATIONS_URL = "/powerop.php"
CONSOLE_URL = "/console.php"


class CACPy:
    """Base class for making requests to the cloud at cost API."""

    def __init__(self, email, api_key):
        """Return a CACPy object.

        Required Arguments:
        email - The email address used to authenticate to the API.
        api_key - The key generated in the CAC panel to access the API.
        """
        self.email = email
        self.api_key = api_key

    def _make_request(self, endpoint, options=dict(), type="GET"):
        data = {
            'key': self.api_key,
            'login': self.email
        }

        # Add any passed in options to the data dictionary to be included
        # in the web request.
        for key in options:
            data[key] = options[key]

        url = BASE_URL + API_VERSION + endpoint

        ret = None
        if type == "GET":
            ret = requests.get(url, params=data)
        elif type == "POST":
            ret = requests.post(url, data=data)
        else:
            raise Exception("InvalidRequestType: " + str(type))

        return ret.json()

    def _commit_power_operation(self, server_id, operation):
        options = {
            'sid': server_id,
            'action': operation
        }
        return self._make_request(POWER_OPERATIONS_URL,
                                  options=options,
                                  type="POST")

    def get_server_info(self):
        """Return an array of dictionaries containing server details.

        The dictionaries will contain keys consistent with the 'data'
        portion of the JSON as documented here:
        https://github.com/cloudatcost/api#list-servers
        """
        jdata = self._make_request(LIST_SERVERS_URL)
        return jdata['data']

    def get_template_info(self):
        """Return an array of dictionaries containing template information.

        The dictionaries will contain keys consistent with the 'data'
        portion of the JSON as documented here:
        https://github.com/cloudatcost/api#list-templates
        """
        jdata = self._make_request(LIST_TEMPLATES_URL)
        return jdata['data']

    def get_task_info(self):
        """Return an array of dictionaries containing task information.

        The dictionaries will contain keys consistent with the 'data'
        portion of the JSON as documented here:
        https://github.com/cloudatcost/api#list-tasks
        """
        jdata = self._make_request(LIST_TASKS_URL)
        return jdata['data']

    def power_on_server(self, server_id):<commit_msg>Return full json payload for get_*_info() calls<commit_after># Python API Wrapper for cloudatcost.com

import requests

BASE_URL = "https://panel.cloudatcost.com/api/"
API_VERSION = "v1"

LIST_SERVERS_URL = "/listservers.php"
LIST_TEMPLATES_URL = "/listtemplates.php"
LIST_TASKS_URL = "/listtasks.php"
POWER_OPERATIONS_URL = "/powerop.php"
CONSOLE_URL = "/console.php"


class CACPy:
    """Base class for making requests to the cloud at cost API."""

    def __init__(self, email, api_key):
        """Return a CACPy object.

        Required Arguments:
        email - The email address used to authenticate to the API.
        api_key - The key generated in the CAC panel to access the API.
        """
        self.email = email
        self.api_key = api_key

    def _make_request(self, endpoint, options=dict(), type="GET"):
        data = {
            'key': self.api_key,
            'login': self.email
        }

        # Add any passed in options to the data dictionary to be included
        # in the web request.
        for key in options:
            data[key] = options[key]

        url = BASE_URL + API_VERSION + endpoint

        ret = None
        if type == "GET":
            ret = requests.get(url, params=data)
        elif type == "POST":
            ret = requests.post(url, data=data)
        else:
            raise Exception("InvalidRequestType: " + str(type))

        return ret.json()

    def _commit_power_operation(self, server_id, operation):
        options = {
            'sid': server_id,
            'action': operation
        }
        return self._make_request(POWER_OPERATIONS_URL,
                                  options=options,
                                  type="POST")

    def get_server_info(self):
        """Return an array of dictionaries containing server details.

        The dictionaries will contain keys consistent with the 'data'
        portion of the JSON as documented here:
        https://github.com/cloudatcost/api#list-servers
        """
        return self._make_request(LIST_SERVERS_URL)

    def get_template_info(self):
        """Return an array of dictionaries containing template information.

        The dictionaries will contain keys consistent with the 'data'
        portion of the JSON as documented here:
        https://github.com/cloudatcost/api#list-templates
        """
        return self._make_request(LIST_TEMPLATES_URL)

    def get_task_info(self):
        """Return an array of dictionaries containing task information.

        The dictionaries will contain keys consistent with the 'data'
        portion of the JSON as documented here:
        https://github.com/cloudatcost/api#list-tasks
        """
        return self._make_request(LIST_TASKS_URL)

    def power_on_server(self, server_id):
{'fraction_non_alphanumeric': 0.08907741251325557, 'fraction_numerical': 0.0003534817956875221, 'mean_word_length': 2.2635524798154556, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5165789', 'n_tokens_mistral': 1591, 'n_tokens_neox': 1536, 'n_words': 471}