@resources.command(ignore_defaults=True, no_args_is_help=False)<EOL><INDENT>@click.option('<STR_LIT>', is_flag=True, default=False,<EOL>help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', help='<STR_LIT>')<EOL>def list(self, root=False, **kwargs):<DEDENT>

<EOL>if kwargs.get('<STR_LIT>', None):<EOL><INDENT>self.set_child_endpoint(parent=kwargs['<STR_LIT>'], inventory=kwargs.get('<STR_LIT>', None))<EOL>kwargs.pop('<STR_LIT>')<EOL><DEDENT>if root and not kwargs.get('<STR_LIT>', None):<EOL><INDENT>raise exc.UsageError('<STR_LIT>')<EOL><DEDENT>if root:<EOL><INDENT>inventory_id = kwargs['<STR_LIT>']<EOL>r = client.get('<STR_LIT>' % inventory_id)<EOL>return r.json()<EOL><DEDENT>return super(Resource, self).list(**kwargs)<EOL>

Return a list of groups.

        =====API DOCS=====
        Retrieve a list of groups.

        :param root: Flag that if set, only root groups of a specific inventory will be listed.
        :type root: bool
        :param parent: Primary key or name of the group whose child groups will be listed.
        :type parent: str
        :param all_pages: Flag that if set, collect all pages of content from the API when returning results.
        :type all_pages: bool
        :param page: The page to show. Ignored if all_pages is set.
        :type page: int
        :param query: Contains 2-tuples used as query parameters to filter resulting resource objects.
        :type query: list
        :param `**kwargs`: Keyword arguments list of available fields used for searching resource objects.
        :returns: A JSON object containing details of all resource objects returned by Tower backend.
        :rtype: dict
        :raises tower_cli.exceptions.UsageError: When ``root`` flag is on and ``inventory`` is not present in
                                                 ``**kwargs``.

        =====API DOCS=====


if name in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>raise AttributeError<EOL><DEDENT>else:<EOL><INDENT>return object.__getattribute__(self, name)<EOL><DEDENT>

Disable inherited methods that cannot be applied to this
        particular resource.


def configure_display(self, data, kwargs=None, write=False):

if settings.format != '<STR_LIT>':<EOL><INDENT>return  <EOL><DEDENT>if write:<EOL><INDENT>obj, obj_type, res, res_type = self.obj_res(kwargs)<EOL>data['<STR_LIT:type>'] = kwargs['<STR_LIT:type>']<EOL>data[obj_type] = obj<EOL>data[res_type] = res<EOL>self.set_display_columns(<EOL>set_false=['<STR_LIT>' if obj_type == '<STR_LIT:user>' else '<STR_LIT:user>'],<EOL>set_true=['<STR_LIT>' if res_type == '<STR_LIT>' else res_type])<EOL><DEDENT>else:<EOL><INDENT>self.set_display_columns(<EOL>set_false=['<STR_LIT:user>', '<STR_LIT>'],<EOL>set_true=['<STR_LIT>', '<STR_LIT>'])<EOL>if '<STR_LIT>' in data:<EOL><INDENT>for i in range(len(data['<STR_LIT>'])):<EOL><INDENT>self.populate_resource_columns(data['<STR_LIT>'][i])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.populate_resource_columns(data)<EOL><DEDENT><DEDENT>

Populates columns and sets display attribute as needed.
        Operates on data.


data, self.endpoint = self.data_endpoint(kwargs)<EOL>r = super(Resource, self).list(**data)<EOL>self.configure_display(r)<EOL>return r<EOL>

Return a list of roles.

        =====API DOCS=====
        Retrieve a list of objects.

        :param all_pages: Flag that if set, collect all pages of content from the API when returning results.
        :type all_pages: bool
        :param page: The page to show. Ignored if all_pages is set.
        :type page: int
        :param query: Contains 2-tuples used as query parameters to filter resulting resource objects.
        :type query: list
        :param `**kwargs`: Keyword arguments list of available fields used for searching resource objects.
        :returns: A JSON object containing details of all resource objects returned by Tower backend.
        :rtype: dict

        =====API DOCS=====


@classmethod<EOL><INDENT>def data_endpoint(cls, in_data, ignore=[]):<DEDENT>

obj, obj_type, res, res_type = cls.obj_res(in_data, fail_on=[])<EOL>data = {}<EOL>if '<STR_LIT>' in ignore:<EOL><INDENT>obj = None<EOL><DEDENT>if '<STR_LIT>' in ignore:<EOL><INDENT>res = None<EOL><DEDENT>if obj and obj_type == '<STR_LIT:user>':<EOL><INDENT>data['<STR_LIT>'] = obj<EOL><DEDENT>if obj and obj_type == '<STR_LIT>':<EOL><INDENT>endpoint = '<STR_LIT>' % (grammar.pluralize(obj_type), obj)<EOL>if res is not None:<EOL><INDENT>data['<STR_LIT>'] = res<EOL><DEDENT><DEDENT>elif res:<EOL><INDENT>endpoint = '<STR_LIT>' % (grammar.pluralize(res_type), res)<EOL><DEDENT>else:<EOL><INDENT>endpoint = '<STR_LIT>'<EOL><DEDENT>if in_data.get('<STR_LIT:type>', False):<EOL><INDENT>data['<STR_LIT>'] = '<STR_LIT>' % in_data['<STR_LIT:type>'].lower()<EOL><DEDENT>for key, value in in_data.items():<EOL><INDENT>if key not in RESOURCE_FIELDS and key not in ['<STR_LIT:type>', '<STR_LIT:user>', '<STR_LIT>']:<EOL><INDENT>data[key] = value<EOL><DEDENT><DEDENT>return data, endpoint<EOL>

Converts a set of CLI input arguments, `in_data`, into
request data and an endpoint that can be used to look
up a role or list of roles.

Also changes the format of `type` in data to what the server
expects for the role model, as it exists in the database.


def role_write(self, fail_on_found=False, disassociate=False, **kwargs):

<EOL>data, self.endpoint = self.data_endpoint(kwargs, ignore=['<STR_LIT>'])<EOL>debug.log('<STR_LIT>', header='<STR_LIT>')<EOL>response = self.read(pk=None, fail_on_no_results=True,<EOL>fail_on_multiple_results=True, **data)<EOL>role_data = response['<STR_LIT>'][<NUM_LIT:0>]<EOL>role_id = role_data['<STR_LIT:id>']<EOL>self.configure_display(role_data, kwargs, write=True)<EOL>obj, obj_type, res, res_type = self.obj_res(kwargs)<EOL>debug.log('<STR_LIT>' % obj_type,<EOL>header='<STR_LIT>')<EOL>data, self.endpoint = self.data_endpoint(kwargs)<EOL>data['<STR_LIT>'] = res_type.replace('<STR_LIT:_>', '<STR_LIT>')<EOL>response = self.read(pk=None, fail_on_no_results=False,<EOL>fail_on_multiple_results=False, **data)<EOL>msg = '<STR_LIT>'<EOL>if response['<STR_LIT:count>'] > <NUM_LIT:0> and not disassociate:<EOL><INDENT>msg = '<STR_LIT>' % obj_type<EOL><DEDENT>elif response['<STR_LIT:count>'] == <NUM_LIT:0> and disassociate:<EOL><INDENT>msg = '<STR_LIT>' % obj_type<EOL><DEDENT>if msg:<EOL><INDENT>role_data['<STR_LIT>'] = False<EOL>if fail_on_found:<EOL><INDENT>raise exc.NotFound(msg)<EOL><DEDENT>else:<EOL><INDENT>debug.log(msg, header='<STR_LIT>')<EOL>return role_data<EOL><DEDENT><DEDENT>debug.log('<STR_LIT>' % (<EOL>'<STR_LIT>' if disassociate else '<STR_LIT>', obj_type), header='<STR_LIT>')<EOL>post_data = {'<STR_LIT:id>': role_id}<EOL>if disassociate:<EOL><INDENT>post_data['<STR_LIT>'] = True<EOL><DEDENT>client.post('<STR_LIT>' % (grammar.pluralize(obj_type), obj),<EOL>data=post_data)<EOL>role_data['<STR_LIT>'] = True<EOL>return role_data<EOL>

Re-implementation of the parent `write` method specific to roles.
        Adds a grantee (user or team) to the resource's role.


return self.role_write(fail_on_found=fail_on_found,<EOL>disassociate=True, **kwargs)<EOL>

Remove a user or a team from a role. Required information:
        1) Type of the role
        2) Resource of the role, inventory, credential, or any other
        3) A user or a team to add to the role

        =====API DOCS=====
        Remove a user or a team from a role. Required information:
        * Type of the role.
        * Resource of the role, inventory, credential, or any other.
        * A user or a team to add to the role.

        :param fail_on_found: Flag that if set, the operation fails if a user/team dose not have the role.
        :type fail_on_found: bool
        :param `**kwargs`: The user to be disassociated and the role to disassociate.
        :returns: parsed JSON of role revoke.
        :rtype: dict

        =====API DOCS=====


def _configuration(self, kwargs, config_item):

if '<STR_LIT>' not in config_item:<EOL><INDENT>if '<STR_LIT>' not in kwargs:<EOL><INDENT>return<EOL><DEDENT>nc = kwargs['<STR_LIT>'] = {}<EOL>for field in Resource.configuration[kwargs['<STR_LIT>']]:<EOL><INDENT>if field not in config_item:<EOL><INDENT>raise exc.TowerCLIError('<STR_LIT>'<EOL>'<STR_LIT>' % field)<EOL><DEDENT>else:<EOL><INDENT>nc[field] = config_item[field]<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>kwargs['<STR_LIT>'] =config_item['<STR_LIT>']<EOL><DEDENT>

Combine configuration-related keyworded arguments into
        notification_configuration.


@resources.command<EOL><INDENT>def list(self, all_pages=False, **kwargs):<DEDENT>

self._separate(kwargs)<EOL>return super(Resource, self).list(all_pages=all_pages, **kwargs)<EOL>

Return a list of notification templates.

        Note here configuration-related fields like
        'notification_configuration' and 'channels' will not be
        used even provided.

        If one or more filters are provided through keyword arguments,
        filter the results accordingly.

        If no filters are provided, return all results.

        =====API DOCS=====
        Retrieve a list of objects.

        :param all_pages: Flag that if set, collect all pages of content from the API when returning results.
        :type all_pages: bool
        :param page: The page to show. Ignored if all_pages is set.
        :type page: int
        :param query: Contains 2-tuples used as query parameters to filter resulting resource objects.
        :type query: list
        :param `**kwargs`: Keyword arguments list of available fields used for searching resource objects.
        :returns: A JSON object containing details of all resource objects returned by Tower backend.
        :rtype: dict

        =====API DOCS=====


@resources.command<EOL><INDENT>@click.option('<STR_LIT>', type=types.Related('<STR_LIT>'),<EOL>required=False, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=click.Choice(['<STR_LIT:error>', '<STR_LIT:success>']),<EOL>required=False, help='<STR_LIT>'<EOL>'<STR_LIT>')<EOL>def create(self, fail_on_found=False, force_on_exists=False, **kwargs):<DEDENT>

config_item = self._separate(kwargs)<EOL>jt_id = kwargs.pop('<STR_LIT>', None)<EOL>status = kwargs.pop('<STR_LIT:status>', '<STR_LIT>')<EOL>old_endpoint = self.endpoint<EOL>if jt_id is not None:<EOL><INDENT>jt = get_resource('<STR_LIT>')<EOL>jt.get(pk=jt_id)<EOL>try:<EOL><INDENT>nt_id = self.get(**copy.deepcopy(kwargs))['<STR_LIT:id>']<EOL><DEDENT>except exc.NotFound:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if fail_on_found:<EOL><INDENT>raise exc.TowerCLIError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>debug.log('<STR_LIT>'<EOL>'<STR_LIT>',<EOL>header='<STR_LIT>')<EOL>return jt.associate_notification_template(<EOL>jt_id, nt_id, status=status)<EOL><DEDENT><DEDENT>self.endpoint = '<STR_LIT>' %(jt_id, status)<EOL><DEDENT>self._configuration(kwargs, config_item)<EOL>result = super(Resource, self).create(**kwargs)<EOL>self.endpoint = old_endpoint<EOL>return result<EOL>

