def all(self, get_all=False, **queryparams):

self.folder_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(), **queryparams)<EOL><DEDENT>

Get all folders used to organize templates.

:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


if '<STR_LIT:name>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>response = self._mc_client._post(url=self._build_path(), data=data)<EOL>if response is not None:<EOL><INDENT>self.folder_id = response['<STR_LIT:id>']<EOL><DEDENT>else:<EOL><INDENT>self.folder_id = None<EOL><DEDENT>return response<EOL>

Create a new template folder.

:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "name": string*
}


def get(self, workflow_id, **queryparams):

self.workflow_id = workflow_id<EOL>return self._mc_client._get(url=self._build_path(workflow_id), **queryparams)<EOL>

Get a summary of an individual Automation workflow’s settings and
content. The trigger_settings object returns information for the first
email in the workflow.

:param workflow_id: The unique id for the Automation workflow
:type workflow_id: :py:class:`str`
:param queryparams: the query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


super(Automations, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.workflow_id = None<EOL>self.actions = AutomationActions(self)<EOL>self.emails = AutomationEmails(self)<EOL>self.removed_subscribers = AutomationRemovedSubscribers(self)<EOL>


self.workflow_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(), **queryparams)<EOL><DEDENT>

Get a summary of an account’s Automations.

:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: the query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


self.workflow_id = workflow_id<EOL>self.email_id = email_id<EOL>return self._mc_client._get(url=self._build_path(workflow_id, '<STR_LIT>', email_id))<EOL>

Get information about an individual Automation workflow email.

:param workflow_id: The unique id for the Automation workflow.
:type workflow_id: :py:class:`str`
:param email_id: The unique id for the Automation workflow email.
:type email_id: :py:class:`str`


def all(self, workflow_id, get_all=False, **queryparams):

