-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from cpageler93/async-http-client
Update to Async HTTP Client
- Loading branch information
Showing
33 changed files
with
966 additions
and
727 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,80 @@ | ||
# JiraSwift | ||
|
||
![Platforms](https://img.shields.io/badge/Platforms-iOS|macOS|tvOS|watchOS|Linux-yellow.svg?style=flat) | ||
![Swift](https://img.shields.io/badge/Swift-5.1-orange.svg?style=flat) | ||
![Platforms](https://img.shields.io/badge/Platforms-iOS%20%7C%20macOS%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux-lightgrey.svg?style=flat) | ||
![Xcode](https://img.shields.io/badge/Xcode-11-blue.svg?style=flat) | ||
[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/cpageler93/JiraSwift/blob/master/LICENSE) | ||
[![Twitter: @cpageler93](https://img.shields.io/badge/contact-@cpageler93-lightgrey.svg?style=flat)](https://twitter.com/cpageler93) | ||
[![Twitter: @cpageler93](https://img.shields.io/badge/contact-@cpageler93-blue.svg?style=flat)](https://twitter.com/cpageler93) | ||
|
||
Jira Client for Swift | ||
`JiraSwift` is a HTTP client for Jira implemented in swift based on [swift-server/async-http-client](https://github.com/swift-server/async-http-client). | ||
|
||
# Framework Usage | ||
|
||
## Usage | ||
|
||
|
||
### Framework | ||
|
||
#### JQL Search | ||
## JQL Search | ||
|
||
```swift | ||
let jiraClient = Jira.Client(url: URL(string: "https://your_jira_url")!, | ||
username: "your_username", | ||
password: "your_password") | ||
jiraClient.search(jql: "key in (XXX027-65, XXX038-3, XXX027-58)") { result in | ||
switch result { | ||
case .success(let result): | ||
for issue in result.issues { | ||
print("issue: \(issue.key)") | ||
} | ||
case .failure: | ||
break | ||
let client = Jira.Client(baseURL: "https://jira.tinyspeck.com", | ||
username: "your_username", | ||
password: "your_password") | ||
|
||
do { | ||
let searchResult = try client.search(jql: "key in (XXX027-65, XXX038-3, XXX027-58)").wait() | ||
for issue in searchResult.issues { | ||
print("\(issue.key): \(issue.fields.assignee?.name ?? "NONE" )") | ||
} | ||
} catch Jira.ClientError.jiraError(let error) { | ||
print(error.errorMessages) | ||
} catch { | ||
print(error) | ||
} | ||
|
||
``` | ||
|
||
### CLI | ||
## Implemented Methods | ||
|
||
| Implemented | Method | Route | | ||
|:----------- |:---------------- |:-------------------------- | | ||
| ✅ | getMyself() | [`/rest/api/2/myself`](https://docs.atlassian.com/software/jira/docs/api/REST/8.4.1/#api/2/myself) | | ||
| ✅ | search() | [`/rest/api/2/search`](https://docs.atlassian.com/software/jira/docs/api/REST/8.4.1/#api/2/search) | | ||
| ✅ | getServerInfo() | [`/rest/api/2/serverInfo`](https://docs.atlassian.com/software/jira/docs/api/REST/8.4.1/#api/2/serverInfo) | | ||
| ✅ | projects() | [`/rest/api/2/project`](https://docs.atlassian.com/software/jira/docs/api/REST/8.4.1/#api/2/project) | | ||
| ✅ | projectTypes() | [`/rest/api/2/project/type`](https://docs.atlassian.com/software/jira/docs/api/REST/8.4.1/#api/2/project/type) | | ||
|
||
# Command Line Interface | ||
|
||
## Environment | ||
|
||
#### JQL Search | ||
You can either setup your environment | ||
|
||
```shell | ||
# setup environment | ||
JIRA_URL=https://your_jira_url | ||
JIRA_USERNAME=your_username | ||
JIRA_PASSWORd=your_password #or leave it blank and get prompted from JiraSwiftCLI | ||
JIRA_PASSWORD=your_password | ||
|
||
./JiraSwiftCLI search "key in (XYZ027-65, XYZ038-3, XYZ027-58)" | ||
jira search --jql "key in (XYZ027-65, XYZ038-3, XYZ027-58)" | ||
``` | ||
|
||
Or pass all values as options to JiraSwiftCLI | ||
Or pass all values as options to jira the command | ||
|
||
```shell | ||
.build/debug/JiraSwiftCLI search "key in (XYZ027-65, XYZ038-3, XYZ027-58)" --url "https://your_jira_url" --username "your_username" --password "your_password" | ||
``` | ||
jira search --url "https://your_jira_url" \ | ||
--username "your_username" \ | ||
--password "your_password" \ | ||
--jql "key in (XYZ027-65, XYZ038-3, XYZ027-58)" | ||
``` | ||
|
||
## Commands | ||
|
||
| Command | Description | | ||
| --------------- | -------------------------- | | ||
| `search` | Search for Issues with JQL | | ||
| `projects` | List all projects | | ||
| `project-types` | List all project types | | ||
|
||
|
||
# Contribute | ||
|
||
Feel free to add a missing REST API method or create an issue if you want me to implement it! | ||
|
||
[Jira REST API Documentation](https://docs.atlassian.com/software/jira/docs/api/REST/8.4.1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// AvatarURLs.swift | ||
// AsyncHTTPClient | ||
// | ||
// Created by Christoph Pageler on 30.09.19. | ||
// | ||
|
||
|
||
public extension Jira { | ||
|
||
class AvatarURLs: Codable { | ||
|
||
public let sixteen: String | ||
public let twentyFour: String | ||
public let thirtyTwo: String | ||
public let fortyEight: String | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case sixteen = "16x16" | ||
case twentyFour = "24x24" | ||
case thirtyTwo = "32x32" | ||
case fortyEight = "48x48" | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// | ||
// JiraIssue.swift | ||
// JiraSwift | ||
// | ||
// Created by Christoph Pageler on 17.11.17. | ||
// | ||
|
||
|
||
import Foundation | ||
|
||
|
||
public extension Jira { | ||
|
||
class Issue: Codable { | ||
|
||
public let id: String | ||
public let key: String | ||
public let fields: Fields | ||
|
||
} | ||
|
||
|
||
class Fields: Codable { | ||
|
||
public let summary: String? | ||
public let project: Jira.Project? | ||
public let status: Status? | ||
public let description: String? | ||
public let issuetype: IssueType? | ||
public let components: [Component]? | ||
public let assignee: Jira.User? | ||
public let creator: Jira.User? | ||
public let reporter: Jira.User? | ||
public let lastViewed: Date? | ||
public let created: Date? | ||
public let updated: Date? | ||
public let duedate: Date? | ||
public let resolution: Resolution? | ||
public let resolutiondate: Date? | ||
public let timespent: Int? | ||
public let timeestimate: Int? | ||
public let watches: Watches? | ||
public let versions: [Version]? | ||
public let fixVersions: [Version]? | ||
public let priority: Priority? | ||
|
||
} | ||
|
||
class Status: Codable { | ||
|
||
public let id: String | ||
public let name: String | ||
public let iconUrl: String | ||
public let description: String | ||
public let statusCategory: StatusCategory | ||
|
||
public class StatusCategory: Codable { | ||
|
||
public let id: Int | ||
public let key: String | ||
public let name: String | ||
public let colorName: String | ||
|
||
} | ||
} | ||
|
||
class Component: Codable { | ||
|
||
public let id: String | ||
public let name: String | ||
|
||
} | ||
|
||
class IssueType: Codable { | ||
|
||
public let id: String | ||
public let description: String | ||
public let iconUrl: String | ||
public let name: String | ||
public let subtask: Bool | ||
|
||
} | ||
|
||
class Resolution: Codable { | ||
|
||
public let id: String | ||
public let name: String | ||
public let description: String | ||
|
||
} | ||
|
||
class Watches: Codable { | ||
|
||
public let watchCount: Int | ||
public let isWatching: Bool | ||
|
||
} | ||
|
||
class Version: Codable { | ||
|
||
public let id: String | ||
public let description: String | ||
public let name: String | ||
public let archived: Bool | ||
public let released: Bool | ||
|
||
// TODO: Implement date parser without time | ||
// public let releaseDate: Date? | ||
|
||
} | ||
|
||
class Priority: Codable { | ||
|
||
public let id: String | ||
public let name: String | ||
public let iconUrl: String | ||
} | ||
} |
Oops, something went wrong.