Create a notification template.

        All required configuration-related fields (required according to
        notification_type) must be provided.

        There are two types of notification template creation: isolatedly
        creating a new notification template and creating a new notification
        template under a job template. Here the two types are discriminated by
        whether to provide --job-template option. --status option controls
        more specific, job-run-status-related association.

        Fields in the resource's `identity` tuple are used for a lookup;
        if a match is found, then no-op (unless `force_on_exists` is set) but
        do not fail (unless `fail_on_found` is set).

        =====API DOCS=====
        Create an object.

        :param fail_on_found: Flag that if set, the operation fails if an object matching the unique criteria
                              already exists.
        :type fail_on_found: bool
        :param force_on_exists: Flag that if set, then if a match is found on unique fields, other fields will
                                be updated to the provided values.; If unset, a match causes the request to be
                                a no-op.
        :type force_on_exists: bool
        :param `**kwargs`: Keyword arguments which, all together, will be used as POST body to create the
                           resource object.
        :returns: A dictionary combining the JSON output of the created resource, as well as two extra fields:
                  "changed", a flag indicating if the resource is created successfully; "id", an integer which
                  is the primary key of the created object.
        :rtype: dict

        =====API DOCS=====


self._pop_none(kwargs)<EOL>result = {}<EOL>for field in Resource.config_fields:<EOL><INDENT>if field in kwargs:<EOL><INDENT>result[field] = kwargs.pop(field)<EOL>if field in Resource.json_fields:<EOL><INDENT>if not isinstance(result[field], six.string_types):<EOL><INDENT>continue<EOL><DEDENT>try:<EOL><INDENT>data = json.loads(result[field])<EOL>result[field] = data<EOL><DEDENT>except ValueError:<EOL><INDENT>raise exc.TowerCLIError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return result<EOL>

Remove None-valued and configuration-related keyworded arguments


@resources.command<EOL><INDENT>def get(self, pk=None, **kwargs):<DEDENT>

self._separate(kwargs)<EOL>return super(Resource, self).get(pk=pk, **kwargs)<EOL>

Return one and exactly one notification template.

        Note here configuration-related fields like
        'notification_configuration' and 'channels' will not be
        used even provided.

        Lookups may be through a primary key, specified as a positional
        argument, and/or through filters specified through keyword arguments.

        If the number of results does not equal one, raise an exception.

        =====API DOCS=====
        Retrieve one and exactly one object.

        :param pk: Primary key of the resource to be read. Tower CLI will only attempt to read *that* object
                   if ``pk`` is provided (not ``None``).
        :type pk: int
        :param `**kwargs`: Keyword arguments used to look up resource object to retrieve if ``pk`` is not provided.
        :returns: loaded JSON of the retrieved resource object.
        :rtype: dict

        =====API DOCS=====


@resources.command<EOL><INDENT>def delete(self, pk=None, fail_on_missing=False, **kwargs):<DEDENT>

self._separate(kwargs)<EOL>return super(Resource, self).delete(pk=pk, fail_on_missing=fail_on_missing, **kwargs)<EOL>

Remove the given notification template.

        Note here configuration-related fields like
        'notification_configuration' and 'channels' will not be
        used even provided.

        If `fail_on_missing` is True, then the object's not being found is
        considered a failure; otherwise, a success with no change is reported.

        =====API DOCS=====
        Remove the given object.

        :param pk: Primary key of the resource to be deleted.
        :type pk: int
        :param fail_on_missing: Flag that if set, the object's not being found is considered a failure; otherwise,
                                a success with no change is reported.
        :type fail_on_missing: bool
        :param `**kwargs`: Keyword arguments used to look up resource object to delete if ``pk`` is not provided.
        :returns: dictionary of only one field "changed", which is a flag indicating whether the specified resource
                  is successfully deleted.
        :rtype: dict

        =====API DOCS=====


<EOL>debug.log('<STR_LIT>', header='<STR_LIT>')<EOL>r = client.get('<STR_LIT>' % (self.endpoint, inventory_source))<EOL>if not r.json()['<STR_LIT>']:<EOL><INDENT>raise exc.BadRequest('<STR_LIT>')<EOL><DEDENT>debug.log('<STR_LIT>', header='<STR_LIT>')<EOL>r = client.post('<STR_LIT>' % (self.endpoint, inventory_source), data={})<EOL>inventory_update_id = r.json()['<STR_LIT>']<EOL>if monitor or wait:<EOL><INDENT>if monitor:<EOL><INDENT>result = self.monitor(inventory_update_id, parent_pk=inventory_source, timeout=timeout)<EOL><DEDENT>elif wait:<EOL><INDENT>result = self.wait(inventory_update_id, parent_pk=inventory_source, timeout=timeout)<EOL><DEDENT>inventory = client.get('<STR_LIT>' % result['<STR_LIT>']).json()['<STR_LIT>']<EOL>result['<STR_LIT>'] = int(inventory)<EOL>return result<EOL><DEDENT>return {<EOL>'<STR_LIT:id>': inventory_update_id,<EOL>'<STR_LIT:status>': '<STR_LIT>'<EOL>}<EOL>

Update the given inventory source.

        =====API DOCS=====
        Update the given inventory source.

        :param inventory_source: Primary key or name of the inventory source to be updated.
        :type inventory_source: str
        :param monitor: Flag that if set, immediately calls ``monitor`` on the newly launched inventory update
                        rather than exiting with a success.
        :type monitor: bool
        :param wait: Flag that if set, monitor the status of the inventory update, but do not print while it is
                     in progress.
        :type wait: bool
        :param timeout: If provided with ``monitor`` flag set, this attempt will time out after the given number
                        of seconds.
        :type timeout: int
        :param `**kwargs`: Fields used to override underlyingl inventory source fields when creating and launching
                           an inventory update.
        :returns: Result of subsequent ``monitor`` call if ``monitor`` flag is on; Result of subsequent ``wait``
                  call if ``wait`` flag is on; dictionary of "status" if none of the two flags are on.
        :rtype: dict
        :raises tower_cli.exceptions.BadRequest: When the inventory source cannot be updated.

        =====API DOCS=====


@resources.command<EOL><INDENT>@click.option('<STR_LIT>', is_flag=True, default=False,<EOL>help='<STR_LIT>')<EOL>def status(self, pk, detail=False, **kwargs):<DEDENT>

<EOL>job = self.last_job_data(pk, **kwargs)<EOL>if detail:<EOL><INDENT>return job<EOL><DEDENT>return {<EOL>'<STR_LIT>': job['<STR_LIT>'],<EOL>'<STR_LIT>': job['<STR_LIT>'],<EOL>'<STR_LIT:status>': job['<STR_LIT:status>'],<EOL>}<EOL>

Print the status of the most recent sync.

        =====API DOCS=====
        Retrieve the current inventory update status.

        :param pk: Primary key of the resource to retrieve status from.
        :type pk: int
        :param detail: Flag that if set, return the full JSON of the job resource rather than a status summary.
        :type detail: bool
        :param `**kwargs`: Keyword arguments used to look up resource object to retrieve status from if ``pk``
                           is not provided.
        :returns: full loaded JSON of the specified unified job if ``detail`` flag is on; trimed JSON containing
                  only "elapsed", "failed" and "status" fields of the unified job if ``detail`` flag is off.
        :rtype: dict

        =====API DOCS=====


@resources.command<EOL><INDENT>@click.option('<STR_LIT>', type=types.Related('<STR_LIT>'),<EOL>required=False, help='<STR_LIT>')<EOL>def create(self, fail_on_found=False, force_on_exists=False, **kwargs):<DEDENT>

jt_id = kwargs.pop('<STR_LIT>', None)<EOL>old_endpoint = self.endpoint<EOL>if jt_id is not None:<EOL><INDENT>jt = get_resource('<STR_LIT>')<EOL>jt.get(pk=jt_id)<EOL>try:<EOL><INDENT>label_id = self.get(name=kwargs.get('<STR_LIT:name>', None), organization=kwargs.get('<STR_LIT>', None))['<STR_LIT:id>']<EOL><DEDENT>except exc.NotFound:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if fail_on_found:<EOL><INDENT>raise exc.TowerCLIError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>debug.log('<STR_LIT>', header='<STR_LIT>')<EOL>return jt.associate_label(job_template=jt_id, label=label_id)<EOL><DEDENT><DEDENT>self.endpoint = '<STR_LIT>' % jt_id<EOL><DEDENT>result = super(Resource, self).create(fail_on_found=fail_on_found, force_on_exists=force_on_exists, **kwargs)<EOL>self.endpoint = old_endpoint<EOL>return result<EOL>

Create a new label.

        There are two types of label creation: isolatedly creating a new label and creating a new label under
        a job template. Here the two types are discriminated by whether to provide --job-template option.

        Fields in the resource's `identity` tuple are used for a lookup; if a match is found, then no-op (unless
        `force_on_exists` is set) but do not fail (unless `fail_on_found` is set).

        =====API DOCS=====
        Create a label.

        :param job_template: Primary key or name of the job template for the created label to associate to.
        :type job_template: str
        :param fail_on_found: Flag that if set, the operation fails if an object matching the unique criteria
                              already exists.
        :type fail_on_found: bool
        :param force_on_exists: Flag that if set, then if a match is found on unique fields, other fields will
                                be updated to the provided values.; If unset, a match causes the request to be
                                a no-op.
        :type force_on_exists: bool
        :param `**kwargs`: Keyword arguments which, all together, will be used as POST body to create the
                           resource object.
        :returns: A dictionary combining the JSON output of the created resource, as well as two extra fields:
                  "changed", a flag indicating if the resource is created successfully; "id", an integer which
                  is the primary key of the created object.
        :rtype: dict
        :raises tower_cli.exceptions.TowerCLIError: When the label already exists and ``fail_on_found`` flag is on.

        =====API DOCS=====


node_res = get_resource('<STR_LIT>')<EOL>node_results = node_res.list(workflow_job_template=wfjt_id,<EOL>all_pages=True)['<STR_LIT>']<EOL>return self._workflow_node_structure(node_results)<EOL>

Returns a dictionary that represents the node network of the
workflow job template


existing_network = self._get_schema(wfjt)<EOL>if not isinstance(existing_network, list):<EOL><INDENT>existing_network = []<EOL><DEDENT>if node_network is None:<EOL><INDENT>if settings.format == '<STR_LIT>':<EOL><INDENT>settings.format = '<STR_LIT>'<EOL><DEDENT>return existing_network<EOL><DEDENT>if hasattr(node_network, '<STR_LIT>'):<EOL><INDENT>node_network = node_network.read()<EOL><DEDENT>node_network = string_to_dict(<EOL>node_network, allow_kv=False, require_dict=False)<EOL>if not isinstance(node_network, list):<EOL><INDENT>node_network = []<EOL><DEDENT>_update_workflow([TreeNode(x, wfjt, include_id=True) for x in existing_network],<EOL>[TreeNode(x, wfjt) for x in node_network])<EOL>if settings.format == '<STR_LIT>':<EOL><INDENT>settings.format = '<STR_LIT>'<EOL><DEDENT>return self._get_schema(wfjt)<EOL>

Convert YAML/JSON content into workflow node objects if
node_network param is given.
If not, print a YAML representation of the node network.

=====API DOCS=====
Convert YAML/JSON content into workflow node objects if ``node_network`` param is given. If not,
print a YAML representation of the node network.

:param wfjt: Primary key or name of the workflow job template to run schema against.
:type wfjt: str
:param node_network: JSON- or YAML-formatted string representing the topology of the workflow job
                     template be updated to.
:type node_network: str
:returns: The latest topology (possibly after modification) of the workflow job template.
:rtype: dict

=====API DOCS=====


