INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Returns Conditional Probability Distribution after setting values to 1.
def conditional_distribution(self, values, inplace=True): """ Returns Conditional Probability Distribution after setting values to 1. Parameters ---------- values: list or array_like A list of tuples of the form (variable_name, variable_state). The values...
Returns a Bayesian Model which is minimal IMap of the Joint Probability Distribution considering the order of the variables.
def minimal_imap(self, order): """ Returns a Bayesian Model which is minimal IMap of the Joint Probability Distribution considering the order of the variables. Parameters ---------- order: array-like The order of the random variables. Examples ...
Checks whether the given BayesianModel is Imap of JointProbabilityDistribution
def is_imap(self, model): """ Checks whether the given BayesianModel is Imap of JointProbabilityDistribution Parameters ----------- model : An instance of BayesianModel Class, for which you want to check the Imap Returns -------- boolean : Tr...
Returns the acceptance probability for given new position ( position ) and momentum
def _acceptance_prob(self, position, position_bar, momentum, momentum_bar): """ Returns the acceptance probability for given new position(position) and momentum """ # Parameters to help in evaluating Joint distribution P(position, momentum) _, logp = self.grad_log_pdf(position, ...
Temporary method to fix issue in numpy 0. 12 #852
def _get_condition(self, acceptance_prob, a): """ Temporary method to fix issue in numpy 0.12 #852 """ if a == 1: return (acceptance_prob ** a) > (1/(2**a)) else: return (1/(acceptance_prob ** a)) > (2**(-a))
Method for choosing initial value of stepsize
def _find_reasonable_stepsize(self, position, stepsize_app=1): """ Method for choosing initial value of stepsize References ----------- Matthew D. Hoffman, Andrew Gelman, The No-U-Turn Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte Carlo. Journal of ...
Runs a single sampling iteration to return a sample
def _sample(self, position, trajectory_length, stepsize, lsteps=None): """ Runs a single sampling iteration to return a sample """ # Resampling momentum momentum = np.reshape(np.random.normal(0, 1, len(position)), position.shape) # position_m here will be the previous sa...
Method to return samples using Hamiltonian Monte Carlo
def sample(self, initial_pos, num_samples, trajectory_length, stepsize=None, return_type='dataframe'): """ Method to return samples using Hamiltonian Monte Carlo Parameters ---------- initial_pos: A 1d array like object Vector representing values of parameter positio...
Method returns a generator type object whose each iteration yields a sample using Hamiltonian Monte Carlo
def generate_sample(self, initial_pos, num_samples, trajectory_length, stepsize=None): """ Method returns a generator type object whose each iteration yields a sample using Hamiltonian Monte Carlo Parameters ---------- initial_pos: A 1d array like object Vect...
Run tha adaptation for stepsize for better proposals of position
def _adapt_params(self, stepsize, stepsize_bar, h_bar, mu, index_i, alpha, n_alpha=1): """ Run tha adaptation for stepsize for better proposals of position """ gamma = 0.05 # free parameter that controls the amount of shrinkage towards mu t0 = 10.0 # free parameter that stabili...
Method returns a generator type object whose each iteration yields a sample using Hamiltonian Monte Carlo
def generate_sample(self, initial_pos, num_adapt, num_samples, trajectory_length, stepsize=None): """ Method returns a generator type object whose each iteration yields a sample using Hamiltonian Monte Carlo Parameters ---------- initial_pos: A 1d array like object ...
A list of states example - [ ( x1 easy ) ( x2 hard ) ]
def is_list_of_states(self, arg): """ A list of states example - [('x1', 'easy'), ('x2', 'hard')] Returns ------- True, if arg is a list of states else False. """ return isinstance(arg, list) and all(isinstance(i, tuple) for i in arg)
A list of list of states example - [[ ( x1 easy ) ( x2 hard ) ] [ ( x1 hard ) ( x2 medium ) ]]
def is_list_of_list_of_states(self, arg): """ A list of list of states example - [[('x1', 'easy'), ('x2', 'hard')], [('x1', 'hard'), ('x2', 'medium')]] Returns ------- True, if arg is a list of list of states else False. """ if arg is None: r...
Add an edge between u and v.
def add_edge(self, u, v, weight=None): """ Add an edge between u and v. The nodes u and v will be automatically added if they are not already in the graph. Parameters ---------- u, v : nodes Nodes can be any hashable Python object. weight: i...
Check if the given nodes form a clique.
def is_clique(self, nodes): """ Check if the given nodes form a clique. Parameters ---------- nodes: list, array-like List of nodes to check if they are a part of any clique. Examples -------- >>> from pgmpy.base import UndirectedGraph ...
Set the start state of the Markov Chain. If the start_state is given as a array - like iterable its contents are reordered in the internal representation.
def set_start_state(self, start_state): """ Set the start state of the Markov Chain. If the start_state is given as a array-like iterable, its contents are reordered in the internal representation. Parameters: ----------- start_state: dict or array-like iterable object ...
Checks if a list representing the state of the variables is valid.
def _check_state(self, state): """ Checks if a list representing the state of the variables is valid. """ if not hasattr(state, '__iter__') or isinstance(state, six.string_types): raise ValueError('Start state must be a non-string iterable object.') state_vars = {s.va...
Add a variable to the model.
def add_variable(self, variable, card=0): """ Add a variable to the model. Parameters: ----------- variable: any hashable python object card: int Representing the cardinality of the variable to be added. Examples: --------- >>> from ...
Add several variables to the model at once.
def add_variables_from(self, variables, cards): """ Add several variables to the model at once. Parameters: ----------- variables: array-like iterable object List of variables to be added. cards: array-like iterable object List of cardinalities o...
Adds a transition model for a particular variable.
def add_transition_model(self, variable, transition_model): """ Adds a transition model for a particular variable. Parameters: ----------- variable: any hashable python object must be an existing variable of the model. transition_model: dict or 2d array ...
Sample from the Markov Chain.
def sample(self, start_state=None, size=1): """ Sample from the Markov Chain. Parameters: ----------- start_state: dict or array-like iterable Representing the starting states of the variables. If None is passed, a random start_state is chosen. size: int ...
Given an instantiation ( partial or complete ) of the variables of the model compute the probability of observing it over multiple windows in a given sample.
def prob_from_sample(self, state, sample=None, window_size=None): """ Given an instantiation (partial or complete) of the variables of the model, compute the probability of observing it over multiple windows in a given sample. If 'sample' is not passed as an argument, generate the stati...
Generator version of self. sample
def generate_sample(self, start_state=None, size=1): """ Generator version of self.sample Return Type: ------------ List of State namedtuples, representing the assignment to all variables of the model. Examples: --------- >>> from pgmpy.models.MarkovChai...
Checks if the given markov chain is stationary and checks the steady state probablity values for the state are consistent.
def is_stationarity(self, tolerance=0.2, sample=None): """ Checks if the given markov chain is stationary and checks the steady state probablity values for the state are consistent. Parameters: ----------- tolerance: float represents the diff between actual s...
Generates a random state of the Markov Chain.
def random_state(self): """ Generates a random state of the Markov Chain. Return Type: ------------ List of namedtuples, representing a random assignment to all variables of the model. Examples: --------- >>> from pgmpy.models import MarkovChain as MC ...
Returns a copy of Markov Chain Model.
def copy(self): """ Returns a copy of Markov Chain Model. Return Type: ------------ MarkovChain : Copy of MarkovChain. Examples: --------- >>> from pgmpy.models import MarkovChain >>> from pgmpy.factors.discrete import State >>> model = M...
Returns True if assertion is contained in this Independencies - object otherwise False.
def contains(self, assertion): """ Returns `True` if `assertion` is contained in this `Independencies`-object, otherwise `False`. Parameters ---------- assertion: IndependenceAssertion()-object Examples -------- >>> from pgmpy.independencies impo...
Adds assertions to independencies.
def add_assertions(self, *assertions): """ Adds assertions to independencies. Parameters ---------- assertions: Lists or Tuples Each assertion is a list or tuple of variable, independent_of and given. Examples -------- >>> from pgmpy.inde...
Returns a new Independencies () - object that additionally contains those IndependenceAssertions that are implied by the the current independencies ( using with the semi - graphoid axioms <https:// en. wikipedia. org/ w/ index. php?title = Conditional_independence&oldid = 708760689#Rules_of_conditional_independence > _...
def closure(self): """ Returns a new `Independencies()`-object that additionally contains those `IndependenceAssertions` that are implied by the the current independencies (using with the `semi-graphoid axioms <https://en.wikipedia.org/w/index.php?title=Conditional_independence&oldid=708...
Returns True if the entailed_independencies are implied by this Independencies - object otherwise False. Entailment is checked using the semi - graphoid axioms.
def entails(self, entailed_independencies): """ Returns `True` if the `entailed_independencies` are implied by this `Independencies`-object, otherwise `False`. Entailment is checked using the semi-graphoid axioms. Might be very slow if more than six variables are involved. Para...
Add an edge between u and v.
def add_edge(self, u, v, *kwargs): """ Add an edge between u and v. The nodes u and v will be automatically added if they are not already in the graph Parameters ---------- u,v : nodes Nodes can be any hashable python object. Examples ...
Returns a list of all ancestors of all the observed nodes.
def _get_ancestors_of(self, obs_nodes_list): """ Returns a list of all ancestors of all the observed nodes. Parameters ---------- obs_nodes_list: string, list-type name of all the observed nodes """ if not obs_nodes_list: return set() ...
Returns all the nodes reachable from start via an active trail.
def active_trail_nodes(self, start, observed=None): """ Returns all the nodes reachable from start via an active trail. Parameters ---------- start: Graph node observed : List of nodes (optional) If given the active trail would be computed assuming these nod...
Returns an instance of Independencies containing the local independencies of each of the variables.
def local_independencies(self, variables): """ Returns an instance of Independencies containing the local independencies of each of the variables. Parameters ---------- variables: str or array like variables whose local independencies are to found. ...
Computes the CPD for each node from a given data in the form of a pandas dataframe. If a variable from the data is not present in the model it adds that node into the model.
def fit(self, data, parent_node=None, estimator=None): """ Computes the CPD for each node from a given data in the form of a pandas dataframe. If a variable from the data is not present in the model, it adds that node into the model. Parameters ---------- data : pandas D...
Computes a score to measure how well the given BayesianModel fits to the data set. ( This method relies on the local_score - method that is implemented in each subclass. )
def score(self, model): """ Computes a score to measure how well the given `BayesianModel` fits to the data set. (This method relies on the `local_score`-method that is implemented in each subclass.) Parameters ---------- model: `BayesianModel` instance The B...
Computes a score that measures how much a \ given variable is \ influenced \ by a given list of potential parents.
def local_score(self, variable, parents): "Computes a score that measures how much a \ given variable is \"influenced\" by a given list of potential parents." var_states = self.state_names[variable] var_cardinality = len(var_states) state_counts = self.state_counts(variable, par...
Generate a cartesian product of input arrays.
def cartesian(arrays, out=None): """Generate a cartesian product of input arrays. Parameters ---------- arrays : list of array-like 1-D arrays to form the cartesian product of. out : ndarray Array to place the cartesian product in. Returns ------- out : ndarray ...
Generate a sample of given size given a probability mass function.
def sample_discrete(values, weights, size=1): """ Generate a sample of given size, given a probability mass function. Parameters ---------- values: numpy.array: Array of all possible values that the random variable can take. weights: numpy.array or list of numpy.array: Array(s) repr...
Generates all subsets of list l ( as tuples ).
def powerset(l): """ Generates all subsets of list `l` (as tuples). Example ------- >>> from pgmpy.utils.mathext import powerset >>> list(powerset([1,2,3])) [(), (1,), (2,), (3,), (1,2), (1,3), (2,3), (1,2,3)] """ return chain.from_iterable(combinations(l, r) for r in range(len(l)+1...
Remove draft pages from space using datetime. now: param confluence:: param space_key:: param count:: param date_now:: return: int counter
def clean_draft_pages_from_space(confluence, space_key, count, date_now): """ Remove draft pages from space using datetime.now :param confluence: :param space_key: :param count: :param date_now: :return: int counter """ pages = confluence.get_all_draft_pages_from_space(space=space_ke...
Remove all draft pages for all spaces older than DRAFT_DAYS: param days: int: param confluence:: return:
def clean_all_draft_pages_from_all_spaces(confluence, days=30): """ Remove all draft pages for all spaces older than DRAFT_DAYS :param days: int :param confluence: :return: """ date_now = datetime.datetime.now() count = 0 limit = 50 flag = True i = 0 while flag: s...
Provide content by type ( page blog comment ): param page_id: A string containing the id of the type content container.: param type:: param start: OPTIONAL: The start point of the collection to return. Default: None ( 0 ).: param limit: OPTIONAL: how many items should be returned after the start index. Default: Site li...
def get_page_child_by_type(self, page_id, type='page', start=None, limit=None): """ Provide content by type (page, blog, comment) :param page_id: A string containing the id of the type content container. :param type: :param start: OPTIONAL: The start point of the collection to re...
Returns the list of labels on a piece of Content.: param space: Space key: param title: Title of the page: param start: OPTIONAL: The start point of the collection to return. Default: None ( 0 ).: param limit: OPTIONAL: The limit of the number of labels to return this may be restricted by fixed system limits. Default: ...
def get_page_by_title(self, space, title, start=None, limit=None): """ Returns the list of labels on a piece of Content. :param space: Space key :param title: Title of the page :param start: OPTIONAL: The start point of the collection to return. Default: None (0). :param ...
Get page by ID: param page_id: Content ID: param expand: OPTIONAL: expand e. g. history: return:
def get_page_by_id(self, page_id, expand=None): """ Get page by ID :param page_id: Content ID :param expand: OPTIONAL: expand e.g. history :return: """ url = 'rest/api/content/{page_id}?expand={expand}'.format(page_id=page_id, expand=expand) return self.ge...
Returns the list of labels on a piece of Content.: param page_id: A string containing the id of the labels content container.: param prefix: OPTIONAL: The prefixes to filter the labels with {
def get_page_labels(self, page_id, prefix=None, start=None, limit=None): """ Returns the list of labels on a piece of Content. :param page_id: A string containing the id of the labels content container. :param prefix: OPTIONAL: The prefixes to filter the labels with {@see Label.Prefix}. ...
Provide content by id with status = draft: param page_id:: param status:: return:
def get_draft_page_by_id(self, page_id, status='draft'): """ Provide content by id with status = draft :param page_id: :param status: :return: """ url = 'rest/api/content/{page_id}?status={status}'.format(page_id=page_id, status=status) return self.get(url...
Get all page by label: param label:: param start: OPTIONAL: The start point of the collection to return. Default: None ( 0 ).: param limit: OPTIONAL: The limit of the number of pages to return this may be restricted by fixed system limits. Default: 50: return:
def get_all_pages_by_label(self, label, start=0, limit=50): """ Get all page by label :param label: :param start: OPTIONAL: The start point of the collection to return. Default: None (0). :param limit: OPTIONAL: The limit of the number of pages to return, this may be restricted b...
Get all pages from space: param space:: param start: OPTIONAL: The start point of the collection to return. Default: None ( 0 ).: param limit: OPTIONAL: The limit of the number of pages to return this may be restricted by fixed system limits. Default: 50: param status: OPTIONAL: return:
def get_all_pages_from_space(self, space, start=0, limit=500, status=None): """ Get all pages from space :param space: :param start: OPTIONAL: The start point of the collection to return. Default: None (0). :param limit: OPTIONAL: The limit of the number of pages to return, this ...
Get list of pages from trash: param space:: param start: OPTIONAL: The start point of the collection to return. Default: None ( 0 ).: param limit: OPTIONAL: The limit of the number of pages to return this may be restricted by fixed system limits. Default: 500: param status:: return:
def get_all_pages_from_space_trash(self, space, start=0, limit=500, status='trashed'): """ Get list of pages from trash :param space: :param start: OPTIONAL: The start point of the collection to return. Default: None (0). :param limit: OPTIONAL: The limit of the number of pages t...
Get list of draft pages from space Use case is cleanup old drafts from Confluence: param space:: param start: OPTIONAL: The start point of the collection to return. Default: None ( 0 ).: param limit: OPTIONAL: The limit of the number of pages to return this may be restricted by fixed system limits. Default: 500: param ...
def get_all_draft_pages_from_space(self, space, start=0, limit=500, status='draft'): """ Get list of draft pages from space Use case is cleanup old drafts from Confluence :param space: :param start: OPTIONAL: The start point of the collection to return. Default: None (0). ...
Search list of draft pages by space key Use case is cleanup old drafts from Confluence: param space: Space Key: param status: Can be changed: param start: OPTIONAL: The start point of the collection to return. Default: None ( 0 ).: param limit: OPTIONAL: The limit of the number of pages to return this may be restricted...
def get_all_draft_pages_from_space_through_cql(self, space, start=0, limit=500, status='draft'): """ Search list of draft pages by space key Use case is cleanup old drafts from Confluence :param space: Space Key :param status: Can be changed :param start: OPTIONAL: The st...
This method removes a page if it has recursive flag method removes including child pages: param page_id:: param status: OPTIONAL: type of page: param recursive: OPTIONAL: if True - will recursively delete all children pages too: return:
def remove_page(self, page_id, status=None, recursive=False): """ This method removes a page, if it has recursive flag, method removes including child pages :param page_id: :param status: OPTIONAL: type of page :param recursive: OPTIONAL: if True - will recursively delete all chi...
Create page from scratch: param space:: param title:: param body:: param parent_id:: param type:: return:
def create_page(self, space, title, body, parent_id=None, type='page'): """ Create page from scratch :param space: :param title: :param body: :param parent_id: :param type: :return: """ log.info('Creating {type} "{space}" -> "{title}"'.form...
Get all spaces with provided limit: param start: OPTIONAL: The start point of the collection to return. Default: None ( 0 ).: param limit: OPTIONAL: The limit of the number of pages to return this may be restricted by fixed system limits. Default: 500
def get_all_spaces(self, start=0, limit=500): """ Get all spaces with provided limit :param start: OPTIONAL: The start point of the collection to return. Default: None (0). :param limit: OPTIONAL: The limit of the number of pages to return, this may be restricted by ...
Add comment into page: param page_id: param text
def add_comment(self, page_id, text): """ Add comment into page :param page_id :param text """ data = {'type': 'comment', 'container': {'id': page_id, 'type': 'page', 'status': 'current'}, 'body': {'storage': {'value': text, 'representation...
Attach ( upload ) a file to a page if it exists it will update the automatically version the new file and keep the old one.: param title: The page name: type title: str: param space: The space name: type space: str: param page_id: The page id to which we would like to upload the file: type page_id: str: param filename:...
def attach_file(self, filename, page_id=None, title=None, space=None, comment=None): """ Attach (upload) a file to a page, if it exists it will update the automatically version the new file and keep the old one. :param title: The page name :type title: ``str`` :param spa...
Set a label on the page: param page_id: content_id format: param label: label to add: return:
def set_page_label(self, page_id, label): """ Set a label on the page :param page_id: content_id format :param label: label to add :return: """ url = 'rest/api/content/{page_id}/label'.format(page_id=page_id) data = {'prefix': 'global', 'na...
Remove content history. It works as experimental method: param page_id:: param version_number: version number: return:
def remove_content_history(self, page_id, version_number): """ Remove content history. It works as experimental method :param page_id: :param version_number: version number :return: """ url = 'rest/experimental/content/{id}/version/{versionNumber}'.format(id=page_...
Remove content history. It works in CLOUD: param page_id:: param version_id:: return:
def remove_content_history_in_cloud(self, page_id, version_id): """ Remove content history. It works in CLOUD :param page_id: :param version_id: :return: """ url = 'rest/api/content/{id}/version/{versionId}'.format(id=page_id, versionId=version_id) self.de...
Check has unknown attachment error on page: param page_id:: return:
def has_unknown_attachment_error(self, page_id): """ Check has unknown attachment error on page :param page_id: :return: """ unknown_attachment_identifier = 'plugins/servlet/confluence/placeholder/unknown-attachment' result = self.get_page_by_id(page_id, expand='b...
Compare content and check is already updated or not: param page_id: Content ID for retrieve storage value: param body: Body for compare it: return: True if the same
def is_page_content_is_already_updated(self, page_id, body): """ Compare content and check is already updated or not :param page_id: Content ID for retrieve storage value :param body: Body for compare it :return: True if the same """ confluence_content = (self.get...
Update page if already exist: param parent_id:: param page_id:: param title:: param body:: param type:: param minor_edit: Indicates whether to notify watchers about changes. If False then notifications will be sent.: return:
def update_page(self, parent_id, page_id, title, body, type='page', minor_edit=False): """ Update page if already exist :param parent_id: :param page_id: :param title: :param body: :param type: :param minor_edit: Indicates whether to no...
Update page or create a page if it is not exists: param parent_id:: param title:: param body:: return:
def update_or_create(self, parent_id, title, body): """ Update page or create a page if it is not exists :param parent_id: :param title: :param body: :return: """ space = self.get_page_space(parent_id) if self.page_exists(space, title): ...
Set the page ( content ) property e. g. add hash parameters: param page_id: content_id format: param data: data should be as json data: return:
def set_page_property(self, page_id, data): """ Set the page (content) property e.g. add hash parameters :param page_id: content_id format :param data: data should be as json data :return: """ url = 'rest/api/content/{page_id}/property'.format(page_id=page_id) ...
Delete the page ( content ) property e. g. delete key of hash: param page_id: content_id format: param page_property: key of property: return:
def delete_page_property(self, page_id, page_property): """ Delete the page (content) property e.g. delete key of hash :param page_id: content_id format :param page_property: key of property :return: """ url = 'rest/api/content/{page_id}/property/{page_property}'....
Get the page ( content ) property e. g. get key of hash: param page_id: content_id format: param page_property_key: key of property: return:
def get_page_property(self, page_id, page_property_key): """ Get the page (content) property e.g. get key of hash :param page_id: content_id format :param page_property_key: key of property :return: """ url = 'rest/api/content/{page_id}/property/{key}'.format(page...
Get the page ( content ) properties: param page_id: content_id format: return: get properties
def get_page_properties(self, page_id): """ Get the page (content) properties :param page_id: content_id format :return: get properties """ url = 'rest/api/content/{page_id}/property'.format(page_id=page_id) return self.get(path=url)
Provide the ancestors from the page ( content ) id: param page_id: content_id format: return: get properties
def get_page_ancestors(self, page_id): """ Provide the ancestors from the page (content) id :param page_id: content_id format :return: get properties """ url = 'rest/api/content/{page_id}?expand=ancestors'.format(page_id=page_id) return (self.get(path=url) or {})....
Clean caches from cache management e. g. com. gliffy. cache. gon org. hibernate. cache. internal. StandardQueryCache_v5
def clean_package_cache(self, cache_name='com.gliffy.cache.gon'): """ Clean caches from cache management e.g. com.gliffy.cache.gon org.hibernate.cache.internal.StandardQueryCache_v5 """ headers = self.form_token_headers data = {'cacheName': cache_name}...
Get all groups from Confluence User management: param start: OPTIONAL: The start point of the collection to return. Default: None ( 0 ).: param limit: OPTIONAL: The limit of the number of groups to return this may be restricted by fixed system limits. Default: 1000: return:
def get_all_groups(self, start=0, limit=1000): """ Get all groups from Confluence User management :param start: OPTIONAL: The start point of the collection to return. Default: None (0). :param limit: OPTIONAL: The limit of the number of groups to return, this may be restricted by ...
Get a paginated collection of users in the given group: param group_name: param start: OPTIONAL: The start point of the collection to return. Default: None ( 0 ).: param limit: OPTIONAL: The limit of the number of users to return this may be restricted by fixed system limits. Default: 1000: return:
def get_group_members(self, group_name='confluence-users', start=0, limit=1000): """ Get a paginated collection of users in the given group :param group_name :param start: OPTIONAL: The start point of the collection to return. Default: None (0). :param limit: OPTIONAL: The limit ...
Get information about a space through space key: param space_key: The unique space key name: param expand: OPTIONAL: additional info from description homepage: return: Returns the space along with its ID
def get_space(self, space_key, expand='description.plain,homepage'): """ Get information about a space through space key :param space_key: The unique space key name :param expand: OPTIONAL: additional info from description, homepage :return: Returns the space along with its ID ...
Get information about a user through username: param username: The user name: param expand: OPTIONAL expand for get status of user. Possible param is status. Results are Active Deactivated: return: Returns the user details
def get_user_details_by_username(self, username, expand=None): """ Get information about a user through username :param username: The user name :param expand: OPTIONAL expand for get status of user. Possible param is "status". Results are "Active, Deactivated" :re...
Get information about a user through user key: param userkey: The user key: param expand: OPTIONAL expand for get status of user. Possible param is status. Results are Active Deactivated: return: Returns the user details
def get_user_details_by_userkey(self, userkey, expand=None): """ Get information about a user through user key :param userkey: The user key :param expand: OPTIONAL expand for get status of user. Possible param is "status". Results are "Active, Deactivated" :return...
Get results from cql search result with all related fields Search for entities in Confluence using the Confluence Query Language ( CQL ): param cql:: param start: OPTIONAL: The start point of the collection to return. Default: 0.: param limit: OPTIONAL: The limit of the number of issues to return this may be restricted...
def cql(self, cql, start=0, limit=None, expand=None, include_archived_spaces=None, excerpt=None): """ Get results from cql search result with all related fields Search for entities in Confluence using the Confluence Query Language (CQL) :param cql: :param start: OPTIONAL: The sta...
Export page as standard pdf exporter: param page_id: Page ID: return: PDF File
def get_page_as_pdf(self, page_id): """ Export page as standard pdf exporter :param page_id: Page ID :return: PDF File """ headers = self.form_token_headers url = 'spaces/flyingpdf/pdfpageexport.action?pageId={pageId}'.format(pageId=page_id) return self.ge...
Provide space parent_id and title of the descendant page it will return the descendant page_id: param space: str: param parent_id: int: param title: str: return: page_id of the page whose title is passed in argument
def get_descendant_page_id(self, space, parent_id, title): """ Provide space, parent_id and title of the descendant page, it will return the descendant page_id :param space: str :param parent_id: int :param title: str :return: page_id of the page whose title is passed in...
Get health status https:// confluence. atlassian. com/ jirakb/ how - to - retrieve - health - check - results - using - rest - api - 867195158. html: return:
def health_check(self): """ Get health status https://confluence.atlassian.com/jirakb/how-to-retrieve-health-check-results-using-rest-api-867195158.html :return: """ # check as Troubleshooting & Support Tools Plugin response = self.get('rest/troubleshooting/1.0/ch...
Reindex the Jira instance Kicks off a reindex. Need Admin permissions to perform this reindex.: param comments: Indicates that comments should also be reindexed. Not relevant for foreground reindex where comments are always reindexed.: param change_history: Indicates that changeHistory should also be reindexed. Not rel...
def reindex(self, comments=True, change_history=True, worklogs=True): """ Reindex the Jira instance Kicks off a reindex. Need Admin permissions to perform this reindex. :param comments: Indicates that comments should also be reindexed. Not relevant for foreground reindex, where c...
Get issues from jql search result with all related fields: param jql:: param fields: list of fields for example: [ priority summary customfield_10007 ]: param start: OPTIONAL: The start point of the collection to return. Default: 0.: param limit: OPTIONAL: The limit of the number of issues to return this may be restric...
def jql(self, jql, fields='*all', start=0, limit=None): """ Get issues from jql search result with all related fields :param jql: :param fields: list of fields, for example: ['priority', 'summary', 'customfield_10007'] :param start: OPTIONAL: The start point of the collection to ...
Get issues from jql search result with all related fields: param jql: JQL query: param limit: max results in the output file: return: CSV file
def csv(self, jql, limit=1000): """ Get issues from jql search result with all related fields :param jql: JQL query :param limit: max results in the output file :return: CSV file """ url = 'sr/jira.issueviews:searchrequest-csv-all-fields/temp/SearchRequest.csv?tem...
Update user attributes based on json: param username:: param data:: return:
def user_update(self, username, data): """ Update user attributes based on json :param username: :param data: :return: """ url = 'rest/api/2/user?username={0}'.format(username) return self.put(url, data=data)
Update user email for new domain changes: param username:: param email:: return:
def user_update_email(self, username, email): """ Update user email for new domain changes :param username: :param email: :return: """ data = {'name': username, 'emailAddress': email} return self.user_update(username, data=data)
Disable user: param username:: return:
def user_deactivate(self, username): """ Disable user :param username: :return: """ url = 'secure/admin/user/EditUser.jspa' headers = self.form_token_headers user = self.user(username) user_update_info = { 'inline': 'true', ...
The disable method throw own rest enpoint
def user_disable_throw_rest_endpoint(self, username, url='rest/scriptrunner/latest/custom/disableUser', param='userName'): """The disable method throw own rest enpoint""" url = "{}?{}={}".format(url, param, username) return self.get(path=url)
Get web sudo cookies using normal http request
def user_get_websudo(self): """ Get web sudo cookies using normal http request""" url = 'secure/admin/WebSudoAuthenticate.jspa' headers = self.form_token_headers data = { 'webSudoPassword': self.password, } return self.post(path=url, data=data, headers=headers...
Fuzzy search using username and display name: param username: Use. to find all users: param start: OPTIONAL: The start point of the collection to return. Default: 0.: param limit: OPTIONAL: The limit of the number of users to return this may be restricted by fixed system limits. Default by built - in method: 50: param ...
def user_find_by_user_string(self, username, start=0, limit=50, include_inactive_users=False, include_active_users=True): """ Fuzzy search using username and display name :param username: Use '.' to find all users :param start: OPTIONAL: The start point of the collection to return. Defau...
Contains a full representation of a the specified project s versions.: param key:: param expand: the parameters to expand: return:
def get_project_versions(self, key, expand=None): """ Contains a full representation of a the specified project's versions. :param key: :param expand: the parameters to expand :return: """ params = {} if expand is not None: params['expand'] = e...
Returns all versions for the specified project. Results are paginated. Results can be ordered by the following fields: sequence name startDate releaseDate: param key: the project key or id: param start: the page offset if not specified then defaults to 0: param limit: how many results on the page should be included. De...
def get_project_versions_paginated(self, key, start=None, limit=None, order_by=None, expand=None): """ Returns all versions for the specified project. Results are paginated. Results can be ordered by the following fields: sequence name startDate re...
Returns the details for a given project role in a project.: param project_key:: param role_id:: return:
def get_project_actors_for_role_project(self, project_key, role_id): """ Returns the details for a given project role in a project. :param project_key: :param role_id: :return: """ url = 'rest/api/2/project/{projectIdOrKey}/role/{id}'.format(projectIdOrKey=project...
Deletes actors ( users or groups ) from a project role. Delete a user from the role:/ rest/ api/ 2/ project/ { projectIdOrKey }/ role/ { roleId } ?user = { username } Delete a group from the role:/ rest/ api/ 2/ project/ { projectIdOrKey }/ role/ { roleId } ?group = { groupname }: param project_key:: param role_id:: pa...
def delete_project_actors(self, project_key, role_id, actor, actor_type=None): """ Deletes actors (users or groups) from a project role. Delete a user from the role: /rest/api/2/project/{projectIdOrKey}/role/{roleId}?user={username} Delete a group from the role: /rest/api/2/project/{proj...
Updates a project. Update project:/ rest/ api/ 2/ project/ { projectIdOrKey }
def update_project(self, project_key, data, expand=None): """ Updates a project. Update project: /rest/api/2/project/{projectIdOrKey} :param project_key: project key of project that needs to be updated :param data: dictionary containing the data to be updated :param expa...
Get custom fields. Evaluated on 7. 12: param search: str: param start: long Default: 1: param limit: int Default: 50: return:
def get_custom_fields(self, search=None, start=1, limit=50): """ Get custom fields. Evaluated on 7.12 :param search: str :param start: long Default: 1 :param limit: int Default: 50 :return: """ url = 'rest/api/2/customFields' params = {} if...
Get issue labels.: param issue_key:: return:
def get_issue_labels(self, issue_key): """ Get issue labels. :param issue_key: :return: """ url = 'rest/api/2/issue/{issue_key}?fields=labels'.format(issue_key=issue_key) return (self.get(url) or {}).get('fields').get('labels')
Provide assignable users for project: param project_key:: param start: OPTIONAL: The start point of the collection to return. Default: 0.: param limit: OPTIONAL: The limit of the number of users to return this may be restricted by fixed system limits. Default by built - in method: 50: return:
def get_all_assignable_users_for_project(self, project_key, start=0, limit=50): """ Provide assignable users for project :param project_key: :param start: OPTIONAL: The start point of the collection to return. Default: 0. :param limit: OPTIONAL: The limit of the number of users t...
REST endpoint for searching groups in a group picker Returns groups with substrings matching a given query. This is mainly for use with the group picker so the returned groups contain html to be used as picker suggestions. The groups are also wrapped in a single response object that also contains a header for use in th...
def get_groups(self, query=None, exclude=None, limit=20): """ REST endpoint for searching groups in a group picker Returns groups with substrings matching a given query. This is mainly for use with the group picker, so the returned groups contain html to be used as picker suggestions. Th...
Create a group by given group parameter
def create_group(self, name): """ Create a group by given group parameter :param name: str :return: New group params """ url = 'rest/api/2/group' data = {'name': name} return self.post(url, data=data)
Delete a group by given group parameter If you delete a group and content is restricted to that group the content will be hidden from all users To prevent this use this parameter to specify a different group to transfer the restrictions ( comments and worklogs only ) to
def remove_group(self, name, swap_group=None): """ Delete a group by given group parameter If you delete a group and content is restricted to that group, the content will be hidden from all users To prevent this, use this parameter to specify a different group to transfer the restriction...
Just wrapping method user group members: param group:: param include_inactive_users:: param start: OPTIONAL: The start point of the collection to return. Default: 0.: param limit: OPTIONAL: The limit of the number of users to return this may be restricted by fixed system limits. Default by built - in method: 50: return...
def get_all_users_from_group(self, group, include_inactive_users=False, start=0, limit=50): """ Just wrapping method user group members :param group: :param include_inactive_users: :param start: OPTIONAL: The start point of the collection to return. Default: 0. :param lim...