text_prompt
stringlengths
157
13.1k
code_prompt
stringlengths
7
19.8k
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_ip_address_from_rackspace_server(server_id): """ returns an ipaddress for a rackspace instance """
nova = connect_to_rackspace() server = nova.servers.get(server_id) # the server was assigned IPv4 and IPv6 addresses, locate the IPv4 address ip_address = None for network in server.networks['public']: if re.match('\d+\.\d+\.\d+\.\d+', network): ip_address = network ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def install_oracle_java(distribution, java_version): """ installs oracle java """
if 'ubuntu' in distribution: accept_oracle_license = ('echo ' 'oracle-java' + java_version + 'installer ' 'shared/accepted-oracle-license-v1-1 ' 'select true | ' '/usr/bin/deb...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def insert_line_in_file_after_regex(path, line, after_regex, use_sudo=False): """ inserts a line in the middle of a file """
tmpfile = str(uuid.uuid4()) get_file(path, tmpfile, use_sudo=use_sudo) with open(tmpfile) as f: original = f.read() if line not in original: outfile = str(uuid.uuid4()) with open(outfile, 'w') as output: for l in original.split('\n'): output.write(l...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def is_vagrant_plugin_installed(plugin, use_sudo=False): """ checks if vagrant plugin is installed """
cmd = 'vagrant plugin list' if use_sudo: results = sudo(cmd) else: results = run(cmd) installed_plugins = [] for line in results: plugin = re.search('^(\S.*) \((.*)\)$', line) installed_plugins.append({'name': plugin.group(0), 've...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def is_deb_package_installed(pkg): """ checks if a particular deb package is installed """
with settings(hide('warnings', 'running', 'stdout', 'stderr'), warn_only=True, capture=True): result = sudo('dpkg-query -l "%s" | grep -q ^.i' % pkg) return not bool(result.return_code)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def is_ssh_available(host, port=22): """ checks if ssh port is open """
s = socket.socket() try: s.connect((host, port)) return True except: return False
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def load_state_from_disk(): """ loads the state from a local data.json file """
if is_there_state(): with open('data.json', 'r') as f: data = json.load(f) return data else: return False
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def print_ec2_info(region, instance_id, access_key_id, secret_access_key, username): """ outputs information about our EC2 instance """
data = get_ec2_info(instance_id=instance_id, region=region, access_key_id=access_key_id, secret_access_key=secret_access_key, username=username) log_green("region: %s" % data['region']) log_green("Instance_type...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def rsync(): """ syncs the src code to the remote box """
log_green('syncing code to remote box...') data = load_state_from_disk() if 'SOURCE_PATH' in os.environ: with lcd(os.environ['SOURCE_PATH']): local("rsync -a " "--info=progress2 " "--exclude .git " "--exclude .tox " ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def save_ec2_state_locally(instance_id, region, username, access_key_id, secret_access_key): """ queries EC2 for details about a particular instance_id and store...
# retrieve the IP information from the instance data = get_ec2_info(instance_id, region, access_key_id, secret_access_key, username) return _save_state_locally(data)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def ssh_session(key_filename, username, ip_address, *cli): """ opens a ssh shell to the host """
local('ssh -t -i %s %s@%s %s' % (key_filename, username, ip_address, "".join(chain.from_iterable(cli))))
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def wait_for_ssh(host, port=22, timeout=600): """ probes the ssh port and waits until it is available """
log_yellow('waiting for ssh...') for iteration in xrange(1, timeout): #noqa sleep(1) if is_ssh_available(host, port): return True else: log_yellow('waiting for ssh...')
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def goToDirectory(alias): """go to a saved directory"""
if not settings.platformCompatible(): return False data = pickle.load(open(settings.getDataFile(), "rb")) try: data[alias] except KeyError: speech.fail("Sorry, it doesn't look like you have saved " + alias + " yet.") speech.fail("Go to the directory you'd like to save and type 'hallie save as " + alias + "...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def list(self, filters=None): """List model instances. Currently this gets *everything* and iterates through all possible pages in the API. This may be unsuitabl...
# Add in the page and page_size parameters to the filter, such # that our request gets *all* objects in the list. However, # don't do this if the user has explicitly included these # parameters in the filter. if not filters: filters = {} if "page" not in fil...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get(self, id): """Get the model instance with a given id. Args: id (int or str): The primary identifier (e.g., pk or UUID) for the task instance to get. Ret...
# Get the object request_url = self._client.base_api_url + self.detail_url.format(id=id) response = self._client.session.get(request_url) # Validate that the request was successful self.validate_request_success( response_text=response.text, request_url=...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def validate_request_success( response_text, request_url, status_code, expected_status_code ): """Validates that a request was successful. Args: response_text (s...
try: assert status_code == expected_status_code except AssertionError: msg = ( "Request to {url} failed with status {status_code}:\n" "The reponse from the request was as follows:\n\n" "{content}" ).format( ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create(self, task_type_id, task_queue_id, arguments=None, name=""): """Create a task instance. Args: task_type_id (int): The ID of the task type to base the...
# Make arguments an empty dictionary if None if arguments is None: arguments = {} # Create the object request_url = self._client.base_api_url + self.list_url data_to_post = { "name": name, "arguments": json.dumps(arguments), "task...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def clone(self, uuid): """Clone the task instance with given UUID. Args: uuid (str): The UUID of the task instance to clone. Returns: :class:`saltant.models.bas...
# Clone the object request_url = self._client.base_api_url + self.clone_url.format( id=uuid ) response = self._client.session.post(request_url) # Validate that the request was successful self.validate_request_success( response_text=response.text...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def terminate(self, uuid): """Terminate the task instance with given UUID. Args: uuid (str): The UUID of the task instance to terminate. Returns: :class:`saltan...
# Clone the object request_url = self._client.base_api_url + self.terminate_url.format( id=uuid ) response = self._client.session.post(request_url) # Validate that the request was successful self.validate_request_success( response_text=response....
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def response_data_to_model_instance(self, response_data): """Convert response data to a task instance model. Args: response_data (dict): The data from the reque...
# Coerce datetime strings into datetime objects response_data["datetime_created"] = dateutil.parser.parse( response_data["datetime_created"] ) if response_data["datetime_finished"]: response_data["datetime_finished"] = dateutil.parser.parse( resp...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _ids_and_column_names(names, force_lower_case=False): """Ensure all column names are unique identifiers."""
fixed = OrderedDict() for name in names: identifier = RowWrapper._make_identifier(name) if force_lower_case: identifier = identifier.lower() while identifier in fixed: identifier = RowWrapper._increment_numeric_suffix(identifier) ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def wrap(self, row: Union[Mapping[str, Any], Sequence[Any]]): """Return row tuple for row."""
return ( self.dataclass( **{ ident: row[column_name] for ident, column_name in self.ids_and_column_names.items() } ) if isinstance(row, Mapping) else self.dataclass( **{ident:...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def wrap_all(self, rows: Iterable[Union[Mapping[str, Any], Sequence[Any]]]): """Return row tuple for each row in rows."""
return (self.wrap(r) for r in rows)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def add_error_handlers(app): """Add custom error handlers for PyMacaronCoreExceptions to the app"""
def handle_validation_error(error): response = jsonify({'message': str(error)}) response.status_code = error.status_code return response app.errorhandler(ValidationError)(handle_validation_error)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def list_backends(self, service_id, version_number): """List all backends for a particular service and version."""
content = self._fetch("/service/%s/version/%d/backend" % (service_id, version_number)) return map(lambda x: FastlyBackend(self, x), content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_backend(self, service_id, version_number, name, address, use_ssl=False, port=80, connect_timeout=1000, first_byte_timeout=15000, betw...
body = self._formdata({ "name": name, "address": address, "use_ssl": use_ssl, "port": port, "connect_timeout": connect_timeout, "first_byte_timeout": first_byte_timeout, "between_bytes_timeout": between_bytes_timeout, "error_threshold": error_threshold, "max_conn": max_conn, "weight": w...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_backend(self, service_id, version_number, name): """Get the backend for a particular service and version."""
content = self._fetch("/service/%s/version/%d/backend/%s" % (service_id, version_number, name)) return FastlyBackend(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_backend(self, service_id, version_number, name_key, **kwargs): """Update the backend for a particular service and version."""
body = self._formdata(kwargs, FastlyBackend.FIELDS) content = self._fetch("/service/%s/version/%d/backend/%s" % (service_id, version_number, name_key), method="PUT", body=body) return FastlyBackend(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def list_cache_settings(self, service_id, version_number): """Get a list of all cache settings for a particular service and version."""
content = self._fetch("/service/%s/version/%d/cache_settings" % (service_id, version_number)) return map(lambda x: FastlyCacheSettings(self, x), content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_cache_settings(self, service_id, version_number, name, action, ttl=None, stale_ttl=None, cache_condition=None): """Create a new cache ...
body = self._formdata({ "name": name, "action": action, "ttl": ttl, "stale_ttl": stale_ttl, "cache_condition": cache_condition, }, FastlyCacheSettings.FIELDS) content = self._fetch("/service/%s/version/%d/cache_settings" % (service_id, version_number), method="POST", body=body) return FastlyCach...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_cache_settings(self, service_id, version_number, name): """Get a specific cache settings object."""
content = self._fetch("/service/%s/version/%d/cache_settings/%s" % (service_id, version_number, name)) return FastlyCacheSettings(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_cache_settings(self, service_id, version_number, name_key, **kwargs): """Update a specific cache settings object."""
body = self._formdata(kwargs, FastlyCacheSettings.FIELDS) content = self._fetch("/service/%s/version/%d/cache_settings/%s" % (service_id, version_number, name_key), method="PUT", body=body) return FastlyCacheSettings(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def delete_cache_settings(self, service_id, version_number, name): """Delete a specific cache settings object."""
content = self._fetch("/service/%s/version/%d/cache_settings/%s" % (service_id, version_number, name), method="DELETE") return self._status(content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def list_conditions(self, service_id, version_number): """Gets all conditions for a particular service and version."""
content = self._fetch("/service/%s/version/%d/condition" % (service_id, version_number)) return map(lambda x: FastlyCondition(self, x), content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_condition(self, service_id, version_number, name, _type, statement, priority="10", comment=None): """Creates a new condition."""
body = self._formdata({ "name": name, "type": _type, "statement": statement, "priority": priority, "comment": comment, }, FastlyCondition.FIELDS) content = self._fetch("/service/%s/version/%d/condition" % (service_id, version_number), method="POST", body=body) return FastlyCondition(self, conten...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_condition(self, service_id, version_number, name): """Gets a specified condition."""
content = self._fetch("/service/%s/version/%d/condition/%s" % (service_id, version_number, name)) return FastlyCondition(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_condition(self, service_id, version_number, name_key, **kwargs): """Updates the specified condition."""
body = self._formdata(kwargs, FastlyCondition.FIELDS) content = self._fetch("/service/%s/version/%d/condition/%s" % (service_id, version_number, name_key), method="PUT", body=body) return FastlyCondition(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def content_edge_check(self, url): """Retrieve headers and MD5 hash of the content for a particular url from each Fastly edge server."""
prefixes = ["http://", "https://"] for prefix in prefixes: if url.startswith(prefix): url = url[len(prefix):] break content = self._fetch("/content/edge_check/%s" % url) return content
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_customer(self, customer_id): """Get a specific customer."""
content = self._fetch("/customer/%s" % customer_id) return FastlyCustomer(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def list_customer_users(self, customer_id): """List all users from a specified customer id."""
content = self._fetch("/customer/users/%s" % customer_id) return map(lambda x: FastlyUser(self, x), content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_customer(self, customer_id, **kwargs): """Update a customer."""
body = self._formdata(kwargs, FastlyCustomer.FIELDS) content = self._fetch("/customer/%s" % customer_id, method="PUT", body=body) return FastlyCustomer(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def list_directors(self, service_id, version_number): """List the directors for a particular service and version."""
content = self._fetch("/service/%s/version/%d/director" % (service_id, version_number)) return map(lambda x: FastlyDirector(self, x), content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_director(self, service_id, version_number, name, quorum=75, _type=FastlyDirectorType.RANDOM, retries=5, shield=None): """Create a director...
body = self._formdata({ "name": name, "quorum": quorum, "type": _type, "retries": retries, "shield": shield, }, FastlyDirector.FIELDS) content = self._fetch("/service/%s/version/%d/director" % (service_id, version_number), method="POST", body=body) return FastlyDirector(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_director(self, service_id, version_number, name): """Get the director for a particular service and version."""
content = self._fetch("/service/%s/version/%d/director/%s" % (service_id, version_number, name)) return FastlyDirector(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_director(self, service_id, version_number, name_key, **kwargs): """Update the director for a particular service and version."""
body = self._formdata(kwargs, FastlyDirector.FIELDS) content = self._fetch("/service/%s/version/%d/director/%s" % (service_id, version_number, name_key), method="PUT", body=body) return FastlyDirector(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_director_backend(self, service_id, version_number, director_name, backend_name): """Returns the relationship between a Backend and a Director. If the B...
content = self._fetch("/service/%s/version/%d/director/%s/backend/%s" % (service_id, version_number, director_name, backend_name), method="GET") return FastlyDirectorBackend(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def delete_director_backend(self, service_id, version_number, director_name, backend_name): """Deletes the relationship between a Backend and a Director. The B...
content = self._fetch("/service/%s/version/%d/director/%s/backend/%s" % (service_id, version_number, director_name, backend_name), method="DELETE") return self._status(content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def list_domains(self, service_id, version_number): """List the domains for a particular service and version."""
content = self._fetch("/service/%s/version/%d/domain" % (service_id, version_number)) return map(lambda x: FastlyDomain(self, x), content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_domain(self, service_id, version_number, name, comment=None): """Create a domain for a particular service and version."""
body = self._formdata({ "name": name, "comment": comment, }, FastlyDomain.FIELDS) content = self._fetch("/service/%s/version/%d/domain" % (service_id, version_number), method="POST", body=body) return FastlyDomain(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_domain(self, service_id, version_number, name): """Get the domain for a particular service and version."""
content = self._fetch("/service/%s/version/%d/domain/%s" % (service_id, version_number, name)) return FastlyDomain(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_domain(self, service_id, version_number, name_key, **kwargs): """Update the domain for a particular service and version."""
body = self._formdata(kwargs, FastlyDomain.FIELDS) content = self._fetch("/service/%s/version/%d/domain/%s" % (service_id, version_number, name_key), method="PUT", body=body) return FastlyDomain(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def check_domain(self, service_id, version_number, name): """Checks the status of a domain's DNS record. Returns an array of 3 items. The first is the details ...
content = self._fetch("/service/%s/version/%d/domain/%s/check" % (service_id, version_number, name)) return FastlyDomainCheck(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_event_log(self, object_id): """Get the specified event log."""
content = self._fetch("/event_log/%s" % object_id, method="GET") return FastlyEventLog(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def list_headers(self, service_id, version_number): """Retrieves all Header objects for a particular Version of a Service."""
content = self._fetch("/service/%s/version/%d/header" % (service_id, version_number)) return map(lambda x: FastlyHeader(self, x), content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_header(self, service_id, version_number, name, destination, source, _type=FastlyHeaderType.RESPONSE, action=FastlyHeaderAction.SET, regex=None, substit...
content = self._fetch("/service/%s/version/%d/header" % (service_id, version_number), method="POST", body=body) return FastlyHeader(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_header(self, service_id, version_number, name): """Retrieves a Header object by name."""
content = self._fetch("/service/%s/version/%d/header/%s" % (service_id, version_number, name)) return FastlyHeader(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_header(self, service_id, version_number, name_key, **kwargs): """Modifies an existing Header object by name."""
body = self._formdata(kwargs, FastlyHeader.FIELDS) content = self._fetch("/service/%s/version/%d/header/%s" % (service_id, version_number, name_key), method="PUT", body=body) return FastlyHeader(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def list_healthchecks(self, service_id, version_number): """List all of the healthchecks for a particular service and version."""
content = self._fetch("/service/%s/version/%d/healthcheck" % (service_id, version_number)) return map(lambda x: FastlyHealthCheck(self, x), content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_healthcheck(self, service_id, version_number, name, host, method="HEAD", path="/", http_version="1.1", timeout=1000, check_interval=5...
body = self._formdata({ "name": name, "method": method, "host": host, "path": path, "http_version": http_version, "timeout": timeout, "check_interval": check_interval, "expected_response": expected_response, "window": window, "threshold": threshold, "initial": initial, }, FastlyHea...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_healthcheck(self, service_id, version_number, name): """Get the healthcheck for a particular service and version."""
content = self._fetch("/service/%s/version/%d/healthcheck/%s" % (service_id, version_number, name)) return FastlyHealthCheck(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def purge_url(self, host, path): """Purge an individual URL."""
content = self._fetch(path, method="PURGE", headers={ "Host": host }) return FastlyPurge(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def check_purge_status(self, purge_id): """Get the status and times of a recently completed purge."""
content = self._fetch("/purge?id=%s" % purge_id) return map(lambda x: FastlyPurgeStatus(self, x), content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def list_request_settings(self, service_id, version_number): """Returns a list of all Request Settings objects for the given service and version."""
content = self._fetch("/service/%s/version/%d/request_settings" % (service_id, version_number)) return map(lambda x: FastlyRequestSetting(self, x), content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_request_setting(self, service_id, version_number, name, default_host=None, force_miss=None, force_ssl=None, action=None, bypass_busy_wa...
body = self._formdata({ "name": name, "default_host": default_host, "force_miss": force_miss, "force_ssl": force_ssl, "action": action, "bypass_busy_wait": bypass_busy_wait, "max_stale_age": max_stale_age, "hash_keys": hash_keys, "xff": xff, "timer_support": timer_support, "geo_heade...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_request_setting(self, service_id, version_number, name): """Gets the specified Request Settings object."""
content = self._fetch("/service/%s/version/%d/request_settings/%s" % (service_id, version_number, name)) return FastlyRequestSetting(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_request_setting(self, service_id, version_number, name_key, **kwargs): """Updates the specified Request Settings object."""
body = self._formdata(kwargs, FastlyHealthCheck.FIELDS) content = self._fetch("/service/%s/version/%d/request_settings/%s" % (service_id, version_number, name_key), method="PUT", body=body) return FastlyRequestSetting(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def list_response_objects(self, service_id, version_number): """Returns all Response Objects for the specified service and version."""
content = self._fetch("/service/%s/version/%d/response_object" % (service_id, version_number)) return map(lambda x: FastlyResponseObject(self, x), content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_response_object(self, service_id, version_number, name, status="200", response="OK", content="", request_condition=None, cache_condition=None): """C...
body = self._formdata({ "name": name, "status": status, "response": response, "content": content, "request_condition": request_condition, "cache_condition": cache_condition, }, FastlyResponseObject.FIELDS) content = self._fetch("/service/%s/version/%d/response_object" % (service_id, version_num...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_response_object(self, service_id, version_number, name): """Gets the specified Response Object."""
content = self._fetch("/service/%s/version/%d/response_object/%s" % (service_id, version_number, name)) return FastlyResponseObject(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_response_object(self, service_id, version_number, name_key, **kwargs): """Updates the specified Response Object."""
body = self._formdata(kwargs, FastlyResponseObject.FIELDS) content = self._fetch("/service/%s/version/%d/response_object/%s" % (service_id, version_number, name_key), method="PUT", body=body) return FastlyResponseObject(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def list_services(self): """List Services."""
content = self._fetch("/service") return map(lambda x: FastlyService(self, x), content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_service(self, service_id): """Get a specific service by id."""
content = self._fetch("/service/%s" % service_id) return FastlyService(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_service_details(self, service_id): """List detailed information on a specified service."""
content = self._fetch("/service/%s/details" % service_id) return FastlyService(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_service_by_name(self, service_name): """Get a specific service by name."""
content = self._fetch("/service/search?name=%s" % service_name) return FastlyService(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def delete_service(self, service_id): """Delete a service."""
content = self._fetch("/service/%s" % service_id, method="DELETE") return self._status(content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def list_domains_by_service(self, service_id): """List the domains within a service."""
content = self._fetch("/service/%s/domain" % service_id, method="GET") return map(lambda x: FastlyDomain(self, x), content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def purge_service(self, service_id): """Purge everything from a service."""
content = self._fetch("/service/%s/purge_all" % service_id, method="POST") return self._status(content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def purge_service_by_key(self, service_id, key): """Purge a particular service by a key."""
content = self._fetch("/service/%s/purge/%s" % (service_id, key), method="POST") return self._status(content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_settings(self, service_id, version_number): """Get the settings for a particular service and version."""
content = self._fetch("/service/%s/version/%d/settings" % (service_id, version_number)) return FastlySettings(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_settings(self, service_id, version_number, settings={}): """Update the settings for a particular service and version."""
body = urllib.urlencode(settings) content = self._fetch("/service/%s/version/%d/settings" % (service_id, version_number), method="PUT", body=body) return FastlySettings(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_stats(self, service_id, stat_type=FastlyStatsType.ALL): """Get the stats from a service."""
content = self._fetch("/service/%s/stats/%s" % (service_id, stat_type)) return content
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def list_syslogs(self, service_id, version_number): """List all of the Syslogs for a particular service and version."""
content = self._fetch("/service/%s/version/%d/syslog" % (service_id, version_number)) return map(lambda x: FastlySyslog(self, x), content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_syslog(self, service_id, version_number, name, address, port=514, use_tls="0", tls_ca_cert=None, token=None, _format=None, response...
body = self._formdata({ "name": name, "address": address, "port": port, "use_tls": use_tls, "tls_ca_cert": tls_ca_cert, "token": token, "format": _format, "response_condition": response_condition, }, FastlySyslog.FIELDS) content = self._fetch("/service/%s/version/%d/syslog" % (service_id,...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_syslog(self, service_id, version_number, name): """Get the Syslog for a particular service and version."""
content = self._fetch("/service/%s/version/%d/syslog/%s" % (service_id, version_number, name)) return FastlySyslog(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_syslog(self, service_id, version_number, name_key, **kwargs): """Update the Syslog for a particular service and version."""
body = self._formdata(kwargs, FastlySyslog.FIELDS) content = self._fetch("/service/%s/version/%d/syslog/%s" % (service_id, version_number, name_key), method="PUT", body=body) return FastlySyslog(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def change_password(self, old_password, new_password): """Update the user's password to a new one."""
body = self._formdata({ "old_password": old_password, "password": new_password, }, ["old_password", "password"]) content = self._fetch("/current_user/password", method="POST", body=body) return FastlyUser(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_user(self, user_id): """Get a specific user."""
content = self._fetch("/user/%s" % user_id) return FastlyUser(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def request_password_reset(self, user_id): """Requests a password reset for the specified user."""
content = self._fetch("/user/%s/password/request_reset" % (user_id), method="POST") return FastlyUser(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def list_vcls(self, service_id, version_number): """List the uploaded VCLs for a particular service and version."""
content = self._fetch("/service/%s/version/%d/vcl" % (service_id, version_number)) return map(lambda x: FastlyVCL(self, x), content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def upload_vcl(self, service_id, version_number, name, content, main=None, comment=None): """Upload a VCL for a particular service and version."""
body = self._formdata({ "name": name, "content": content, "comment": comment, "main": main, }, FastlyVCL.FIELDS) content = self._fetch("/service/%s/version/%d/vcl" % (service_id, version_number), method="POST", body=body) return FastlyVCL(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_vcl(self, service_id, version_number, name, include_content=True): """Get the uploaded VCL for a particular service and version."""
content = self._fetch("/service/%s/version/%d/vcl/%s?include_content=%d" % (service_id, version_number, name, int(include_content))) return FastlyVCL(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_vcl_html(self, service_id, version_number, name): """Get the uploaded VCL for a particular service and version with HTML syntax highlighting."""
content = self._fetch("/service/%s/version/%d/vcl/%s/content" % (service_id, version_number, name)) return content.get("content", None)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_generated_vcl(self, service_id, version_number): """Display the generated VCL for a particular service and version."""
content = self._fetch("/service/%s/version/%d/generated_vcl" % (service_id, version_number)) return FastlyVCL(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_generated_vcl_html(self, service_id, version_number): """Display the content of generated VCL with HTML syntax highlighting."""
content = self._fetch("/service/%s/version/%d/generated_vcl/content" % (service_id, version_number)) return content.get("content", None)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set_main_vcl(self, service_id, version_number, name): """Set the specified VCL as the main."""
content = self._fetch("/service/%s/version/%d/vcl/%s/main" % (service_id, version_number, name), method="PUT") return FastlyVCL(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_vcl(self, service_id, version_number, name_key, **kwargs): """Update the uploaded VCL for a particular service and version."""
body = self._formdata(kwargs, FastlyVCL.FIELDS) content = self._fetch("/service/%s/version/%d/vcl/%s" % (service_id, version_number, name_key), method="PUT", body=body) return FastlyVCL(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_version(self, service_id, inherit_service_id=None, comment=None): """Create a version for a particular service."""
body = self._formdata({ "service_id": service_id, "inherit_service_id": inherit_service_id, "comment": comment, }, FastlyVersion.FIELDS) content = self._fetch("/service/%s/version" % service_id, method="POST", body=body) return FastlyVersion(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_version(self, service_id, version_number): """Get the version for a particular service."""
content = self._fetch("/service/%s/version/%d" % (service_id, version_number)) return FastlyVersion(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_version(self, service_id, version_number, **kwargs): """Update a particular version for a particular service."""
body = self._formdata(kwargs, FastlyVersion.FIELDS) content = self._fetch("/service/%s/version/%d/" % (service_id, version_number), method="PUT", body=body) return FastlyVersion(self, content)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def clone_version(self, service_id, version_number): """Clone the current configuration into a new version."""
content = self._fetch("/service/%s/version/%d/clone" % (service_id, version_number), method="PUT") return FastlyVersion(self, content)