<EOL>node_list_pos = {}<EOL>for i, node_result in enumerate(node_results):<EOL><INDENT>for rel in ['<STR_LIT:success>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>node_result['<STR_LIT>'.format(rel)] = []<EOL><DEDENT>node_list_pos[node_result['<STR_LIT:id>']] = i<EOL><DEDENT>for node_result in node_results:<EOL><INDENT>for rel in ['<STR_LIT:success>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>for sub_node_id in node_result['<STR_LIT>'.format(rel)]:<EOL><INDENT>j = node_list_pos[sub_node_id]<EOL>node_results[j]['<STR_LIT>'.format(rel)].append(<EOL>node_result['<STR_LIT:id>'])<EOL><DEDENT><DEDENT><DEDENT>root_nodes = []<EOL>for node_result in node_results:<EOL><INDENT>is_root = True<EOL>for rel in ['<STR_LIT:success>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>if node_result['<STR_LIT>'.format(rel)] != []:<EOL><INDENT>is_root = False<EOL>break<EOL><DEDENT><DEDENT>if is_root:<EOL><INDENT>root_nodes.append(node_result['<STR_LIT:id>'])<EOL><DEDENT><DEDENT>def branch_schema(node_id):<EOL><INDENT>i = node_list_pos[node_id]<EOL>node_dict = node_results[i]<EOL>ret_dict = {"<STR_LIT:id>": node_id}<EOL>for fd in NODE_STANDARD_FIELDS:<EOL><INDENT>val = node_dict.get(fd, None)<EOL>if val is not None:<EOL><INDENT>if fd == '<STR_LIT>':<EOL><INDENT>job_type = node_dict['<STR_LIT>'][<EOL>'<STR_LIT>']['<STR_LIT>']<EOL>ujt_key = JOB_TYPES[job_type]<EOL>ret_dict[ujt_key] = val<EOL><DEDENT>else:<EOL><INDENT>ret_dict[fd] = val<EOL><DEDENT><DEDENT><DEDENT>for rel in ['<STR_LIT:success>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>sub_node_id_list = node_dict['<STR_LIT>'.format(rel)]<EOL>if len(sub_node_id_list) == <NUM_LIT:0>:<EOL><INDENT>continue<EOL><DEDENT>relationship_name = '<STR_LIT>'.format(rel)<EOL>ret_dict[relationship_name] = []<EOL>for sub_node_id in sub_node_id_list:<EOL><INDENT>ret_dict[relationship_name].append(<EOL>branch_schema(sub_node_id))<EOL><DEDENT><DEDENT>return ret_dict<EOL><DEDENT>schema_dict = []<EOL>for root_node_id in root_nodes:<EOL><INDENT>schema_dict.append(branch_schema(root_node_id))<EOL><DEDENT>return schema_dict<EOL>

Takes the list results from the API in `node_results` and
translates this data into a dictionary organized in a
human-readable heirarchial structure


return self._assoc('<STR_LIT>' % status,<EOL>workflow, notification_template)<EOL>

Associate a notification template from this workflow.

        =====API DOCS=====
        Associate a notification template from this workflow job template.

        :param workflow: The workflow job template to associate to.
        :type workflow: str
        :param notification_template: The notification template to be associated.
        :type notification_template: str
        :param status: type of notification this notification template should be associated to.
        :type status: str
        :returns: Dictionary of only one key "changed", which indicates whether the association succeeded.
        :rtype: dict

        =====API DOCS=====


return self._disassoc('<STR_LIT>' % status,<EOL>workflow, notification_template)<EOL>

Disassociate a notification template from this workflow.

        =====API DOCS=====
        Disassociate a notification template from this workflow job template.

        :param job_template: The workflow job template to disassociate from.
        :type job_template: str
        :param notification_template: The notification template to be disassociated.
        :type notification_template: str
        :param status: type of notification this notification template should be disassociated from.
        :type status: str
        :returns: Dictionary of only one key "changed", which indicates whether the disassociation succeeded.
        :rtype: dict

        =====API DOCS=====


if '<STR_LIT>' in kwargs:<EOL><INDENT>kwargs['<STR_LIT>'] = kwargs.pop('<STR_LIT>')<EOL><DEDENT>r = super(Resource, self).read(*args, **kwargs)<EOL>if '<STR_LIT>' in r:<EOL><INDENT>for d in r['<STR_LIT>']:<EOL><INDENT>self._promote_actor(d)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self._promote_actor(d)<EOL><DEDENT>return r<EOL>

Do extra processing so we can display the actor field as
a top-level field


@resources.command(<EOL>use_fields_as_options=(<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>)<EOL>)<EOL><INDENT>@click.option('<STR_LIT>', is_flag=True, default=False,<EOL>help='<STR_LIT>'<EOL>'<STR_LIT>')<EOL>@click.option('<STR_LIT>', is_flag=True, default=False,<EOL>help='<STR_LIT>'<EOL>'<STR_LIT>')<EOL>@click.option('<STR_LIT>', required=False, type=int,<EOL>help='<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>def launch(self, monitor=False, wait=False, timeout=None, **kwargs):<DEDENT>

<EOL>r = client.get('<STR_LIT:/>')<EOL>if '<STR_LIT>' not in r.json():<EOL><INDENT>raise exc.TowerCLIError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>self._pop_none(kwargs)<EOL>debug.log('<STR_LIT>', header='<STR_LIT>')<EOL>result = client.post(self.endpoint, data=kwargs)<EOL>command = result.json()<EOL>command_id = command['<STR_LIT:id>']<EOL>if monitor:<EOL><INDENT>return self.monitor(command_id, timeout=timeout)<EOL><DEDENT>elif wait:<EOL><INDENT>return self.wait(command_id, timeout=timeout)<EOL><DEDENT>answer = OrderedDict((<EOL>('<STR_LIT>', True),<EOL>('<STR_LIT:id>', command_id),<EOL>))<EOL>answer.update(result.json())<EOL>return answer<EOL>

Launch a new ad-hoc command.

        Runs a user-defined command from Ansible Tower, immediately starts it,
        and returns back an ID in order for its status to be monitored.

        =====API DOCS=====
        Launch a new ad-hoc command.

        :param monitor: Flag that if set, immediately calls ``monitor`` on the newly launched command rather
                        than exiting with a success.
        :type monitor: bool
        :param wait: Flag that if set, monitor the status of the job, but do not print while job is in progress.
        :type wait: bool
        :param timeout: If provided with ``monitor`` flag set, this attempt will time out after the given number
                        of seconds.
        :type timeout: int
        :param `**kwargs`: Fields needed to create and launch an ad hoc command.
        :returns: Result of subsequent ``monitor`` call if ``monitor`` flag is on; Result of subsequent ``wait``
                  call if ``wait`` flag is on; dictionary of "id" and "changed" if none of the two flags are on.
        :rtype: dict
        :raises tower_cli.exceptions.TowerCLIError: When ad hoc commands are not available in Tower backend.

        =====API DOCS=====


return self._disassoc('<STR_LIT>' % status,<EOL>job_template, notification_template)<EOL>

Disassociate a notification template from this job template.

        =====API DOCS=====
        Disassociate a notification template from this job template.

        :param job_template: The job template to disassociate from.
        :type job_template: str
        :param notification_template: The notification template to be disassociated.
        :type notification_template: str
        :param status: type of notification this notification template should be disassociated from.
        :type status: str
        :returns: Dictionary of only one key "changed", which indicates whether the disassociation succeeded.
        :rtype: dict

        =====API DOCS=====


url = self.endpoint + '<STR_LIT>' % pk<EOL>if not host_config_key:<EOL><INDENT>host_config_key = client.get(url).json()['<STR_LIT>']<EOL><DEDENT>post_data = {'<STR_LIT>': host_config_key}<EOL>if extra_vars:<EOL><INDENT>post_data['<STR_LIT>'] = parser.process_extra_vars(list(extra_vars), force_json=True)<EOL><DEDENT>r = client.post(url, data=post_data, auth=None)<EOL>if r.status_code == <NUM_LIT>:<EOL><INDENT>return {'<STR_LIT>': True}<EOL><DEDENT>

Contact Tower and request a configuration update using this job template.

        =====API DOCS=====
        Contact Tower and request a provisioning callback using this job template.

        :param pk: Primary key of the job template to run provisioning callback against.
        :type pk: int
        :param host_config_key: Key string used to authenticate the callback host.
        :type host_config_key: str
        :param extra_vars: Extra variables that are passed to provisioning callback.
        :type extra_vars: array of str
        :returns: A dictionary of a single key "changed", which indicates whether the provisioning callback
                  is successful.
        :rtype: dict

        =====API DOCS=====


<EOL>def actual_decorator(method):<EOL><INDENT>method._cli_command = True<EOL>method._cli_command_attrs = kwargs<EOL>return method<EOL><DEDENT>if method and isinstance(method, types.FunctionType):<EOL><INDENT>return actual_decorator(method)<EOL><DEDENT>else:<EOL><INDENT>return actual_decorator<EOL><DEDENT>

Mark this method as a CLI command.

    This will only have any meaningful effect in methods that are members of a
    Resource subclass.


<EOL>try:<EOL><INDENT>return next(s for s in self.list()['<STR_LIT>'] if s['<STR_LIT:id>'] == pk)<EOL><DEDENT>except StopIteration:<EOL><INDENT>raise exc.NotFound('<STR_LIT>')<EOL><DEDENT>

Return one and exactly one object

        =====API DOCS=====
        Return one and exactly one Tower setting.

        :param pk: Primary key of the Tower setting to retrieve
        :type pk: int
        :returns: loaded JSON of the retrieved Tower setting object.
        :rtype: dict
        :raises tower_cli.exceptions.NotFound: When no specified Tower setting exists.

        =====API DOCS=====


if name in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>raise AttributeError<EOL><DEDENT>else:<EOL><INDENT>return object.__getattribute__(self, name)<EOL><DEDENT>

Disable inherited methods that cannot be applied to this
        particular resource.


prev_value = new_value = self.get(setting)['<STR_LIT:value>']<EOL>answer = OrderedDict()<EOL>encrypted = '<STR_LIT>' in six.text_type(prev_value)<EOL>if encrypted or six.text_type(prev_value) != six.text_type(value):<EOL><INDENT>if setting == '<STR_LIT>':<EOL><INDENT>r = client.post('<STR_LIT>',<EOL>data=self.coerce_type(setting, value))<EOL>new_value = r.json()<EOL><DEDENT>else:<EOL><INDENT>r = client.patch(<EOL>self.endpoint,<EOL>data={setting: self.coerce_type(setting, value)}<EOL>)<EOL>new_value = r.json()[setting]<EOL><DEDENT>answer.update(r.json())<EOL><DEDENT>changed = encrypted or (prev_value != new_value)<EOL>answer.update({<EOL>'<STR_LIT>': changed,<EOL>'<STR_LIT:id>': setting,<EOL>'<STR_LIT:value>': new_value,<EOL>})<EOL>return answer<EOL>

Modify an already existing object.

        Positional argument SETTING is the setting name and VALUE is its value,
        which can be provided directly or obtained from a file name if prefixed with '@'.

        =====API DOCS=====
        Modify an already existing Tower setting.

        :param setting: The name of the Tower setting to be modified.
        :type setting: str
        :param value: The new value of the Tower setting.
        :type value: str
        :returns: A dictionary combining the JSON output of the modified resource, as well as two extra fields:
                  "changed", a flag indicating if the resource is successfully updated; "id", an integer which
                  is the primary key of the updated object.
        :rtype: dict

        =====API DOCS=====


def jt_aggregate(func, is_create=False, has_pk=False):

def helper(kwargs, obj):<EOL><INDENT>"""<STR_LIT>"""<EOL>unified_job_template = None<EOL>for item in UNIFIED_JT:<EOL><INDENT>if kwargs.get(item, None) is not None:<EOL><INDENT>jt_id = kwargs.pop(item)<EOL>if unified_job_template is None:<EOL><INDENT>unified_job_template = (item, jt_id)<EOL><DEDENT>else:<EOL><INDENT>raise exc.UsageError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL><DEDENT><DEDENT><DEDENT>if unified_job_template is not None:<EOL><INDENT>kwargs['<STR_LIT>'] = unified_job_template[<NUM_LIT:1>]<EOL>obj.identity = tuple(list(obj.identity) + ['<STR_LIT>'])<EOL>return '<STR_LIT:/>'.join([UNIFIED_JT[unified_job_template[<NUM_LIT:0>]],<EOL>str(unified_job_template[<NUM_LIT:1>]), '<STR_LIT>'])<EOL><DEDENT>elif is_create:<EOL><INDENT>raise exc.UsageError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>def decorator_without_pk(obj, *args, **kwargs):<EOL><INDENT>old_endpoint = obj.endpoint<EOL>new_endpoint = helper(kwargs, obj)<EOL>if is_create:<EOL><INDENT>obj.endpoint = new_endpoint<EOL><DEDENT>result = func(obj, *args, **kwargs)<EOL>obj.endpoint = old_endpoint<EOL>return result<EOL><DEDENT>def decorator_with_pk(obj, pk=None, *args, **kwargs):<EOL><INDENT>old_endpoint = obj.endpoint<EOL>new_endpoint = helper(kwargs, obj)<EOL>if is_create:<EOL><INDENT>obj.endpoint = new_endpoint<EOL><DEDENT>result = func(obj, pk=pk, *args, **kwargs)<EOL>obj.endpoint = old_endpoint<EOL>return result<EOL><DEDENT>decorator = decorator_with_pk if has_pk else decorator_without_pk<EOL>for item in CLICK_ATTRS:<EOL><INDENT>setattr(decorator, item, getattr(func, item, []))<EOL><DEDENT>decorator.__doc__ = func.__doc__<EOL>return decorator<EOL>

Decorator to aggregate unified_jt-related fields.

    Args:
        func: The CURD method to be decorated.
        is_create: Boolean flag showing whether this method is create.
        has_pk: Boolean flag showing whether this method uses pk as argument.

    Returns:
        A function with necessary click-related attributes whose keyworded
        arguments are aggregated.

    Raises:
        exc.UsageError: Either more than one unified jt fields are
            provided, or none is provided when is_create flag is set.


pass<EOL>

Placeholder to get swapped out for `stdout`.

        =====API DOCS=====
        foobar
        =====API DOCS=====


@resources.command(use_fields_as_options=(<EOL>'<STR_LIT:name>', '<STR_LIT:description>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>'<EOL>))<EOL><INDENT>def modify(self, pk=None, create_on_missing=False, **kwargs):<DEDENT>

<EOL>if '<STR_LIT>' in kwargs and '<STR_LIT>' not in kwargs:<EOL><INDENT>kwargs['<STR_LIT>'] = kwargs.pop('<STR_LIT>')<EOL><DEDENT>return super(Resource, self).write(<EOL>pk, create_on_missing=create_on_missing,<EOL>force_on_exists=True, **kwargs<EOL>)<EOL>

Modify an already existing.

        To edit the project's organizations, see help for organizations.

        Fields in the resource's `identity` tuple can be used in lieu of a
        primary key for a lookup; in such a case, only other fields are
        written.

        To modify unique fields, you must use the primary key for the lookup.

        =====API DOCS=====
        Modify an already existing project.

        :param pk: Primary key of the resource to be modified.
        :type pk: int
        :param create_on_missing: Flag that if set, a new object is created if ``pk`` is not set and objects
                                  matching the appropriate unique criteria is not found.
        :type create_on_missing: bool
        :param `**kwargs`: Keyword arguments which, all together, will be used as PATCH body to modify the
                           resource object. if ``pk`` is not set, key-value pairs of ``**kwargs`` which are
                           also in resource's identity will be used to lookup existing reosource.
        :returns: A dictionary combining the JSON output of the modified resource, as well as two extra fields:
                  "changed", a flag indicating if the resource is successfully updated; "id", an integer which
                  is the primary key of the updated object.
        :rtype: dict

        =====API DOCS=====


@resources.command(use_fields_as_options=('<STR_LIT:name>', '<STR_LIT>'))<EOL><INDENT>@click.option('<STR_LIT>', is_flag=True, default=False,<EOL>help='<STR_LIT>'<EOL>'<STR_LIT>')<EOL>@click.option('<STR_LIT>', is_flag=True, default=False,<EOL>help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', required=False, type=int,<EOL>help='<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>def update(self, pk=None, create_on_missing=False, monitor=False,<EOL>wait=False, timeout=None, name=None, organization=None):<DEDENT>

<EOL>project = self.get(pk, name=name, organization=organization)<EOL>pk = project['<STR_LIT:id>']<EOL>debug.log('<STR_LIT>',<EOL>header='<STR_LIT>')<EOL>result = client.get('<STR_LIT>' % pk)<EOL>if not result.json()['<STR_LIT>']:<EOL><INDENT>raise exc.CannotStartJob('<STR_LIT>')<EOL><DEDENT>debug.log('<STR_LIT>', header='<STR_LIT>')<EOL>result = client.post('<STR_LIT>' % pk)<EOL>project_update_id = result.json()['<STR_LIT>']<EOL>if monitor:<EOL><INDENT>return self.monitor(project_update_id, parent_pk=pk,<EOL>timeout=timeout)<EOL><DEDENT>elif wait:<EOL><INDENT>return self.wait(project_update_id, parent_pk=pk, timeout=timeout)<EOL><DEDENT>return {<EOL>'<STR_LIT:id>': project_update_id,<EOL>'<STR_LIT>': True,<EOL>}<EOL>

Trigger a project update job within Ansible Tower.
        Only meaningful on non-manual projects.

        =====API DOCS=====
        Update the given project.

        :param pk: Primary key of the project to be updated.
        :type pk: int
        :param monitor: Flag that if set, immediately calls ``monitor`` on the newly launched project update
                        rather than exiting with a success.
        :type monitor: bool
        :param wait: Flag that if set, monitor the status of the project update, but do not print while it is
                     in progress.
        :type wait: bool
        :param timeout: If provided with ``monitor`` flag set, this attempt will time out after the given number
                        of seconds.
        :type timeout: int
        :param name: Name of the project to be updated if ``pk`` is not set.
        :type name: str
        :param organization: Primary key or name of the organization the project to be updated belonging to if
                             ``pk`` is not set.
        :type organization: str
        :returns: Result of subsequent ``monitor`` call if ``monitor`` flag is on; Result of subsequent ``wait``
                  call if ``wait`` flag is on; dictionary of "status" if none of the two flags are on.
        :rtype: dict
        :raises tower_cli.exceptions.CannotStartJob: When the project cannot be updated.

        =====API DOCS=====


@resources.command<EOL><INDENT>@click.option('<STR_LIT>', is_flag=True, default=False,<EOL>help='<STR_LIT>')<EOL>def status(self, pk=None, detail=False, **kwargs):<DEDENT>

<EOL>job = self.last_job_data(pk, **kwargs)<EOL>if detail:<EOL><INDENT>return job<EOL><DEDENT>return {<EOL>'<STR_LIT>': job['<STR_LIT>'],<EOL>'<STR_LIT>': job['<STR_LIT>'],<EOL>'<STR_LIT:status>': job['<STR_LIT:status>'],<EOL>}<EOL>

Print the status of the most recent update.

        =====API DOCS=====
        Print the status of the most recent update.

        :param pk: Primary key of the resource to retrieve status from.
        :type pk: int
        :param detail: Flag that if set, return the full JSON of the job resource rather than a status summary.
        :type detail: bool
        :param `**kwargs`: Keyword arguments used to look up resource object to retrieve status from if ``pk``
                           is not provided.
        :returns: full loaded JSON of the specified unified job if ``detail`` flag is on; trimed JSON containing
                  only "elapsed", "failed" and "status" fields of the unified job if ``detail`` flag is off.
        :rtype: dict
        =====API DOCS=====


return self._assoc_or_create('<STR_LIT>', parent, child, **kwargs)<EOL>

Add a node to always run after the parent is finished.

        =====API DOCS=====
        Add a node to always run after the parent is finished.

        :param parent: Primary key of parent node to associate always node to.
        :type parent: int
        :param child: Primary key of child node to be associated.
        :type child: int
        :param `**kwargs`: Fields used to create child node if ``child`` is not provided.
        :returns: Dictionary of only one key "changed", which indicates whether the association succeeded.
        :rtype: dict

        =====API DOCS=====


return self._disassoc(<EOL>self._forward_rel_name('<STR_LIT>'), parent, child)<EOL>

Remove a failure node link.
        The resulatant 2 nodes will both become root nodes.

        =====API DOCS=====
        Remove a failure node link.

        :param parent: Primary key of parent node to disassociate failure node from.
        :type parent: int
        :param child: Primary key of child node to be disassociated.
        :type child: int
        :returns: Dictionary of only one key "changed", which indicates whether the disassociation succeeded.
        :rtype: dict

        =====API DOCS=====


def _parent_filter(self, parent, relationship, **kwargs):

if parent is None or relationship is None:<EOL><INDENT>return {}<EOL><DEDENT>parent_filter_kwargs = {}<EOL>query_params = ((self._reverse_rel_name(relationship), parent),)<EOL>parent_filter_kwargs['<STR_LIT>'] = query_params<EOL>if kwargs.get('<STR_LIT>', None) is None:<EOL><INDENT>parent_data = self.read(pk=parent)['<STR_LIT>'][<NUM_LIT:0>]<EOL>parent_filter_kwargs['<STR_LIT>'] = parent_data[<EOL>'<STR_LIT>']<EOL><DEDENT>return parent_filter_kwargs<EOL>

Returns filtering parameters to limit a search to the children
of a particular node by a particular relationship.


Remove an always node link.
        The resultant 2 nodes will both become root nodes.

        =====API DOCS=====
        Remove an always node link.

        :param parent: Primary key of parent node to disassociate always node from.
        :type parent: int
        :param child: Primary key of child node to be disassociated.
        :type child: int
        :returns: Dictionary of only one key "changed", which indicates whether the disassociation succeeded.
        :rtype: dict

        =====API DOCS=====


@resources.command(ignore_defaults=True)<EOL><INDENT>def list_facts(self, pk=None, **kwargs):<DEDENT>

res = self.get(pk=pk, **kwargs)<EOL>url = self.endpoint + '<STR_LIT>' % (res['<STR_LIT:id>'], '<STR_LIT>')<EOL>return client.get(url, params={}).json()<EOL>

Return a JSON object of all available facts of the given host.

        Note global option --format is not available here, as the output would always be JSON-formatted.

        =====API DOCS=====
        List all available facts of the given host.

        :param pk: Primary key of the target host.
        :type pk: int
        :param `**kwargs`: Keyword arguments list of available fields used for searching resource objects.
        :returns: A JSON object of all available facts of the given host.
        :rtype: dict
        =====API DOCS=====


t.register_json('<STR_LIT>',<EOL>{<EOL>'<STR_LIT:id>': <NUM_LIT>, '<STR_LIT>': <NUM_LIT:1>, '<STR_LIT:status>': '<STR_LIT>',<EOL>'<STR_LIT>': <NUM_LIT>, '<STR_LIT>': <NUM_LIT:0.0>,<EOL>}, method='<STR_LIT:GET>')<EOL>

After starting job, the launch method may grab info about
    the job just launched from this endpoint


t.register_json('<STR_LIT>', {<EOL>'<STR_LIT>': True,<EOL>'<STR_LIT>': extra_vars,<EOL>'<STR_LIT:id>': <NUM_LIT:1>,<EOL>'<STR_LIT:name>': '<STR_LIT>',<EOL>'<STR_LIT>': {'<STR_LIT>': '<STR_LIT>'},<EOL>})<EOL>register_get(t)<EOL>t.register_json('<STR_LIT>', {'<STR_LIT:version>': '<STR_LIT>'}, method='<STR_LIT:GET>')<EOL>t.register_json('<STR_LIT>', {}, method='<STR_LIT:GET>')<EOL>t.register_json('<STR_LIT>', {'<STR_LIT:id>': <NUM_LIT>},<EOL>method='<STR_LIT:POST>')<EOL>

Endpoints that are needed to get information from job template.
    This particular combination also entails
    1) version of Tower - 2.2.0
    2) successful job launch, id=42
    3) prompts user for variables on launch


class BasicResource(models.Resource):<EOL><INDENT>endpoint = '<STR_LIT>'<EOL>name = models.Field(unique=True)<EOL><DEDENT>self.resource = BasicResource()<EOL>self.command = ResSubcommand(self.resource)<EOL>

Install a resource instance sufficient for testing common
        things with subcommands.


reqs = []<EOL>version_spec_in_play = None<EOL>for line in open(filename, '<STR_LIT:r>').read().strip().split('<STR_LIT:\n>'):<EOL><INDENT>if not line.strip():<EOL><INDENT>continue<EOL><DEDENT>if not line.startswith('<STR_LIT:#>'):<EOL><INDENT>reqs.append(line)<EOL>continue<EOL><DEDENT>match = re.search(r'<STR_LIT>'<EOL>r'<STR_LIT>', line)<EOL>if match:<EOL><INDENT>version_spec_in_play = match.groupdict()<EOL>for key in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>version_spec_in_play[key] = int(version_spec_in_play[key])<EOL><DEDENT>continue<EOL><DEDENT>if '<STR_LIT:U+0020>' not in line[<NUM_LIT:1>:].strip() and version_spec_in_play:<EOL><INDENT>package = line[<NUM_LIT:1>:].strip()<EOL>op = version_spec_in_play['<STR_LIT>']<EOL>vspec = (version_spec_in_play['<STR_LIT>'],<EOL>version_spec_in_play['<STR_LIT>'])<EOL>if '<STR_LIT:=>' in op and sys.version_info[<NUM_LIT:0>:<NUM_LIT:2>] == vspec:<EOL><INDENT>reqs.append(package)<EOL><DEDENT>elif '<STR_LIT:>>' in op and sys.version_info[<NUM_LIT:0>:<NUM_LIT:2>] > vspec:<EOL><INDENT>reqs.append(package)<EOL><DEDENT>elif '<STR_LIT:<>' in op and sys.version_info[<NUM_LIT:0>:<NUM_LIT:2>] < vspec:<EOL><INDENT>reqs.append(package)<EOL><DEDENT><DEDENT><DEDENT>return reqs<EOL>

Parse out a list of requirements from the given requirements
    requirements file.


return cls._item_dict.keys()<EOL>


@classmethod<EOL><INDENT>def lookup(cls, key, get=False):<DEDENT>

if get:<EOL><INDENT>item = cls._item_dict.get(key)<EOL>return item.name if item else key<EOL><DEDENT>return cls._item_dict[key].name<EOL>


@classmethod<EOL><INDENT>def verbose(cls, key=False, default='<STR_LIT>'):<DEDENT>

if key is False:<EOL><INDENT>items = cls._item_dict.values()<EOL>return [(x.key, x.value) for x in sorted(items, key=lambda x:x.sort or x.key)]<EOL><DEDENT>item = cls._item_dict.get(key)<EOL>return item.value if item else default<EOL>

Returns the verbose name for a given enum value


return [x.name for x in cls._item_dict.values()]<EOL>


rc = requests.get(messages_url, timeout=timeout)<EOL>rc.encoding = '<STR_LIT:utf-8>'  <EOL>rc = rc.text<EOL>data = re.findall('<STR_LIT>', rc)<EOL>balls = {}<EOL>for i in data:<EOL><INDENT>balls[int(i[<NUM_LIT:0>])] = i[<NUM_LIT:1>]<EOL><DEDENT>return balls<EOL>

Return all balls in dict {id0: ball0, id1: ball1}.


if not self._stadiums:<EOL><INDENT>self._stadiums = stadiums()<EOL><DEDENT>return self._stadiums<EOL>

Return all stadiums in dict {id0: stadium0, id1: stadium1}.

        :params year: Year.


rc = requests.get(messages_url, timeout=timeout)<EOL>rc.encoding = '<STR_LIT:utf-8>'  <EOL>rc = rc.text<EOL>data = re.findall('<STR_LIT>' % year, rc)<EOL>leagues = {}<EOL>for i in data:<EOL><INDENT>leagues[int(i[<NUM_LIT:0>])] = i[<NUM_LIT:1>]<EOL><DEDENT>return leagues<EOL>

Return all leagues in dict {id0: league0, id1: legaue1}.

    :params year: Year.


def bid(self, trade_id, bid, fast=False):

method = '<STR_LIT>'<EOL>url = '<STR_LIT>' % trade_id<EOL>if not fast:<EOL><INDENT>rc = self.tradeStatus(trade_id)[<NUM_LIT:0>]<EOL>if rc['<STR_LIT>'] >= bid or self.credits < bid:<EOL><INDENT>return False  <EOL><DEDENT><DEDENT>data = {'<STR_LIT>': bid}<EOL>try:<EOL><INDENT>rc = self.__request__(method, url, data=json.dumps(data), params={'<STR_LIT>': self.sku_b}, fast=fast)[<EOL>'<STR_LIT>'][<NUM_LIT:0>]<EOL><DEDENT>except PermissionDenied:  <EOL><INDENT>return False<EOL><DEDENT>if rc['<STR_LIT>'] == '<STR_LIT>' or (<EOL>rc['<STR_LIT>'] == '<STR_LIT>' and rc['<STR_LIT>'] == '<STR_LIT>'):  <EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT>

Make a bid.

        :params trade_id: Trade id.
        :params bid: Amount of credits You want to spend.
        :params fast: True for fastest bidding (skips trade status & credits check).


method = '<STR_LIT:GET>'<EOL>url = '<STR_LIT>'<EOL>rc = self.__request__(method, url)<EOL>return rc<EOL>


def search(self, ctype, level=None, category=None, assetId=None, defId=None,<EOL>min_price=None, max_price=None, min_buy=None, max_buy=None,<EOL>league=None, club=None, position=None, zone=None, nationality=None,<EOL>rare=False, playStyle=None, start=<NUM_LIT:0>, page_size=itemsPerPage['<STR_LIT>'],<EOL>fast=False):

<EOL>method = '<STR_LIT:GET>'<EOL>url = '<STR_LIT>'<EOL>if start == <NUM_LIT:0>:<EOL><INDENT>events = [self.pin.event('<STR_LIT>', '<STR_LIT>'), self.pin.event('<STR_LIT>', '<STR_LIT>')]<EOL>self.pin.send(events, fast=fast)<EOL><DEDENT>params = {<EOL>'<STR_LIT:start>': start,<EOL>'<STR_LIT>': page_size,<EOL>'<STR_LIT:type>': ctype,  <EOL>}<EOL>if level:<EOL><INDENT>params['<STR_LIT>'] = level<EOL><DEDENT>if category:<EOL><INDENT>params['<STR_LIT>'] = category<EOL><DEDENT>if assetId:<EOL><INDENT>params['<STR_LIT>'] = assetId<EOL><DEDENT>if defId:<EOL><INDENT>params['<STR_LIT>'] = defId<EOL><DEDENT>if min_price:<EOL><INDENT>params['<STR_LIT>'] = min_price<EOL><DEDENT>if max_price:<EOL><INDENT>params['<STR_LIT>'] = max_price<EOL><DEDENT>if min_buy:<EOL><INDENT>params['<STR_LIT>'] = min_buy<EOL><DEDENT>if max_buy:<EOL><INDENT>params['<STR_LIT>'] = max_buy<EOL><DEDENT>if league:<EOL><INDENT>params['<STR_LIT>'] = league<EOL><DEDENT>if club:<EOL><INDENT>params['<STR_LIT>'] = club<EOL><DEDENT>if position:<EOL><INDENT>params['<STR_LIT>'] = position<EOL><DEDENT>if zone:<EOL><INDENT>params['<STR_LIT>'] = zone<EOL><DEDENT>if nationality:<EOL><INDENT>params['<STR_LIT>'] = nationality<EOL><DEDENT>if rare:<EOL><INDENT>params['<STR_LIT>'] = '<STR_LIT>'<EOL><DEDENT>if playStyle:<EOL><INDENT>params['<STR_LIT>'] = playStyle<EOL><DEDENT>rc = self.__request__(method, url, params=params, fast=fast)<EOL>if start == <NUM_LIT:0>:<EOL><INDENT>events = [self.pin.event('<STR_LIT>', '<STR_LIT>'), self.pin.event('<STR_LIT>', '<STR_LIT>')]<EOL>self.pin.send(events, fast=fast)<EOL><DEDENT>return [itemParse(i) for i in rc.get('<STR_LIT>', ())]<EOL>

Prepare search request, send and return parsed data as a dict.

        :param ctype: [development / ? / ?] Card type.
        :param level: (optional) [?/?/gold] Card level.
        :param category: (optional) [fitness/?/?] Card category.
        :param assetId: (optional) Asset id.
        :param defId: (optional) Definition id.
        :param min_price: (optional) Minimal price.
        :param max_price: (optional) Maximum price.
        :param min_buy: (optional) Minimal buy now price.
        :param max_buy: (optional) Maximum buy now price.
        :param league: (optional) League id.
        :param club: (optional) Club id.
        :param position: (optional) Position.
        :param nationality: (optional) Nation id.
        :param rare: (optional) [boolean] True for searching special cards.
        :param playStyle: (optional) Play style.
        :param start: (optional) Start page sent to server so it supposed to be 12/15, 24/30 etc. (default platform page_size*n)
        :param page_size: (optional) Page size (items per page).


rc = requests.get(messages_url, timeout=timeout)<EOL>rc.encoding = '<STR_LIT:utf-8>'  <EOL>rc = rc.text<EOL>data = re.findall('<STR_LIT>' % year, rc)<EOL>stadiums = {}<EOL>for i in data:<EOL><INDENT>stadiums[int(i[<NUM_LIT:0>])] = i[<NUM_LIT:1>]<EOL><DEDENT>return stadiums<EOL>

Return all stadium in dict {id0: stadium0, id1: stadium1}.

    :params year: Year.


def __sendToPile__(self, pile, trade_id=None, item_id=None):

method = '<STR_LIT>'<EOL>url = '<STR_LIT>'<EOL>if not isinstance(item_id, (list, tuple)):<EOL><INDENT>item_id = (item_id,)<EOL><DEDENT>data = {"<STR_LIT>": [{'<STR_LIT>': pile, '<STR_LIT:id>': str(i)} for i in item_id]}<EOL>rc = self.__request__(method, url, data=json.dumps(data))<EOL>if rc['<STR_LIT>'][<NUM_LIT:0>]['<STR_LIT:success>']:<EOL><INDENT>self.logger.info("<STR_LIT>".format(trade_id, item_id, pile))<EOL><DEDENT>else:<EOL><INDENT>self.logger.error("<STR_LIT>".format(trade_id, item_id, pile,<EOL>rc['<STR_LIT>'][<NUM_LIT:0>][<EOL>'<STR_LIT>']))<EOL><DEDENT>return rc['<STR_LIT>'][<NUM_LIT:0>]['<STR_LIT:success>']<EOL>

Send to pile.

        :params trade_id: (optional?) Trade id.
        :params item_id: Iteam id.


def sendToSbs(self, challenge_id, item_id):

<EOL>method = '<STR_LIT>'<EOL>url = '<STR_LIT>' % challenge_id<EOL>squad = self.sbsSquad(challenge_id)<EOL>players = []<EOL>moved = False<EOL>n = <NUM_LIT:0><EOL>for i in squad['<STR_LIT>']['<STR_LIT>']:<EOL><INDENT>if i['<STR_LIT>']['<STR_LIT:id>'] == item_id:  <EOL><INDENT>return False<EOL><DEDENT>if i['<STR_LIT>']['<STR_LIT:id>'] == <NUM_LIT:0> and not moved:<EOL><INDENT>i['<STR_LIT>']['<STR_LIT:id>'] = item_id<EOL>moved = True<EOL><DEDENT>players.append({"<STR_LIT:index>": n,<EOL>"<STR_LIT>": {"<STR_LIT:id>": i['<STR_LIT>']['<STR_LIT:id>'],<EOL>"<STR_LIT>": False}})<EOL>n += <NUM_LIT:1><EOL><DEDENT>data = {'<STR_LIT>': players}<EOL>if not moved:<EOL><INDENT>return False<EOL><DEDENT>else:<EOL><INDENT>self.__request__(method, url, data=json.dumps(data))<EOL>return True<EOL><DEDENT>

Send card FROM CLUB to first free slot in sbs squad.


method = '<STR_LIT>'<EOL>url = '<STR_LIT>'<EOL>self.__request__(method, url)<EOL>


return baseId(*args, **kwargs)<EOL>

Calculate base id and version from a resource id.


method = '<STR_LIT:GET>'<EOL>url = '<STR_LIT>'<EOL>rc = self.__request__(method, url)<EOL>events = [self.pin.event('<STR_LIT>', '<STR_LIT>')]<EOL>self.pin.send(events, fast=fast)<EOL>events = [self.pin.event('<STR_LIT>', '<STR_LIT>')]<EOL>self.pin.send(events, fast=fast)<EOL>events = [self.pin.event('<STR_LIT>', '<STR_LIT>')]<EOL>self.pin.send(events, fast=fast)<EOL>return [itemParse(i) for i in rc.get('<STR_LIT>', ())]<EOL>


if not self._playstyles:<EOL><INDENT>self._playstyles = playstyles()<EOL><DEDENT>return self._playstyles<EOL>

Return all playstyles in dict {id0: playstyle0, id1: playstyle1}.

        :params year: Year.


if year not in self._teams:<EOL><INDENT>self._teams[year] = teams(year)<EOL><DEDENT>return self._teams[year]<EOL>

Return all teams in dict {id0: team0, id1: team1}.

        :params year: Year.


method = '<STR_LIT:GET>'<EOL>url = '<STR_LIT>'<EOL>rc = self.__request__(method, url)<EOL>events = [self.pin.event('<STR_LIT>', '<STR_LIT>'), self.pin.event('<STR_LIT>', '<STR_LIT>')]<EOL>if rc.get('<STR_LIT>'):<EOL><INDENT>events.append(self.pin.event('<STR_LIT>', '<STR_LIT>'))<EOL><DEDENT>self.pin.send(events)<EOL>return [itemParse(i) for i in rc.get('<STR_LIT>', ())]<EOL>


if self.cookies_file:<EOL><INDENT>self.r.cookies.save(ignore_discard=True)<EOL>with open(self.token_file, '<STR_LIT:w>') as f:<EOL><INDENT>f.write('<STR_LIT>' % (self.token_type, self.access_token))<EOL><DEDENT><DEDENT>


method = '<STR_LIT:GET>'<EOL>url = '<STR_LIT>'<EOL>rc = self.__request__(method, url)<EOL>return rc['<STR_LIT>']<EOL>


<EOL>base_id = baseId(resource_id)<EOL>if base_id in self.players:<EOL><INDENT>return self.players[base_id]<EOL><DEDENT>else:  <EOL><INDENT>url = '<STR_LIT>'.format(card_info_url, base_id)<EOL>return requests.get(url, timeout=self.timeout).json()<EOL><DEDENT>

Return card info.

        :params resource_id: Resource id.


method = '<STR_LIT>'<EOL>url = '<STR_LIT>'<EOL>if not isinstance(trade_id, (list, tuple)):<EOL><INDENT>trade_id = (trade_id,)<EOL><DEDENT>trade_id = (str(i) for i in trade_id)<EOL>params = {'<STR_LIT>': '<STR_LIT:U+002C>'.join(trade_id)}<EOL>self.__request__(method, url, params=params)  <EOL>return True<EOL>

Remove cards from watchlist.

        :params trade_id: Trade id.


rc = requests.get(messages_url, timeout=timeout)<EOL>rc.encoding = '<STR_LIT:utf-8>'  <EOL>rc = rc.text<EOL>data = re.findall('<STR_LIT>' % year, rc)<EOL>playstyles = {}<EOL>for i in data:<EOL><INDENT>playstyles[int(i[<NUM_LIT:0>])] = i[<NUM_LIT:1>]<EOL><DEDENT>return playstyles<EOL>

Return all playstyles in dict {id0: playstyle0, id1: playstyle1}.

    :params year: Year.


return None<EOL>

Default value for optional column configuration. Only child
classes will have non-None values for this field. Value
depends on child class implementation.

Note: Some child classes do not require any extra options
(e.g. OrganicChemicalFormula), in that case, this implementation
will be invoked and no options will be present in the dictionary.

:return: Options dictionary, or None if not implemented in child
:rtype: dict or None


return {<EOL>"<STR_LIT:type>": self.type,<EOL>"<STR_LIT:name>": self.name,<EOL>"<STR_LIT>": self.group_by_key,<EOL>"<STR_LIT>": self.role,<EOL>"<STR_LIT>": self.units,<EOL>"<STR_LIT>": self.build_options()<EOL>}<EOL>

Converts the column to a dictionary representation accepted
by the Citrination server.

:return: Dictionary with basic options, plus any column type specific
    options held under the "options" key
:rtype: dict


def __init__(self, name, role, group_by_key=False, units=None, length=None):

super(VectorColumn, self).__init__(name=name,<EOL>role=role,<EOL>group_by_key=group_by_key,<EOL>units=units)<EOL>self.length = length<EOL>

Constructor.

:param name: The name of the column
:type name: str
:param role: The role the column will play in machine learning:
               "Input"
               "Output"
               "Latent Variable"
               "Ignore"
:type role: str
:param group_by_key: Whether or not this column should be used for
    grouping during cross validation
:type group_by_key: bool
:param units: Optionally, the units for this column
:type units: str
:param length: The length of vectors in this column
:type length: int


def __init__(self, key, value, loss=None):

self._key = key<EOL>self._value = value<EOL>self._loss = loss<EOL>

Constructor.

:param key: The descriptor key for the prediction
:type key: str
:param value: The predicted value
:type value: str or float
:param loss: The loss for the prediction
:type loss: float


return self._projections.get(key)<EOL>

Retrieves the projection registered under a particular
descriptor key.

:param key: A descriptor key
:return: A :class:`Projection`


return self._projections.keys()<EOL>

List the descriptor keys with registered projections.

:return: List of descriptor keys


def add_projection(self, key, projection):

self._projections[key] = projection<EOL>

Register a projection under a descriptor key.

:param key: The descriptor key for the projection
:type key: str
:param projection: The projection for the provided descriptor key
:type projection: :class:`Projection`


def check_predict_status(self, view_id, predict_request_id):

failure_message = "<STR_LIT>"<EOL>bare_response = self._get_success_json(self._get(<EOL>'<STR_LIT>' + str(view_id) + '<STR_LIT>' + str(predict_request_id) + '<STR_LIT>',<EOL>None, failure_message=failure_message))<EOL>result = bare_response["<STR_LIT:data>"]<EOL>return result<EOL>

Returns a string indicating the status of the prediction job

:param view_id: The data view id returned from data view create
:param predict_request_id: The id returned from predict
:return: Status data, also includes results if state is finished


def predict(self, data_view_id, candidates, method="<STR_LIT>", use_prior=True):

uid = self.submit_predict_request(data_view_id, candidates, method, use_prior)<EOL>while self.check_predict_status(data_view_id, uid)['<STR_LIT:status>'] not in ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>time.sleep(<NUM_LIT:1>)<EOL><DEDENT>result = self.check_predict_status(data_view_id, uid)<EOL>if result["<STR_LIT:status>"] == "<STR_LIT>":<EOL><INDENT>paired = zip(result["<STR_LIT>"]["<STR_LIT>"], result["<STR_LIT>"]["<STR_LIT>"])<EOL>prediction_result_format = [{k: (p[<NUM_LIT:0>][k], p[<NUM_LIT:1>][k]) for k in p[<NUM_LIT:0>].keys()} for p in paired]<EOL>return list(map(<EOL>lambda c: _get_prediction_result_from_candidate(c), prediction_result_format<EOL>))<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError(<EOL>"<STR_LIT>".format(uid, result["<STR_LIT:status>"])<EOL>)<EOL><DEDENT>

Predict endpoint. This simply wraps the async methods (submit and poll for status/results).

:param data_view_id: The ID of the data view to use for prediction
:type data_view_id: str
:param candidates: A list of candidates to make predictions on
:type candidates: list of dicts
:param method: Method for propagating predictions through model graphs. "scalar" uses linearized uncertainty
propagation, whereas "scalar_from_distribution" still returns scalar predictions but uses sampling to
propagate uncertainty without a linear approximation.
:type method: str ("scalar" or "scalar_from_distribution")
:param use_prior:  Whether to apply prior values implied by the property descriptors
:type use_prior: bool
:return: The results of the prediction
:rtype: list of :class:`PredictionResult`


failure_message = "<STR_LIT>".format(data_view_id)<EOL>return self._get_success_json(self._get(routes.data_analysis(data_view_id), failure_message=failure_message))<EOL>

Data analysis endpoint.

:param data_view_id: The model identifier (id number for data views)
:type data_view_id: str
:return: dictionary containing information about the data, e.g. dCorr and tsne


url = routes.get_data_view(data_view_id)<EOL>response = self._get(url).json()<EOL>result = response["<STR_LIT:data>"]["<STR_LIT>"]<EOL>datasets_list = []<EOL>for dataset in result["<STR_LIT>"]:<EOL><INDENT>datasets_list.append(Dataset(<EOL>name=dataset["<STR_LIT:name>"],<EOL>id=dataset["<STR_LIT:id>"],<EOL>description=dataset["<STR_LIT:description>"]<EOL>))<EOL><DEDENT>columns_list = []<EOL>for column in result["<STR_LIT>"]:<EOL><INDENT>columns_list.append(ColumnFactory.from_dict(column))<EOL><DEDENT>return DataView(<EOL>view_id=data_view_id,<EOL>name=result["<STR_LIT:name>"],<EOL>description=result["<STR_LIT:description>"],<EOL>datasets=datasets_list,<EOL>columns=columns_list,<EOL>)<EOL>

Retrieves a summary of information for a given data view
    - view id
    - name
    - description
    - columns

:param data_view_id: The ID number of the data view to which the
    run belongs, as a string
:type data_view_id: str


def get_design_run_status(self, data_view_id, run_uuid):

url = routes.get_data_view_design_status(data_view_id, run_uuid)<EOL>response = self._get(url).json()<EOL>status = response["<STR_LIT:data>"]<EOL>return ProcessStatus(<EOL>result=status.get("<STR_LIT:result>"),<EOL>progress=status.get("<STR_LIT>"),<EOL>status=status.get("<STR_LIT:status>"),<EOL>messages=status.get("<STR_LIT>")<EOL>)<EOL>

Retrieves the status of an in progress or completed design run

:param data_view_id: The ID number of the data view to which the
    run belongs, as a string
:type data_view_id: str
:param run_uuid: The UUID of the design run to retrieve status for
:type run_uuid: str
:return: A :class:`ProcessStatus` object


return self.ready == True<EOL>

Indicates whether or not the service is ready to be used.

:return: A boolean
:rtype: bool


def __init__(self, xs, ys, responses, tags, uids):

self._xs = xs<EOL>self._ys = ys<EOL>self._responses = responses<EOL>self._tags = tags<EOL>self._uids = uids<EOL>

Constructor.

:param xs: A list of x values of the projection.
:type xs: list of floats
:param ys: A list of y values of the projection.
:type ys: list of floats
:param responses: A list of z values of the projection.
:type responses: list of floats
:param tags: A list of tags for the projected points
:type tags: list of strings
:param uids: A list of record UIDs for the projected points
:type uids: list of strings


return "<STR_LIT>".format(data_view_id)<EOL>

URL for retrieving the statuses of all services
associated with a data view.

:param data_view_id: The ID of the desired data views
:type data_view_id: str


def __init__(self, title, normalized_progress, subtitle=None, subevent=None):

self._title = title<EOL>self._subtitle = subtitle<EOL>self._subevent = subevent<EOL>self._normalized_progress = normalized_progress<EOL>

Constructor.

:param title: The title of the event
:type title: str
:param subtitle: More detail about the event
:type subtitle: str
:param subevent: An event object describing the current state of the service's
    progress toward readiness
:type subevent: Event
:param normalized_progress: The fractional representation of the status of the event
:type normalized_progress: float


try:<EOL><INDENT>return self._values[key]<EOL><DEDENT>except KeyError:<EOL><INDENT>return None<EOL><DEDENT>

Retrieves a predicted value.

:param key: A descriptor key for a registered predicted value.
:type key: str
:return: The value stored at the provided descriptor key. None if no key is provided.
:rtype: :class:`PredictedValue`


def __init__(self, result, progress, status, messages=None):

self._status = status<EOL>self._result = result<EOL>self._progress = progress<EOL>self._messages = messages<EOL>

Constructor.

:param result: The result of the process
:type result: any
:param progress: The progress of the process as as percentage
:type progress: int
:param status: The status string for the process
:type status: str
:param messages: A list of messages representing the steps the process
    has already progressed through
:type messages: list of str


self._uuid = uuid<EOL>

Constructor.

:param uuid: The UUID of an in progress design run.
:type uuid: str


def __init__(self, best_materials, next_experiments):

self._best_materials = best_materials<EOL>self._next_experiments = next_experiments<EOL>

Constructor.

:param best_materials: An array of candidate dictionaries
:type best_materials: list of dictionaries
:param next_experiments: An array of candidate dictionaries
:type next_experiments: list of dictionaries


def __init__(self, name, accepted_categories):

self._type = "<STR_LIT>"<EOL>self._name = name<EOL>self._categories = accepted_categories<EOL>

Constructor.

:param name: The name of the column in the data
    view to which this constraint should be applied
:type name: str
:param accepted_categories: An array of categories to constrain the name to
:type accepted_categories: list of str


def __init__(self, name, elements, minimum, maximum):

if not <NUM_LIT:0> <= minimum <= <NUM_LIT:100>:<EOL><INDENT>raise CitrinationClientError("<STR_LIT>")<EOL><DEDENT>if not <NUM_LIT:0> <= maximum <= <NUM_LIT:100>:<EOL><INDENT>raise CitrinationClientError("<STR_LIT>")<EOL><DEDENT>if not maximum >= minimum:<EOL><INDENT>raise CitrinationClientError("<STR_LIT>")<EOL><DEDENT>self._type = "<STR_LIT>"<EOL>self._elements = elements<EOL>self._name = name<EOL>self._min = minimum<EOL>self._max = maximum<EOL>

Constructor.

:param name: The name of the column in the data
    view to which this constraint should be applied
:type name: str
:param elements: An array of element abbreviations as
    strings, e.g. ["Mg", "C"]
:type elements: list of str
:param minimum: The minimum value (<= 100) as a percentage
    at which the specified elements should appear in
    candidate compositions
:type minimum: float
:param maximum: The maximum value (<= 100) as a percentage
    at which the specified elements should appear in
    candidate compositions
:type maximum: float


self._type = "<STR_LIT>"        <EOL>self._name = name<EOL>self._value = value<EOL>

Constructor.

:param name: The name of the column in the data
    view to which this constraint should be applied
:type name: str
:param value: The value the column should be constrained to
:type value: float


return "<STR_LIT>".format(self.api_url, route)<EOL>

Get a fully qualified api route.
:param route: the route (e.g., /model)
:return: the fully qualified route (e.g., https://citrination.com/model)


def _delete(self, route, headers=None, failure_message=None):

headers = self._get_headers(headers)<EOL>response_lambda = (lambda: requests.delete(<EOL>self._get_qualified_route(route), headers=headers, verify=False, proxies=self.proxies)<EOL>)<EOL>response = check_for_rate_limiting(response_lambda(), response_lambda)<EOL>return self._handle_response(response, failure_message)<EOL>

Execute a delete request and return the result
:param headers:
:return:


def _post(self, route, data, headers=None, failure_message=None):

headers = self._get_headers(headers)<EOL>response_lambda = (<EOL>lambda: requests.post(<EOL>self._get_qualified_route(route), headers=headers, data=data, verify=False, proxies=self.proxies<EOL>)<EOL>)<EOL>response = check_for_rate_limiting(response_lambda(), response_lambda)<EOL>return self._handle_response(response, failure_message)<EOL>

Execute a post request and return the result
:param data:
:param headers:
:return:


def _get(self, route, headers=None, failure_message=None):

headers = self._get_headers(headers)<EOL>response_lambda = (<EOL>lambda: requests.get(self._get_qualified_route(route), headers=headers, verify=False, proxies=self.proxies)<EOL>)<EOL>response = check_for_rate_limiting(response_lambda(), response_lambda)<EOL>return self._handle_response(response, failure_message)<EOL>

Execute a post request and return the result
:param headers:
:return:


def _put(self, route, data, headers=None, failure_message=None):

headers = self._get_headers(headers)<EOL>response_lambda = (<EOL>lambda: requests.put(<EOL>self._get_qualified_route(route), headers=headers, data=data, verify=False, proxies=self.proxies<EOL>)<EOL>)<EOL>response = check_for_rate_limiting(response_lambda(), response_lambda)<EOL>return self._handle_response(response, failure_message)<EOL>

Execute a put request and return the result
:param data:
:param headers:
:return:


def create_dataset(self, name=None, description=None, public=False):

data = {<EOL>"<STR_LIT>": _convert_bool_to_public_value(public)<EOL>}<EOL>if name:<EOL><INDENT>data["<STR_LIT:name>"] = name<EOL><DEDENT>if description:<EOL><INDENT>data["<STR_LIT:description>"] = description<EOL><DEDENT>dataset = {"<STR_LIT>": data}<EOL>failure_message = "<STR_LIT>"<EOL>result = self._get_success_json(self._post_json(routes.create_dataset(), dataset, failure_message=failure_message))<EOL>return _dataset_from_response_dict(result)<EOL>

Create a new data set.

:param name: name of the dataset
:type name: str
:param description: description for the dataset
:type description: str
:param public: A boolean indicating whether or not the dataset should be public.
:type public: bool
:return: The newly created dataset.
:rtype: :class:`Dataset`


def download_files(self, dataset_files, destination='<STR_LIT:.>'):

if not isinstance(dataset_files, list):<EOL><INDENT>dataset_files = [dataset_files]<EOL><DEDENT>for f in dataset_files:<EOL><INDENT>filename = f.path.lstrip('<STR_LIT:/>')<EOL>local_path = os.path.join(destination, filename)<EOL>if not os.path.isdir(os.path.dirname(local_path)):<EOL><INDENT>os.makedirs(os.path.dirname(local_path))<EOL><DEDENT>r = requests.get(f.url, stream=True)<EOL>with open(local_path, '<STR_LIT:wb>') as output_file:<EOL><INDENT>shutil.copyfileobj(r.raw, output_file)<EOL><DEDENT><DEDENT>

Downloads file(s) to a local destination.

:param dataset_files:
:type dataset_files: list of :class: `DatasetFile`
:param destination: The path to the desired local download destination
:type destination: str
:param chunk: Whether or not to chunk the file. Default True
:type chunk: bool


def list_files(self, dataset_id, glob="<STR_LIT:.>", is_dir=False):

data = {<EOL>"<STR_LIT:list>": {<EOL>"<STR_LIT>": glob,<EOL>"<STR_LIT>": is_dir<EOL>}<EOL>}<EOL>return self._get_success_json(self._post_json(routes.list_files(dataset_id), data, failure_message="<STR_LIT>".format(dataset_id)))['<STR_LIT>']<EOL>

List matched filenames in a dataset on Citrination.

:param dataset_id: The ID of the dataset to search for files.
:type dataset_id: int
:param glob: A pattern which will be matched against files in the dataset.
:type glob: str
:param is_dir: A boolean indicating whether or not the pattern should match against the beginning of paths in the dataset.
:type is_dir: bool
:return: A list of filepaths in the dataset matching the provided glob.
:rtype: list of strings


def upload(self, dataset_id, source_path, dest_path=None):

upload_result = UploadResult()<EOL>source_path = str(source_path)<EOL>if not dest_path:<EOL><INDENT>dest_path = source_path<EOL><DEDENT>else:<EOL><INDENT>dest_path = str(dest_path)<EOL><DEDENT>if os.path.isdir(source_path):<EOL><INDENT>for path, subdirs, files in os.walk(source_path):<EOL><INDENT>relative_path = os.path.relpath(path, source_path)<EOL>current_dest_prefix = dest_path<EOL>if relative_path is not "<STR_LIT:.>":<EOL><INDENT>current_dest_prefix = os.path.join(current_dest_prefix, relative_path)<EOL><DEDENT>for name in files:<EOL><INDENT>current_dest_path = os.path.join(current_dest_prefix, name)<EOL>current_source_path = os.path.join(path, name)<EOL>try:<EOL><INDENT>if self.upload(dataset_id, current_source_path, current_dest_path).successful():<EOL><INDENT>upload_result.add_success(current_source_path)<EOL><DEDENT>else:<EOL><INDENT>upload_result.add_failure(current_source_path,"<STR_LIT>")<EOL><DEDENT><DEDENT>except (CitrinationClientError, ValueError) as e:<EOL><INDENT>upload_result.add_failure(current_source_path, str(e))<EOL><DEDENT><DEDENT><DEDENT>return upload_result<EOL><DEDENT>elif os.path.isfile(source_path):<EOL><INDENT>file_data = { "<STR_LIT>": str(dest_path), "<STR_LIT>": str(source_path)}<EOL>j = self._get_success_json(self._post_json(routes.upload_to_dataset(dataset_id), data=file_data))<EOL>s3url = _get_s3_presigned_url(j)<EOL>with open(source_path, '<STR_LIT:rb>') as f:<EOL><INDENT>if os.stat(source_path).st_size == <NUM_LIT:0>:<EOL><INDENT>data = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>data = f<EOL><DEDENT>r = requests.put(s3url, data=data, headers=j["<STR_LIT>"])<EOL>if r.status_code == <NUM_LIT:200>:<EOL><INDENT>data = {'<STR_LIT>': j['<STR_LIT:url>']['<STR_LIT:path>'], '<STR_LIT>': j['<STR_LIT>']}<EOL>self._post_json(routes.update_file(j['<STR_LIT>']), data=data)<EOL>upload_result.add_success(source_path)<EOL>return upload_result<EOL><DEDENT>else:<EOL><INDENT>raise CitrinationClientError("<STR_LIT>".format(source_path))<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>".format(source_path))<EOL><DEDENT>

Upload a file, specifying source and dest paths a file (acts as the scp command).asdfasdf

:param source_path: The path to the file on the source host asdf
:type source_path: str
:param dest_path: The path to the file where the contents of the upload will be written (on the dest host)
:type dest_path: str
:return: The result of the upload process
:rtype: :class:`UploadResult`


return len(self._failures) == <NUM_LIT:0><EOL>

Indicates whether or not the entire upload was successful.

:return: Whether or not the upload was successful
:rtype: bool


def __init__(self, logic=None, weight=None, simple=None, simple_weight=None, id=None, is_featured=None,<EOL>name=None, description=None, owner=None, email=None, updated_at=None, query=None, **kwargs):

self._logic = None<EOL>self.logic = logic<EOL>self._weight = None<EOL>self.weight = weight<EOL>self._simple = None<EOL>self.simple = simple<EOL>self._simple_weight = None<EOL>self.simple_weight = simple_weight<EOL>self._id = None<EOL>self.id = id<EOL>self._is_featured = None<EOL>self.is_featured = is_featured<EOL>self._name = None<EOL>self.name = name<EOL>self._description = None<EOL>self.description = description<EOL>self._owner = None<EOL>self.owner = owner<EOL>self._email = None<EOL>self.email = email<EOL>self._updated_at = None<EOL>self.updated_at = updated_at<EOL>self._query = None<EOL>self.query = query<EOL>

Constructor.

:param logic: The logic to apply to the query ('SHOULD', 'MUST', 'MUST_NOT', or 'OPTIONAL').
:param weight: Weight for the query.
:param simple: String with the simple search to run against all fields.
:param simple_weight: Dictionary of relative paths to their weights for simple queries.
:param id: One or more :class:`Filter` objects with filters against the id field.
:param is_featured:  One or more :class:`BooleanFilter` objects with filters against the isFeatured field.
:param name: One or more :class:`Filter` objects with filters against the name field.
:param description: One or more :class:`Filter` objects with filters against the description field.
:param owner: One or more :class:`Filter` objects with filters against the owner field.
:param email: One or more :class:`Filter` objects with filters against the email field.
:param updated_at: One or more :class:`Filter` objects with filters against the time that the dataset was last updated.
:param query: One or more :class:`DatasetQuery` objects with nested queries.


def __init__(self, query=None, from_index=None, size=None, random_results=None, random_seed=None,<EOL>score_relevance=None, return_max_score=None, timeout=None, count_pifs=None, **kwargs):

super(DatasetReturningQuery, self).__init__(<EOL>query=query, from_index=from_index, size=size, random_results=random_results, random_seed=random_seed,<EOL>score_relevance=score_relevance, return_max_score=return_max_score, timeout=timeout, **kwargs)<EOL>self._count_pifs = None<EOL>self.count_pifs = count_pifs<EOL>

Constructor.

:param query: One or more :class:`DataQuery` objects with the queries to run.
:param from_index: Index of the first hit that should be returned.
:param size: Total number of hits the should be returned.
:param random_results: Whether to return a random set of records.
:param random_seed: The random seed to use.
:param score_relevance: Whether to use relevance scoring.
:param return_max_score: Whether to return the maximum score.
:param timeout: The number of milliseconds to wait for the query to execute.
:param count_pifs: Whether to return counts of PIFs for each dataset.


def __init__(self, took=None, total_num_hits=None, max_score=None, hits=None, **kwargs):

super(DatasetSearchResult, self).__init__(<EOL>took=took, total_num_hits=total_num_hits, max_score=max_score,<EOL>hits=self._get_object(DatasetSearchHit, hits), **kwargs)<EOL>

Constructor.

:param took: Number of milliseconds that the query took to execute.
:param total_num_hits: Total number of hits.
:param max_score: The maximum score.
:param hits: List of :class:`DatasetSearchHit` objects.


def __init__(self, id=None, score=None, is_featured=None, name=None, description=None, owner=None, email=None, <EOL>num_pifs=None, updated_at=None, **kwargs):

self._id = None<EOL>self.id = id<EOL>self._score = None<EOL>self.score = score<EOL>self._is_featured = None<EOL>self.is_featured = is_featured<EOL>self._name = None<EOL>self.name = name<EOL>self._description = None<EOL>self.description = description<EOL>self._owner = None<EOL>self.owner = owner<EOL>self._email = None<EOL>self.email = email<EOL>self._num_pifs = None<EOL>self.num_pifs = num_pifs<EOL>self._updated_at = None<EOL>self.updated_at = updated_at<EOL>

Constructor.

:param id: String with the ID of the record.
:param score: Score with the relevancy of the result.
:param is_featured: Whether the dataset is a featured one.
:param name: Name of the dataset.
:param description: Description of the dataset.
:param owner: Name of the owner of the dataset.
:param email: Email address of the owner of the dataset.
:param num_pifs: Number of PIFs in the dataset.
:param updated_at: String with the last time that the dataset was updated.


def __init__(self, took=None, results=None, **kwargs):

self._took = None<EOL>self.took = took<EOL>self._results = None<EOL>self.results = results<EOL>

Constructor.

:param took: Number of milliseconds that the query took to execute.
:param results: List of :class:`DatasetMultiSearchResultElement` objects.


def __init__(self, logic=None, weight=None, simple=None, simple_weight=None, id=None, name=None, content=None,<EOL>updated_at=None, query=None, **kwargs):

self._logic = None<EOL>self.logic = logic<EOL>self._weight = None<EOL>self.weight = weight<EOL>self._simple = None<EOL>self.simple = simple<EOL>self._simple_weight = None<EOL>self.simple_weight = simple_weight<EOL>self._id = None<EOL>self.id = id<EOL>self._name = None<EOL>self.name = name<EOL>self._content = None<EOL>self.content = content<EOL>self._updated_at = None<EOL>self.updated_at = updated_at<EOL>self._query = None<EOL>self.query = query<EOL>

Constructor.

:param logic: The logic to apply to the query ('SHOULD', 'MUST', 'MUST_NOT', or 'OPTIONAL').
:param weight: Weight for the query.
:param simple: String with the simple search to run against all fields.
:param simple_weight: Dictionary of relative paths to their weights for simple queries.
:param id: One or more :class:`Filter` objects with filters against the id field.
:param name: One or more :class:`Filter` objects with filters against the name field.
:param content: One or more :class:`Filter` objects with filters against the content field.
:param updated_at: One or more :class:`Filter` objects with filters against the time that the dataset was last updated.
:param query: One or more :class:`DatasetQuery` objects with nested queries.


Constructor.

:param took: Number of milliseconds that the query took to execute.
:param results: List of :class:`FileMultiSearchResultElement` objects.


def __init__(self, result=None, status=None, **kwargs):

self._result = None<EOL>self.result = result<EOL>self._status = None<EOL>self.status = status<EOL>

Constructor.

:param result: A single :class:`FileSearchResult` object with the query results.
:param status: 'SUCCESS', 'ERROR', or 'NOT_EXECUTED'.


if values is None:<EOL><INDENT>return []<EOL><DEDENT>elif isinstance(values, list):<EOL><INDENT>return values<EOL><DEDENT>else:<EOL><INDENT>return [values]<EOL><DEDENT>

Helper method that wraps values in a list. If the input is a list then it is returned. If the input is None then an empty list is returned. For anything else, the input value is wrapped as a single-element list.

:param values: Value to make sure exists in a list.
:return: List with the input values.


self._validate_search_query(dataset_returning_query)<EOL>return self._execute_search_query(<EOL>dataset_returning_query,<EOL>DatasetSearchResult<EOL>)<EOL>

Run a dataset query against Citrination.

:param dataset_returning_query: :class:`DatasetReturningQuery` to execute.
:type dataset_returning_query: :class:`DatasetReturningQuery`
:return: Dataset search result object with the results of the query.
:rtype: :class:`DatasetSearchResult`


failure_message = "<STR_LIT>"<EOL>response_dict = self._get_success_json(<EOL>self._post(routes.pif_multi_search, data=json.dumps(multi_query, cls=QueryEncoder),<EOL>failure_message=failure_message))<EOL>return PifMultiSearchResult(**keys_to_snake_case(response_dict['<STR_LIT>']))<EOL>

Run each in a list of PIF queries against Citrination.

:param multi_query: :class:`MultiQuery` object to execute.
:return: :class:`PifMultiSearchResult` object with the results of the query.


def __init__(self, logic=None, weight=None, exists=None, equal=None, filter=None, **kwargs):

self._logic = None<EOL>self.logic = logic<EOL>self._weight = None<EOL>self.weight = weight<EOL>self._exists = None<EOL>self.exists = exists<EOL>self._equal = None<EOL>self.equal = equal<EOL>self._filter = None<EOL>self.filter = filter<EOL>

Constructor.

:param logic: Logic for this filter. Must be equal to one of "MUST", "MUST_NOT", "SHOULD", or "OPTIONAL".
:param weight: Weight for the filter.
:param exists: True/False to simply test whether the field exists and has a non-null value.
:param equal: String with the phrase to match against.
:param filter: List of :class:`BooleanFilter` objects with sub-filters.


def __init__(self, query=None, extraction_sort=None, from_index=None, size=None, random_results=None,<EOL>random_seed=None, score_relevance=None, return_max_score=None, timeout=None, **kwargs):

super(BaseReturningQuery, self).__init__(query=query, extraction_sort=extraction_sort, **kwargs)<EOL>if '<STR_LIT>' in '<STR_LIT>':<EOL><INDENT>self.from_index = kwargs['<STR_LIT>']<EOL><DEDENT>self._from = None<EOL>self.from_index = from_index<EOL>self._size = None<EOL>self.size = size<EOL>self._random_results = None<EOL>self.random_results = random_results<EOL>self._random_seed = None<EOL>self.random_seed = random_seed<EOL>self._score_relevance = None<EOL>self.score_relevance = score_relevance<EOL>self._return_max_score = None<EOL>self.return_max_score = return_max_score<EOL>self._timeout = None<EOL>self.timeout = timeout<EOL>

Base class for all queries against datasets and the items that they contain on Citrination.

:param query: One or more :class:`DataQuery` objects with the queries to run.
:param extraction_sort: A single :class:`ExtractionSort` object for sorting.
:param from_index: Index of the first hit that should be returned.
:param size: Total number of hits the should be returned.
:param random_results: Whether to return a random set of records.
:param random_seed: The random seed to use.
:param score_relevance: Whether to use relevance scoring.
:param return_max_score: Whether to return the maximum score.
:param timeout: The number of milliseconds to wait for the query to execute.


def __init__(self, logic=None, weight=None, simple=None, simple_weight=None, dataset=None, system=None, file=None,<EOL>query=None, **kwargs):

self._logic = None<EOL>self.logic = logic<EOL>self._weight = None<EOL>self.weight = weight<EOL>self._simple = None<EOL>self.simple = simple<EOL>self._simple_weight = None<EOL>self.simple_weight = simple_weight<EOL>self._dataset = None<EOL>self.dataset = dataset<EOL>self._system = None<EOL>self.system = system<EOL>self._file = None<EOL>self.file = file<EOL>self._query = None<EOL>self.query = query<EOL>

Constructor.

:param logic: The logic to apply to the query ('SHOULD', 'MUST', 'MUST_NOT', or 'OPTIONAL').
:param weight: Weight for the query.
:param simple: String with the simple search to run against all fields.
:param simple_weight: Dictionary of relative paths to their weights for simple queries.
:param dataset: One or more :class:`DatasetQuery` objects with queries against dataset metadata.
:param system: One or more :class:`PifSystemQuery` objects with queries against PIF systems
:param file: One or more :class:`FileQuery` objects with queries against file content or metadata.
:type file: :class:`FileQuery`
:param query: Nested list of :class:`DataQuery` objects.


def __init__(self, queries=None, **kwargs):

self._queries = None<EOL>self.queries = queries<EOL>

Constructor.

:param queries: One or more queries to run.


self._took = None<EOL>self.took = took<EOL>self._total_num_hits = None<EOL>self.total_num_hits = total_num_hits<EOL>self._max_score = None<EOL>self.max_score = max_score<EOL>self._hits = None<EOL>self.hits = hits<EOL>

Constructor.

:param took: Number of milliseconds that the query took to execute.
:param total_num_hits: Total number of hits.
:param max_score: The maximum score.
:param hits: List of hits.


def __init__(self, sort=None, logic=None, weight=None, simple=None, simple_weight=None, extract_as=None,<EOL>extract_all=None, extract_when_missing=None, length=None, offset=None, filter=None, **kwargs):

super(ChemicalFieldQuery, self).__init__(<EOL>sort=sort, weight=weight, logic=logic, simple=simple, simple_weight=simple_weight, extract_as=extract_as,<EOL>extract_all=extract_all, extract_when_missing=extract_when_missing, length=length, offset=offset, **kwargs)<EOL>self._filter = None<EOL>self.filter = filter<EOL>

Constructor.

:param sort: ASCENDING or DESCENDING to set the sort order on this field.
:param logic: Logic for this query. Must be equal to one of "MUST", "MUST_NOT", "SHOULD", or "OPTIONAL".
:param weight: Weight for the query.
:param simple: String with the simple search to run against all fields.
:param simple_weight: Dictionary of relative paths to their weights for simple queries.
:param extract_as: String with the alias to save this field under.
:param extract_all: Boolean setting whether all values in an array should be extracted.
:param extract_when_missing: Any valid JSON-supported object or PIF object. This value is returned when a value is missing that should be extracted (and the overall query is still satisfied).
:param length: One or more :class:`FieldOperation` objects against the length field.
:param offset: One or more :class:`FieldOperation` objects against the offset field.
:param filter: One or more :class:`ChemicalFilter` objects against this field.


def __init__(self, logic=None, weight=None, simple=None, simple_weight=None, extract_as=None,<EOL>extract_all=None, extract_when_missing=None, tags=None, length=None, offset=None, element=None,<EOL>actual_weight_percent=None, actual_atomic_percent=None, ideal_weight_percent=None,<EOL>ideal_atomic_percent=None, query=None, **kwargs):

super(CompositionQuery, self).__init__(<EOL>logic=logic, weight=weight, simple=simple, simple_weight=simple_weight, extract_as=extract_as,<EOL>extract_all=extract_all, extract_when_missing=extract_when_missing, tags=tags, length=length,<EOL>offset=offset, **kwargs)<EOL>self._element = None<EOL>self.element = element<EOL>self._actual_weight_percent = None<EOL>self.actual_weight_percent = actual_weight_percent<EOL>self._actual_atomic_percent = None<EOL>self.actual_atomic_percent = actual_atomic_percent<EOL>self._ideal_weight_percent = None<EOL>self.ideal_weight_percent = ideal_weight_percent<EOL>self._ideal_atomic_percent = None<EOL>self.ideal_atomic_percent = ideal_atomic_percent<EOL>self._query = None<EOL>self.query = query<EOL>

Constructor.

:param logic: Logic for this filter. Must be equal to one of "MUST", "MUST_NOT", "SHOULD", or "OPTIONAL".
:param weight: Weight of the query.
:param simple: String with the simple query to run against all fields.
:param simple_weight: Dictionary of relative paths to their weights for simple queries.
:param extract_as: String with the alias to save this field under.
:param extract_all: Boolean setting whether all values in an array should be extracted.
:param extract_when_missing: Any valid JSON-supported object or PIF object. This value is returned when a value is missing that should be extracted (and the overall query is still satisfied).
:param tags: One or more :class:`FieldQuery` operations against the tags field.
:param length: One or more :class:`FieldQuery` operations against the length field.
:param offset: One or more :class:`FieldQuery` operations against the offset field.
:param element: One or more :class:`ChemicalFieldQuery` operations against the element field.
:param actual_weight_percent: One or more :class:`FieldQuery` operations against the actual weight percent field.
:param actual_atomic_percent: One or more :class:`FieldQuery` operations against the actual atomic percent field.
:param ideal_weight_percent: One or more :class:`FieldQuery` operations against the ideal weight percent field.
:param ideal_atomic_percent: One or more :class:`FieldQuery` operations against the ideal atomic percent field.
:param query: One or more :class:`CompositionQuery` objects with the nest queries.


def __init__(self, key=None, order=None, **kwargs):

self._key = None<EOL>self.key = key<EOL>self._order = None<EOL>self.order = order<EOL>

Constructor.

:param key: String with the key that will be sorted on.
:param order: The order to use. Either ASCENDING or DESCENDING.


def __init__(self, logic=None, weight=None, simple=None, simple_weight=None, extract_as=None, extract_all=None,<EOL>extract_when_missing=None, tags=None, length=None, offset=None, name=None, value=None,<EOL>query=None, **kwargs):

super(IdQuery, self).__init__(<EOL>logic=logic, weight=weight, simple=simple, simple_weight=simple_weight, extract_as=extract_as,<EOL>extract_all=extract_all, extract_when_missing=extract_when_missing, tags=tags, length=length,<EOL>offset=offset, **kwargs)<EOL>self._name = None<EOL>self.name = name<EOL>self._value = None<EOL>self.value = value<EOL>self._query = None<EOL>self.query = query<EOL>

Constructor.

:param logic: Logic for this filter. Must be equal to one of "MUST", "MUST_NOT", "SHOULD", or "OPTIONAL".
:param weight: Weight of the query.
:param simple: String with the query to run over all fields.
:param simple_weight: Dictionary of relative paths to their weights for simple queries.
:param extract_as: String with the alias to save this field under.
:param extract_all: Boolean setting whether all values in an array should be extracted.
:param extract_when_missing: Any valid JSON-supported object or PIF object. This value is returned when a value is missing that should be extracted (and the overall query is still satisfied).
:param tags: One or more :class:`FieldQuery` operations against the tags field.
:param length: One or more :class:`FieldQuery` operations against the length field.
:param offset: One or more :class:`FieldQuery` operations against the offset field.
:param name: One or more :class:`FieldQuery` operations against the name field.
:param value: One or more :class:`FieldQuery` operations against the value field.
:param query: One or more :class:`IdQuery` objects with nested queries.


def __init__(self, sort=None, logic=None, weight=None, simple=None, simple_weight=None, extract_as=None,<EOL>extract_all=None, extract_when_missing=None, length=None, offset=None, **kwargs):

self._sort = None<EOL>self.sort = sort<EOL>self._logic = None<EOL>self.logic = logic<EOL>self._weight = None<EOL>self.weight = weight<EOL>self._simple = None<EOL>self.simple = simple<EOL>self._simple_weight = None<EOL>self.simple_weight = simple_weight<EOL>self._extract_as = None<EOL>self.extract_as = extract_as<EOL>self._extract_all = None<EOL>self.extract_all = extract_all<EOL>self._extract_when_missing = None<EOL>self.extract_when_missing = extract_when_missing<EOL>self._length = None<EOL>self.length = length<EOL>self._offset = None<EOL>self.offset = offset<EOL>

Constructor.

:param sort: ASCENDING or DESCENDING to set the sort order on this field.
:param logic: Logic for this query. Must be equal to one of "MUST", "MUST_NOT", "SHOULD", or "OPTIONAL".
:param weight: Weight for the query.
:param simple: String with the simple search to run against all fields.
:param simple_weight: Dictionary of relative paths to their weights for simple queries.
:param extract_as: String with the alias to save this field under.
:param extract_all: Boolean setting whether all values in an array should be extracted.
:param extract_when_missing: Any valid JSON-supported object or PIF object. This value is returned when a value is missing that should be extracted (and the overall query is still satisfied).
:param length: One or more :class:`FieldQuery` operations against the length field.
:param offset: One or more :class:`FieldQuery` operations against the offset field.