Giter Club home page Giter Club logo

elixir-ex_jira's Introduction

ExJira

Elixir wrapper for the JIRA REST API as outlined here.

Still in development. POST has not been tested. Need remainder of resources implemented. Contributions welcome!

Build Status Coverage Status Project license Hex.pm package Hex.pm downloads

Installation

ExJira can be installed by adding ex_jira to your list of dependencies in mix.exs:

def deps do
  [{:ex_jira, "~> 0.0.5"}]
end

Configuration

ExJira requires three application variables. Add the following variables to your config.exs file (this example retrieves those variables from environment variables):

config :ex_jira,
  account: System.get_env("JIRA_ACCOUNT"),
  username: System.get_env("JIRA_USERNAME"),
  password: System.get_env("JIRA_PASSWORD")

The HTTPotion timeout value is configurable by the optional timeout application variable, which defaults to 30_000 (30 seconds) when not set:

config :ex_jira,
  timeout: 60_000

For testing purposes, you can override the HTTP client that ExJira uses via the following application variable:

config :ex_jira,
  http_client: ExJira.MockClient

Usage

Dashboard

{:ok, dashboards} = ExJira.Dashboard.all()
{:ok, dashboards} = ExJira.Dashboard.all(filter: "favourite")
dashboards = ExJira.Dashboard.all!()
dashboards = ExJira.Dashboard.all!(filter: "favourite")

Project

{:ok, projects} = ExJira.Project.all()
{:ok, projects} = ExJira.Project.all(expand: "description,url")
projects = ExJira.Project.all!()
projects = ExJira.Project.all!(expand: "description,url")

{:ok, project} = ExJira.Project.get("1001")
{:ok, project} = ExJira.Project.get("1001", expand: "description,url")
project = ExJira.Project.get!("1001")
project = ExJira.Project.get!("1001", expand: "description,url")

{:ok, issues} = ExJira.Project.get_issues("1001")
{:ok, issues} = ExJira.Project.get_issues("1001", expand: "operations")
issues = ExJira.Project.get_issues!("1001")
issues = ExJira.Project.get_issues!("1001", expand: "operations")

Raw requests to Jira for resources that are not yet implemented can be made like this:

{:ok, dashboards} = ExJira.Request.get_one("/dashboard","filter=favourite")
{:ok, ret} = ExJira.Request.post("/project", "", "{\"name\":\"test\"}")

Docs can be found at https://hexdocs.pm/ex_jira.

elixir-ex_jira's People

Contributors

thefirstavenger avatar zachallett avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

elixir-ex_jira's Issues

`Request.get_more/5` returning an unhandled response type upon second request

ERROR:

17:51:30.119 [debug] ExJira.Request: Sending GET to https://jira.company_name.com/rest/api/latest/dashboard?startAt=20&&maxResults=300 using Elixir.HTTPotion
** (FunctionClauseError) no function clause matching in ExJira.Request.get_more/5

    The following arguments were given to ExJira.Request.get_more/5:

        # 1
        {:ok, %{"errorMessages" => ["The 'startAt' param (300) must be a multiple of the 'maxResults' param (20)"], "errors" => %{}}}

        # 2
         ...
        [truncated]

I believe it is related to this line:

https://github.com/TheFirstAvenger/elixir-ex_jira/blame/master/lib/ex_jira/utils/request.ex#L66

Is there a reason that the request is being constructed with a maxResult of 300 rather than just using the "next" => "https://jira.company_name.com/rest/api/latest/dashboard?maxResults=20&startAt=20" provided by the response from the previous request?

Seen here:

  ...

  "maxResults" => 20,
  "next" => "https://jira.company_name.com/rest/api/latest/dashboard?maxResults=20&startAt=20",
  "startAt" => 0,
  "total" => 27
}

The other issue that I noticed was the double ampersand in the request uri that is an effect of #{query_params} being placed in the middle of this line:

request( "GET", resource_path, "startAt=#{length(prev_items) + length(items)}&#{query_params}&maxResults=300", "" )

and then resolving to nil.

If it is alright with you I am working on a PR to resolve this issue, and is why I had the question regarding why maxResult is jumping from 20 to 300 after the first iteration.

I will try and get a PR up in the next day, work permitting.

Calling Dashboard Api

when i was calling ExJira.Dashboard.all() this api it will gives me the below error -
{:error, "Invalid content-type returned: text/plain"}
i also change the
%HTTPotion.Response{
body: body,
headers: %{hdrs: %{"content-type" => "application/json;charset=UTF-8"}}
} to
%HTTPotion.Response{
body: body,
headers: %{hdrs: %{"content-type" => "text/plain;charset=UTF-8"}}
} in request.ex but it will not work . can you please help me to solve it ?

Calling Search API

I'm having trouble getting up and running with this library.

I'm trying:

ExJira.Request.get_all("/search", "", "jql=key=SD-1000")

It returns {:ok, nil}

The log says ExJira.Request: Sending GET to https://myjira.atlassian.net/rest/api/latest/search?jql=key=SD-1000 with using Elixir.HTTPotion

I've validated that https://myjira.atlassian.net/rest/api/latest/search?jql=key=SD-1000 returns valid JSON.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.