Giter VIP home page Giter VIP logo

jira4s's Introduction

Jira4s

Build Status Maven Central

Atlassian Jira Client for Scala

Dependencies

Getting Started

Add the following to your build.sbt:

libraryDependencies += "com.github.allantl" %% "jira4s" % "0.2.0"

Usage

This library exposes two types of client

  • JiraSingleTenantClient for authentication using api token and basic auth.
  • JiraMultiTenantClient for Atlassian Connect add-on and OAuth(not supported yet).

To initialize the client with authentication using ApiToken or BasicAuthentication

import cats.Id
import com.allantl.jira4s.auth.{ApiToken, BasicAuthentication}
import com.allantl.jira4s.v2.JiraSingleTenantClient
import com.softwaremill.sttp.HttpURLConnectionBackend

object Jira4S extends App {
    implicit val sttpBackend = HttpURLConnectionBackend()

    // ApiToken
    val client: JiraSingleTenantClient[Id] = JiraSingleTenantClient(
        ApiToken(
          "jiraUrl",
          "email",
          "apiToken"
        )
    )

    // Basic Auth
    val client2: JiraSingleTenantClient[Id] = JiraSingleTenantClient(
        BasicAuthentication(
          "jiraUrl",
          "email",
          "password"
        )
    )

    val issue = client.getIssue("10000")

}

If you are developing an Atlassian Connect add-on

import cats.Id
import com.allantl.jira4s.auth.{AcJwtConfig, AuthContext}
import com.allantl.jira4s.v2.JiraMultiTenantClient
import com.softwaremill.sttp.HttpURLConnectionBackend

object Jira4S extends App {

  implicit val sttpBackend = HttpURLConnectionBackend()

  val jwtExpirationInSeconds = 5L
  val client: JiraMultiTenantClient[Id] = JiraMultiTenantClient(
    AcJwtConfig(
      "addOnKey",
      jwtExpirationInSeconds
    )
  )

  // You need to specify an implicit AuthContext when making a request to Jira
  case class UserCtx(instanceUrl: String, accessToken: String) extends AuthContext

  implicit val userCtx = UserCtx(
    "http://your-domain.atlassian.net",
    "atlassian-host-shared-secret"
  )

  val issue = client.getIssue("10000")

}

Configuration

You can add configuration using environment variables or HOCON in application config. Then, you can initialize the client with

import com.allantl.jira4s.v2.{JiraMultiTenantClient, JiraSingleTenantClient}
import com.softwaremill.sttp.HttpURLConnectionBackend

object Jira4S extends App {

  implicit val sttpBackend = HttpURLConnectionBackend()

  val singleTenantClient = JiraSingleTenantClient()
  val multiTenantClient = JiraMultiTenantClient()

}

Api Token:

jira4s {
  jira-url = "https://your-domain.atlassian.net"
  username = "username"
  api-token = "api-token"
}

Environment Variables:

export JIRA4S_JIRA_URL = "https://your-domain.atlassian.net"
export JIRA4S_USERNAME = "username"
export JIRA4S_API_TOKEN = "api-token"

Basic Authentication

jira4s {
  jira-url = "https://your-domain.atlassian.net"
  username = "username"
  password = "password"
}

Environment Variables:

export JIRA4S_JIRA_URL = "https://your-domain.atlassian.net"
export JIRA4S_USERNAME = "username"
export JIRA4S_PASSWORD = "password"

Atlassian connect add-on

jira4s {
  add-on-key = "Your add on key"
  jwt-expiration-in-seconds = 5
}

Environment Variables:

export JIRA4S_ADD_ON_KEY = "Your add on key"
export JIRA4S_JWT_EXPIRATION_IN_SECONDS = 5

Backend

Sttp supports different type of backends which return different type of effects. Please take a look at sttp docs.

Logging

To add logging to the client, please refer here.

jira4s's People

Contributors

allantl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jira4s's Issues

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.