repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
mikemelch/hallie
hallie/modules/user.py
saveDirectory
def saveDirectory(alias): """save a directory to a certain alias/nickname""" if not settings.platformCompatible(): return False dataFile = open(settings.getDataFile(), "wb") currentDirectory = os.path.abspath(".") directory = {alias : currentDirectory} pickle.dump(directory, dataFile) speech.success(alias + " will now link to " + currentDirectory + ".") speech.success("Tip: use 'hallie go to " + alias + "' to change to this directory.")
python
def saveDirectory(alias): """save a directory to a certain alias/nickname""" if not settings.platformCompatible(): return False dataFile = open(settings.getDataFile(), "wb") currentDirectory = os.path.abspath(".") directory = {alias : currentDirectory} pickle.dump(directory, dataFile) speech.success(alias + " will now link to " + currentDirectory + ".") speech.success("Tip: use 'hallie go to " + alias + "' to change to this directory.")
[ "def", "saveDirectory", "(", "alias", ")", ":", "if", "not", "settings", ".", "platformCompatible", "(", ")", ":", "return", "False", "dataFile", "=", "open", "(", "settings", ".", "getDataFile", "(", ")", ",", "\"wb\"", ")", "currentDirectory", "=", "os", ".", "path", ".", "abspath", "(", "\".\"", ")", "directory", "=", "{", "alias", ":", "currentDirectory", "}", "pickle", ".", "dump", "(", "directory", ",", "dataFile", ")", "speech", ".", "success", "(", "alias", "+", "\" will now link to \"", "+", "currentDirectory", "+", "\".\"", ")", "speech", ".", "success", "(", "\"Tip: use 'hallie go to \"", "+", "alias", "+", "\"' to change to this directory.\"", ")" ]
save a directory to a certain alias/nickname
[ "save", "a", "directory", "to", "a", "certain", "alias", "/", "nickname" ]
train
https://github.com/mikemelch/hallie/blob/a6dbb691145a85b776a1919e4c7930e0ae598437/hallie/modules/user.py#L26-L35
mikemelch/hallie
hallie/modules/user.py
goToDirectory
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 + "\'") return try: (output, error) = subprocess.Popen(["osascript", "-e", CHANGE_DIR % (data[alias])], stdout=subprocess.PIPE).communicate() except: speech.fail("Something seems to have gone wrong. Please report this error to michaelmelchione@gmail.com.") return speech.success("Successfully navigating to " + data[alias])
python
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 + "\'") return try: (output, error) = subprocess.Popen(["osascript", "-e", CHANGE_DIR % (data[alias])], stdout=subprocess.PIPE).communicate() except: speech.fail("Something seems to have gone wrong. Please report this error to michaelmelchione@gmail.com.") return speech.success("Successfully navigating to " + data[alias])
[ "def", "goToDirectory", "(", "alias", ")", ":", "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", "+", "\"\\'\"", ")", "return", "try", ":", "(", "output", ",", "error", ")", "=", "subprocess", ".", "Popen", "(", "[", "\"osascript\"", ",", "\"-e\"", ",", "CHANGE_DIR", "%", "(", "data", "[", "alias", "]", ")", "]", ",", "stdout", "=", "subprocess", ".", "PIPE", ")", ".", "communicate", "(", ")", "except", ":", "speech", ".", "fail", "(", "\"Something seems to have gone wrong. Please report this error to michaelmelchione@gmail.com.\"", ")", "return", "speech", ".", "success", "(", "\"Successfully navigating to \"", "+", "data", "[", "alias", "]", ")" ]
go to a saved directory
[ "go", "to", "a", "saved", "directory" ]
train
https://github.com/mikemelch/hallie/blob/a6dbb691145a85b776a1919e4c7930e0ae598437/hallie/modules/user.py#L37-L53
saltant-org/saltant-py
saltant/models/resource.py
ModelManager.list
def list(self, filters=None): """List model instances. Currently this gets *everything* and iterates through all possible pages in the API. This may be unsuitable for production environments with huge databases, so finer grained page support should likely be added at some point. Args: filters (dict, optional): API query filters to apply to the request. For example: .. code-block:: python {'name__startswith': 'azure', 'user__in': [1, 2, 3, 4],} See saltant's API reference at https://saltant-org.github.io/saltant/ for each model's available filters. Returns: list: A list of :class:`saltant.models.resource.Model` subclass instances (for example, container task type model instances). """ # 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 filters: filters["page"] = 1 if "page_size" not in filters: # The below "magic number" is 2^63 - 1, which is the largest # number you can hold in a 64 bit integer. The main point # here is that we want to get everything in one page (unless # otherwise specified, of course). filters["page_size"] = 9223372036854775807 # Form the request URL - first add in the query filters query_filter_sub_url = "" for idx, filter_param in enumerate(filters): # Prepend '?' or '&' if idx == 0: query_filter_sub_url += "?" else: query_filter_sub_url += "&" # Add in the query filter query_filter_sub_url += "{param}={val}".format( param=filter_param, val=filters[filter_param] ) # Stitch together all sub-urls request_url = ( self._client.base_api_url + self.list_url + query_filter_sub_url ) # Make the request response = self._client.session.get(request_url) # Validate that the request was successful self.validate_request_success( response_text=response.text, request_url=request_url, status_code=response.status_code, expected_status_code=HTTP_200_OK, ) # Return a list of model instances return self.response_data_to_model_instances_list(response.json())
python
def list(self, filters=None): """List model instances. Currently this gets *everything* and iterates through all possible pages in the API. This may be unsuitable for production environments with huge databases, so finer grained page support should likely be added at some point. Args: filters (dict, optional): API query filters to apply to the request. For example: .. code-block:: python {'name__startswith': 'azure', 'user__in': [1, 2, 3, 4],} See saltant's API reference at https://saltant-org.github.io/saltant/ for each model's available filters. Returns: list: A list of :class:`saltant.models.resource.Model` subclass instances (for example, container task type model instances). """ # 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 filters: filters["page"] = 1 if "page_size" not in filters: # The below "magic number" is 2^63 - 1, which is the largest # number you can hold in a 64 bit integer. The main point # here is that we want to get everything in one page (unless # otherwise specified, of course). filters["page_size"] = 9223372036854775807 # Form the request URL - first add in the query filters query_filter_sub_url = "" for idx, filter_param in enumerate(filters): # Prepend '?' or '&' if idx == 0: query_filter_sub_url += "?" else: query_filter_sub_url += "&" # Add in the query filter query_filter_sub_url += "{param}={val}".format( param=filter_param, val=filters[filter_param] ) # Stitch together all sub-urls request_url = ( self._client.base_api_url + self.list_url + query_filter_sub_url ) # Make the request response = self._client.session.get(request_url) # Validate that the request was successful self.validate_request_success( response_text=response.text, request_url=request_url, status_code=response.status_code, expected_status_code=HTTP_200_OK, ) # Return a list of model instances return self.response_data_to_model_instances_list(response.json())
[ "def", "list", "(", "self", ",", "filters", "=", "None", ")", ":", "# 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", "filters", ":", "filters", "[", "\"page\"", "]", "=", "1", "if", "\"page_size\"", "not", "in", "filters", ":", "# The below \"magic number\" is 2^63 - 1, which is the largest", "# number you can hold in a 64 bit integer. The main point", "# here is that we want to get everything in one page (unless", "# otherwise specified, of course).", "filters", "[", "\"page_size\"", "]", "=", "9223372036854775807", "# Form the request URL - first add in the query filters", "query_filter_sub_url", "=", "\"\"", "for", "idx", ",", "filter_param", "in", "enumerate", "(", "filters", ")", ":", "# Prepend '?' or '&'", "if", "idx", "==", "0", ":", "query_filter_sub_url", "+=", "\"?\"", "else", ":", "query_filter_sub_url", "+=", "\"&\"", "# Add in the query filter", "query_filter_sub_url", "+=", "\"{param}={val}\"", ".", "format", "(", "param", "=", "filter_param", ",", "val", "=", "filters", "[", "filter_param", "]", ")", "# Stitch together all sub-urls", "request_url", "=", "(", "self", ".", "_client", ".", "base_api_url", "+", "self", ".", "list_url", "+", "query_filter_sub_url", ")", "# Make the request", "response", "=", "self", ".", "_client", ".", "session", ".", "get", "(", "request_url", ")", "# Validate that the request was successful", "self", ".", "validate_request_success", "(", "response_text", "=", "response", ".", "text", ",", "request_url", "=", "request_url", ",", "status_code", "=", "response", ".", "status_code", ",", "expected_status_code", "=", "HTTP_200_OK", ",", ")", "# Return a list of model instances", "return", "self", ".", "response_data_to_model_instances_list", "(", "response", ".", "json", "(", ")", ")" ]
List model instances. Currently this gets *everything* and iterates through all possible pages in the API. This may be unsuitable for production environments with huge databases, so finer grained page support should likely be added at some point. Args: filters (dict, optional): API query filters to apply to the request. For example: .. code-block:: python {'name__startswith': 'azure', 'user__in': [1, 2, 3, 4],} See saltant's API reference at https://saltant-org.github.io/saltant/ for each model's available filters. Returns: list: A list of :class:`saltant.models.resource.Model` subclass instances (for example, container task type model instances).
[ "List", "model", "instances", "." ]
train
https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/resource.py#L53-L129
saltant-org/saltant-py
saltant/models/resource.py
ModelManager.get
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. Returns: :class:`saltant.models.resource.Model`: A :class:`saltant.models.resource.Model` subclass instance representing the resource requested. """ # 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=request_url, status_code=response.status_code, expected_status_code=HTTP_200_OK, ) # Return a model instance return self.response_data_to_model_instance(response.json())
python
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. Returns: :class:`saltant.models.resource.Model`: A :class:`saltant.models.resource.Model` subclass instance representing the resource requested. """ # 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=request_url, status_code=response.status_code, expected_status_code=HTTP_200_OK, ) # Return a model instance return self.response_data_to_model_instance(response.json())
[ "def", "get", "(", "self", ",", "id", ")", ":", "# 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", "=", "request_url", ",", "status_code", "=", "response", ".", "status_code", ",", "expected_status_code", "=", "HTTP_200_OK", ",", ")", "# Return a model instance", "return", "self", ".", "response_data_to_model_instance", "(", "response", ".", "json", "(", ")", ")" ]
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. Returns: :class:`saltant.models.resource.Model`: A :class:`saltant.models.resource.Model` subclass instance representing the resource requested.
[ "Get", "the", "model", "instance", "with", "a", "given", "id", "." ]
train
https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/resource.py#L131-L157
saltant-org/saltant-py
saltant/models/resource.py
ModelManager.validate_request_success
def validate_request_success( response_text, request_url, status_code, expected_status_code ): """Validates that a request was successful. Args: response_text (str): The response body of the request. request_url (str): The URL the request was made at. status_code (int): The status code of the response. expected_status_code (int): The expected status code of the response. Raises: :class:`saltant.exceptions.BadHttpRequestError`: The HTTP request failed. """ 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( url=request_url, status_code=status_code, content=response_text ) raise BadHttpRequestError(msg)
python
def validate_request_success( response_text, request_url, status_code, expected_status_code ): """Validates that a request was successful. Args: response_text (str): The response body of the request. request_url (str): The URL the request was made at. status_code (int): The status code of the response. expected_status_code (int): The expected status code of the response. Raises: :class:`saltant.exceptions.BadHttpRequestError`: The HTTP request failed. """ 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( url=request_url, status_code=status_code, content=response_text ) raise BadHttpRequestError(msg)
[ "def", "validate_request_success", "(", "response_text", ",", "request_url", ",", "status_code", ",", "expected_status_code", ")", ":", "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", "(", "url", "=", "request_url", ",", "status_code", "=", "status_code", ",", "content", "=", "response_text", ")", "raise", "BadHttpRequestError", "(", "msg", ")" ]
Validates that a request was successful. Args: response_text (str): The response body of the request. request_url (str): The URL the request was made at. status_code (int): The status code of the response. expected_status_code (int): The expected status code of the response. Raises: :class:`saltant.exceptions.BadHttpRequestError`: The HTTP request failed.
[ "Validates", "that", "a", "request", "was", "successful", "." ]
train
https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/resource.py#L194-L220
saltant-org/saltant-py
saltant/models/base_task_instance.py
BaseTaskInstance.sync
def sync(self): """Sync this model with latest data on the saltant server. Note that in addition to returning the updated object, it also updates the existing object. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: This task instance ... instance after syncing. """ self = self.manager.get(uuid=self.uuid) return self
python
def sync(self): """Sync this model with latest data on the saltant server. Note that in addition to returning the updated object, it also updates the existing object. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: This task instance ... instance after syncing. """ self = self.manager.get(uuid=self.uuid) return self
[ "def", "sync", "(", "self", ")", ":", "self", "=", "self", ".", "manager", ".", "get", "(", "uuid", "=", "self", ".", "uuid", ")", "return", "self" ]
Sync this model with latest data on the saltant server. Note that in addition to returning the updated object, it also updates the existing object. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: This task instance ... instance after syncing.
[ "Sync", "this", "model", "with", "latest", "data", "on", "the", "saltant", "server", "." ]
train
https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/base_task_instance.py#L92-L104
saltant-org/saltant-py
saltant/models/base_task_instance.py
BaseTaskInstance.wait_until_finished
def wait_until_finished( self, refresh_period=DEFAULT_TASK_INSTANCE_WAIT_REFRESH_PERIOD ): """Wait until a task instance with the given UUID is finished. Args: refresh_period (int, optional): How many seconds to wait before checking the task's status. Defaults to 5 seconds. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: This task instance model after it finished. """ return self.manager.wait_until_finished( uuid=self.uuid, refresh_period=refresh_period )
python
def wait_until_finished( self, refresh_period=DEFAULT_TASK_INSTANCE_WAIT_REFRESH_PERIOD ): """Wait until a task instance with the given UUID is finished. Args: refresh_period (int, optional): How many seconds to wait before checking the task's status. Defaults to 5 seconds. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: This task instance model after it finished. """ return self.manager.wait_until_finished( uuid=self.uuid, refresh_period=refresh_period )
[ "def", "wait_until_finished", "(", "self", ",", "refresh_period", "=", "DEFAULT_TASK_INSTANCE_WAIT_REFRESH_PERIOD", ")", ":", "return", "self", ".", "manager", ".", "wait_until_finished", "(", "uuid", "=", "self", ".", "uuid", ",", "refresh_period", "=", "refresh_period", ")" ]
Wait until a task instance with the given UUID is finished. Args: refresh_period (int, optional): How many seconds to wait before checking the task's status. Defaults to 5 seconds. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: This task instance model after it finished.
[ "Wait", "until", "a", "task", "instance", "with", "the", "given", "UUID", "is", "finished", "." ]
train
https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/base_task_instance.py#L125-L141
saltant-org/saltant-py
saltant/models/base_task_instance.py
BaseTaskInstanceManager.create
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 task instance on. task_queue_id (int): The ID of the task queue to run the job on. arguments (dict, optional): The arguments to give the task type. name (str, optional): A non-unique name to give the task instance. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: A task instance model instance representing the task instance just created. """ # 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_type": task_type_id, "task_queue": task_queue_id, } response = self._client.session.post(request_url, data=data_to_post) # Validate that the request was successful self.validate_request_success( response_text=response.text, request_url=request_url, status_code=response.status_code, expected_status_code=HTTP_201_CREATED, ) # Return a model instance representing the task instance return self.response_data_to_model_instance(response.json())
python
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 task instance on. task_queue_id (int): The ID of the task queue to run the job on. arguments (dict, optional): The arguments to give the task type. name (str, optional): A non-unique name to give the task instance. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: A task instance model instance representing the task instance just created. """ # 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_type": task_type_id, "task_queue": task_queue_id, } response = self._client.session.post(request_url, data=data_to_post) # Validate that the request was successful self.validate_request_success( response_text=response.text, request_url=request_url, status_code=response.status_code, expected_status_code=HTTP_201_CREATED, ) # Return a model instance representing the task instance return self.response_data_to_model_instance(response.json())
[ "def", "create", "(", "self", ",", "task_type_id", ",", "task_queue_id", ",", "arguments", "=", "None", ",", "name", "=", "\"\"", ")", ":", "# 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_type\"", ":", "task_type_id", ",", "\"task_queue\"", ":", "task_queue_id", ",", "}", "response", "=", "self", ".", "_client", ".", "session", ".", "post", "(", "request_url", ",", "data", "=", "data_to_post", ")", "# Validate that the request was successful", "self", ".", "validate_request_success", "(", "response_text", "=", "response", ".", "text", ",", "request_url", "=", "request_url", ",", "status_code", "=", "response", ".", "status_code", ",", "expected_status_code", "=", "HTTP_201_CREATED", ",", ")", "# Return a model instance representing the task instance", "return", "self", ".", "response_data_to_model_instance", "(", "response", ".", "json", "(", ")", ")" ]
Create a task instance. Args: task_type_id (int): The ID of the task type to base the task instance on. task_queue_id (int): The ID of the task queue to run the job on. arguments (dict, optional): The arguments to give the task type. name (str, optional): A non-unique name to give the task instance. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: A task instance model instance representing the task instance just created.
[ "Create", "a", "task", "instance", "." ]
train
https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/base_task_instance.py#L178-L220
saltant-org/saltant-py
saltant/models/base_task_instance.py
BaseTaskInstanceManager.clone
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.base_task_instance.BaseTaskInstance`: A task instance model instance representing the task instance created due to the clone. """ # 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, request_url=request_url, status_code=response.status_code, expected_status_code=HTTP_201_CREATED, ) # Return a model instance return self.response_data_to_model_instance(response.json())
python
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.base_task_instance.BaseTaskInstance`: A task instance model instance representing the task instance created due to the clone. """ # 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, request_url=request_url, status_code=response.status_code, expected_status_code=HTTP_201_CREATED, ) # Return a model instance return self.response_data_to_model_instance(response.json())
[ "def", "clone", "(", "self", ",", "uuid", ")", ":", "# 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", ",", "request_url", "=", "request_url", ",", "status_code", "=", "response", ".", "status_code", ",", "expected_status_code", "=", "HTTP_201_CREATED", ",", ")", "# Return a model instance", "return", "self", ".", "response_data_to_model_instance", "(", "response", ".", "json", "(", ")", ")" ]
Clone the task instance with given UUID. Args: uuid (str): The UUID of the task instance to clone. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: A task instance model instance representing the task instance created due to the clone.
[ "Clone", "the", "task", "instance", "with", "given", "UUID", "." ]
train
https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/base_task_instance.py#L222-L249
saltant-org/saltant-py
saltant/models/base_task_instance.py
BaseTaskInstanceManager.terminate
def terminate(self, uuid): """Terminate the task instance with given UUID. Args: uuid (str): The UUID of the task instance to terminate. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: A task instance model instance representing the task instance that was told to terminate. """ # 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.text, request_url=request_url, status_code=response.status_code, expected_status_code=HTTP_202_ACCEPTED, ) # Return a model instance return self.response_data_to_model_instance(response.json())
python
def terminate(self, uuid): """Terminate the task instance with given UUID. Args: uuid (str): The UUID of the task instance to terminate. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: A task instance model instance representing the task instance that was told to terminate. """ # 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.text, request_url=request_url, status_code=response.status_code, expected_status_code=HTTP_202_ACCEPTED, ) # Return a model instance return self.response_data_to_model_instance(response.json())
[ "def", "terminate", "(", "self", ",", "uuid", ")", ":", "# 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", ".", "text", ",", "request_url", "=", "request_url", ",", "status_code", "=", "response", ".", "status_code", ",", "expected_status_code", "=", "HTTP_202_ACCEPTED", ",", ")", "# Return a model instance", "return", "self", ".", "response_data_to_model_instance", "(", "response", ".", "json", "(", ")", ")" ]
Terminate the task instance with given UUID. Args: uuid (str): The UUID of the task instance to terminate. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: A task instance model instance representing the task instance that was told to terminate.
[ "Terminate", "the", "task", "instance", "with", "given", "UUID", "." ]
train
https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/base_task_instance.py#L267-L294
saltant-org/saltant-py
saltant/models/base_task_instance.py
BaseTaskInstanceManager.wait_until_finished
def wait_until_finished( self, uuid, refresh_period=DEFAULT_TASK_INSTANCE_WAIT_REFRESH_PERIOD ): """Wait until a task instance with the given UUID is finished. Args: uuid (str): The UUID of the task instance to wait for. refresh_period (float, optional): How many seconds to wait in between checking the task's status. Defaults to 5 seconds. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: A task instance model instance representing the task instance which we waited for. """ # Wait for the task to finish task_instance = self.get(uuid) while task_instance.state not in TASK_INSTANCE_FINISH_STATUSES: # Wait a bit time.sleep(refresh_period) # Query again task_instance = self.get(uuid) return task_instance
python
def wait_until_finished( self, uuid, refresh_period=DEFAULT_TASK_INSTANCE_WAIT_REFRESH_PERIOD ): """Wait until a task instance with the given UUID is finished. Args: uuid (str): The UUID of the task instance to wait for. refresh_period (float, optional): How many seconds to wait in between checking the task's status. Defaults to 5 seconds. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: A task instance model instance representing the task instance which we waited for. """ # Wait for the task to finish task_instance = self.get(uuid) while task_instance.state not in TASK_INSTANCE_FINISH_STATUSES: # Wait a bit time.sleep(refresh_period) # Query again task_instance = self.get(uuid) return task_instance
[ "def", "wait_until_finished", "(", "self", ",", "uuid", ",", "refresh_period", "=", "DEFAULT_TASK_INSTANCE_WAIT_REFRESH_PERIOD", ")", ":", "# Wait for the task to finish", "task_instance", "=", "self", ".", "get", "(", "uuid", ")", "while", "task_instance", ".", "state", "not", "in", "TASK_INSTANCE_FINISH_STATUSES", ":", "# Wait a bit", "time", ".", "sleep", "(", "refresh_period", ")", "# Query again", "task_instance", "=", "self", ".", "get", "(", "uuid", ")", "return", "task_instance" ]
Wait until a task instance with the given UUID is finished. Args: uuid (str): The UUID of the task instance to wait for. refresh_period (float, optional): How many seconds to wait in between checking the task's status. Defaults to 5 seconds. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: A task instance model instance representing the task instance which we waited for.
[ "Wait", "until", "a", "task", "instance", "with", "the", "given", "UUID", "is", "finished", "." ]
train
https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/base_task_instance.py#L312-L338
saltant-org/saltant-py
saltant/models/base_task_instance.py
BaseTaskInstanceManager.response_data_to_model_instance
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 request's response. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: A task instance model instance representing the task instance from the reponse data. """ # 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( response_data["datetime_finished"] ) # Instantiate a model for the task instance return super( BaseTaskInstanceManager, self ).response_data_to_model_instance(response_data)
python
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 request's response. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: A task instance model instance representing the task instance from the reponse data. """ # 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( response_data["datetime_finished"] ) # Instantiate a model for the task instance return super( BaseTaskInstanceManager, self ).response_data_to_model_instance(response_data)
[ "def", "response_data_to_model_instance", "(", "self", ",", "response_data", ")", ":", "# 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", "(", "response_data", "[", "\"datetime_finished\"", "]", ")", "# Instantiate a model for the task instance", "return", "super", "(", "BaseTaskInstanceManager", ",", "self", ")", ".", "response_data_to_model_instance", "(", "response_data", ")" ]
Convert response data to a task instance model. Args: response_data (dict): The data from the request's response. Returns: :class:`saltant.models.base_task_instance.BaseTaskInstance`: A task instance model instance representing the task instance from the reponse data.
[ "Convert", "response", "data", "to", "a", "task", "instance", "model", "." ]
train
https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/base_task_instance.py#L340-L364
OLC-Bioinformatics/sipprverse
cgecore/cgefinder.py
CGEFinder.kma
def kma(inputfile_1, out_path, databases, db_path_kma, min_cov=0.6, threshold=0.9, kma_path="cge/kma/kma", sample_name="", inputfile_2=None, kma_mrs=None, kma_gapopen=None, kma_gapextend=None, kma_penalty=None, kma_reward=None, kma_pm=None, kma_fpm=None, kma_memmode=False, kma_nanopore=False, debug=False, kma_add_args=None): """ I expect that there will only be one hit pr gene, but if there are more, I assume that the sequence of the hits are the same in the res file and the aln file. """ threshold = threshold * 100 min_cov = min_cov * 100 kma_results = dict() kma_results["excluded"] = dict() if(sample_name): sample_name = "_" + sample_name # Initiate output dicts. gene_align_sbjct = {} gene_align_query = {} gene_align_homo = {} for db in databases: kma_db = db_path_kma + "/" + db kma_outfile = out_path + "/kma_" + db + sample_name kma_cmd = ("%s -t_db %s -o %s -e 1.0" % (kma_path, kma_db, kma_outfile)) if(inputfile_2 is not None): kma_cmd += " -ipe " + inputfile_1 + " " + inputfile_2 else: kma_cmd += " -i " + inputfile_1 if(kma_mrs is not None): kma_cmd += " -mrs " + str(kma_mrs) if(kma_gapopen is not None): kma_cmd += " -gapopen " + str(kma_gapopen) if(kma_gapextend is not None): kma_cmd += " -gapextend " + str(kma_gapextend) if(kma_penalty is not None): kma_cmd += " -penalty " + str(kma_penalty) if(kma_reward is not None): kma_cmd += " -reward " + str(kma_reward) if(kma_pm is not None): kma_cmd += " -pm " + kma_pm if(kma_fpm is not None): kma_cmd += " -fpm " + kma_fpm if (kma_memmode): kma_cmd += " -mem_mode " if (kma_nanopore): kma_cmd += " -bcNano " kma_cmd += " -mp 20 " if (kma_add_args is not None): kma_cmd += " " + kma_add_args + " " # kma output files align_filename = kma_outfile + ".aln" res_filename = kma_outfile + ".res" # If .res file exists then skip mapping if os.path.isfile(res_filename) and os.access(res_filename, os.R_OK): print("Found " + res_filename + " skipping DB.") else: # Call KMA if(debug): print("KMA cmd: " + kma_cmd) process = subprocess.Popen(kma_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = process.communicate() kma_results[db] = 'No hit found' # Open res file try: res_file = open(res_filename, "r") header = res_file.readline() except IOError as error: sys.exit("Error: KMA did not run as expected.\n" + "KMA finished with the following response:" + "\n{}\n{}".format(out.decode("utf-8"), err.decode("utf-8"))) for line in res_file: if kma_results[db] == 'No hit found': kma_results[db] = dict() # kma_results[db]["excluded"] = dict() # continue data = [data.strip() for data in line.split("\t")] gene = data[0] sbjct_len = int(data[3]) sbjct_ident = float(data[4]) coverage = float(data[5]) depth = float(data[-3]) q_value = float(data[-2]) p_value = float(data[-1]) if gene not in kma_results[db]: hit = gene else: hit = gene + "_" + str(len(kma_results[db][gene]) + 1) exclude_reasons = [] if(coverage < min_cov or sbjct_ident < threshold): exclude_reasons.append(coverage) exclude_reasons.append(sbjct_ident) if(exclude_reasons): # kma_results[db]["excluded"][hit] = exclude_reasons kma_results["excluded"][hit] = exclude_reasons kma_results[db][hit] = dict() kma_results[db][hit]['sbjct_length'] = sbjct_len kma_results[db][hit]["perc_coverage"] = coverage kma_results[db][hit]["sbjct_string"] = [] kma_results[db][hit]["query_string"] = [] kma_results[db][hit]["homo_string"] = [] kma_results[db][hit]["sbjct_header"] = gene kma_results[db][hit]["perc_ident"] = sbjct_ident kma_results[db][hit]["query_start"] = "NA" kma_results[db][hit]["query_end"] = "NA" kma_results[db][hit]["contig_name"] = "NA" kma_results[db][hit]["HSP_length"] = "" kma_results[db][hit]["cal_score"] = q_value kma_results[db][hit]["depth"] = depth kma_results[db][hit]["p_value"] = p_value res_file.close() if kma_results[db] == 'No hit found': continue # Open align file with open(align_filename, "r") as align_file: hit_no = dict() gene = "" # Parse through alignments for line in align_file: # Skip empty lines if(not line.strip()): continue # Check when a new gene alignment start if line.startswith("#"): gene = line[1:].strip() if gene not in hit_no: hit_no[gene] = str(1) else: hit_no[gene] += str(int(hit_no[gene]) + 1) else: # Check if gene one of the user specified genes if hit_no[gene] == '1': hit = gene else: hit = gene + "_" + hit_no[gene] if hit in kma_results[db]: line_data = line.split("\t")[-1].strip() if line.startswith("template"): kma_results[db][hit]["sbjct_string"] += ( [line_data]) elif line.startswith("query"): kma_results[db][hit]["query_string"] += ( [line_data]) else: kma_results[db][hit]["homo_string"] += ( [line_data]) else: print(hit + " not in results: ", kma_results) # concatinate all sequences lists and find subject start # and subject end gene_align_sbjct[db] = {} gene_align_query[db] = {} gene_align_homo[db] = {} for hit in kma_results[db]: # if(hit == "excluded"): # continue align_sbjct = "".join(kma_results[db][hit]['sbjct_string']) align_query = "".join(kma_results[db][hit]['query_string']) align_homo = "".join(kma_results[db][hit]['homo_string']) # Extract only aligned sequences start = re.search("^-*(\w+)", align_query).start(1) end = re.search("\w+(-*)$", align_query).start(1) kma_results[db][hit]['sbjct_string'] = align_sbjct[start:end] kma_results[db][hit]['query_string'] = align_query[start:end] kma_results[db][hit]['homo_string'] = align_homo[start:end] # Save align start and stop positions relative to # subject sequence kma_results[db][hit]['sbjct_start'] = start + 1 kma_results[db][hit]["sbjct_end"] = end + 1 kma_results[db][hit]["HSP_length"] = end - start # Count gaps in the alignment kma_results[db][hit]["gaps"] = ( kma_results[db][hit]['sbjct_string'].count("-") + kma_results[db][hit]['query_string'].count("-")) # Save sequences covering the entire subject sequence # in seperate variables gene_align_sbjct[db][hit] = align_sbjct gene_align_query[db][hit] = align_query gene_align_homo[db][hit] = align_homo return FinderResult(kma_results, gene_align_sbjct, gene_align_query, gene_align_homo)
python
def kma(inputfile_1, out_path, databases, db_path_kma, min_cov=0.6, threshold=0.9, kma_path="cge/kma/kma", sample_name="", inputfile_2=None, kma_mrs=None, kma_gapopen=None, kma_gapextend=None, kma_penalty=None, kma_reward=None, kma_pm=None, kma_fpm=None, kma_memmode=False, kma_nanopore=False, debug=False, kma_add_args=None): """ I expect that there will only be one hit pr gene, but if there are more, I assume that the sequence of the hits are the same in the res file and the aln file. """ threshold = threshold * 100 min_cov = min_cov * 100 kma_results = dict() kma_results["excluded"] = dict() if(sample_name): sample_name = "_" + sample_name # Initiate output dicts. gene_align_sbjct = {} gene_align_query = {} gene_align_homo = {} for db in databases: kma_db = db_path_kma + "/" + db kma_outfile = out_path + "/kma_" + db + sample_name kma_cmd = ("%s -t_db %s -o %s -e 1.0" % (kma_path, kma_db, kma_outfile)) if(inputfile_2 is not None): kma_cmd += " -ipe " + inputfile_1 + " " + inputfile_2 else: kma_cmd += " -i " + inputfile_1 if(kma_mrs is not None): kma_cmd += " -mrs " + str(kma_mrs) if(kma_gapopen is not None): kma_cmd += " -gapopen " + str(kma_gapopen) if(kma_gapextend is not None): kma_cmd += " -gapextend " + str(kma_gapextend) if(kma_penalty is not None): kma_cmd += " -penalty " + str(kma_penalty) if(kma_reward is not None): kma_cmd += " -reward " + str(kma_reward) if(kma_pm is not None): kma_cmd += " -pm " + kma_pm if(kma_fpm is not None): kma_cmd += " -fpm " + kma_fpm if (kma_memmode): kma_cmd += " -mem_mode " if (kma_nanopore): kma_cmd += " -bcNano " kma_cmd += " -mp 20 " if (kma_add_args is not None): kma_cmd += " " + kma_add_args + " " # kma output files align_filename = kma_outfile + ".aln" res_filename = kma_outfile + ".res" # If .res file exists then skip mapping if os.path.isfile(res_filename) and os.access(res_filename, os.R_OK): print("Found " + res_filename + " skipping DB.") else: # Call KMA if(debug): print("KMA cmd: " + kma_cmd) process = subprocess.Popen(kma_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = process.communicate() kma_results[db] = 'No hit found' # Open res file try: res_file = open(res_filename, "r") header = res_file.readline() except IOError as error: sys.exit("Error: KMA did not run as expected.\n" + "KMA finished with the following response:" + "\n{}\n{}".format(out.decode("utf-8"), err.decode("utf-8"))) for line in res_file: if kma_results[db] == 'No hit found': kma_results[db] = dict() # kma_results[db]["excluded"] = dict() # continue data = [data.strip() for data in line.split("\t")] gene = data[0] sbjct_len = int(data[3]) sbjct_ident = float(data[4]) coverage = float(data[5]) depth = float(data[-3]) q_value = float(data[-2]) p_value = float(data[-1]) if gene not in kma_results[db]: hit = gene else: hit = gene + "_" + str(len(kma_results[db][gene]) + 1) exclude_reasons = [] if(coverage < min_cov or sbjct_ident < threshold): exclude_reasons.append(coverage) exclude_reasons.append(sbjct_ident) if(exclude_reasons): # kma_results[db]["excluded"][hit] = exclude_reasons kma_results["excluded"][hit] = exclude_reasons kma_results[db][hit] = dict() kma_results[db][hit]['sbjct_length'] = sbjct_len kma_results[db][hit]["perc_coverage"] = coverage kma_results[db][hit]["sbjct_string"] = [] kma_results[db][hit]["query_string"] = [] kma_results[db][hit]["homo_string"] = [] kma_results[db][hit]["sbjct_header"] = gene kma_results[db][hit]["perc_ident"] = sbjct_ident kma_results[db][hit]["query_start"] = "NA" kma_results[db][hit]["query_end"] = "NA" kma_results[db][hit]["contig_name"] = "NA" kma_results[db][hit]["HSP_length"] = "" kma_results[db][hit]["cal_score"] = q_value kma_results[db][hit]["depth"] = depth kma_results[db][hit]["p_value"] = p_value res_file.close() if kma_results[db] == 'No hit found': continue # Open align file with open(align_filename, "r") as align_file: hit_no = dict() gene = "" # Parse through alignments for line in align_file: # Skip empty lines if(not line.strip()): continue # Check when a new gene alignment start if line.startswith("#"): gene = line[1:].strip() if gene not in hit_no: hit_no[gene] = str(1) else: hit_no[gene] += str(int(hit_no[gene]) + 1) else: # Check if gene one of the user specified genes if hit_no[gene] == '1': hit = gene else: hit = gene + "_" + hit_no[gene] if hit in kma_results[db]: line_data = line.split("\t")[-1].strip() if line.startswith("template"): kma_results[db][hit]["sbjct_string"] += ( [line_data]) elif line.startswith("query"): kma_results[db][hit]["query_string"] += ( [line_data]) else: kma_results[db][hit]["homo_string"] += ( [line_data]) else: print(hit + " not in results: ", kma_results) # concatinate all sequences lists and find subject start # and subject end gene_align_sbjct[db] = {} gene_align_query[db] = {} gene_align_homo[db] = {} for hit in kma_results[db]: # if(hit == "excluded"): # continue align_sbjct = "".join(kma_results[db][hit]['sbjct_string']) align_query = "".join(kma_results[db][hit]['query_string']) align_homo = "".join(kma_results[db][hit]['homo_string']) # Extract only aligned sequences start = re.search("^-*(\w+)", align_query).start(1) end = re.search("\w+(-*)$", align_query).start(1) kma_results[db][hit]['sbjct_string'] = align_sbjct[start:end] kma_results[db][hit]['query_string'] = align_query[start:end] kma_results[db][hit]['homo_string'] = align_homo[start:end] # Save align start and stop positions relative to # subject sequence kma_results[db][hit]['sbjct_start'] = start + 1 kma_results[db][hit]["sbjct_end"] = end + 1 kma_results[db][hit]["HSP_length"] = end - start # Count gaps in the alignment kma_results[db][hit]["gaps"] = ( kma_results[db][hit]['sbjct_string'].count("-") + kma_results[db][hit]['query_string'].count("-")) # Save sequences covering the entire subject sequence # in seperate variables gene_align_sbjct[db][hit] = align_sbjct gene_align_query[db][hit] = align_query gene_align_homo[db][hit] = align_homo return FinderResult(kma_results, gene_align_sbjct, gene_align_query, gene_align_homo)
[ "def", "kma", "(", "inputfile_1", ",", "out_path", ",", "databases", ",", "db_path_kma", ",", "min_cov", "=", "0.6", ",", "threshold", "=", "0.9", ",", "kma_path", "=", "\"cge/kma/kma\"", ",", "sample_name", "=", "\"\"", ",", "inputfile_2", "=", "None", ",", "kma_mrs", "=", "None", ",", "kma_gapopen", "=", "None", ",", "kma_gapextend", "=", "None", ",", "kma_penalty", "=", "None", ",", "kma_reward", "=", "None", ",", "kma_pm", "=", "None", ",", "kma_fpm", "=", "None", ",", "kma_memmode", "=", "False", ",", "kma_nanopore", "=", "False", ",", "debug", "=", "False", ",", "kma_add_args", "=", "None", ")", ":", "threshold", "=", "threshold", "*", "100", "min_cov", "=", "min_cov", "*", "100", "kma_results", "=", "dict", "(", ")", "kma_results", "[", "\"excluded\"", "]", "=", "dict", "(", ")", "if", "(", "sample_name", ")", ":", "sample_name", "=", "\"_\"", "+", "sample_name", "# Initiate output dicts.", "gene_align_sbjct", "=", "{", "}", "gene_align_query", "=", "{", "}", "gene_align_homo", "=", "{", "}", "for", "db", "in", "databases", ":", "kma_db", "=", "db_path_kma", "+", "\"/\"", "+", "db", "kma_outfile", "=", "out_path", "+", "\"/kma_\"", "+", "db", "+", "sample_name", "kma_cmd", "=", "(", "\"%s -t_db %s -o %s -e 1.0\"", "%", "(", "kma_path", ",", "kma_db", ",", "kma_outfile", ")", ")", "if", "(", "inputfile_2", "is", "not", "None", ")", ":", "kma_cmd", "+=", "\" -ipe \"", "+", "inputfile_1", "+", "\" \"", "+", "inputfile_2", "else", ":", "kma_cmd", "+=", "\" -i \"", "+", "inputfile_1", "if", "(", "kma_mrs", "is", "not", "None", ")", ":", "kma_cmd", "+=", "\" -mrs \"", "+", "str", "(", "kma_mrs", ")", "if", "(", "kma_gapopen", "is", "not", "None", ")", ":", "kma_cmd", "+=", "\" -gapopen \"", "+", "str", "(", "kma_gapopen", ")", "if", "(", "kma_gapextend", "is", "not", "None", ")", ":", "kma_cmd", "+=", "\" -gapextend \"", "+", "str", "(", "kma_gapextend", ")", "if", "(", "kma_penalty", "is", "not", "None", ")", ":", "kma_cmd", "+=", "\" -penalty \"", "+", "str", "(", "kma_penalty", ")", "if", "(", "kma_reward", "is", "not", "None", ")", ":", "kma_cmd", "+=", "\" -reward \"", "+", "str", "(", "kma_reward", ")", "if", "(", "kma_pm", "is", "not", "None", ")", ":", "kma_cmd", "+=", "\" -pm \"", "+", "kma_pm", "if", "(", "kma_fpm", "is", "not", "None", ")", ":", "kma_cmd", "+=", "\" -fpm \"", "+", "kma_fpm", "if", "(", "kma_memmode", ")", ":", "kma_cmd", "+=", "\" -mem_mode \"", "if", "(", "kma_nanopore", ")", ":", "kma_cmd", "+=", "\" -bcNano \"", "kma_cmd", "+=", "\" -mp 20 \"", "if", "(", "kma_add_args", "is", "not", "None", ")", ":", "kma_cmd", "+=", "\" \"", "+", "kma_add_args", "+", "\" \"", "# kma output files", "align_filename", "=", "kma_outfile", "+", "\".aln\"", "res_filename", "=", "kma_outfile", "+", "\".res\"", "# If .res file exists then skip mapping", "if", "os", ".", "path", ".", "isfile", "(", "res_filename", ")", "and", "os", ".", "access", "(", "res_filename", ",", "os", ".", "R_OK", ")", ":", "print", "(", "\"Found \"", "+", "res_filename", "+", "\" skipping DB.\"", ")", "else", ":", "# Call KMA", "if", "(", "debug", ")", ":", "print", "(", "\"KMA cmd: \"", "+", "kma_cmd", ")", "process", "=", "subprocess", ".", "Popen", "(", "kma_cmd", ",", "shell", "=", "True", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "stderr", "=", "subprocess", ".", "PIPE", ")", "out", ",", "err", "=", "process", ".", "communicate", "(", ")", "kma_results", "[", "db", "]", "=", "'No hit found'", "# Open res file", "try", ":", "res_file", "=", "open", "(", "res_filename", ",", "\"r\"", ")", "header", "=", "res_file", ".", "readline", "(", ")", "except", "IOError", "as", "error", ":", "sys", ".", "exit", "(", "\"Error: KMA did not run as expected.\\n\"", "+", "\"KMA finished with the following response:\"", "+", "\"\\n{}\\n{}\"", ".", "format", "(", "out", ".", "decode", "(", "\"utf-8\"", ")", ",", "err", ".", "decode", "(", "\"utf-8\"", ")", ")", ")", "for", "line", "in", "res_file", ":", "if", "kma_results", "[", "db", "]", "==", "'No hit found'", ":", "kma_results", "[", "db", "]", "=", "dict", "(", ")", "# kma_results[db][\"excluded\"] = dict()", "# continue", "data", "=", "[", "data", ".", "strip", "(", ")", "for", "data", "in", "line", ".", "split", "(", "\"\\t\"", ")", "]", "gene", "=", "data", "[", "0", "]", "sbjct_len", "=", "int", "(", "data", "[", "3", "]", ")", "sbjct_ident", "=", "float", "(", "data", "[", "4", "]", ")", "coverage", "=", "float", "(", "data", "[", "5", "]", ")", "depth", "=", "float", "(", "data", "[", "-", "3", "]", ")", "q_value", "=", "float", "(", "data", "[", "-", "2", "]", ")", "p_value", "=", "float", "(", "data", "[", "-", "1", "]", ")", "if", "gene", "not", "in", "kma_results", "[", "db", "]", ":", "hit", "=", "gene", "else", ":", "hit", "=", "gene", "+", "\"_\"", "+", "str", "(", "len", "(", "kma_results", "[", "db", "]", "[", "gene", "]", ")", "+", "1", ")", "exclude_reasons", "=", "[", "]", "if", "(", "coverage", "<", "min_cov", "or", "sbjct_ident", "<", "threshold", ")", ":", "exclude_reasons", ".", "append", "(", "coverage", ")", "exclude_reasons", ".", "append", "(", "sbjct_ident", ")", "if", "(", "exclude_reasons", ")", ":", "# kma_results[db][\"excluded\"][hit] = exclude_reasons", "kma_results", "[", "\"excluded\"", "]", "[", "hit", "]", "=", "exclude_reasons", "kma_results", "[", "db", "]", "[", "hit", "]", "=", "dict", "(", ")", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "'sbjct_length'", "]", "=", "sbjct_len", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"perc_coverage\"", "]", "=", "coverage", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"sbjct_string\"", "]", "=", "[", "]", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"query_string\"", "]", "=", "[", "]", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"homo_string\"", "]", "=", "[", "]", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"sbjct_header\"", "]", "=", "gene", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"perc_ident\"", "]", "=", "sbjct_ident", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"query_start\"", "]", "=", "\"NA\"", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"query_end\"", "]", "=", "\"NA\"", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"contig_name\"", "]", "=", "\"NA\"", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"HSP_length\"", "]", "=", "\"\"", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"cal_score\"", "]", "=", "q_value", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"depth\"", "]", "=", "depth", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"p_value\"", "]", "=", "p_value", "res_file", ".", "close", "(", ")", "if", "kma_results", "[", "db", "]", "==", "'No hit found'", ":", "continue", "# Open align file", "with", "open", "(", "align_filename", ",", "\"r\"", ")", "as", "align_file", ":", "hit_no", "=", "dict", "(", ")", "gene", "=", "\"\"", "# Parse through alignments", "for", "line", "in", "align_file", ":", "# Skip empty lines", "if", "(", "not", "line", ".", "strip", "(", ")", ")", ":", "continue", "# Check when a new gene alignment start", "if", "line", ".", "startswith", "(", "\"#\"", ")", ":", "gene", "=", "line", "[", "1", ":", "]", ".", "strip", "(", ")", "if", "gene", "not", "in", "hit_no", ":", "hit_no", "[", "gene", "]", "=", "str", "(", "1", ")", "else", ":", "hit_no", "[", "gene", "]", "+=", "str", "(", "int", "(", "hit_no", "[", "gene", "]", ")", "+", "1", ")", "else", ":", "# Check if gene one of the user specified genes", "if", "hit_no", "[", "gene", "]", "==", "'1'", ":", "hit", "=", "gene", "else", ":", "hit", "=", "gene", "+", "\"_\"", "+", "hit_no", "[", "gene", "]", "if", "hit", "in", "kma_results", "[", "db", "]", ":", "line_data", "=", "line", ".", "split", "(", "\"\\t\"", ")", "[", "-", "1", "]", ".", "strip", "(", ")", "if", "line", ".", "startswith", "(", "\"template\"", ")", ":", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"sbjct_string\"", "]", "+=", "(", "[", "line_data", "]", ")", "elif", "line", ".", "startswith", "(", "\"query\"", ")", ":", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"query_string\"", "]", "+=", "(", "[", "line_data", "]", ")", "else", ":", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"homo_string\"", "]", "+=", "(", "[", "line_data", "]", ")", "else", ":", "print", "(", "hit", "+", "\" not in results: \"", ",", "kma_results", ")", "# concatinate all sequences lists and find subject start", "# and subject end", "gene_align_sbjct", "[", "db", "]", "=", "{", "}", "gene_align_query", "[", "db", "]", "=", "{", "}", "gene_align_homo", "[", "db", "]", "=", "{", "}", "for", "hit", "in", "kma_results", "[", "db", "]", ":", "# if(hit == \"excluded\"):", "# continue", "align_sbjct", "=", "\"\"", ".", "join", "(", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "'sbjct_string'", "]", ")", "align_query", "=", "\"\"", ".", "join", "(", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "'query_string'", "]", ")", "align_homo", "=", "\"\"", ".", "join", "(", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "'homo_string'", "]", ")", "# Extract only aligned sequences", "start", "=", "re", ".", "search", "(", "\"^-*(\\w+)\"", ",", "align_query", ")", ".", "start", "(", "1", ")", "end", "=", "re", ".", "search", "(", "\"\\w+(-*)$\"", ",", "align_query", ")", ".", "start", "(", "1", ")", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "'sbjct_string'", "]", "=", "align_sbjct", "[", "start", ":", "end", "]", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "'query_string'", "]", "=", "align_query", "[", "start", ":", "end", "]", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "'homo_string'", "]", "=", "align_homo", "[", "start", ":", "end", "]", "# Save align start and stop positions relative to", "# subject sequence", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "'sbjct_start'", "]", "=", "start", "+", "1", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"sbjct_end\"", "]", "=", "end", "+", "1", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"HSP_length\"", "]", "=", "end", "-", "start", "# Count gaps in the alignment", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "\"gaps\"", "]", "=", "(", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "'sbjct_string'", "]", ".", "count", "(", "\"-\"", ")", "+", "kma_results", "[", "db", "]", "[", "hit", "]", "[", "'query_string'", "]", ".", "count", "(", "\"-\"", ")", ")", "# Save sequences covering the entire subject sequence", "# in seperate variables", "gene_align_sbjct", "[", "db", "]", "[", "hit", "]", "=", "align_sbjct", "gene_align_query", "[", "db", "]", "[", "hit", "]", "=", "align_query", "gene_align_homo", "[", "db", "]", "[", "hit", "]", "=", "align_homo", "return", "FinderResult", "(", "kma_results", ",", "gene_align_sbjct", ",", "gene_align_query", ",", "gene_align_homo", ")" ]
I expect that there will only be one hit pr gene, but if there are more, I assume that the sequence of the hits are the same in the res file and the aln file.
[ "I", "expect", "that", "there", "will", "only", "be", "one", "hit", "pr", "gene", "but", "if", "there", "are", "more", "I", "assume", "that", "the", "sequence", "of", "the", "hits", "are", "the", "same", "in", "the", "res", "file", "and", "the", "aln", "file", "." ]
train
https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/cgefinder.py#L28-L247
brunns/brunns-row
src/brunns/row/rowwrapper.py
RowWrapper._ids_and_column_names
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) fixed[identifier] = name return fixed
python
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) fixed[identifier] = name return fixed
[ "def", "_ids_and_column_names", "(", "names", ",", "force_lower_case", "=", "False", ")", ":", "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", ")", "fixed", "[", "identifier", "]", "=", "name", "return", "fixed" ]
Ensure all column names are unique identifiers.
[ "Ensure", "all", "column", "names", "are", "unique", "identifiers", "." ]
train
https://github.com/brunns/brunns-row/blob/f7076a2d3072447719f728caadf08f33a6a26a7a/src/brunns/row/rowwrapper.py#L54-L64
brunns/brunns-row
src/brunns/row/rowwrapper.py
RowWrapper._make_identifier
def _make_identifier(string): """Attempt to convert string into a valid identifier by replacing invalid characters with "_"s, and prefixing with "a_" if necessary.""" string = re.sub(r"[ \-+/\\*%&$£#@.,;:'" "?<>]", "_", string) if re.match(r"^\d", string): string = "a_{0}".format(string) return string
python
def _make_identifier(string): """Attempt to convert string into a valid identifier by replacing invalid characters with "_"s, and prefixing with "a_" if necessary.""" string = re.sub(r"[ \-+/\\*%&$£#@.,;:'" "?<>]", "_", string) if re.match(r"^\d", string): string = "a_{0}".format(string) return string
[ "def", "_make_identifier", "(", "string", ")", ":", "string", "=", "re", ".", "sub", "(", "r\"[ \\-+/\\\\*%&$£#@.,;:'\" ", "?<>]\",", " ", "_\",", " ", "tring)", "", "if", "re", ".", "match", "(", "r\"^\\d\"", ",", "string", ")", ":", "string", "=", "\"a_{0}\"", ".", "format", "(", "string", ")", "return", "string" ]
Attempt to convert string into a valid identifier by replacing invalid characters with "_"s, and prefixing with "a_" if necessary.
[ "Attempt", "to", "convert", "string", "into", "a", "valid", "identifier", "by", "replacing", "invalid", "characters", "with", "_", "s", "and", "prefixing", "with", "a_", "if", "necessary", "." ]
train
https://github.com/brunns/brunns-row/blob/f7076a2d3072447719f728caadf08f33a6a26a7a/src/brunns/row/rowwrapper.py#L67-L73
brunns/brunns-row
src/brunns/row/rowwrapper.py
RowWrapper._increment_numeric_suffix
def _increment_numeric_suffix(s): """Increment (or add) numeric suffix to identifier.""" if re.match(r".*\d+$", s): return re.sub(r"\d+$", lambda n: str(int(n.group(0)) + 1), s) return s + "_2"
python
def _increment_numeric_suffix(s): """Increment (or add) numeric suffix to identifier.""" if re.match(r".*\d+$", s): return re.sub(r"\d+$", lambda n: str(int(n.group(0)) + 1), s) return s + "_2"
[ "def", "_increment_numeric_suffix", "(", "s", ")", ":", "if", "re", ".", "match", "(", "r\".*\\d+$\"", ",", "s", ")", ":", "return", "re", ".", "sub", "(", "r\"\\d+$\"", ",", "lambda", "n", ":", "str", "(", "int", "(", "n", ".", "group", "(", "0", ")", ")", "+", "1", ")", ",", "s", ")", "return", "s", "+", "\"_2\"" ]
Increment (or add) numeric suffix to identifier.
[ "Increment", "(", "or", "add", ")", "numeric", "suffix", "to", "identifier", "." ]
train
https://github.com/brunns/brunns-row/blob/f7076a2d3072447719f728caadf08f33a6a26a7a/src/brunns/row/rowwrapper.py#L76-L80
brunns/brunns-row
src/brunns/row/rowwrapper.py
RowWrapper.wrap
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: val for ident, val in zip(self.ids_and_column_names.keys(), row)} ) )
python
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: val for ident, val in zip(self.ids_and_column_names.keys(), row)} ) )
[ "def", "wrap", "(", "self", ",", "row", ":", "Union", "[", "Mapping", "[", "str", ",", "Any", "]", ",", "Sequence", "[", "Any", "]", "]", ")", ":", "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", ":", "val", "for", "ident", ",", "val", "in", "zip", "(", "self", ".", "ids_and_column_names", ".", "keys", "(", ")", ",", "row", ")", "}", ")", ")" ]
Return row tuple for row.
[ "Return", "row", "tuple", "for", "row", "." ]
train
https://github.com/brunns/brunns-row/blob/f7076a2d3072447719f728caadf08f33a6a26a7a/src/brunns/row/rowwrapper.py#L82-L95
brunns/brunns-row
src/brunns/row/rowwrapper.py
RowWrapper.wrap_all
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)
python
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)
[ "def", "wrap_all", "(", "self", ",", "rows", ":", "Iterable", "[", "Union", "[", "Mapping", "[", "str", ",", "Any", "]", ",", "Sequence", "[", "Any", "]", "]", "]", ")", ":", "return", "(", "self", ".", "wrap", "(", "r", ")", "for", "r", "in", "rows", ")" ]
Return row tuple for each row in rows.
[ "Return", "row", "tuple", "for", "each", "row", "in", "rows", "." ]
train
https://github.com/brunns/brunns-row/blob/f7076a2d3072447719f728caadf08f33a6a26a7a/src/brunns/row/rowwrapper.py#L97-L99
pymacaron/pymacaron-core
pymacaron_core/exceptions.py
add_error_handlers
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)
python
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)
[ "def", "add_error_handlers", "(", "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", ")" ]
Add custom error handlers for PyMacaronCoreExceptions to the app
[ "Add", "custom", "error", "handlers", "for", "PyMacaronCoreExceptions", "to", "the", "app" ]
train
https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/exceptions.py#L25-L33
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.list_backends
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)
python
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)
[ "def", "list_backends", "(", "self", ",", "service_id", ",", "version_number", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/backend\"", "%", "(", "service_id", ",", "version_number", ")", ")", "return", "map", "(", "lambda", "x", ":", "FastlyBackend", "(", "self", ",", "x", ")", ",", "content", ")" ]
List all backends for a particular service and version.
[ "List", "all", "backends", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L123-L127
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.create_backend
def create_backend(self, service_id, version_number, name, address, use_ssl=False, port=80, connect_timeout=1000, first_byte_timeout=15000, between_bytes_timeout=10000, error_threshold=0, max_conn=20, weight=100, auto_loadbalance=False, shield=None, request_condition=None, healthcheck=None, comment=None): """Create a backend for a particular service and version.""" 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": weight, "auto_loadbalance": auto_loadbalance, "shield": shield, "request_condition": request_condition, "healthcheck": healthcheck, "comment": comment, }, FastlyBackend.FIELDS) content = self._fetch("/service/%s/version/%d/backend" % (service_id, version_number), method="POST", body=body) return FastlyBackend(self, content)
python
def create_backend(self, service_id, version_number, name, address, use_ssl=False, port=80, connect_timeout=1000, first_byte_timeout=15000, between_bytes_timeout=10000, error_threshold=0, max_conn=20, weight=100, auto_loadbalance=False, shield=None, request_condition=None, healthcheck=None, comment=None): """Create a backend for a particular service and version.""" 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": weight, "auto_loadbalance": auto_loadbalance, "shield": shield, "request_condition": request_condition, "healthcheck": healthcheck, "comment": comment, }, FastlyBackend.FIELDS) content = self._fetch("/service/%s/version/%d/backend" % (service_id, version_number), method="POST", body=body) return FastlyBackend(self, content)
[ "def", "create_backend", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ",", "address", ",", "use_ssl", "=", "False", ",", "port", "=", "80", ",", "connect_timeout", "=", "1000", ",", "first_byte_timeout", "=", "15000", ",", "between_bytes_timeout", "=", "10000", ",", "error_threshold", "=", "0", ",", "max_conn", "=", "20", ",", "weight", "=", "100", ",", "auto_loadbalance", "=", "False", ",", "shield", "=", "None", ",", "request_condition", "=", "None", ",", "healthcheck", "=", "None", ",", "comment", "=", "None", ")", ":", "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\"", ":", "weight", ",", "\"auto_loadbalance\"", ":", "auto_loadbalance", ",", "\"shield\"", ":", "shield", ",", "\"request_condition\"", ":", "request_condition", ",", "\"healthcheck\"", ":", "healthcheck", ",", "\"comment\"", ":", "comment", ",", "}", ",", "FastlyBackend", ".", "FIELDS", ")", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/backend\"", "%", "(", "service_id", ",", "version_number", ")", ",", "method", "=", "\"POST\"", ",", "body", "=", "body", ")", "return", "FastlyBackend", "(", "self", ",", "content", ")" ]
Create a backend for a particular service and version.
[ "Create", "a", "backend", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L130-L167
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_backend
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)
python
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)
[ "def", "get_backend", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/backend/%s\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")", ")", "return", "FastlyBackend", "(", "self", ",", "content", ")" ]
Get the backend for a particular service and version.
[ "Get", "the", "backend", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L170-L173
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.update_backend
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)
python
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)
[ "def", "update_backend", "(", "self", ",", "service_id", ",", "version_number", ",", "name_key", ",", "*", "*", "kwargs", ")", ":", "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", ")" ]
Update the backend for a particular service and version.
[ "Update", "the", "backend", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L176-L180
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.check_backends
def check_backends(self, service_id, version_number): """Performs a health check against each backend in version. If the backend has a specific type of healthcheck, that one is performed, otherwise a HEAD request to / is performed. The first item is the details on the Backend itself. The second item is details of the specific HTTP request performed as a health check. The third item is the response details.""" content = self._fetch("/service/%s/version/%d/backend/check_all" % (service_id, version_number)) # TODO: Use a strong-typed class for output? return content
python
def check_backends(self, service_id, version_number): """Performs a health check against each backend in version. If the backend has a specific type of healthcheck, that one is performed, otherwise a HEAD request to / is performed. The first item is the details on the Backend itself. The second item is details of the specific HTTP request performed as a health check. The third item is the response details.""" content = self._fetch("/service/%s/version/%d/backend/check_all" % (service_id, version_number)) # TODO: Use a strong-typed class for output? return content
[ "def", "check_backends", "(", "self", ",", "service_id", ",", "version_number", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/backend/check_all\"", "%", "(", "service_id", ",", "version_number", ")", ")", "# TODO: Use a strong-typed class for output?", "return", "content" ]
Performs a health check against each backend in version. If the backend has a specific type of healthcheck, that one is performed, otherwise a HEAD request to / is performed. The first item is the details on the Backend itself. The second item is details of the specific HTTP request performed as a health check. The third item is the response details.
[ "Performs", "a", "health", "check", "against", "each", "backend", "in", "version", ".", "If", "the", "backend", "has", "a", "specific", "type", "of", "healthcheck", "that", "one", "is", "performed", "otherwise", "a", "HEAD", "request", "to", "/", "is", "performed", ".", "The", "first", "item", "is", "the", "details", "on", "the", "Backend", "itself", ".", "The", "second", "item", "is", "details", "of", "the", "specific", "HTTP", "request", "performed", "as", "a", "health", "check", ".", "The", "third", "item", "is", "the", "response", "details", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L189-L193
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.list_cache_settings
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)
python
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)
[ "def", "list_cache_settings", "(", "self", ",", "service_id", ",", "version_number", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/cache_settings\"", "%", "(", "service_id", ",", "version_number", ")", ")", "return", "map", "(", "lambda", "x", ":", "FastlyCacheSettings", "(", "self", ",", "x", ")", ",", "content", ")" ]
Get a list of all cache settings for a particular service and version.
[ "Get", "a", "list", "of", "all", "cache", "settings", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L196-L199
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.create_cache_settings
def create_cache_settings(self, service_id, version_number, name, action, ttl=None, stale_ttl=None, cache_condition=None): """Create a new cache settings object.""" 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 FastlyCacheSettings(self, content)
python
def create_cache_settings(self, service_id, version_number, name, action, ttl=None, stale_ttl=None, cache_condition=None): """Create a new cache settings object.""" 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 FastlyCacheSettings(self, content)
[ "def", "create_cache_settings", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ",", "action", ",", "ttl", "=", "None", ",", "stale_ttl", "=", "None", ",", "cache_condition", "=", "None", ")", ":", "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", "FastlyCacheSettings", "(", "self", ",", "content", ")" ]
Create a new cache settings object.
[ "Create", "a", "new", "cache", "settings", "object", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L202-L219
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_cache_settings
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)
python
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)
[ "def", "get_cache_settings", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/cache_settings/%s\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")", ")", "return", "FastlyCacheSettings", "(", "self", ",", "content", ")" ]
Get a specific cache settings object.
[ "Get", "a", "specific", "cache", "settings", "object", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L222-L225
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.update_cache_settings
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)
python
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)
[ "def", "update_cache_settings", "(", "self", ",", "service_id", ",", "version_number", ",", "name_key", ",", "*", "*", "kwargs", ")", ":", "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", ")" ]
Update a specific cache settings object.
[ "Update", "a", "specific", "cache", "settings", "object", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L228-L232
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.delete_cache_settings
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)
python
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)
[ "def", "delete_cache_settings", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/cache_settings/%s\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")", ",", "method", "=", "\"DELETE\"", ")", "return", "self", ".", "_status", "(", "content", ")" ]
Delete a specific cache settings object.
[ "Delete", "a", "specific", "cache", "settings", "object", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L235-L238
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.list_conditions
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)
python
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)
[ "def", "list_conditions", "(", "self", ",", "service_id", ",", "version_number", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/condition\"", "%", "(", "service_id", ",", "version_number", ")", ")", "return", "map", "(", "lambda", "x", ":", "FastlyCondition", "(", "self", ",", "x", ")", ",", "content", ")" ]
Gets all conditions for a particular service and version.
[ "Gets", "all", "conditions", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L241-L244
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.create_condition
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, content)
python
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, content)
[ "def", "create_condition", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ",", "_type", ",", "statement", ",", "priority", "=", "\"10\"", ",", "comment", "=", "None", ")", ":", "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", ",", "content", ")" ]
Creates a new condition.
[ "Creates", "a", "new", "condition", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L247-L264
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_condition
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)
python
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)
[ "def", "get_condition", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/condition/%s\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")", ")", "return", "FastlyCondition", "(", "self", ",", "content", ")" ]
Gets a specified condition.
[ "Gets", "a", "specified", "condition", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L267-L270
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.update_condition
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)
python
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)
[ "def", "update_condition", "(", "self", ",", "service_id", ",", "version_number", ",", "name_key", ",", "*", "*", "kwargs", ")", ":", "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", ")" ]
Updates the specified condition.
[ "Updates", "the", "specified", "condition", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L273-L277
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.content_edge_check
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
python
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
[ "def", "content_edge_check", "(", "self", ",", "url", ")", ":", "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" ]
Retrieve headers and MD5 hash of the content for a particular url from each Fastly edge server.
[ "Retrieve", "headers", "and", "MD5", "hash", "of", "the", "content", "for", "a", "particular", "url", "from", "each", "Fastly", "edge", "server", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L286-L294
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_customer
def get_customer(self, customer_id): """Get a specific customer.""" content = self._fetch("/customer/%s" % customer_id) return FastlyCustomer(self, content)
python
def get_customer(self, customer_id): """Get a specific customer.""" content = self._fetch("/customer/%s" % customer_id) return FastlyCustomer(self, content)
[ "def", "get_customer", "(", "self", ",", "customer_id", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/customer/%s\"", "%", "customer_id", ")", "return", "FastlyCustomer", "(", "self", ",", "content", ")" ]
Get a specific customer.
[ "Get", "a", "specific", "customer", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L303-L306
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.list_customer_users
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)
python
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)
[ "def", "list_customer_users", "(", "self", ",", "customer_id", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/customer/users/%s\"", "%", "customer_id", ")", "return", "map", "(", "lambda", "x", ":", "FastlyUser", "(", "self", ",", "x", ")", ",", "content", ")" ]
List all users from a specified customer id.
[ "List", "all", "users", "from", "a", "specified", "customer", "id", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L315-L318
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.update_customer
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)
python
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)
[ "def", "update_customer", "(", "self", ",", "customer_id", ",", "*", "*", "kwargs", ")", ":", "body", "=", "self", ".", "_formdata", "(", "kwargs", ",", "FastlyCustomer", ".", "FIELDS", ")", "content", "=", "self", ".", "_fetch", "(", "\"/customer/%s\"", "%", "customer_id", ",", "method", "=", "\"PUT\"", ",", "body", "=", "body", ")", "return", "FastlyCustomer", "(", "self", ",", "content", ")" ]
Update a customer.
[ "Update", "a", "customer", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L321-L325
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.delete_customer
def delete_customer(self, customer_id): """Delete a customer.""" content = self._fetch("/customer/%s" % customer_id, method="DELETE") return self._status(content)
python
def delete_customer(self, customer_id): """Delete a customer.""" content = self._fetch("/customer/%s" % customer_id, method="DELETE") return self._status(content)
[ "def", "delete_customer", "(", "self", ",", "customer_id", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/customer/%s\"", "%", "customer_id", ",", "method", "=", "\"DELETE\"", ")", "return", "self", ".", "_status", "(", "content", ")" ]
Delete a customer.
[ "Delete", "a", "customer", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L328-L331
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.list_directors
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)
python
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)
[ "def", "list_directors", "(", "self", ",", "service_id", ",", "version_number", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/director\"", "%", "(", "service_id", ",", "version_number", ")", ")", "return", "map", "(", "lambda", "x", ":", "FastlyDirector", "(", "self", ",", "x", ")", ",", "content", ")" ]
List the directors for a particular service and version.
[ "List", "the", "directors", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L334-L337
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.create_director
def create_director(self, service_id, version_number, name, quorum=75, _type=FastlyDirectorType.RANDOM, retries=5, shield=None): """Create a director for a particular service and version.""" 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)
python
def create_director(self, service_id, version_number, name, quorum=75, _type=FastlyDirectorType.RANDOM, retries=5, shield=None): """Create a director for a particular service and version.""" 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)
[ "def", "create_director", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ",", "quorum", "=", "75", ",", "_type", "=", "FastlyDirectorType", ".", "RANDOM", ",", "retries", "=", "5", ",", "shield", "=", "None", ")", ":", "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", ")" ]
Create a director for a particular service and version.
[ "Create", "a", "director", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L340-L356
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_director
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)
python
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)
[ "def", "get_director", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/director/%s\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")", ")", "return", "FastlyDirector", "(", "self", ",", "content", ")" ]
Get the director for a particular service and version.
[ "Get", "the", "director", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L359-L362
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.update_director
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)
python
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)
[ "def", "update_director", "(", "self", ",", "service_id", ",", "version_number", ",", "name_key", ",", "*", "*", "kwargs", ")", ":", "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", ")" ]
Update the director for a particular service and version.
[ "Update", "the", "director", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L365-L369
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_director_backend
def get_director_backend(self, service_id, version_number, director_name, backend_name): """Returns the relationship between a Backend and a Director. If the Backend has been associated with the Director, it returns a simple record indicating this. Otherwise, returns a 404.""" 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)
python
def get_director_backend(self, service_id, version_number, director_name, backend_name): """Returns the relationship between a Backend and a Director. If the Backend has been associated with the Director, it returns a simple record indicating this. Otherwise, returns a 404.""" 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)
[ "def", "get_director_backend", "(", "self", ",", "service_id", ",", "version_number", ",", "director_name", ",", "backend_name", ")", ":", "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", ")" ]
Returns the relationship between a Backend and a Director. If the Backend has been associated with the Director, it returns a simple record indicating this. Otherwise, returns a 404.
[ "Returns", "the", "relationship", "between", "a", "Backend", "and", "a", "Director", ".", "If", "the", "Backend", "has", "been", "associated", "with", "the", "Director", "it", "returns", "a", "simple", "record", "indicating", "this", ".", "Otherwise", "returns", "a", "404", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L378-L381
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.delete_director_backend
def delete_director_backend(self, service_id, version_number, director_name, backend_name): """Deletes the relationship between a Backend and a Director. The Backend is no longer considered a member of the Director and thus will not have traffic balanced onto it from this Director.""" 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)
python
def delete_director_backend(self, service_id, version_number, director_name, backend_name): """Deletes the relationship between a Backend and a Director. The Backend is no longer considered a member of the Director and thus will not have traffic balanced onto it from this Director.""" 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)
[ "def", "delete_director_backend", "(", "self", ",", "service_id", ",", "version_number", ",", "director_name", ",", "backend_name", ")", ":", "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", ")" ]
Deletes the relationship between a Backend and a Director. The Backend is no longer considered a member of the Director and thus will not have traffic balanced onto it from this Director.
[ "Deletes", "the", "relationship", "between", "a", "Backend", "and", "a", "Director", ".", "The", "Backend", "is", "no", "longer", "considered", "a", "member", "of", "the", "Director", "and", "thus", "will", "not", "have", "traffic", "balanced", "onto", "it", "from", "this", "Director", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L390-L393
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.list_domains
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)
python
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)
[ "def", "list_domains", "(", "self", ",", "service_id", ",", "version_number", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/domain\"", "%", "(", "service_id", ",", "version_number", ")", ")", "return", "map", "(", "lambda", "x", ":", "FastlyDomain", "(", "self", ",", "x", ")", ",", "content", ")" ]
List the domains for a particular service and version.
[ "List", "the", "domains", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L396-L399
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.create_domain
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)
python
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)
[ "def", "create_domain", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ",", "comment", "=", "None", ")", ":", "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", ")" ]
Create a domain for a particular service and version.
[ "Create", "a", "domain", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L402-L414
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_domain
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)
python
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)
[ "def", "get_domain", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/domain/%s\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")", ")", "return", "FastlyDomain", "(", "self", ",", "content", ")" ]
Get the domain for a particular service and version.
[ "Get", "the", "domain", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L417-L420
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.update_domain
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)
python
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)
[ "def", "update_domain", "(", "self", ",", "service_id", ",", "version_number", ",", "name_key", ",", "*", "*", "kwargs", ")", ":", "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", ")" ]
Update the domain for a particular service and version.
[ "Update", "the", "domain", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L423-L427
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.check_domain
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 for the domain. The second is the current CNAME of the domain. The third is a boolean indicating whether or not it has been properly setup to use Fastly.""" content = self._fetch("/service/%s/version/%d/domain/%s/check" % (service_id, version_number, name)) return FastlyDomainCheck(self, content)
python
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 for the domain. The second is the current CNAME of the domain. The third is a boolean indicating whether or not it has been properly setup to use Fastly.""" content = self._fetch("/service/%s/version/%d/domain/%s/check" % (service_id, version_number, name)) return FastlyDomainCheck(self, content)
[ "def", "check_domain", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/domain/%s/check\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")", ")", "return", "FastlyDomainCheck", "(", "self", ",", "content", ")" ]
Checks the status of a domain's DNS record. Returns an array of 3 items. The first is the details for the domain. The second is the current CNAME of the domain. The third is a boolean indicating whether or not it has been properly setup to use Fastly.
[ "Checks", "the", "status", "of", "a", "domain", "s", "DNS", "record", ".", "Returns", "an", "array", "of", "3", "items", ".", "The", "first", "is", "the", "details", "for", "the", "domain", ".", "The", "second", "is", "the", "current", "CNAME", "of", "the", "domain", ".", "The", "third", "is", "a", "boolean", "indicating", "whether", "or", "not", "it", "has", "been", "properly", "setup", "to", "use", "Fastly", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L436-L439
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.check_domains
def check_domains(self, service_id, version_number): """Checks the status of all domain DNS records for a Service Version. Returns an array items in the same format as the single domain /check.""" content = self._fetch("/service/%s/version/%d/domain/check_all" % (service_id, version_number)) return map(lambda x: FastlyDomainCheck(self, x), content)
python
def check_domains(self, service_id, version_number): """Checks the status of all domain DNS records for a Service Version. Returns an array items in the same format as the single domain /check.""" content = self._fetch("/service/%s/version/%d/domain/check_all" % (service_id, version_number)) return map(lambda x: FastlyDomainCheck(self, x), content)
[ "def", "check_domains", "(", "self", ",", "service_id", ",", "version_number", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/domain/check_all\"", "%", "(", "service_id", ",", "version_number", ")", ")", "return", "map", "(", "lambda", "x", ":", "FastlyDomainCheck", "(", "self", ",", "x", ")", ",", "content", ")" ]
Checks the status of all domain DNS records for a Service Version. Returns an array items in the same format as the single domain /check.
[ "Checks", "the", "status", "of", "all", "domain", "DNS", "records", "for", "a", "Service", "Version", ".", "Returns", "an", "array", "items", "in", "the", "same", "format", "as", "the", "single", "domain", "/", "check", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L442-L445
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_event_log
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)
python
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)
[ "def", "get_event_log", "(", "self", ",", "object_id", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/event_log/%s\"", "%", "object_id", ",", "method", "=", "\"GET\"", ")", "return", "FastlyEventLog", "(", "self", ",", "content", ")" ]
Get the specified event log.
[ "Get", "the", "specified", "event", "log", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L448-L451
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.list_headers
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)
python
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)
[ "def", "list_headers", "(", "self", ",", "service_id", ",", "version_number", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/header\"", "%", "(", "service_id", ",", "version_number", ")", ")", "return", "map", "(", "lambda", "x", ":", "FastlyHeader", "(", "self", ",", "x", ")", ",", "content", ")" ]
Retrieves all Header objects for a particular Version of a Service.
[ "Retrieves", "all", "Header", "objects", "for", "a", "particular", "Version", "of", "a", "Service", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L454-L457
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.create_header
def create_header(self, service_id, version_number, name, destination, source, _type=FastlyHeaderType.RESPONSE, action=FastlyHeaderAction.SET, regex=None, substitution=None, ignore_if_set=None, priority=10, response_condition=None, cache_condition=None, request_condition=None): body = self._formdata({ "name": name, "dst": destination, "src": source, "type": _type, "action": action, "regex": regex, "substitution": substitution, "ignore_if_set": ignore_if_set, "priority": priority, "response_condition": response_condition, "request_condition": request_condition, "cache_condition": cache_condition, }, FastlyHeader.FIELDS) """Creates a new Header object.""" content = self._fetch("/service/%s/version/%d/header" % (service_id, version_number), method="POST", body=body) return FastlyHeader(self, content)
python
def create_header(self, service_id, version_number, name, destination, source, _type=FastlyHeaderType.RESPONSE, action=FastlyHeaderAction.SET, regex=None, substitution=None, ignore_if_set=None, priority=10, response_condition=None, cache_condition=None, request_condition=None): body = self._formdata({ "name": name, "dst": destination, "src": source, "type": _type, "action": action, "regex": regex, "substitution": substitution, "ignore_if_set": ignore_if_set, "priority": priority, "response_condition": response_condition, "request_condition": request_condition, "cache_condition": cache_condition, }, FastlyHeader.FIELDS) """Creates a new Header object.""" content = self._fetch("/service/%s/version/%d/header" % (service_id, version_number), method="POST", body=body) return FastlyHeader(self, content)
[ "def", "create_header", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ",", "destination", ",", "source", ",", "_type", "=", "FastlyHeaderType", ".", "RESPONSE", ",", "action", "=", "FastlyHeaderAction", ".", "SET", ",", "regex", "=", "None", ",", "substitution", "=", "None", ",", "ignore_if_set", "=", "None", ",", "priority", "=", "10", ",", "response_condition", "=", "None", ",", "cache_condition", "=", "None", ",", "request_condition", "=", "None", ")", ":", "body", "=", "self", ".", "_formdata", "(", "{", "\"name\"", ":", "name", ",", "\"dst\"", ":", "destination", ",", "\"src\"", ":", "source", ",", "\"type\"", ":", "_type", ",", "\"action\"", ":", "action", ",", "\"regex\"", ":", "regex", ",", "\"substitution\"", ":", "substitution", ",", "\"ignore_if_set\"", ":", "ignore_if_set", ",", "\"priority\"", ":", "priority", ",", "\"response_condition\"", ":", "response_condition", ",", "\"request_condition\"", ":", "request_condition", ",", "\"cache_condition\"", ":", "cache_condition", ",", "}", ",", "FastlyHeader", ".", "FIELDS", ")", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/header\"", "%", "(", "service_id", ",", "version_number", ")", ",", "method", "=", "\"POST\"", ",", "body", "=", "body", ")", "return", "FastlyHeader", "(", "self", ",", "content", ")" ]
Creates a new Header object.
[ "Creates", "a", "new", "Header", "object", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L460-L477
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_header
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)
python
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)
[ "def", "get_header", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/header/%s\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")", ")", "return", "FastlyHeader", "(", "self", ",", "content", ")" ]
Retrieves a Header object by name.
[ "Retrieves", "a", "Header", "object", "by", "name", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L480-L483
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.update_header
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)
python
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)
[ "def", "update_header", "(", "self", ",", "service_id", ",", "version_number", ",", "name_key", ",", "*", "*", "kwargs", ")", ":", "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", ")" ]
Modifies an existing Header object by name.
[ "Modifies", "an", "existing", "Header", "object", "by", "name", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L486-L490
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.list_healthchecks
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)
python
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)
[ "def", "list_healthchecks", "(", "self", ",", "service_id", ",", "version_number", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/healthcheck\"", "%", "(", "service_id", ",", "version_number", ")", ")", "return", "map", "(", "lambda", "x", ":", "FastlyHealthCheck", "(", "self", ",", "x", ")", ",", "content", ")" ]
List all of the healthchecks for a particular service and version.
[ "List", "all", "of", "the", "healthchecks", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L499-L502
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.create_healthcheck
def create_healthcheck(self, service_id, version_number, name, host, method="HEAD", path="/", http_version="1.1", timeout=1000, check_interval=5000, expected_response=200, window=5, threshold=3, initial=1): """Create a healthcheck for a particular service and version.""" 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, }, FastlyHealthCheck.FIELDS) content = self._fetch("/service/%s/version/%d/healthcheck" % (service_id, version_number), method="POST", body=body) return FastlyHealthCheck(self, content)
python
def create_healthcheck(self, service_id, version_number, name, host, method="HEAD", path="/", http_version="1.1", timeout=1000, check_interval=5000, expected_response=200, window=5, threshold=3, initial=1): """Create a healthcheck for a particular service and version.""" 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, }, FastlyHealthCheck.FIELDS) content = self._fetch("/service/%s/version/%d/healthcheck" % (service_id, version_number), method="POST", body=body) return FastlyHealthCheck(self, content)
[ "def", "create_healthcheck", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ",", "host", ",", "method", "=", "\"HEAD\"", ",", "path", "=", "\"/\"", ",", "http_version", "=", "\"1.1\"", ",", "timeout", "=", "1000", ",", "check_interval", "=", "5000", ",", "expected_response", "=", "200", ",", "window", "=", "5", ",", "threshold", "=", "3", ",", "initial", "=", "1", ")", ":", "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", ",", "}", ",", "FastlyHealthCheck", ".", "FIELDS", ")", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/healthcheck\"", "%", "(", "service_id", ",", "version_number", ")", ",", "method", "=", "\"POST\"", ",", "body", "=", "body", ")", "return", "FastlyHealthCheck", "(", "self", ",", "content", ")" ]
Create a healthcheck for a particular service and version.
[ "Create", "a", "healthcheck", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L505-L534
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_healthcheck
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)
python
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)
[ "def", "get_healthcheck", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/healthcheck/%s\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")", ")", "return", "FastlyHealthCheck", "(", "self", ",", "content", ")" ]
Get the healthcheck for a particular service and version.
[ "Get", "the", "healthcheck", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L537-L540
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.purge_url
def purge_url(self, host, path): """Purge an individual URL.""" content = self._fetch(path, method="PURGE", headers={ "Host": host }) return FastlyPurge(self, content)
python
def purge_url(self, host, path): """Purge an individual URL.""" content = self._fetch(path, method="PURGE", headers={ "Host": host }) return FastlyPurge(self, content)
[ "def", "purge_url", "(", "self", ",", "host", ",", "path", ")", ":", "content", "=", "self", ".", "_fetch", "(", "path", ",", "method", "=", "\"PURGE\"", ",", "headers", "=", "{", "\"Host\"", ":", "host", "}", ")", "return", "FastlyPurge", "(", "self", ",", "content", ")" ]
Purge an individual URL.
[ "Purge", "an", "individual", "URL", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L556-L559
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.check_purge_status
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)
python
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)
[ "def", "check_purge_status", "(", "self", ",", "purge_id", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/purge?id=%s\"", "%", "purge_id", ")", "return", "map", "(", "lambda", "x", ":", "FastlyPurgeStatus", "(", "self", ",", "x", ")", ",", "content", ")" ]
Get the status and times of a recently completed purge.
[ "Get", "the", "status", "and", "times", "of", "a", "recently", "completed", "purge", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L562-L565
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.list_request_settings
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)
python
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)
[ "def", "list_request_settings", "(", "self", ",", "service_id", ",", "version_number", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/request_settings\"", "%", "(", "service_id", ",", "version_number", ")", ")", "return", "map", "(", "lambda", "x", ":", "FastlyRequestSetting", "(", "self", ",", "x", ")", ",", "content", ")" ]
Returns a list of all Request Settings objects for the given service and version.
[ "Returns", "a", "list", "of", "all", "Request", "Settings", "objects", "for", "the", "given", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L568-L571
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.create_request_setting
def create_request_setting(self, service_id, version_number, name, default_host=None, force_miss=None, force_ssl=None, action=None, bypass_busy_wait=None, max_stale_age=None, hash_keys=None, xff=None, timer_support=None, geo_headers=None, request_condition=None): """Creates a new Request Settings object.""" 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_headers": geo_headers, "request_condition": request_condition, }, FastlyRequestSetting.FIELDS) content = self._fetch("/service/%s/version/%d/request_settings" % (service_id, version_number), method="POST", body=body) return FastlyRequestSetting(self, content)
python
def create_request_setting(self, service_id, version_number, name, default_host=None, force_miss=None, force_ssl=None, action=None, bypass_busy_wait=None, max_stale_age=None, hash_keys=None, xff=None, timer_support=None, geo_headers=None, request_condition=None): """Creates a new Request Settings object.""" 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_headers": geo_headers, "request_condition": request_condition, }, FastlyRequestSetting.FIELDS) content = self._fetch("/service/%s/version/%d/request_settings" % (service_id, version_number), method="POST", body=body) return FastlyRequestSetting(self, content)
[ "def", "create_request_setting", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ",", "default_host", "=", "None", ",", "force_miss", "=", "None", ",", "force_ssl", "=", "None", ",", "action", "=", "None", ",", "bypass_busy_wait", "=", "None", ",", "max_stale_age", "=", "None", ",", "hash_keys", "=", "None", ",", "xff", "=", "None", ",", "timer_support", "=", "None", ",", "geo_headers", "=", "None", ",", "request_condition", "=", "None", ")", ":", "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_headers\"", ":", "geo_headers", ",", "\"request_condition\"", ":", "request_condition", ",", "}", ",", "FastlyRequestSetting", ".", "FIELDS", ")", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/request_settings\"", "%", "(", "service_id", ",", "version_number", ")", ",", "method", "=", "\"POST\"", ",", "body", "=", "body", ")", "return", "FastlyRequestSetting", "(", "self", ",", "content", ")" ]
Creates a new Request Settings object.
[ "Creates", "a", "new", "Request", "Settings", "object", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L574-L605
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_request_setting
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)
python
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)
[ "def", "get_request_setting", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/request_settings/%s\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")", ")", "return", "FastlyRequestSetting", "(", "self", ",", "content", ")" ]
Gets the specified Request Settings object.
[ "Gets", "the", "specified", "Request", "Settings", "object", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L608-L611
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.update_request_setting
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)
python
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)
[ "def", "update_request_setting", "(", "self", ",", "service_id", ",", "version_number", ",", "name_key", ",", "*", "*", "kwargs", ")", ":", "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", ")" ]
Updates the specified Request Settings object.
[ "Updates", "the", "specified", "Request", "Settings", "object", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L614-L618
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.list_response_objects
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)
python
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)
[ "def", "list_response_objects", "(", "self", ",", "service_id", ",", "version_number", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/response_object\"", "%", "(", "service_id", ",", "version_number", ")", ")", "return", "map", "(", "lambda", "x", ":", "FastlyResponseObject", "(", "self", ",", "x", ")", ",", "content", ")" ]
Returns all Response Objects for the specified service and version.
[ "Returns", "all", "Response", "Objects", "for", "the", "specified", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L627-L630
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.create_response_object
def create_response_object(self, service_id, version_number, name, status="200", response="OK", content="", request_condition=None, cache_condition=None): """Creates a new Response Object.""" 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_number), method="POST", body=body) return FastlyResponseObject(self, content)
python
def create_response_object(self, service_id, version_number, name, status="200", response="OK", content="", request_condition=None, cache_condition=None): """Creates a new Response Object.""" 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_number), method="POST", body=body) return FastlyResponseObject(self, content)
[ "def", "create_response_object", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ",", "status", "=", "\"200\"", ",", "response", "=", "\"OK\"", ",", "content", "=", "\"\"", ",", "request_condition", "=", "None", ",", "cache_condition", "=", "None", ")", ":", "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_number", ")", ",", "method", "=", "\"POST\"", ",", "body", "=", "body", ")", "return", "FastlyResponseObject", "(", "self", ",", "content", ")" ]
Creates a new Response Object.
[ "Creates", "a", "new", "Response", "Object", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L633-L644
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_response_object
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)
python
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)
[ "def", "get_response_object", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/response_object/%s\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")", ")", "return", "FastlyResponseObject", "(", "self", ",", "content", ")" ]
Gets the specified Response Object.
[ "Gets", "the", "specified", "Response", "Object", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L647-L650
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.update_response_object
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)
python
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)
[ "def", "update_response_object", "(", "self", ",", "service_id", ",", "version_number", ",", "name_key", ",", "*", "*", "kwargs", ")", ":", "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", ")" ]
Updates the specified Response Object.
[ "Updates", "the", "specified", "Response", "Object", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L653-L657
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.create_service
def create_service(self, customer_id, name, publish_key=None, comment=None): """Create a service.""" body = self._formdata({ "customer_id": customer_id, "name": name, "publish_key": publish_key, "comment": comment, }, FastlyService.FIELDS) content = self._fetch("/service", method="POST", body=body) return FastlyService(self, content)
python
def create_service(self, customer_id, name, publish_key=None, comment=None): """Create a service.""" body = self._formdata({ "customer_id": customer_id, "name": name, "publish_key": publish_key, "comment": comment, }, FastlyService.FIELDS) content = self._fetch("/service", method="POST", body=body) return FastlyService(self, content)
[ "def", "create_service", "(", "self", ",", "customer_id", ",", "name", ",", "publish_key", "=", "None", ",", "comment", "=", "None", ")", ":", "body", "=", "self", ".", "_formdata", "(", "{", "\"customer_id\"", ":", "customer_id", ",", "\"name\"", ":", "name", ",", "\"publish_key\"", ":", "publish_key", ",", "\"comment\"", ":", "comment", ",", "}", ",", "FastlyService", ".", "FIELDS", ")", "content", "=", "self", ".", "_fetch", "(", "\"/service\"", ",", "method", "=", "\"POST\"", ",", "body", "=", "body", ")", "return", "FastlyService", "(", "self", ",", "content", ")" ]
Create a service.
[ "Create", "a", "service", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L666-L675
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.list_services
def list_services(self): """List Services.""" content = self._fetch("/service") return map(lambda x: FastlyService(self, x), content)
python
def list_services(self): """List Services.""" content = self._fetch("/service") return map(lambda x: FastlyService(self, x), content)
[ "def", "list_services", "(", "self", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service\"", ")", "return", "map", "(", "lambda", "x", ":", "FastlyService", "(", "self", ",", "x", ")", ",", "content", ")" ]
List Services.
[ "List", "Services", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L678-L681
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_service
def get_service(self, service_id): """Get a specific service by id.""" content = self._fetch("/service/%s" % service_id) return FastlyService(self, content)
python
def get_service(self, service_id): """Get a specific service by id.""" content = self._fetch("/service/%s" % service_id) return FastlyService(self, content)
[ "def", "get_service", "(", "self", ",", "service_id", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s\"", "%", "service_id", ")", "return", "FastlyService", "(", "self", ",", "content", ")" ]
Get a specific service by id.
[ "Get", "a", "specific", "service", "by", "id", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L684-L687
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_service_details
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)
python
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)
[ "def", "get_service_details", "(", "self", ",", "service_id", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/details\"", "%", "service_id", ")", "return", "FastlyService", "(", "self", ",", "content", ")" ]
List detailed information on a specified service.
[ "List", "detailed", "information", "on", "a", "specified", "service", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L690-L693
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_service_by_name
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)
python
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)
[ "def", "get_service_by_name", "(", "self", ",", "service_name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/search?name=%s\"", "%", "service_name", ")", "return", "FastlyService", "(", "self", ",", "content", ")" ]
Get a specific service by name.
[ "Get", "a", "specific", "service", "by", "name", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L696-L699
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.update_service
def update_service(self, service_id, **kwargs): """Update a service.""" body = self._formdata(kwargs, FastlyService.FIELDS) content = self._fetch("/service/%s" % service_id, method="PUT", body=body) return FastlyService(self, content)
python
def update_service(self, service_id, **kwargs): """Update a service.""" body = self._formdata(kwargs, FastlyService.FIELDS) content = self._fetch("/service/%s" % service_id, method="PUT", body=body) return FastlyService(self, content)
[ "def", "update_service", "(", "self", ",", "service_id", ",", "*", "*", "kwargs", ")", ":", "body", "=", "self", ".", "_formdata", "(", "kwargs", ",", "FastlyService", ".", "FIELDS", ")", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s\"", "%", "service_id", ",", "method", "=", "\"PUT\"", ",", "body", "=", "body", ")", "return", "FastlyService", "(", "self", ",", "content", ")" ]
Update a service.
[ "Update", "a", "service", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L702-L706
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.delete_service
def delete_service(self, service_id): """Delete a service.""" content = self._fetch("/service/%s" % service_id, method="DELETE") return self._status(content)
python
def delete_service(self, service_id): """Delete a service.""" content = self._fetch("/service/%s" % service_id, method="DELETE") return self._status(content)
[ "def", "delete_service", "(", "self", ",", "service_id", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s\"", "%", "service_id", ",", "method", "=", "\"DELETE\"", ")", "return", "self", ".", "_status", "(", "content", ")" ]
Delete a service.
[ "Delete", "a", "service", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L709-L712
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.list_domains_by_service
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)
python
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)
[ "def", "list_domains_by_service", "(", "self", ",", "service_id", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/domain\"", "%", "service_id", ",", "method", "=", "\"GET\"", ")", "return", "map", "(", "lambda", "x", ":", "FastlyDomain", "(", "self", ",", "x", ")", ",", "content", ")" ]
List the domains within a service.
[ "List", "the", "domains", "within", "a", "service", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L715-L718
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.purge_service
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)
python
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)
[ "def", "purge_service", "(", "self", ",", "service_id", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/purge_all\"", "%", "service_id", ",", "method", "=", "\"POST\"", ")", "return", "self", ".", "_status", "(", "content", ")" ]
Purge everything from a service.
[ "Purge", "everything", "from", "a", "service", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L721-L724
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.purge_service_by_key
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)
python
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)
[ "def", "purge_service_by_key", "(", "self", ",", "service_id", ",", "key", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/purge/%s\"", "%", "(", "service_id", ",", "key", ")", ",", "method", "=", "\"POST\"", ")", "return", "self", ".", "_status", "(", "content", ")" ]
Purge a particular service by a key.
[ "Purge", "a", "particular", "service", "by", "a", "key", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L727-L730
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_settings
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)
python
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)
[ "def", "get_settings", "(", "self", ",", "service_id", ",", "version_number", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/settings\"", "%", "(", "service_id", ",", "version_number", ")", ")", "return", "FastlySettings", "(", "self", ",", "content", ")" ]
Get the settings for a particular service and version.
[ "Get", "the", "settings", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L733-L736
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.update_settings
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)
python
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)
[ "def", "update_settings", "(", "self", ",", "service_id", ",", "version_number", ",", "settings", "=", "{", "}", ")", ":", "body", "=", "urllib", ".", "urlencode", "(", "settings", ")", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/settings\"", "%", "(", "service_id", ",", "version_number", ")", ",", "method", "=", "\"PUT\"", ",", "body", "=", "body", ")", "return", "FastlySettings", "(", "self", ",", "content", ")" ]
Update the settings for a particular service and version.
[ "Update", "the", "settings", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L739-L743
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_stats
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
python
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
[ "def", "get_stats", "(", "self", ",", "service_id", ",", "stat_type", "=", "FastlyStatsType", ".", "ALL", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/stats/%s\"", "%", "(", "service_id", ",", "stat_type", ")", ")", "return", "content" ]
Get the stats from a service.
[ "Get", "the", "stats", "from", "a", "service", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L746-L749
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.list_syslogs
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)
python
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)
[ "def", "list_syslogs", "(", "self", ",", "service_id", ",", "version_number", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/syslog\"", "%", "(", "service_id", ",", "version_number", ")", ")", "return", "map", "(", "lambda", "x", ":", "FastlySyslog", "(", "self", ",", "x", ")", ",", "content", ")" ]
List all of the Syslogs for a particular service and version.
[ "List", "all", "of", "the", "Syslogs", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L752-L755
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.create_syslog
def create_syslog(self, service_id, version_number, name, address, port=514, use_tls="0", tls_ca_cert=None, token=None, _format=None, response_condition=None): """Create a Syslog for a particular service and version.""" 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, version_number), method="POST", body=body) return FastlySyslog(self, content)
python
def create_syslog(self, service_id, version_number, name, address, port=514, use_tls="0", tls_ca_cert=None, token=None, _format=None, response_condition=None): """Create a Syslog for a particular service and version.""" 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, version_number), method="POST", body=body) return FastlySyslog(self, content)
[ "def", "create_syslog", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ",", "address", ",", "port", "=", "514", ",", "use_tls", "=", "\"0\"", ",", "tls_ca_cert", "=", "None", ",", "token", "=", "None", ",", "_format", "=", "None", ",", "response_condition", "=", "None", ")", ":", "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", ",", "version_number", ")", ",", "method", "=", "\"POST\"", ",", "body", "=", "body", ")", "return", "FastlySyslog", "(", "self", ",", "content", ")" ]
Create a Syslog for a particular service and version.
[ "Create", "a", "Syslog", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L758-L781
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_syslog
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)
python
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)
[ "def", "get_syslog", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/syslog/%s\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")", ")", "return", "FastlySyslog", "(", "self", ",", "content", ")" ]
Get the Syslog for a particular service and version.
[ "Get", "the", "Syslog", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L784-L787
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.update_syslog
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)
python
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)
[ "def", "update_syslog", "(", "self", ",", "service_id", ",", "version_number", ",", "name_key", ",", "*", "*", "kwargs", ")", ":", "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", ")" ]
Update the Syslog for a particular service and version.
[ "Update", "the", "Syslog", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L790-L794
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.change_password
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)
python
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)
[ "def", "change_password", "(", "self", ",", "old_password", ",", "new_password", ")", ":", "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", ")" ]
Update the user's password to a new one.
[ "Update", "the", "user", "s", "password", "to", "a", "new", "one", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L803-L810
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_user
def get_user(self, user_id): """Get a specific user.""" content = self._fetch("/user/%s" % user_id) return FastlyUser(self, content)
python
def get_user(self, user_id): """Get a specific user.""" content = self._fetch("/user/%s" % user_id) return FastlyUser(self, content)
[ "def", "get_user", "(", "self", ",", "user_id", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/user/%s\"", "%", "user_id", ")", "return", "FastlyUser", "(", "self", ",", "content", ")" ]
Get a specific user.
[ "Get", "a", "specific", "user", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L819-L822
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.create_user
def create_user(self, customer_id, name, login, password, role=FastlyRoles.USER, require_new_password=True): """Create a user.""" body = self._formdata({ "customer_id": customer_id, "name": name, "login": login, "password": password, "role": role, "require_new_password": require_new_password, }, FastlyUser.FIELDS) content = self._fetch("/user", method="POST", body=body) return FastlyUser(self, content)
python
def create_user(self, customer_id, name, login, password, role=FastlyRoles.USER, require_new_password=True): """Create a user.""" body = self._formdata({ "customer_id": customer_id, "name": name, "login": login, "password": password, "role": role, "require_new_password": require_new_password, }, FastlyUser.FIELDS) content = self._fetch("/user", method="POST", body=body) return FastlyUser(self, content)
[ "def", "create_user", "(", "self", ",", "customer_id", ",", "name", ",", "login", ",", "password", ",", "role", "=", "FastlyRoles", ".", "USER", ",", "require_new_password", "=", "True", ")", ":", "body", "=", "self", ".", "_formdata", "(", "{", "\"customer_id\"", ":", "customer_id", ",", "\"name\"", ":", "name", ",", "\"login\"", ":", "login", ",", "\"password\"", ":", "password", ",", "\"role\"", ":", "role", ",", "\"require_new_password\"", ":", "require_new_password", ",", "}", ",", "FastlyUser", ".", "FIELDS", ")", "content", "=", "self", ".", "_fetch", "(", "\"/user\"", ",", "method", "=", "\"POST\"", ",", "body", "=", "body", ")", "return", "FastlyUser", "(", "self", ",", "content", ")" ]
Create a user.
[ "Create", "a", "user", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L825-L836
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.update_user
def update_user(self, user_id, **kwargs): """Update a user.""" body = self._formdata(kwargs, FastlyUser.FIELDS) content = self._fetch("/user/%s" % user_id, method="PUT", body=body) return FastlyUser(self, content)
python
def update_user(self, user_id, **kwargs): """Update a user.""" body = self._formdata(kwargs, FastlyUser.FIELDS) content = self._fetch("/user/%s" % user_id, method="PUT", body=body) return FastlyUser(self, content)
[ "def", "update_user", "(", "self", ",", "user_id", ",", "*", "*", "kwargs", ")", ":", "body", "=", "self", ".", "_formdata", "(", "kwargs", ",", "FastlyUser", ".", "FIELDS", ")", "content", "=", "self", ".", "_fetch", "(", "\"/user/%s\"", "%", "user_id", ",", "method", "=", "\"PUT\"", ",", "body", "=", "body", ")", "return", "FastlyUser", "(", "self", ",", "content", ")" ]
Update a user.
[ "Update", "a", "user", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L839-L843
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.delete_user
def delete_user(self, user_id): """Delete a user.""" content = self._fetch("/user/%s" % user_id, method="DELETE") return self._status(content)
python
def delete_user(self, user_id): """Delete a user.""" content = self._fetch("/user/%s" % user_id, method="DELETE") return self._status(content)
[ "def", "delete_user", "(", "self", ",", "user_id", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/user/%s\"", "%", "user_id", ",", "method", "=", "\"DELETE\"", ")", "return", "self", ".", "_status", "(", "content", ")" ]
Delete a user.
[ "Delete", "a", "user", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L846-L849
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.request_password_reset
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)
python
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)
[ "def", "request_password_reset", "(", "self", ",", "user_id", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/user/%s/password/request_reset\"", "%", "(", "user_id", ")", ",", "method", "=", "\"POST\"", ")", "return", "FastlyUser", "(", "self", ",", "content", ")" ]
Requests a password reset for the specified user.
[ "Requests", "a", "password", "reset", "for", "the", "specified", "user", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L852-L855
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.list_vcls
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)
python
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)
[ "def", "list_vcls", "(", "self", ",", "service_id", ",", "version_number", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/vcl\"", "%", "(", "service_id", ",", "version_number", ")", ")", "return", "map", "(", "lambda", "x", ":", "FastlyVCL", "(", "self", ",", "x", ")", ",", "content", ")" ]
List the uploaded VCLs for a particular service and version.
[ "List", "the", "uploaded", "VCLs", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L858-L861
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.upload_vcl
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)
python
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)
[ "def", "upload_vcl", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ",", "content", ",", "main", "=", "None", ",", "comment", "=", "None", ")", ":", "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", ")" ]
Upload a VCL for a particular service and version.
[ "Upload", "a", "VCL", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L864-L873
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_vcl
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)
python
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)
[ "def", "get_vcl", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ",", "include_content", "=", "True", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/vcl/%s?include_content=%d\"", "%", "(", "service_id", ",", "version_number", ",", "name", ",", "int", "(", "include_content", ")", ")", ")", "return", "FastlyVCL", "(", "self", ",", "content", ")" ]
Get the uploaded VCL for a particular service and version.
[ "Get", "the", "uploaded", "VCL", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L882-L885
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_vcl_html
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)
python
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)
[ "def", "get_vcl_html", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/vcl/%s/content\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")", ")", "return", "content", ".", "get", "(", "\"content\"", ",", "None", ")" ]
Get the uploaded VCL for a particular service and version with HTML syntax highlighting.
[ "Get", "the", "uploaded", "VCL", "for", "a", "particular", "service", "and", "version", "with", "HTML", "syntax", "highlighting", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L888-L891
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_generated_vcl
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)
python
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)
[ "def", "get_generated_vcl", "(", "self", ",", "service_id", ",", "version_number", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/generated_vcl\"", "%", "(", "service_id", ",", "version_number", ")", ")", "return", "FastlyVCL", "(", "self", ",", "content", ")" ]
Display the generated VCL for a particular service and version.
[ "Display", "the", "generated", "VCL", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L894-L897
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.get_generated_vcl_html
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)
python
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)
[ "def", "get_generated_vcl_html", "(", "self", ",", "service_id", ",", "version_number", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/generated_vcl/content\"", "%", "(", "service_id", ",", "version_number", ")", ")", "return", "content", ".", "get", "(", "\"content\"", ",", "None", ")" ]
Display the content of generated VCL with HTML syntax highlighting.
[ "Display", "the", "content", "of", "generated", "VCL", "with", "HTML", "syntax", "highlighting", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L900-L903
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.set_main_vcl
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)
python
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)
[ "def", "set_main_vcl", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/vcl/%s/main\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")", ",", "method", "=", "\"PUT\"", ")", "return", "FastlyVCL", "(", "self", ",", "content", ")" ]
Set the specified VCL as the main.
[ "Set", "the", "specified", "VCL", "as", "the", "main", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L906-L909
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.update_vcl
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)
python
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)
[ "def", "update_vcl", "(", "self", ",", "service_id", ",", "version_number", ",", "name_key", ",", "*", "*", "kwargs", ")", ":", "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", ")" ]
Update the uploaded VCL for a particular service and version.
[ "Update", "the", "uploaded", "VCL", "for", "a", "particular", "service", "and", "version", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L912-L916
obulpathi/cdn-fastly-python
fastly/__init__.py
FastlyConnection.create_version
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)
python
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)
[ "def", "create_version", "(", "self", ",", "service_id", ",", "inherit_service_id", "=", "None", ",", "comment", "=", "None", ")", ":", "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", ")" ]
Create a version for a particular service.
[ "Create", "a", "version", "for", "a", "particular", "service", "." ]
train
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L925-L933