Added license and updated README

This commit is contained in:
Aaron Sky 2020-05-05 13:47:38 -04:00
parent de5c63f9c8
commit 7109360feb
4 changed files with 77 additions and 6 deletions

9
LICENSE Normal file
View File

@ -0,0 +1,9 @@
Copyright 2020 Aaron Sky
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,3 +1,68 @@
# Buildkite
A description of this package.
![Build Status](https://github.com/aaronsky/buildkite-swift/workflows/CI/badge.svg)
A Swift library and client for the Buildkite REST API.
## Usage
Add the dependency to your `Package.swift` file:
```swift
let package = Package(
name: "myproject",
dependencies: [
.package(url: "https://github.com/aaronsky/buildkite-swift.git", from: "0.1.0"),
],
targets: [
.target(
name: "myproject",
dependencies: ["Buildkite"]),
]
)
```
As an example, here is a way you can use the closure-based interface to list all pipelines:
```swift
import Buildkite
let client = Buildkite()
client.token = "..." // Your scoped Buildkite API access token
client.send(Pipeline.Resources.List(organization: "buildkite")) { result in
do {
let response = try result.get()
let pipelines = response.content
print(pipelines)
} catch {
print(error)
}
}
```
You can even use Combine, if you'd like!
```swift
import Buildkite
let client = Buildkite()
client.token = "..." // Your scoped Buildkite API access token
var cancellables: Set<AnyCancellable> = []
client.sendPublisher(Pipeline.Resources.List(organization: "buildkite"))
.map(\.content)
.sink(recieveCompletion: { _ in }) { pipelines in
print(pipelines)
}.store(in: &cancellables)
```
The entire publicly documented REST API surface is supported by this package.
## References
- [Buildkite](https://buildkite.com/)
- [Buildkite API Documentation](https://buildkite.com/docs/apis/rest-api)
## License
Buildkite for Swift is released under the BSD-2 license. [See LICENSE](https://github.com/aaronsky/buildkite-swift/blob/master/LICENSE) for details.

View File

@ -23,16 +23,13 @@ extension Pipeline.Resources {
public typealias Content = [Pipeline]
/// organization slug
public var organization: String
/// pipeline slug
public var pipeline: String
public var path: String {
"organizations/\(organization)/pipelines"
}
public init(organization: String, pipeline: String) {
public init(organization: String) {
self.organization = organization
self.pipeline = pipeline
}
}

View File

@ -65,7 +65,7 @@ class PipelinesTests: XCTestCase {
let expectation = XCTestExpectation()
context.client.send(Pipeline.Resources.List(organization: "buildkite", pipeline: "my-pipeline")) { result in
context.client.send(Pipeline.Resources.List(organization: "buildkite")) { result in
do {
let response = try result.get()
XCTAssertEqual(expected, response.content)