atlassian-cloud-api

A REST API Implementation to Jira Cloud APIs for creating reports and for performing other Jira queries.

Using the API

Jiraone basically allows you to create a report based method using Atlassian REST API on your cloud infrastructure. It uses a class method on the Endpoint class, so you can easily call the direct Atlassian API. In generating reports, you can create functions, classes or even methods to derive the desired results.

from jiraone import LOGIN, endpoint

user = "email"
password = "token"
link = "https://yourinstance.atlassian.net"
LOGIN(user=user, password=password, url=link)


def priorities():
        load = LOGIN.get(endpoint.get_all_priorities())
        if load.status_code == 200:
             # some expression here
             ...

The script comes with a “User” and “Project” classes which includes basic reporting examples. The User class has a user generator, which easily enables you to fetch all users on the instance without you programming such yourself. All these methods and functions are accessible directly from the jiraone package.

endpoint

endpoint.MethodName()
This is an alias to the EndPoints class and it has many methods that can be called directly.
Example usage: endpoint.myself(), endpoint.search_users()

LOGIN

LOGIN()
This is a call to the Credentials class and the accepted parameters are

from jiraone import LOGIN

user = "email"
password = "token"
link = "https://yourinstance.atlassian.net"
LOGIN(user=user, password=password, url=link)


Attributes, available to the LOGIN alias

Methods, available to the LOGIN alias, it returns a response object.
The keyword argument of payload can be any json object you want to pass to the method. Subsequently, you can pass other keyword arguments such as files, data etc.

echo

echo(object)
This is a function which uses a copy of the PrettyPrint Class used to nicely format a represented printed result. To call, simply use the function echo.
It accepts one required parameter, which can be any object.
Example usage:

from jiraone import echo
    
data = "hello world"
echo(data)
# prints //
# 'hello world'


add_log

add_log(message, level)
This function is used to log messages to a log file. It accepts two required parameters message and level of which both are strings. The function uses the logging module and writes a log, based on 3 levels.

from jiraone import add_log
    
message = "successfully Initiated the script"
add_log(message, "info")


file_writer

file_writer(folder=”string”, file_name=”string”, data=[iterable], mark=”string”, mode=”string”, content=”string[bytes]”)
This function helps in creating a csv file or a normal file. It comes with the below parameters as keyword arguments

from jiraone import file_writer
    
a_list = [1, 14, 22, "hello", "file"]
files = file_writer(folder="TEST", file_name="test.csv", data=a_list)
    

file_reader

file_writer(folder=”string”, file_name=”string”, mode=”string”, content=bool, skip=bool)
This function helps in reading a csv file and returning a list comprehension of the data or read a byte file. Accepted parameter include

from jiraone import file_reader
    
files = file_reader(folder="TEST", file_name="test.csv")
    

path_builder

path_builder(path=”string”, file_name=”string”)
This function helps to build a directory path and file path then returns the file path in the directory. parameters include

from jiraone import path_builder
    
path = "Test_folder"
file = "test.csv"
dir_path = path_builder(path=path, file_name=file)
    
# output
# "Test_folder/test.csv"

For

For(object)

The For class is a class to show the implementation of a ‘for’ loop. it calls the __iter__ magic method then the __next__ method and raises a StopIteration once it reaches the end of the loop. Datatype expected are list, dict, tuple, str, set or int. It contains one required parameter called data which it uses to receive the various datatype and translate them into a list of items, retaining their own unique datatype.

It also contains a unique method called __dictionary__() which helps in indexing dict objects. It works the same way as any iteration.
Example usage:

from jiraone import For

diction = {1: 4, "hello": "hi", "value": True, "why": False}
d = For(diction).__dictionary__(2)  # calls the 3rd item in the list

# output
# {"value": True}

replacement_placeholder

replacement_placeholder(string=””, data=[list], iterable=[list], row=integer)
This function returns multiple string replacement. This can be used to replace multiple strings in a list where a placeholder can be identified and used as a marker to replace the strings.

Example usage:

from jiraone import replacement_placeholder

hold = ["Hello", "John doe", "Post mortem"]
text = ["<name> <name>, welcome to the <name> of what is to come"]
cb = replacement_placeholder("<name>", text, hold, 0)
print(cb)

# output
# ["Hello John doe, welcome to the Post mortem of what is to come"]

field

Alias to the Field class and it basically helps to update custom or system fields on Jira. It comes with the below methods.

Attributes - You have access to two vital attributes.

Methods - Below are the various methods that can be used.
field.search_field(find_field=”string”)
This helps to search for a custom field. The paramater needed find_field which should be a string.

field.get_field(find_field=”string”)
This helps to search for system fields or custom fields. The paramater needed find_field which should be a string.

field.update_field_data(data=[Any], find_field=”string”, field_type=”string”, key_or_id=Union[string, integer], show=[Bool], kwargs=[Any])

This method helps with updating fields. Performs a put request, with the below parameters.

field.data_load(data=[Any], s=[Any])

field.multi_field(data=[Any], s=”string”)

field.cascading(data=[String,List])

field.extract_issue_field_options(key_or_id=Union[string, integer], search=None, amend=None, data=Any)

Example usage:

from jiraone import field, echo, LOGIN

user = "email"
password = "token"
link = "https://yourinstance.atlassian.net"
LOGIN(user=user, password=password, url=link)

issue = "T6-75"
fields = "Multiple files" # a multiselect custom field
case_value = ["COM Row 1", "Thanos"]
for value in case_value:
    c = field.update_field_data(data=value, find_field=fields, key_or_id=issue, options="add", show=False)
    echo(c)

# output
# < Response[204] >

field.comment_on(key_or_id=String, comment_id=Integer, method=String[“GET”, “PUT”, “DELETE”, “POST”], kwargs)

Other variables