self.workflow_id = workflow_id<EOL>self.email_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(workflow_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(workflow_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get a summary of the emails in an Automation workflow.

:param workflow_id: The unique id for the Automation workflow.
:type workflow_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: the query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


super(AutomationEmails, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.workflow_id = None<EOL>self.email_id = None<EOL>self.actions = AutomationEmailActions(self)<EOL>self.queues = AutomationEmailQueues(self)<EOL>


self.workflow_id = workflow_id<EOL>self.email_id = email_id<EOL>self.subscriber_hash = None<EOL>return self._mc_client._get(url=self._build_path(workflow_id, '<STR_LIT>', email_id, '<STR_LIT>'))<EOL>

Get information about an Automation email queue.

:param workflow_id: The unique id for the Automation workflow.
:type workflow_id: :py:class:`str`
:param email_id: The unique id for the Automation workflow email.
:type email_id: :py:class:`str`


super(AutomationEmailQueues, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.workflow_id = None<EOL>self.email_id = None<EOL>self.subscriber_hash = None<EOL>


return self._mc_client._get(url=self._build_path(), **queryparams)<EOL>

Search all campaigns for the specified query terms.

:param queryparams: The query string parameters
queryparams['fields'] = array
queryparams['exclude_fields'] = array
queryparams['query'] = string
queryparams['snip_start'] = string
queryparams['snip_end'] = string
queryparams['offset'] = integer


super(TemplateDefaultContent, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.template_id = None<EOL>


self.template_id = template_id<EOL>return self._mc_client._delete(url=self._build_path(template_id))<EOL>

Delete a specific template.

:param template_id: The unique id for the template.
:type template_id: :py:class:`str`


self.template_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(), **queryparams)<EOL><DEDENT>

Get a list of an account’s available templates.

:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer
queryparams['created_by'] = string
queryparams['before_created_at'] = string
queryparams['since_created_at'] = string
queryparams['type'] = string
queryparams['folder_id'] = string


return self._mc_client._get(url=self._build_path(list_id, '<STR_LIT>', segment_id))<EOL>


def update(self, list_id, segment_id, data):

return self._mc_client._patch(url=self._build_path(list_id, '<STR_LIT>', segment_id), data=data)<EOL>


return self._mc_client._post(url=self._build_path(list_id, '<STR_LIT>'), data=data)<EOL>


self.file_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(), **queryparams)<EOL><DEDENT>

Get a list of available images and files stored in the File Manager for the account.

:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer
queryparams['type'] = string
queryparams['created_by'] = string
queryparams['before_created_at'] = string
queryparams['since_created_at'] = string
queryparams['sort_field'] = string
queryparams['sort_dir'] = string


self.file_id = file_id<EOL>return self._mc_client._delete(url=self._build_path(file_id))<EOL>

Remove a specific file from the File Manager.

:param file_id: The unique id for the File Manager file.
:type file_id: :py:class:`str`


self.file_id = file_id<EOL>if '<STR_LIT:name>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>return self._mc_client._patch(url=self._build_path(file_id), data=data)<EOL>

Update a file in the File Manager.

:param file_id: The unique id for the File Manager file.
:type file_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "name": string*,
    "file_data": string*
}


self.file_id = file_id<EOL>return self._mc_client._get(url=self._build_path(file_id), **queryparams)<EOL>

Get information about a specific file in the File Manager.

:param file_id: The unique id for the File Manager file.
:type file_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


def all(self, list_id, segment_id, get_all=False, **queryparams):

self.list_id = list_id<EOL>self.segment_id = segment_id<EOL>self.subscriber_hash = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(list_id, '<STR_LIT>', segment_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(list_id, '<STR_LIT>', segment_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get information about members in a saved segment.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param segment_id: The unique id for the segment.
:type segment_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


def all(self, campaign_id, get_all=False, **queryparams):

self.campaign_id = campaign_id<EOL>self.subscriber_hash = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(campaign_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(campaign_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get a list of member’s subscriber activity in a specific campaign.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


if '<STR_LIT:url>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>response = self._mc_client._post(url=self._build_path(), data=data)<EOL>if response is not None:<EOL><INDENT>self.batch_webhook_id = response['<STR_LIT:id>']<EOL><DEDENT>else:<EOL><INDENT>self.batch_webhook_id = None<EOL><DEDENT>return response<EOL>

Configure a webhook that will fire whenever any batch request
completes processing.

:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "url": string*
}


super(ReportSubReports, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.campaign_id = None<EOL>


super(ReportCampaignAbuseReports, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.campaign_id = None<EOL>self.report_id = None<EOL>


def all(self, campaign_id, **queryparams):

self.campaign_id = campaign_id<EOL>self.report_id = None<EOL>return self._mc_client._get(url=self._build_path(campaign_id, '<STR_LIT>'), **queryparams)<EOL>

Get a list of abuse complaints for a specific campaign.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


self.app_id = app_id<EOL>return self._mc_client._get(url=self._build_path(app_id), **queryparams)<EOL>

Get information about a specific authorized application

:param app_id: The unique id for the connected authorized application
:type app_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


self.app_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(), **queryparams)<EOL><DEDENT>

Get a list of an account’s registered, connected applications.

:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


if '<STR_LIT:id>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT:name>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if not re.match(r"<STR_LIT>", data['<STR_LIT>']):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>response = self._mc_client._post(url=self._build_path(), data=data)<EOL>if response is not None:<EOL><INDENT>self.store_id = response['<STR_LIT:id>']<EOL><DEDENT>else:<EOL><INDENT>self.store_id = None<EOL><DEDENT>return response<EOL>

Add a new store to your MailChimp account.

Error checking on the currency code verifies that it is in the correct
three-letter, all-caps format as specified by ISO 4217 but does not
check that it is a valid code as the list of valid codes changes over
time.

:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "id": string*,
    "list_id": string*,
    "name": string*,
    "currency_code": string*
}


super(Stores, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.store_id = None<EOL>self.carts = StoreCarts(self)<EOL>self.customers = StoreCustomers(self)<EOL>self.orders = StoreOrders(self)<EOL>self.products = StoreProducts(self)<EOL>


self.store_id = store_id<EOL>return self._mc_client._delete(url=self._build_path(store_id))<EOL>

Delete a store. Deleting a store will also delete any associated
subresources, including Customers, Orders, Products, and Carts.

:param store_id: The store id.
:type store_id: :py:class:`str`


self.store_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(), **queryparams)<EOL><DEDENT>

Get information about all stores in the account.

:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


def all(self, campaign_id, link_id, get_all=False, **queryparams):

self.campaign_id = campaign_id<EOL>self.link_id = link_id<EOL>self.subscriber_hash = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(campaign_id, '<STR_LIT>', link_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(<EOL>url=self._build_path(campaign_id, '<STR_LIT>', link_id, '<STR_LIT>'),<EOL>**queryparams<EOL>)<EOL><DEDENT>

Get information about list members who clicked on a specific link in a
campaign.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param link_id: The id for the link.
:type link_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


def update(self, store_id, cart_id, data):

self.store_id = store_id<EOL>self.cart_id = cart_id<EOL>return self._mc_client._patch(url=self._build_path(store_id, '<STR_LIT>', cart_id), data=data)<EOL>

Update a specific cart.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param cart_id: The id for the cart.
:type cart_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`


super(StoreCarts, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.store_id = None<EOL>self.cart_id = None<EOL>self.lines = StoreCartLines(self)<EOL>


def all(self, store_id, get_all=False, **queryparams):

self.store_id = store_id<EOL>self.cart_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(store_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(store_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get information about a store’s carts.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


def get(self, store_id, cart_id, **queryparams):

self.store_id = store_id<EOL>self.cart_id = cart_id<EOL>return self._mc_client._get(url=self._build_path(store_id, '<STR_LIT>', cart_id), **queryparams)<EOL>

Get information about a specific cart.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param cart_id: The id for the cart.
:type cart_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


def update(self, store_id, product_id, data):

self.store_id = store_id<EOL>self.product_id = product_id<EOL>return self._mc_client._patch(<EOL>url=self._build_path(store_id, '<STR_LIT>', product_id),<EOL>data=data<EOL>)<EOL>

Update a product.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param product_id: The id for the product of a store.
:type product_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`


super(StoreProducts, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.store_id = None<EOL>self.product_id = None<EOL>self.images = StoreProductImages(self)<EOL>self.variants = StoreProductVariants(self)<EOL>


self.store_id = store_id<EOL>self.product_id = product_id<EOL>return self._mc_client._delete(url=self._build_path(store_id, '<STR_LIT>', product_id))<EOL>

Delete a product.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param product_id: The id for the product of a store.
:type product_id: :py:class:`str`


def all(self, list_id, get_all=False, **queryparams):

self.list_id = list_id<EOL>self.month = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(list_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(list_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get a month-by-month summary of a specific list’s growth activity.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


super(Conversations, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.conversation_id = None<EOL>self.messages = ConversationMessages(self)<EOL>


def get(self, conversation_id, **queryparams):

self.conversation_id = conversation_id<EOL>return self._mc_client._get(url=self._build_path(conversation_id), **queryparams)<EOL>

Get details about an individual conversation.

:param conversation_id: The unique id for the conversation.
:type conversation_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


self.workflow_id = workflow_id<EOL>return self._mc_client._post(url=self._build_path(workflow_id, '<STR_LIT>'))<EOL>

Pause all emails in a specific Automation workflow.

:param workflow_id: The unique id for the Automation workflow.
:type workflow_id: :py:class:`str`


super(ReportLocations, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.campaign_id = None<EOL>


self.campaign_id = campaign_id<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(campaign_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(campaign_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get top open locations for a specific campaign.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


self.campaign_id = campaign_id<EOL>return self._mc_client._get(url=self._build_path(campaign_id, '<STR_LIT>'), **queryparams)<EOL>

Get statistics for the top-performing email domains in a campaign.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


super(StoreOrderLines, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.store_id = None<EOL>self.order_id = None<EOL>self.line_id = None<EOL>


def all(self, store_id, order_id, get_all=False, **queryparams):

self.store_id = store_id<EOL>self.order_id = order_id<EOL>self.line_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(store_id, '<STR_LIT>', order_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(store_id, '<STR_LIT>', order_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get information about an order’s line items.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param order_id: The id for the order in a store.
:type order_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


def get(self, store_id, order_id, line_id, **queryparams):

self.store_id = store_id<EOL>self.order_id = order_id<EOL>self.line_id = line_id<EOL>return self._mc_client._get(url=self._build_path(store_id, '<STR_LIT>', order_id, '<STR_LIT>', line_id), **queryparams)<EOL>

Get information about a specific order line item.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param order_id: The id for the order in a store.
:type order_id: :py:class:`str`
:param line_id: The id for the line item of a cart.
:type line_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


def update(self, campaign_id, feedback_id, data):

self.campaign_id = campaign_id<EOL>self.feedback_id = feedback_id<EOL>if '<STR_LIT:message>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>return self._mc_client._patch(url=self._build_path(campaign_id, '<STR_LIT>', feedback_id), data=data)<EOL>

Update a specific feedback message for a campaign.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param feedback_id: The unique id for the feedback message.
:type feedback_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "message": string*
}


self.campaign_id = campaign_id<EOL>self.feedback_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(campaign_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(campaign_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get team feedback while you’re working together on a MailChimp
campaign.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


super(CampaignFeedback, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.campaign_id = None<EOL>self.feedback_id = None<EOL>


def delete(self, campaign_id, feedback_id):

self.campaign_id = campaign_id<EOL>self.feedback_id = feedback_id<EOL>return self._mc_client._delete(url=self._build_path(campaign_id, '<STR_LIT>', feedback_id))<EOL>

Remove a specific feedback message for a campaign.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param feedback_id: The unique id for the feedback message.
:type feedback_id: :py:class:`str`


def all(self, campaign_id, get_all=False,  **queryparams):

Get detailed information about any campaign emails that were opened by a list member.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer
queryparams['since'] = str


def all(self, conversation_id, **queryparams):

self.conversation_id = conversation_id<EOL>self.message_id = None<EOL>return self._mc_client._get(url=self._build_path(conversation_id, '<STR_LIT>'), **queryparams)<EOL>

Get messages from a specific conversation.

This endpoint does not currently support count and offset, preventing
it from having the get_all parameter that most all() methods have

:param conversation_id: The unique id for the conversation.
:type conversation_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = p[
queryparams['is_read'] = string
queryparams['before_timestamp'] = string
queryparams['since_timestamp'] = string


def create(self, conversation_id, data):

self.conversation_id = conversation_id<EOL>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>check_email(data['<STR_LIT>'])<EOL>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if data['<STR_LIT>'] not in [True, False]:<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>response =  self._mc_client._post(url=self._build_path(conversation_id, '<STR_LIT>'), data=data)<EOL>if response is not None:<EOL><INDENT>self.message_id = response['<STR_LIT:id>']<EOL><DEDENT>else:<EOL><INDENT>self.message_id = None<EOL><DEDENT>return response<EOL>

Post a new message to a conversation.

:param conversation_id: The unique id for the conversation.
:type conversation_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "from_email": string*,
    "read": boolean*
}


def delete(self, store_id, customer_id):

self.store_id = store_id<EOL>self.customer_id = customer_id<EOL>return self._mc_client._delete(url=self._build_path(store_id, '<STR_LIT>', customer_id))<EOL>

Delete a customer from a store.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param customer_id: The id for the customer of a store.
:type customer_id: :py:class:`str`


self.store_id = store_id<EOL>if '<STR_LIT:id>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>check_email(data['<STR_LIT>'])<EOL>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if data['<STR_LIT>'] not in [True, False]:<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>response = self._mc_client._post(url=self._build_path(store_id, '<STR_LIT>'), data=data)<EOL>if response is not None:<EOL><INDENT>self.customer_id = response['<STR_LIT:id>']<EOL><DEDENT>else:<EOL><INDENT>self.customer_id = None<EOL><DEDENT>return response<EOL>

Add a new customer to a store.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "id": string*,
    "email_address": string*,
    "opt_in_status": boolean*
}


def update(self, store_id, customer_id, data):

self.store_id = store_id<EOL>self.customer_id = customer_id<EOL>return self._mc_client._patch(url=self._build_path(store_id, '<STR_LIT>', customer_id), data=data)<EOL>

Update a customer.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param customer_id: The id for the customer of a store.
:type customer_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`


def delete(self, list_id, category_id, interest_id):

self.list_id = list_id<EOL>self.category_id = category_id<EOL>self.interest_id = interest_id<EOL>return self._mc_client._delete(<EOL>url=self._build_path(list_id, '<STR_LIT>', category_id, '<STR_LIT>', interest_id)<EOL>)<EOL>

Delete interests or group names in a specific category.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param category_id: The unique id for the interest category.
:type category_id: :py:class:`str`
:param interest_id: The specific interest or ‘group name’.
:type interest_id: :py:class:`str`


def update(self, list_id, category_id, interest_id, data):

self.list_id = list_id<EOL>self.category_id = category_id<EOL>self.interest_id = interest_id<EOL>if '<STR_LIT:name>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>return self._mc_client._patch(<EOL>url=self._build_path(list_id, '<STR_LIT>', category_id, '<STR_LIT>', interest_id),<EOL>data=data<EOL>)<EOL>

Update interests or ‘group names’ for a specific category.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param category_id: The unique id for the interest category.
:type category_id: :py:class:`str`
:param interest_id: The specific interest or ‘group name’.
:type interest_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "name": string*
}


def get(self, list_id, category_id, interest_id, **queryparams):

self.list_id = list_id<EOL>self.category_id = category_id<EOL>self.interest_id = interest_id<EOL>return self._mc_client._get(<EOL>url=self._build_path(list_id, '<STR_LIT>', category_id, '<STR_LIT>', interest_id),<EOL>**queryparams<EOL>)<EOL>

Get interests or ‘group names’ for a specific category.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param category_id: The unique id for the interest category.
:type category_id: :py:class:`str`
:param interest_id: The specific interest or ‘group name’.
:type interest_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


def all(self, list_id, category_id, get_all=False, **queryparams):

self.list_id = list_id<EOL>self.category_id = category_id<EOL>self.interest_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(list_id, '<STR_LIT>', category_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(<EOL>url=self._build_path(list_id, '<STR_LIT>', category_id, '<STR_LIT>'),<EOL>**queryparams<EOL>)<EOL><DEDENT>

Get a list of this category’s interests.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param category_id: The unique id for the interest category.
:type category_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


def create(self, list_id, category_id, data):

self.list_id = list_id<EOL>self.category_id = category_id<EOL>if '<STR_LIT:name>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>response =  self._mc_client._post(<EOL>url=self._build_path(list_id, '<STR_LIT>', category_id, '<STR_LIT>'),<EOL>data=data<EOL>)<EOL>if response is not None:<EOL><INDENT>self.interest_id = response['<STR_LIT:id>']<EOL><DEDENT>else:<EOL><INDENT>self.interest_id = None<EOL><DEDENT>return response<EOL>

Create a new interest or ‘group name’ for a specific category.

The documentation lists only the name request body parameter so it is
being documented and error-checked as if it were required based on the
description of the method.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param category_id: The unique id for the interest category.
:type category_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "name": string*
}


super(ListInterestCategoryInterest, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.list_id = None<EOL>self.category_id = None<EOL>self.interest_id = None<EOL>


def get(self, folder_id, **queryparams):

self.folder_id = folder_id<EOL>return self._mc_client._get(url=self._build_path(folder_id), **queryparams)<EOL>

Get information about a specific folder used to organize campaigns.

:param folder_id: The unique id for the campaign folder.
:type folder_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


super(CampaignFolders, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.folder_id = None<EOL>


def all(self, get_all=False, **queryparams):

self.folder_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(), **queryparams)<EOL><DEDENT>

Get all folders used to organize campaigns.

:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


super(ListActivity, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.list_id = None<EOL>


def all(self, campaign_id, **queryparams):

self.campaign_id = campaign_id<EOL>return self._mc_client._get(url=self._build_path(campaign_id, '<STR_LIT>'), **queryparams)<EOL>

Get feedback based on a campaign’s statistics. Advice feedback is
based on campaign stats like opens, clicks, unsubscribes, bounces, and
more.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


super(ReportCampaignAdvice, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.campaign_id = None<EOL>


self.campaign_id = campaign_id<EOL>return self._mc_client._post(url=self._build_path(campaign_id, '<STR_LIT>'))<EOL>

Pause an RSS-Driven campaign.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`


super(CampaignActions, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.campaign_id = None<EOL>


Send a MailChimp campaign. For RSS Campaigns, the campaign will send
according to its schedule. All other campaigns will send immediately.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`


self.campaign_id = campaign_id<EOL>return self._mc_client._put(url=self._build_path(campaign_id, '<STR_LIT:content>'), data=data)<EOL>

Set the content for a campaign.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`


def get(self, campaign_id, **queryparams):

self.campaign_id = campaign_id<EOL>return self._mc_client._get(url=self._build_path(campaign_id, '<STR_LIT:content>'), **queryparams)<EOL>

Get the the HTML and plain-text content for a campaign.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


super(ReportClickDetailReports, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.campaign_id = None<EOL>self.link_id = None<EOL>self.members = ReportClickDetailMembers(self)<EOL>


def get(self, campaign_id, link_id, **queryparams):

self.campaign_id = campaign_id<EOL>self.link_id = link_id<EOL>return self._mc_client._get(url=self._build_path(campaign_id, '<STR_LIT>', link_id), **queryparams)<EOL>

Get click details for a specific link in a campaign.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param link_id: The id for the link.
:type link_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


def all(self, store_id, cart_id, get_all=False, **queryparams):

self.store_id = store_id<EOL>self.cart_id = cart_id<EOL>self.line_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(store_id, '<STR_LIT>', cart_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(store_id, '<STR_LIT>', cart_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get information about a cart’s line items.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param cart_id: The id for the cart.
:type cart_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


def delete(self, store_id, cart_id, line_id):

self.store_id = store_id<EOL>self.cart_id = cart_id<EOL>self.line_id = line_id<EOL>return self._mc_client._delete(url=self._build_path(store_id, '<STR_LIT>', cart_id, '<STR_LIT>', line_id))<EOL>

Delete a cart.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param cart_id: The id for the cart.
:type cart_id: :py:class:`str`
:param line_id: The id for the line item of a cart.
:type line_id: :py:class:`str`


if '<STR_LIT>' in queryparams:<EOL><INDENT>self.list_id = queryparams['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>self.list_id = None<EOL><DEDENT>return self._mc_client._get(url=self._build_path(), **queryparams)<EOL>

Search for list members. This search can be restricted to a specific
list, or can be used to search across all lists in an account.

:param queryparams: The query string parameters
queryparams['fields'] = array
queryparams['exclude_fields'] = array
queryparams['query'] = string
queryparams['list_id'] = string
queryparams['offset'] = integer


def get(self, list_id, segment_id, **queryparams):

self.list_id = list_id<EOL>self.segment_id = segment_id<EOL>return self._mc_client._get(url=self._build_path(list_id, '<STR_LIT>', segment_id), **queryparams)<EOL>

Get information about a specific segment.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param segment_id: The unique id for the segment.
:type segment_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


self.store_id = store_id<EOL>if '<STR_LIT:id>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT:id>' not in data['<STR_LIT>']:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if not re.match(r"<STR_LIT>", data['<STR_LIT>']):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>for line in data['<STR_LIT>']:<EOL><INDENT>if '<STR_LIT:id>' not in line:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in line:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in line:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in line:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in line:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT><DEDENT>response = self._mc_client._post(url=self._build_path(store_id, '<STR_LIT>'), data=data)<EOL>if response is not None:<EOL><INDENT>self.order_id = response['<STR_LIT:id>']<EOL><DEDENT>else:<EOL><INDENT>self.order_id = None<EOL><DEDENT>return response<EOL>

Add a new order to a store.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "id": string*,
    "customer": object*
    {
        "'id": string*
    },
    "curency_code": string*,
    "order_total": number*,
    "lines": array*
    [
        {
            "id": string*,
            "product_id": string*,
            "product_variant_id": string*,
            "quantity": integer*,
            "price": number*
        }
    ]
}


super(StoreOrders, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.store_id = None<EOL>self.order_id = None<EOL>self.lines = StoreOrderLines(self)<EOL>


def all(self, store_id, get_all=False, **queryparams):

self.store_id = store_id<EOL>self.order_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(store_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(store_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get information about a store’s orders.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer
queryparams['customer_id'] = string


self.workflow_id = workflow_id<EOL>self.email_id = email_id<EOL>return self._mc_client._post(url=self._build_path(workflow_id, '<STR_LIT>', email_id, '<STR_LIT>'))<EOL>

Start an automated email.

:param workflow_id: The unique id for the Automation workflow.
:type workflow_id: :py:class:`str`
:param email_id: The unique id for the Automation workflow email.
:type email_id: :py:class:`str`


def create(self, store_id, promo_rule_id, data):

self.store_id = store_id<EOL>if '<STR_LIT:id>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT:code>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>response = self._mc_client._post(url=self._build_path(store_id, '<STR_LIT>', promo_rule_id, '<STR_LIT>'), data=data)<EOL>if response is not None:<EOL><INDENT>return response<EOL><DEDENT>

Add a new promo code to a store.

:param store_id: The store id
:type store_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict'
data = {
    "id": string*,
    "code": string*,
    "redemption_url": string*,
    "usage_count": string,
    "enabled": boolean,
    "created_at_foreign": string,
    "updated_at_foreign": string,
}


super(StorePromoCodes, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.store_id = None<EOL>

Initialize the Endpoint
:param args:
:param kwargs:


def all(self, store_id, promo_rule_id, get_all=False, **queryparams):

self.store_id=store_id<EOL>self.promo_rule_id=promo_rule_id<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(store_id, '<STR_LIT>', promo_rule_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(store_id, '<STR_LIT>', promo_rule_id), **queryparams)<EOL><DEDENT>

Get information about a store’s promo codes.

:param store_id: The store's id
:type store_id: `str`
:param promo_rule_id: The store promo rule id
:type store_id: `str`
:param get_all:
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


return self._mc_client._get(url=self._build_path())<EOL>

A health check for the API that won’t return any account-specific information.


super(Ping, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>


self.list_id = list_id<EOL>self.category_id = category_id<EOL>return self._mc_client._delete(url=self._build_path(list_id, '<STR_LIT>', category_id))<EOL>

Delete a specific interest category.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param category_id: The unique id for the interest category.
:type category_id: :py:class:`str`


def all(self, list_id, get_all=False, **queryparams):

self.list_id = list_id<EOL>self.category_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(list_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(list_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get information about a list’s interest categories.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer
queryparams['type'] = string


self.list_id = list_id<EOL>if '<STR_LIT:title>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT:type>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if data['<STR_LIT:type>'] not in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>response = self._mc_client._post(url=self._build_path(list_id, '<STR_LIT>'), data=data)<EOL>if response is not None:<EOL><INDENT>self.category_id = response['<STR_LIT:id>']<EOL><DEDENT>else:<EOL><INDENT>self.category_id = None<EOL><DEDENT>return response<EOL>

Create a new interest category.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "title": string*,
    "type": string* (Must be one of 'checkboxes', 'dropdown', 'radio', or 'hidden')
}


super(ListInterestCategories, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.list_id = None<EOL>self.category_id = None<EOL>self.interests = ListInterestCategoryInterest(self)<EOL>


super(ReportGoogleAnalytics, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.campaign_id = None<EOL>self.profile_id = None<EOL>


def all(self, campaign_id, get_all=False, **queryparams):

self.campaign_id = campaign_id<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(campaign_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(campaign_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get a summary of Google Analytics reports for a specific campaign.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams:  The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


self.list_id = list_id<EOL>self.merge_id = merge_id<EOL>return self._mc_client._delete(url=self._build_path(list_id, '<STR_LIT>', merge_id))<EOL>

Delete a specific merge field in a list.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param merge_id: The id for the merge field.
:type merge_id: :py:class:`str`


self.list_id = list_id<EOL>self.merge_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(list_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(list_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get a list of all merge fields (formerly merge vars) for a list.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer
queryparams['type'] = string
queryparams['required'] = boolean


super(ListMergeFields, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.list_id = None<EOL>self.merge_id = None<EOL>


self.list_id = list_id<EOL>if '<STR_LIT:name>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT:type>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>response = self._mc_client._post(url=self._build_path(list_id, '<STR_LIT>'), data=data)<EOL>if response is not None:<EOL><INDENT>self.merge_id = response['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>self.merge_id = None<EOL><DEDENT>return response<EOL>

Add a new merge field for a specific list.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "name": string*,
    "type": string*
}


self.campaign_id = campaign_id<EOL>self.subscriber_hash = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(campaign_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(campaign_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get information about members who have unsubscribed from a specific
campaign.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


def get(self, campaign_id, subscriber_hash, **queryparams):

subscriber_hash = check_subscriber_hash(subscriber_hash)<EOL>self.campaign_id = campaign_id<EOL>self.subscriber_hash = subscriber_hash<EOL>return self._mc_client._get(url=self._build_path(campaign_id, '<STR_LIT>', subscriber_hash), **queryparams)<EOL>

Get information about a specific list member who unsubscribed from a
campaign.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param subscriber_hash: The MD5 hash of the lowercase version of the
  list member’s email address.
:type subscriber_hash: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


def update(self, list_id, subscriber_hash, data):

subscriber_hash = check_subscriber_hash(subscriber_hash)<EOL>self.list_id = list_id<EOL>self.subscriber_hash = subscriber_hash<EOL>return self._mc_client._patch(url=self._build_path(list_id, '<STR_LIT>', subscriber_hash), data=data)<EOL>

Update information for a specific list member.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param subscriber_hash: The MD5 hash of the lowercase version of the
    list member’s email address.
:type subscriber_hash: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`


def delete(self, list_id, subscriber_hash):

subscriber_hash = check_subscriber_hash(subscriber_hash)<EOL>self.list_id = list_id<EOL>self.subscriber_hash = subscriber_hash<EOL>return self._mc_client._delete(url=self._build_path(list_id, '<STR_LIT>', subscriber_hash))<EOL>

Delete a member from a list.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param subscriber_hash: The MD5 hash of the lowercase version of the
  list member’s email address.
:type subscriber_hash: :py:class:`str`


self.list_id = list_id<EOL>if '<STR_LIT:status>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if data['<STR_LIT:status>'] not in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>check_email(data['<STR_LIT>'])<EOL>response = self._mc_client._post(url=self._build_path(list_id, '<STR_LIT>'), data=data)<EOL>if response is not None:<EOL><INDENT>self.subscriber_hash = response['<STR_LIT:id>']<EOL><DEDENT>else:<EOL><INDENT>self.subscriber_hash = None<EOL><DEDENT>return response<EOL>

Add a new member to the list.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "status": string*, (Must be one of 'subscribed', 'unsubscribed', 'cleaned',
        'pending', or 'transactional')
    "email_address": string*
}


super(ListMembers, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.list_id = None<EOL>self.subscriber_hash = None<EOL>self.activity = ListMemberActivity(self)<EOL>self.goals = ListMemberGoals(self)<EOL>self.notes = ListMemberNotes(self)<EOL>


self.batch_id = None<EOL>self.operation_status = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(), **queryparams)<EOL><DEDENT>

Get a summary of batch requests that have been made.

:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>for op in data['<STR_LIT>']:<EOL><INDENT>if '<STR_LIT>' not in op:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if op['<STR_LIT>'] not in ['<STR_LIT:GET>', '<STR_LIT:POST>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'.format(op['<STR_LIT>']))<EOL><DEDENT>if '<STR_LIT:path>' not in op:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT><DEDENT>return self._mc_client._post(url=self._build_path(), data=data)<EOL>

Begin processing a batch operations request.

:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "operations": array*
    [
        {
            "method": string* (Must be one of "GET", "POST", "PUT", "PATCH", or "DELETE")
            "path": string*,
        }
    ]
}


self.batch_id = batch_id<EOL>self.operation_status = None<EOL>return self._mc_client._get(url=self._build_path(batch_id), **queryparams)<EOL>

Get the status of a batch request.

:param batch_id: The unique id for the batch operation.
:type batch_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


self.batch_id = batch_id<EOL>self.operation_status = None<EOL>return self._mc_client._delete(url=self._build_path(batch_id))<EOL>

Stops a batch request from running. Since only one batch request is
run at a time, this can be used to cancel a long running request. The
results of any completed operations will not be available after this
call.

:param batch_id: The unique id for the batch operation.
:type batch_id: :py:class:`str`


super(BatchOperations, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.batch_id = None<EOL>self.operation_status = None<EOL>


if '<STR_LIT:name>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>response = self._mc_client._post(url=self._build_path(), data=data)<EOL>if response is not None:<EOL><INDENT>self.folder_id = response['<STR_LIT:id>']<EOL><DEDENT>else:<EOL><INDENT>self.folder_id = None<EOL><DEDENT>return response<EOL>

Create a new folder in the File Manager.

:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "name": string*
}


def update(self, list_id, subscriber_hash, note_id, data):

subscriber_hash = check_subscriber_hash(subscriber_hash)<EOL>self.list_id = list_id<EOL>self.subscriber_hash = subscriber_hash<EOL>self.note_id = note_id<EOL>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>return self._mc_client._patch(<EOL>url=self._build_path(list_id, '<STR_LIT>', subscriber_hash, '<STR_LIT>', note_id),<EOL>data=data<EOL>)<EOL>

Update a specific note for a specific list member.

The documentation lists only the note request body parameter so it is
being documented and error-checked as if it were required based on the
description of the method.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param subscriber_hash: The MD5 hash of the lowercase version of the
  list member’s email address.
:type subscriber_hash: :py:class:`str`
:param note_id: The id for the note.
:type note_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "note": string*
}


def get(self, list_id, subscriber_hash, note_id, **queryparams):

subscriber_hash = check_subscriber_hash(subscriber_hash)<EOL>self.list_id = list_id<EOL>self.subscriber_hash = subscriber_hash<EOL>self.note_id = note_id<EOL>return self._mc_client._get(<EOL>url=self._build_path(list_id, '<STR_LIT>', subscriber_hash, '<STR_LIT>', note_id),<EOL>**queryparams<EOL>)<EOL>

Get a specific note for a specific list member.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param subscriber_hash: The MD5 hash of the lowercase version of the
  list member’s email address.
:type subscriber_hash: :py:class:`str`
:param note_id: The id for the note.
:type note_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


def all(self, list_id, subscriber_hash, get_all=False, **queryparams):

subscriber_hash = check_subscriber_hash(subscriber_hash)<EOL>self.list_id = list_id<EOL>self.subscriber_hash = subscriber_hash<EOL>self.note_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(list_id, '<STR_LIT>', subscriber_hash, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(list_id, '<STR_LIT>', subscriber_hash, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get recent notes for a specific list member.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param subscriber_hash: The MD5 hash of the lowercase version of the
  list member’s email address.
:type subscriber_hash: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


self.store_id = store_id<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(store_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(store_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get information about a store’s promo rules.

:param store_id: The store's id
:type store_id: `str`
:param get_all:
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


def get(self, store_id, promo_rule_id, **queryparams):

self.store_id = store_id<EOL>self.promo_rule_id = promo_rule_id<EOL>return self._mc_client._get(url=self._build_path(store_id, '<STR_LIT>', promo_rule_id), **queryparams)<EOL>

Get information about a specific promo rule.

:param store_id: The store's id
:type store_id: `string`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


def update(self, store_id, promo_rule_id, data):

self.store_id = store_id<EOL>self.promo_rule_id = promo_rule_id<EOL>return self._mc_client._patch(url=self._build_path(store_id, '<STR_LIT>', promo_rule_id), data=data)<EOL>

Update a promo rule

:param store_id: The store id
:type :py:class:`str`
:param promo_rule_id: The id for the promo rule of a store.
:type :py:class:`str`
:param data:
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "id": string,
    "title": string,
    "description": string,
    "starts_at": string,
    "ends_at": string,
    "amount": number,
    "type": string,
    "target": string,
    "enabled": boolean,
    "created_at_foreign": string,
    "updated_at_foreign": string,
}


def all(self, store_id, product_id, get_all=False, **queryparams):

self.store_id = store_id<EOL>self.product_id = product_id<EOL>self.image_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(store_id, '<STR_LIT>', product_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._post(url=self._build_path(store_id, '<STR_LIT>', product_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get information about a product’s images.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param product_id: The id for the product of a store.
:type product_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


def create(self, store_id, product_id, data):

self.store_id = store_id<EOL>self.product_id = product_id<EOL>if '<STR_LIT:id>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT:title>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>response = self._mc_client._post(url=self._build_path(store_id, '<STR_LIT>', product_id, '<STR_LIT>'), data=data)<EOL>if response is not None:<EOL><INDENT>self.image_id = response['<STR_LIT:id>']<EOL><DEDENT>else:<EOL><INDENT>self.image_id = None<EOL><DEDENT>return response<EOL>

Add a new image to the product.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param product_id: The id for the product of a store.
:type product_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "id": string*,
    "url": string*
}


super(ListMemberGoals, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.list_id = None<EOL>self.subscriber_hash = None<EOL>


def all(self, list_id, subscriber_hash, **queryparams):

subscriber_hash = check_subscriber_hash(subscriber_hash)<EOL>self.list_id = list_id<EOL>self.subscriber_hash = subscriber_hash<EOL>return self._mc_client._get(url=self._build_path(list_id, '<STR_LIT>', subscriber_hash, '<STR_LIT>'), **queryparams)<EOL>

Get the last 50 Goal events for a member on a specific list.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param subscriber_hash: The MD5 hash of the lowercase version of the
  list member’s email address.
:type subscriber_hash: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


self.store_id = store_id<EOL>self.product_id = product_id<EOL>self.variant_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(store_id, '<STR_LIT>', product_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(<EOL>url=self._build_path(store_id, '<STR_LIT>', product_id, '<STR_LIT>'),<EOL>**queryparams<EOL>)<EOL><DEDENT>

Get information about a product’s variants.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param product_id: The id for the product of a store.
:type product_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


def delete(self, store_id, product_id, variant_id):

self.store_id = store_id<EOL>self.product_id = product_id<EOL>self.variant_id = variant_id<EOL>return self._mc_client._delete(url=self._build_path(store_id, '<STR_LIT>', product_id, '<STR_LIT>', variant_id))<EOL>

Delete a product variant.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param product_id: The id for the product of a store.
:type product_id: :py:class:`str`
:param variant_id: The id for the product variant.
:type variant_id: :py:class:`str`


super(StoreProductVariants, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.store_id = None<EOL>self.product_id = None<EOL>self.variant_id = None<EOL>


def update(self, store_id, product_id, variant_id, data):

self.store_id = store_id<EOL>self.product_id = product_id<EOL>self.variant_id = variant_id<EOL>return self._mc_client._patch(<EOL>url=self._build_path(store_id, '<STR_LIT>', product_id, '<STR_LIT>', variant_id),<EOL>data=data<EOL>)<EOL>

Update a product variant.

:param store_id: The store id.
:type store_id: :py:class:`str`
:param product_id: The id for the product of a store.
:type product_id: :py:class:`str`
:param variant_id: The id for the product variant.
:type variant_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`


super(Root, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>


self.campaign_id = campaign_id<EOL>self.subscriber_hash = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(campaign_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(campaign_id, '<STR_LIT>'), **queryparams)<EOL><DEDENT>

Get information about campaign recipients.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer


subscriber_hash = check_subscriber_hash(subscriber_hash)<EOL>self.campaign_id = campaign_id<EOL>self.subscriber_hash = subscriber_hash<EOL>return self._mc_client._get(url=self._build_path(campaign_id, '<STR_LIT>', subscriber_hash), **queryparams)<EOL>

Get information about a specific campaign recipient.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param subscriber_hash: The MD5 hash of the lowercase version of the
  list member’s email address.
:type subscriber_hash: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


self.list_id = list_id<EOL>return self._mc_client._get(url=self._build_path(list_id), **queryparams)<EOL>

Get information about a specific list in your MailChimp account.
Results include list members who have signed up but haven’t confirmed
their subscription yet and unsubscribed or cleaned.

:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


def all(self, get_all=False, **queryparams):

self.list_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(), **queryparams)<EOL><DEDENT>

Get information about all lists in the account.

:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer
queryparams['before_date_created'] = string
queryparams['since_date_created'] = string
queryparams['before_campaign_last_sent'] = string
queryparams['since_campaign_last_sent'] = string
queryparams['email'] = string
queryparams['sort_field'] = string (Must be 'date_created')
queryparams['sort_dir'] = string (Must be one of 'ASC' or 'DESC')


super(CampaignSendChecklist, self).__init__(*args, **kwargs)<EOL>self.endpoint = '<STR_LIT>'<EOL>self.campaign_id = None<EOL>


def get(self, campaign_id, **queryparams):

self.campaign_id = campaign_id<EOL>return self._mc_client._get(url=self._build_path(campaign_id, '<STR_LIT>'), **queryparams)<EOL>

Review the send checklist for a campaign, and resolve any issues
before sending.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []


if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data['<STR_LIT>']:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data['<STR_LIT>']:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data['<STR_LIT>']:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data['<STR_LIT>']:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>check_email(data['<STR_LIT>']['<STR_LIT>'])<EOL>if '<STR_LIT:type>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if not data['<STR_LIT:type>'] in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if data['<STR_LIT:type>'] == '<STR_LIT>':<EOL><INDENT>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data['<STR_LIT>']:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if data['<STR_LIT>']['<STR_LIT>'] not in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>if data['<STR_LIT:type>'] == '<STR_LIT>':<EOL><INDENT>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data['<STR_LIT>']:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if not data['<STR_LIT>']['<STR_LIT>'] in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>response = self._mc_client._post(url=self._build_path(), data=data)<EOL>if response is not None:<EOL><INDENT>self.campaign_id = response['<STR_LIT:id>']<EOL><DEDENT>else:<EOL><INDENT>self.campaign_id = None<EOL><DEDENT>return response<EOL>

Create a new MailChimp campaign.

The ValueError raised by an invalid type in data does not mention
'absplit' as a potential value because the documentation indicates
that the absplit type has been deprecated.

:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "recipients": object*
    {
        "list_id": string*
    },
    "settings": object*
    {
        "subject_line": string*,
        "from_name": string*,
        "reply_to": string*
    },
    "variate_settings": object* (Required if type is "variate")
    {
        "winner_criteria": string* (Must be one of "opens", "clicks", "total_revenue", or "manual")
    },
    "rss_opts": object* (Required if type is "rss")
    {
        "feed_url": string*,
        "frequency": string* (Must be one of "daily", "weekly", or "monthly")
    },
    "type": string* (Must be one of "regular", "plaintext", "rss", "variate", or "absplit")
}


self.campaign_id = campaign_id<EOL>if '<STR_LIT>' not in data:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data['<STR_LIT>']:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data['<STR_LIT>']:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' not in data['<STR_LIT>']:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>check_email(data['<STR_LIT>']['<STR_LIT>'])<EOL>return self._mc_client._patch(url=self._build_path(campaign_id), data=data)<EOL>

Update some or all of the settings for a specific campaign.

:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
    "settings": object*
    {
        "subject_line": string*,
        "from_name": string*,
        "reply_to": string*
    },
}


self.campaign_id = None<EOL>if get_all:<EOL><INDENT>return self._iterate(url=self._build_path(), **queryparams)<EOL><DEDENT>else:<EOL><INDENT>return self._mc_client._get(url=self._build_path(), **queryparams)<EOL><DEDENT>

Get all campaigns in an account.

.. note::
    The before_create_time, since_create_time, before_send_time, and
    since_send_time queryparams expect times to be listed in the ISO
    8601 format in UTC (ex. 2015-10-21T15:41:36+00:00).

:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = []
queryparams['count'] = integer
queryparams['offset'] = integer
queryparams['type'] = []
queryparams['status'] = []
queryparams['before_send_time'] = string
queryparams['since_send_time'] = string
queryparams['before_create_time'] = string
queryparams['since_create_time'] = string
queryparams['list_id'] = string
queryparams['folder_id'] = string
queryparams['sort_field'] = string
queryparams['sort_dir'] = string


self.workflow_id = workflow_id<EOL>return self._mc_client._get(url=self._build_path(workflow_id, '<STR_LIT>'))<EOL>

Get information about subscribers who were removed from an Automation
workflow.

:param workflow_id: The unique id for the Automation workflow.
:type workflow_id: :py:class:`str`


r.headers['<STR_LIT>'] = '<STR_LIT>' + self._access_token<EOL>return r<EOL>

Authorize with the access token provided in __init__


@_enabled_or_noop<EOL><INDENT>def _post(self, url, data=None):<DEDENT>

url = urljoin(self.base_url, url)<EOL>try:<EOL><INDENT>r = self._make_request(**dict(<EOL>method='<STR_LIT:POST>',<EOL>url=url,<EOL>json=data,<EOL>auth=self.auth,<EOL>timeout=self.timeout,<EOL>hooks=self.request_hooks,<EOL>headers=self.request_headers<EOL>))<EOL><DEDENT>except requests.exceptions.RequestException as e:<EOL><INDENT>raise e<EOL><DEDENT>else:<EOL><INDENT>if r.status_code >= <NUM_LIT>:<EOL><INDENT>try:<EOL><INDENT>error_data = r.json()<EOL><DEDENT>except ValueError:<EOL><INDENT>error_data = { "<STR_LIT>": r }<EOL><DEDENT>raise MailChimpError(error_data)<EOL><DEDENT>if r.status_code == <NUM_LIT>:<EOL><INDENT>return None<EOL><DEDENT>return r.json()<EOL><DEDENT>

Handle authenticated POST requests

:param url: The url for the endpoint including path parameters
:type url: :py:class:`str`
:param data: The request body parameters
:type data: :py:data:`none` or :py:class:`dict`
:returns: The JSON output from the API or an error message


@_enabled_or_noop<EOL><INDENT>def _get(self, url, **queryparams):<DEDENT>

url = urljoin(self.base_url, url)<EOL>if len(queryparams):<EOL><INDENT>url += '<STR_LIT:?>' + urlencode(queryparams)<EOL><DEDENT>try:<EOL><INDENT>r = self._make_request(**dict(<EOL>method='<STR_LIT:GET>',<EOL>url=url,<EOL>auth=self.auth,<EOL>timeout=self.timeout,<EOL>hooks=self.request_hooks,<EOL>headers=self.request_headers<EOL>))<EOL><DEDENT>except requests.exceptions.RequestException as e:<EOL><INDENT>raise e<EOL><DEDENT>else:<EOL><INDENT>if r.status_code >= <NUM_LIT>:<EOL><INDENT>raise MailChimpError(r.json())<EOL><DEDENT>return r.json()<EOL><DEDENT>

Handle authenticated GET requests

:param url: The url for the endpoint including path parameters
:type url: :py:class:`str`
:param queryparams: The query string parameters
:returns: The JSON output from the API


@_enabled_or_noop<EOL><INDENT>def _patch(self, url, data=None):<DEDENT>

url = urljoin(self.base_url, url)<EOL>try:<EOL><INDENT>r = self._make_request(**dict(<EOL>method='<STR_LIT>',<EOL>url=url,<EOL>json=data,<EOL>auth=self.auth,<EOL>timeout=self.timeout,<EOL>hooks=self.request_hooks,<EOL>headers=self.request_headers<EOL>))<EOL><DEDENT>except requests.exceptions.RequestException as e:<EOL><INDENT>raise e<EOL><DEDENT>else:<EOL><INDENT>if r.status_code >= <NUM_LIT>:<EOL><INDENT>raise MailChimpError(r.json())<EOL><DEDENT>return r.json()<EOL><DEDENT>

Handle authenticated PATCH requests

:param url: The url for the endpoint including path parameters
:type url: :py:class:`str`
:param data: The request body parameters
:type data: :py:data:`none` or :py:class:`dict`
:returns: The JSON output from the API


url = urljoin(self.base_url, url)<EOL>try:<EOL><INDENT>r = self._make_request(**dict(<EOL>method='<STR_LIT>',<EOL>url=url,<EOL>auth=self.auth,<EOL>timeout=self.timeout,<EOL>hooks=self.request_hooks,<EOL>headers=self.request_headers<EOL>))<EOL><DEDENT>except requests.exceptions.RequestException as e:<EOL><INDENT>raise e<EOL><DEDENT>else:<EOL><INDENT>if r.status_code >= <NUM_LIT>:<EOL><INDENT>raise MailChimpError(r.json())<EOL><DEDENT>if r.status_code == <NUM_LIT>:<EOL><INDENT>return<EOL><DEDENT>return r.json()<EOL><DEDENT>

Handle authenticated DELETE requests

:param url: The url for the endpoint including path parameters
:type url: :py:class:`str`
:returns: The JSON output from the API


try:<EOL><INDENT>return self.get_metadata()['<STR_LIT>']<EOL><DEDENT>except requests.exceptions.RequestException:<EOL><INDENT>raise<EOL><DEDENT>

Get the base_url from the authentication metadata


try:<EOL><INDENT>r = requests.get('<STR_LIT>', auth=self)<EOL><DEDENT>except requests.exceptions.RequestException as e:<EOL><INDENT>raise e<EOL><DEDENT>else:<EOL><INDENT>r.raise_for_status()<EOL>output = r.json()<EOL>if '<STR_LIT:error>' in output:<EOL><INDENT>raise requests.exceptions.RequestException(output['<STR_LIT:error>'])<EOL><DEDENT>return output<EOL><DEDENT>

Get the metadata returned after authentication


@_enabled_or_noop<EOL><INDENT>def _put(self, url, data=None):<DEDENT>

url = urljoin(self.base_url, url)<EOL>try:<EOL><INDENT>r = self._make_request(**dict(<EOL>method='<STR_LIT>',<EOL>url=url,<EOL>json=data,<EOL>auth=self.auth,<EOL>timeout=self.timeout,<EOL>hooks=self.request_hooks,<EOL>headers=self.request_headers<EOL>))<EOL><DEDENT>except requests.exceptions.RequestException as e:<EOL><INDENT>raise e<EOL><DEDENT>else:<EOL><INDENT>if r.status_code >= <NUM_LIT>:<EOL><INDENT>try:<EOL><INDENT>error_data = r.json()<EOL><DEDENT>except ValueError:<EOL><INDENT>error_data = { "<STR_LIT>": r }<EOL><DEDENT>raise MailChimpError(error_data)<EOL><DEDENT>return r.json()<EOL><DEDENT>

Handle authenticated PUT requests

:param url: The url for the endpoint including path parameters
:type url: :py:class:`str`
:param data: The request body parameters
:type data: :py:data:`none` or :py:class:`dict`
:returns: The JSON output from the API


def __init__(self, mc_api=None, mc_user='<STR_LIT>', access_token=None, enabled=True, timeout=None,<EOL>request_hooks=None, request_headers=None):

super(MailChimpClient, self).__init__()<EOL>self.enabled = enabled<EOL>self.timeout = timeout<EOL>if access_token:<EOL><INDENT>self.auth = MailChimpOAuth(access_token)<EOL>self.base_url = self.auth.get_base_url() + '<STR_LIT>'<EOL><DEDENT>elif mc_api:<EOL><INDENT>if not re.match(r"<STR_LIT>", mc_api.split('<STR_LIT:->')[<NUM_LIT:0>]):<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>self.auth = HTTPBasicAuth(mc_user, mc_api)<EOL>datacenter = mc_api.split('<STR_LIT:->').pop()<EOL>self.base_url = '<STR_LIT>'.format(datacenter)<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>self.request_headers = request_headers or requests.utils.default_headers()<EOL>self.request_hooks = request_hooks or requests.hooks.default_hooks()<EOL>

Initialize the class with your optional user_id and required api_key.

If `enabled` is not True, these methods become no-ops. This is
particularly useful for testing or disabling with configuration.

:param mc_api: Mailchimp API key
:type mc_api: :py:class:`str`
:param mc_user: Mailchimp user id
:type mc_user: :py:class:`str`
:param access_token: The OAuth access token
:type access_token: :py:class:`str`
:param enabled: Whether the API should execute any requests
:type enabled: :py:class:`bool`
:param timeout: (optional) How long to wait for the server to send
    data before giving up, as a float, or a :ref:`(connect timeout,
    read timeout) <timeouts>` tuple.
:type timeout: float or tuple
:param request_hooks: (optional) Hooks for :py:func:`requests.requests`.
:type request_hooks: :py:class:`dict`
:param request_headers: (optional) Headers for
    :py:func:`requests.requests`.
:type request_headers: :py:class:`dict`


con = sqlite3.connect(self.tmp_cookie_file)<EOL>cur = con.cursor()<EOL>try:<EOL><INDENT>cur.execute('<STR_LIT>'<EOL>'<STR_LIT>'.format(self.domain_name))<EOL><DEDENT>except sqlite3.OperationalError:<EOL><INDENT>cur.execute('<STR_LIT>'<EOL>'<STR_LIT>'.format(self.domain_name))<EOL><DEDENT>cj = http.cookiejar.CookieJar()<EOL>for item in cur.fetchall():<EOL><INDENT>host, path, secure, expires, name = item[:<NUM_LIT:5>]<EOL>value = self._decrypt(item[<NUM_LIT:5>], item[<NUM_LIT:6>])<EOL>c = create_cookie(host, path, secure, expires, name, value)<EOL>cj.set_cookie(c)<EOL><DEDENT>con.close()<EOL>return cj<EOL>


cj = http.cookiejar.CookieJar()<EOL>for cookie_fn in [chrome, firefox]:<EOL><INDENT>try:<EOL><INDENT>for cookie in cookie_fn(domain_name=domain_name):<EOL><INDENT>cj.set_cookie(cookie)<EOL><DEDENT><DEDENT>except BrowserCookieError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return cj<EOL>

Try to load cookies from all supported browsers and return combined cookiejar
    Optionally pass in a domain name to only load cookies from the specified domain


return Chrome(cookie_file, domain_name).load()<EOL>

Returns a cookiejar of the cookies used by Chrome. Optionally pass in a
    domain name to only load cookies from the specified domain


def create_cookie(host, path, secure, expires, name, value):

return http.cookiejar.Cookie(<NUM_LIT:0>, name, value, None, False, host, host.startswith('<STR_LIT:.>'), host.startswith('<STR_LIT:.>'), path,<EOL>True, secure, expires, False, None, None, {})<EOL>


def _decrypt(self, value, encrypted_value):

if sys.platform == '<STR_LIT:win32>':<EOL><INDENT>return self._decrypt_windows_chrome(value, encrypted_value)<EOL><DEDENT>if value or (encrypted_value[:<NUM_LIT:3>] != b'<STR_LIT>'):<EOL><INDENT>return value<EOL><DEDENT>encrypted_value = encrypted_value[<NUM_LIT:3>:]<EOL>encrypted_value_half_len = int(len(encrypted_value) / <NUM_LIT:2>)<EOL>cipher = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(self.key, self.iv))<EOL>decrypted = cipher.feed(encrypted_value[:encrypted_value_half_len])<EOL>decrypted += cipher.feed(encrypted_value[encrypted_value_half_len:])<EOL>decrypted += cipher.feed()<EOL>return decrypted.decode("<STR_LIT:utf-8>")<EOL>


<EOL>count = <NUM_LIT:1><EOL>count_value = values.get('<STR_LIT:count>', <NUM_LIT:1>)<EOL>if isinstance(count_value, int):<EOL><INDENT>count = max(count_value, <NUM_LIT:1>)<EOL><DEDENT>def with_index(name, idx):<EOL><INDENT>if name and idx:<EOL><INDENT>return '<STR_LIT>' % (name, idx)<EOL><DEDENT>return name<EOL><DEDENT>def get_instance(n, idx=None):<EOL><INDENT>return BlockadeContainerConfig(<EOL>with_index(n, idx),<EOL>values['<STR_LIT:image>'],<EOL>command=values.get('<STR_LIT>'),<EOL>links=values.get('<STR_LIT>'),<EOL>volumes=values.get('<STR_LIT>'),<EOL>publish_ports=values.get('<STR_LIT>'),<EOL>expose_ports=values.get('<STR_LIT>'),<EOL>environment=values.get('<STR_LIT>'),<EOL>hostname=values.get('<STR_LIT>'),<EOL>dns=values.get('<STR_LIT>'),<EOL>start_delay=values.get('<STR_LIT>', <NUM_LIT:0>),<EOL>neutral=values.get('<STR_LIT>', False),<EOL>holy=values.get('<STR_LIT>', False),<EOL>container_name=with_index(values.get('<STR_LIT>'), idx),<EOL>cap_add=values.get('<STR_LIT>'))<EOL><DEDENT>if count == <NUM_LIT:1>:<EOL><INDENT>yield get_instance(name)<EOL><DEDENT>else:<EOL><INDENT>for idx in range(<NUM_LIT:1>, count+<NUM_LIT:1>):<EOL><INDENT>yield get_instance(name, idx)<EOL><DEDENT><DEDENT>

Convert a dictionary of configuration values
into a sequence of BlockadeContainerConfig instances


if not isinstance(containers, collections.Mapping):<EOL><INDENT>containers = dict((c.name, c) for c in containers)<EOL><DEDENT>container_links = dict((name, set(c.links.keys()))<EOL>for name, c in containers.items())<EOL>sorted_names = _resolve(container_links)<EOL>return [containers[name] for name in sorted_names]<EOL>

Sort a dictionary or list of containers into dependency order

    Returns a sequence


wait(lambda: len(multiprocessing.active_children()) == <NUM_LIT:0>)<EOL>

Wait for child processes to exit

    The testing system launches and terminates child processes, but
    doesn't wait for them to actually die. So in a few places we need
    this extra call


__with_containers(opts, Blockade.restart)<EOL>


config = load_config(opts.config)<EOL>b = get_blockade(config, opts)<EOL>containers = b.status()<EOL>print_containers(containers, opts.json)<EOL>


config = load_config(opts.config)<EOL>b = get_blockade(config, opts)<EOL>b.join()<EOL>

Restore full networking between containers


__with_containers(opts, Blockade.flaky)<EOL>

Make the network flaky for some or all containers


config = load_config(opts.config)<EOL>b = get_blockade(config, opts)<EOL>puts(b.logs(opts.container).decode(encoding='<STR_LIT>'))<EOL>


config = load_config(opts.config)<EOL>b = get_blockade(config, opts)<EOL>b.add_container(opts.containers)<EOL>

Add one or more existing Docker containers to a Blockade group


config = load_config(opts.config)<EOL>b = get_blockade(config, opts)<EOL>if opts.random:<EOL><INDENT>if opts.partitions:<EOL><INDENT>raise BlockadeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>b.random_partition()<EOL><DEDENT>else:<EOL><INDENT>partitions = []<EOL>for partition in opts.partitions:<EOL><INDENT>names = []<EOL>for name in partition.split("<STR_LIT:U+002C>"):<EOL><INDENT>name = name.strip()<EOL>if name:<EOL><INDENT>names.append(name)<EOL><DEDENT><DEDENT>partitions.append(names)<EOL><DEDENT>if not partitions:<EOL><INDENT>raise BlockadeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>b.partition(partitions)<EOL><DEDENT>

Partition the network between containers

    Replaces any existing partitions outright. Any containers NOT specified
    in arguments will be globbed into a single implicit partition. For
    example if you have three containers: c1, c2, and c3 and you run:

        blockade partition c1

    The result will be a partition with just c1 and another partition with
    c2 and c3.

    Alternatively, --random may be specified, and zero or more random
    partitions will be generated by blockade.


config = load_config(opts.config)<EOL>b = get_blockade(config, opts)<EOL>containers = b.create(verbose=opts.verbose, force=opts.force)<EOL>print_containers(containers, opts.json)<EOL>

Start the containers and link them together


import blockade.version<EOL>puts("<STR_LIT>" + blockade.version.__version__)<EOL>


if opts.data_dir is None:<EOL><INDENT>raise BlockadeError("<STR_LIT>")<EOL><DEDENT>rest.start(data_dir=opts.data_dir, port=opts.port, debug=opts.debug,<EOL>host_exec=get_host_exec())<EOL>


kill_signal = opts.signal if hasattr(opts, '<STR_LIT>') else "<STR_LIT>"<EOL>__with_containers(opts, Blockade.kill, signal=kill_signal)<EOL>


config = load_config(opts.config)<EOL>b = get_blockade(config, opts)<EOL>b.destroy()<EOL>

Destroy all containers and restore networks


if not chain:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>self.call("<STR_LIT>", chain)<EOL>


millisec = random.randint(self._start_min_delay, self._start_max_delay)<EOL>self._timer = threading.Timer(millisec / <NUM_LIT>, self.event_timeout)<EOL>self._timer.start()<EOL>


def _sm_relieve_pain(self, *args, **kwargs):

_logger.info(<EOL>"<STR_LIT>" % self._blockade_name)<EOL>self._do_reset_all()<EOL>millisec = random.randint(self._start_min_delay, self._start_max_delay)<EOL>self._timer = threading.Timer(millisec/<NUM_LIT>, self.event_timeout)<EOL>self._timer.start()<EOL>

End the blockade event and return to a steady state


if self._done_notification_func is not None:<EOL><INDENT>self._done_notification_func()<EOL><DEDENT>self._timer.cancel()<EOL>

Delete all state associated with the chaos session


def _sm_stop_from_pain(self, *args, **kwargs):

_logger.info("<STR_LIT>" % self._blockade_name)<EOL>self._do_reset_all()<EOL>

Stop chaos while there is a blockade event in progress


_logger.info("<STR_LIT>" % self._blockade_name)<EOL>self._do_blockade_event()<EOL>millisec = random.randint(self._run_min_time, self._run_max_time)<EOL>self._timer = threading.Timer(millisec / <NUM_LIT>, self.event_timeout)<EOL>self._timer.start()<EOL>


try:<EOL><INDENT>os.makedirs(self._state_dir)<EOL><DEDENT>except OSError as err:<EOL><INDENT>if err.errno != errno.EEXIST:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>


self._containers = deepcopy(containers)<EOL>self.__write(containers, initialize=True)<EOL>

Initialize a new state file with the given contents.
This function fails in case the state file already exists.


container = self._containers.get(name, None)<EOL>if not container is None:<EOL><INDENT>return container.get('<STR_LIT:id>', None)<EOL><DEDENT>return None<EOL>

Try to find the container ID with the specified name


return "<STR_LIT>" % self._blockade_id<EOL>

Generate blockade nework name based on the blockade_id


try:<EOL><INDENT>with open(self._state_file) as f:<EOL><INDENT>state = yaml.safe_load(f)<EOL>self._containers = state['<STR_LIT>']<EOL><DEDENT><DEDENT>except (IOError, OSError) as err:<EOL><INDENT>if err.errno == errno.ENOENT:<EOL><INDENT>raise NotInitializedError("<STR_LIT>")<EOL><DEDENT>raise InconsistentStateError("<STR_LIT>"<EOL>+ str(err))<EOL><DEDENT>except Exception as err:<EOL><INDENT>raise InconsistentStateError("<STR_LIT>"<EOL>+ str(err))<EOL><DEDENT>

Try to load a blockade state file in the current directory


return Fasta(self.id, '<STR_LIT>'.join([genetic_codes.codes[genetic_code].get(self.seq[x:x+<NUM_LIT:3>].upper(), '<STR_LIT:X>') for x in range(frame, len(self)-<NUM_LIT:1>-frame, <NUM_LIT:3>)]))<EOL>

Returns a Fasta sequence, translated into amino acids. Starts translating from 'frame', where frame expected to be 0,1 or 2


gc_total = <NUM_LIT:0.0><EOL>num_bases = <NUM_LIT:0.0><EOL>n_tuple = tuple('<STR_LIT>')<EOL>accepted_bases = tuple('<STR_LIT>')<EOL>for base, count in Counter(self.seq).items():<EOL><INDENT>if base not in n_tuple:<EOL><INDENT>num_bases += count<EOL>if base in accepted_bases:  <EOL><INDENT>gc_total += count<EOL><DEDENT><DEDENT><DEDENT>gc_content = gc_total / num_bases<EOL>if not as_decimal:  <EOL><INDENT>gc_content *= <NUM_LIT:100><EOL><DEDENT>return gc_content<EOL>

Returns the GC content for the sequence.
        Notes:
            This method ignores N when calculating the length of the sequence.
            It does not, however ignore other ambiguous bases. It also only
            includes the ambiguous base S (G or C). In this sense the method is
            conservative with its calculation.

        Args:
            as_decimal (bool): Return the result as a decimal. Setting to False
            will return as a percentage. i.e for the sequence GCAT it will
            return 0.5 by default and 50.00 if set to False.

        Returns:
            float: GC content calculated as the number of G, C, and S divided
            by the number of (non-N) bases (length).


s = list(self.seq)<EOL>for i in range(len(s)):<EOL><INDENT>if s[i] in redundant_nts:<EOL><INDENT>s[i] = '<STR_LIT>'.join(redundant_nts[s[i]])<EOL><DEDENT><DEDENT>seqs = []<EOL>for x in itertools.product(*s):<EOL><INDENT>seqs.append(Fasta(self.id + '<STR_LIT:.>' + str(len(seqs) + <NUM_LIT:1>), '<STR_LIT>'.join(x)))<EOL><DEDENT>return seqs<EOL>

Assumes sequence is nucleotides. Returns list of all combinations of redundant nucleotides. e.g. R is A or G, so CRT would have combinations CAT and CGT


return Fastq(self.id, self.seq[start:end], self.qual[start:end])<EOL>

Returns Fastq object with the same name, of the bases from start to end, but not including end


return Fasta(self.id, self.seq[start:end])<EOL>

Returns Fasta object with the same name, of the bases from start to end, but not including end


if len(self) != len(qual_scores):<EOL><INDENT>raise Error('<STR_LIT>', self.id)<EOL><DEDENT>return Fastq(self.id, self.seq, '<STR_LIT>'.join([chr(max(<NUM_LIT:0>, min(x, <NUM_LIT>)) + <NUM_LIT>) for x in qual_scores]))<EOL>

Returns a Fastq object. qual_scores expected to be a list of numbers, like you would get in a .qual file


self.seq = self.seq.replace(old, new)<EOL>

Replaces all occurrences of 'old' with 'new


def orfs(self, frame=<NUM_LIT:0>, revcomp=False):

assert frame in [<NUM_LIT:0>,<NUM_LIT:1>,<NUM_LIT:2>]<EOL>if revcomp:<EOL><INDENT>self.revcomp()<EOL><DEDENT>aa_seq = self.translate(frame=frame).seq.rstrip('<STR_LIT:X>')<EOL>if revcomp:<EOL><INDENT>self.revcomp()<EOL><DEDENT>orfs = _orfs_from_aa_seq(aa_seq)<EOL>for i in range(len(orfs)):<EOL><INDENT>if revcomp:<EOL><INDENT>start = len(self) - (orfs[i].end * <NUM_LIT:3> + <NUM_LIT:3>) - frame<EOL>end = len(self) - (orfs[i].start * <NUM_LIT:3>) - <NUM_LIT:1> - frame<EOL><DEDENT>else:<EOL><INDENT>start = orfs[i].start * <NUM_LIT:3> + frame<EOL>end = orfs[i].end * <NUM_LIT:3> + <NUM_LIT:2> + frame<EOL><DEDENT>orfs[i] = intervals.Interval(start, end)<EOL><DEDENT>return orfs<EOL>

Returns a list of ORFs that the sequence has, starting on the given
           frame. Each returned ORF is an interval.Interval object.
           If revomp=True, then finds the ORFs of the reverse complement
           of the sequence.


def replace_interval(self, start, end, new, qual_string):

if len(new) != len(qual_string):<EOL><INDENT>raise Error('<STR_LIT>')<EOL><DEDENT>super().replace_interval(start, end, new)<EOL>self.qual = self.qual[<NUM_LIT:0>:start] + qual_string + self.qual[end + <NUM_LIT:1>:]<EOL>

Replaces the sequence from start to end with the sequence "new


if self.id.endswith('<STR_LIT>') or self.id.endswith('<STR_LIT>'):<EOL><INDENT>self.id = self.id[:-<NUM_LIT:2>]<EOL><DEDENT>

Removes any trailing /1 or /2 off the end of the name


self.id = self.id.split()[<NUM_LIT:0>]<EOL>

Removes everything in the name after the first whitespace character


self.seq = self.seq.translate(str.maketrans("<STR_LIT>", "<STR_LIT>"))[::-<NUM_LIT:1>]<EOL>


def gaps(self, min_length = <NUM_LIT:1>):

gaps = []<EOL>regex = re.compile('<STR_LIT>', re.IGNORECASE)<EOL>for m in regex.finditer(self.seq):<EOL><INDENT>if m.span()[<NUM_LIT:1>] - m.span()[<NUM_LIT:0>] + <NUM_LIT:1> >= min_length:<EOL><INDENT>gaps.append(intervals.Interval(m.span()[<NUM_LIT:0>], m.span()[<NUM_LIT:1>] - <NUM_LIT:1>))<EOL><DEDENT><DEDENT>return gaps<EOL>

Finds the positions of all gaps in the sequence that are at least min_length long. Returns a list of Intervals. Coords are zero-based


self.seq = re.sub(r'''<STR_LIT>''', '<STR_LIT:N>', self.seq)<EOL>

Replace all non acgt characters with an N (case insensitive)


super().trim(start, end)<EOL>self.qual = self.qual[start:len(self.qual) - end]<EOL>

Removes first 'start'/'end' bases off the start/end of the sequence


seq_reader = sequences.file_reader(infile)<EOL>f_out = utils.open_file_write(outfile)<EOL>for sequence in seq_reader:<EOL><INDENT>print("<STR_LIT>" + sequence.id, file=f_out)<EOL>print("<STR_LIT>" + sequence.seq, file=f_out)<EOL>print("<STR_LIT:=>", file=f_out)<EOL><DEDENT>utils.close(f_out)<EOL>

Converts input sequence file into a "Boulder-IO format", as used by primer3


def split_by_fixed_size(infile, outfiles_prefix, chunk_size, tolerance, skip_if_all_Ns=False):

file_count = <NUM_LIT:1><EOL>coords = []<EOL>small_sequences = []  <EOL>seq_reader = sequences.file_reader(infile)<EOL>f_coords = utils.open_file_write(outfiles_prefix + '<STR_LIT>')<EOL>for seq in seq_reader:<EOL><INDENT>if skip_if_all_Ns and seq.is_all_Ns():<EOL><INDENT>continue<EOL><DEDENT>if len(seq) < chunk_size:<EOL><INDENT>small_sequences.append(copy.copy(seq))<EOL><DEDENT>elif len(seq) <= chunk_size + tolerance:<EOL><INDENT>f = utils.open_file_write(outfiles_prefix + '<STR_LIT:.>' + str(file_count))<EOL>print(seq, file=f)<EOL>utils.close(f)<EOL>file_count += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>chunks = [(x,x+chunk_size) for x in range(<NUM_LIT:0>, len(seq), chunk_size)]<EOL>if chunks[-<NUM_LIT:1>][<NUM_LIT:1>] - <NUM_LIT:1> > len(seq):<EOL><INDENT>chunks[-<NUM_LIT:1>] = (chunks[-<NUM_LIT:1>][<NUM_LIT:0>], len(seq))<EOL><DEDENT>if len(chunks) > <NUM_LIT:1> and (chunks[-<NUM_LIT:1>][<NUM_LIT:1>] - chunks[-<NUM_LIT:1>][<NUM_LIT:0>]) <= tolerance:<EOL><INDENT>chunks[-<NUM_LIT:2>] = (chunks[-<NUM_LIT:2>][<NUM_LIT:0>], chunks[-<NUM_LIT:1>][<NUM_LIT:1>])<EOL>chunks.pop()<EOL><DEDENT>offset = <NUM_LIT:0><EOL>for chunk in chunks:<EOL><INDENT>if not(skip_if_all_Ns and seq.is_all_Ns(start=chunk[<NUM_LIT:0>], end=chunk[<NUM_LIT:1>]-<NUM_LIT:1>)):<EOL><INDENT>f = utils.open_file_write(outfiles_prefix + '<STR_LIT:.>' + str(file_count))<EOL>chunk_id = seq.id + '<STR_LIT::>' + str(chunk[<NUM_LIT:0>]+<NUM_LIT:1>) + '<STR_LIT:->' + str(chunk[<NUM_LIT:1>])<EOL>print(sequences.Fasta(chunk_id, seq[chunk[<NUM_LIT:0>]:chunk[<NUM_LIT:1>]]), file=f)<EOL>print(chunk_id, seq.id, offset, sep='<STR_LIT:\t>', file=f_coords)<EOL>utils.close(f)<EOL>file_count += <NUM_LIT:1><EOL><DEDENT>offset += chunk[<NUM_LIT:1>] - chunk[<NUM_LIT:0>]<EOL><DEDENT><DEDENT><DEDENT>if len(small_sequences):<EOL><INDENT>f = utils.open_file_write(outfiles_prefix + '<STR_LIT:.>' + str(file_count))<EOL>file_count += <NUM_LIT:1><EOL>base_count = <NUM_LIT:0><EOL>for seq in small_sequences:<EOL><INDENT>if base_count > <NUM_LIT:0> and base_count + len(seq) > chunk_size + tolerance:<EOL><INDENT>utils.close(f)<EOL>f = utils.open_file_write(outfiles_prefix + '<STR_LIT:.>' + str(file_count))<EOL>file_count += <NUM_LIT:1><EOL>base_count = <NUM_LIT:0><EOL><DEDENT>print(seq, file=f)<EOL>base_count += len(seq)<EOL><DEDENT>utils.close(f)<EOL><DEDENT>

Splits  fasta/q file into separate files, with up to (chunk_size + tolerance) bases in each file


def scaffolds_to_contigs(infile, outfile, number_contigs=False):

seq_reader = sequences.file_reader(infile)<EOL>fout = utils.open_file_write(outfile)<EOL>for seq in seq_reader:<EOL><INDENT>contigs = seq.contig_coords()<EOL>counter = <NUM_LIT:1><EOL>for contig in contigs:<EOL><INDENT>if number_contigs:<EOL><INDENT>name = seq.id + '<STR_LIT:.>' + str(counter)<EOL>counter += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>name = '<STR_LIT:.>'.join([seq.id, str(contig.start + <NUM_LIT:1>), str(contig.end + <NUM_LIT:1>)])<EOL><DEDENT>print(sequences.Fasta(name, seq[contig.start:contig.end+<NUM_LIT:1>]), file=fout)<EOL><DEDENT><DEDENT>utils.close(fout)<EOL>

Makes a file of contigs from scaffolds by splitting at every N.
       Use number_contigs=True to add .1, .2, etc onto end of each
       contig, instead of default to append coordinates.