Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing API calls: manage hosted repositories, get integrations #48

Merged
merged 16 commits into from
Jun 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ We're providing a Plaground in which you can easily interact with `XcodeServerSD
| Delete a bot | :no_entry: | :white_check_mark: |
| _Get bot's most recent integrations_ | :white_check_mark: | :white_check_mark: |
| _Enqueue a new integration_ | :white_check_mark: | :white_check_mark: |
| _List integrations on server_ | :white_check_mark: | :no_entry: |
| _Retrieve an integration by ID_ | :white_check_mark: | :no_entry: |
| _List integrations on server_ | :white_check_mark: | :white_check_mark: |
| _Retrieve an integration by ID_ | :white_check_mark: | :white_check_mark: |
| Cancel integration | :no_entry: | :white_check_mark: |
| _List the commits included in an integration_ | :white_check_mark: | :no_entry: |
| _List the build issues produced by an integration_ | :white_check_mark: | :no_entry: |
| _List devices connected to server_ | :white_check_mark: | :white_check_mark: |
| _List hosted repositories on server_ | :white_check_mark: | :no_entry: |
| _Create a new hosted repository_ | :white_check_mark: | :no_entry: |
| _List hosted repositories on server_ | :white_check_mark: | :white_check_mark: |
| _Create a new hosted repository_ | :white_check_mark: | :white_check_mark: |
| Get supported platforms | :no_entry: | :white_check_mark: |
| Get SCM branches from Blueprint | :no_entry: | :white_check_mark: |
| Verify user can manage server | :no_entry: | :white_check_mark: |
Expand Down
13 changes: 13 additions & 0 deletions XcodeServerSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@
3AA922BA1B3F4666005A0F73 /* DVR.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AA922AC1B3F4630005A0F73 /* DVR.framework */; };
3ABE68661B3AC3C500FA0A61 /* DeviceSpecification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3ABE68651B3AC3C500FA0A61 /* DeviceSpecification.swift */; };
3ABE68671B3AC3C500FA0A61 /* DeviceSpecification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3ABE68651B3AC3C500FA0A61 /* DeviceSpecification.swift */; };
7045917F1B4074CC00BA226C /* Repository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7045917E1B4074CC00BA226C /* Repository.swift */; };
704591861B40945700BA226C /* RepositoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 704591851B40945700BA226C /* RepositoryTests.swift */; };
705D59A11B3AE502002521BA /* HTTPUtilsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 705D59A01B3AE502002521BA /* HTTPUtilsTests.swift */; };
707D08961B2C684C003900F3 /* XcodeServerConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 707D08951B2C684C003900F3 /* XcodeServerConfig.swift */; };
707D08981B2C6954003900F3 /* EmailConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 707D08971B2C6954003900F3 /* EmailConfiguration.swift */; };
Expand All @@ -115,6 +117,8 @@
709ED67C1B35FD3F00A06038 /* XcodeServerEntityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 709ED67B1B35FD3F00A06038 /* XcodeServerEntityTests.swift */; };
709ED6801B3608FC00A06038 /* XcodeServerConfigTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 709ED67F1B3608FC00A06038 /* XcodeServerConfigTests.swift */; };
70B21FF81B3AFB1D00EAD4EB /* BotConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70B21FF71B3AFB1D00EAD4EB /* BotConfigurationTests.swift */; };
70E1413A1B409EA000AC98DB /* Repository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7045917E1B4074CC00BA226C /* Repository.swift */; };
70E1413B1B409EA100AC98DB /* Repository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7045917E1B4074CC00BA226C /* Repository.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -226,6 +230,8 @@
3AA9223D1B3F0E2C005A0F73 /* scm_branches_response_error.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = scm_branches_response_error.json; path = Data/scm_branches_response_error.json; sourceTree = "<group>"; };
3AA922A31B3F4630005A0F73 /* DVR.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = DVR.xcodeproj; path = Carthage/Checkouts/DVR/DVR.xcodeproj; sourceTree = "<group>"; };
3ABE68651B3AC3C500FA0A61 /* DeviceSpecification.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeviceSpecification.swift; sourceTree = "<group>"; };
7045917E1B4074CC00BA226C /* Repository.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Repository.swift; sourceTree = "<group>"; };
704591851B40945700BA226C /* RepositoryTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepositoryTests.swift; sourceTree = "<group>"; };
705D59A01B3AE502002521BA /* HTTPUtilsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTTPUtilsTests.swift; sourceTree = "<group>"; };
707D08951B2C684C003900F3 /* XcodeServerConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XcodeServerConfig.swift; sourceTree = "<group>"; };
707D08971B2C6954003900F3 /* EmailConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmailConfiguration.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -366,6 +372,7 @@
3A058A921B315BB50077FD47 /* TestUtils.swift */,
705D59A01B3AE502002521BA /* HTTPUtilsTests.swift */,
70B21FF71B3AFB1D00EAD4EB /* BotConfigurationTests.swift */,
704591851B40945700BA226C /* RepositoryTests.swift */,
3A7B48CA1B2A5AC40077ABEA /* Supporting Files */,
);
path = XcodeServerSDKTests;
Expand Down Expand Up @@ -421,6 +428,7 @@
3A7B48DB1B2A5ADE0077ABEA /* SourceControlBlueprint.swift */,
707D089B1B2C69C4003900F3 /* Trigger.swift */,
707D089D1B2C6A1F003900F3 /* TriggerConditions.swift */,
7045917E1B4074CC00BA226C /* Repository.swift */,
);
path = "Server Entities";
sourceTree = "<group>";
Expand Down Expand Up @@ -741,6 +749,7 @@
11376BE71B3A2FEB0005A681 /* Errors.swift in Sources */,
11376BE81B3A2FEB0005A681 /* Server.swift in Sources */,
11376BE91B3A2FEB0005A681 /* XcodeServerConstants.swift in Sources */,
70E1413A1B409EA000AC98DB /* Repository.swift in Sources */,
11376BE01B3A2FE30005A681 /* BotSchedule.swift in Sources */,
11376BE11B3A2FE30005A681 /* Trigger.swift in Sources */,
11376BE21B3A2FE30005A681 /* TriggerConditions.swift in Sources */,
Expand Down Expand Up @@ -771,6 +780,7 @@
11FB71A81B34AF2400D57A52 /* BotConfiguration.swift in Sources */,
11FB71A91B34AF2400D57A52 /* EmailConfiguration.swift in Sources */,
11FB71AA1B34AF2400D57A52 /* BotSchedule.swift in Sources */,
70E1413B1B409EA100AC98DB /* Repository.swift in Sources */,
3ABE68671B3AC3C500FA0A61 /* DeviceSpecification.swift in Sources */,
11FB71AB1B34AF2400D57A52 /* Trigger.swift in Sources */,
11FB71AC1B34AF2400D57A52 /* TriggerConditions.swift in Sources */,
Expand All @@ -793,6 +803,7 @@
11FB71B81B34B00000D57A52 /* XcodeServerTests.swift in Sources */,
3A06D5FF1B3C184D00F0A6C5 /* HTTPUtilsTests.swift in Sources */,
3A06D5FD1B3C184400F0A6C5 /* XcodeServerEntityTests.swift in Sources */,
704591871B40945E00BA226C /* RepositoryTests.swift in Sources */,
11FB71B91B34B00000D57A52 /* BotParsingTests.swift in Sources */,
11FB71BA1B34B00000D57A52 /* TestUtils.swift in Sources */,
3A06D5FE1B3C184700F0A6C5 /* XcodeServerConfigTests.swift in Sources */,
Expand All @@ -815,6 +826,7 @@
707D089C1B2C69C4003900F3 /* Trigger.swift in Sources */,
3A7B48E21B2A5ADE0077ABEA /* BotConfiguration.swift in Sources */,
3A7B48EA1B2A5ADE0077ABEA /* XcodeServerEntity.swift in Sources */,
7045917F1B4074CC00BA226C /* Repository.swift in Sources */,
3ABE68661B3AC3C500FA0A61 /* DeviceSpecification.swift in Sources */,
707D08961B2C684C003900F3 /* XcodeServerConfig.swift in Sources */,
3A7B48EB1B2A5ADE0077ABEA /* XcodeServerFactory.swift in Sources */,
Expand All @@ -837,6 +849,7 @@
3A058A8E1B31595A0077FD47 /* BotParsingTests.swift in Sources */,
705D59A11B3AE502002521BA /* HTTPUtilsTests.swift in Sources */,
709ED67C1B35FD3F00A06038 /* XcodeServerEntityTests.swift in Sources */,
704591861B40945700BA226C /* RepositoryTests.swift in Sources */,
3A058A931B315BB50077FD47 /* TestUtils.swift in Sources */,
3A7B48CD1B2A5AC40077ABEA /* XcodeServerTests.swift in Sources */,
709ED6801B3608FC00A06038 /* XcodeServerConfigTests.swift in Sources */,
Expand Down
150 changes: 150 additions & 0 deletions XcodeServerSDK/Server Entities/Repository.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
//
// Repository.swift
// XcodeServerSDK
//
// Created by Mateusz Zając on 28.06.2015.
// Copyright © 2015 Honza Dvorsky. All rights reserved.
//

import Foundation

public class Repository: XcodeRead {

/**
Enumeration describing HTTP access to the repository

- None: No users are not allowed to read or write
- LoggedIn: Logged in users are allowed to read and write
*/
public enum HTTPAccessType: Int {

case None = 0
case LoggedIn

public func toString() -> String {
switch self {
case .None:
return "No users are not allowed to read or write"
case .LoggedIn:
return "Logged in users are allowed to read and write"
}
}

}

/**
Enumeration describing HTTPS access to the repository

- SelectedReadWrite: Only selected users can read and/or write
- LoggedInReadSelectedWrite: Only selected users can write but all logged in can read
- LoggedInReadWrite: All logged in users can read and write
*/
public enum SSHAccessType: Int {

case SelectedReadWrite = 0
case LoggedInReadSelectedWrite
case LoggedInReadWrite

public func toString() -> String {
switch self {
case .SelectedReadWrite:
return "Only selected users can read and/or write"
case .LoggedInReadSelectedWrite:
return "Only selected users can write but all logged in can read"
case .LoggedInReadWrite:
return "All logged in users can read and write"
}
}

}

public let name: String
public var httpAccess: HTTPAccessType = HTTPAccessType.None
// XCS's defualt if SelectedReadWrite but if you don't provide
// array of IDs, nobody will have access to the repository
public var sshAccess: SSHAccessType = SSHAccessType.LoggedInReadWrite
public var writeAccessExternalIds: [String] = []
public var readAccessExternalIds: [String] = []

/**
Designated initializer.

- parameter name: Name of the repository.
- parameter httpsAccess: HTTPS access type for the users.
- parameter sshAccess: SSH access type for the users.
- parameter writeAccessExternalIds: ID of users allowed to write to the repository.
- parameter readAccessExternalIds: ID of users allowed to read from the repository.

- returns: Initialized repository struct.
*/
public init(name: String, httpAccess: HTTPAccessType?, sshAccess: SSHAccessType?, writeAccessExternalIds: [String]?, readAccessExternalIds: [String]?) {
self.name = name

if let httpAccess = httpAccess {
self.httpAccess = httpAccess
}

if let sshAccess = sshAccess {
self.sshAccess = sshAccess
}

if let writeIDs = writeAccessExternalIds {
self.writeAccessExternalIds = writeIDs
}

if let readIDs = readAccessExternalIds {
self.readAccessExternalIds = readIDs
}
}

/**
Convenience initializer.
This initializer will only allow you to provie name and will create a
deault repository with values set to:
- **HTTP Access** - No user is allowed to read/write to repository
- **SSH Access** - Only selected users are allowed to read/write to repository
- **Empty arrays** of write and rad external IDs

- parameter name: Name of the repository.

- returns: Initialized default repository wwith provided name
*/
public convenience init(name: String) {
self.init(name: name, httpAccess: nil, sshAccess: nil, writeAccessExternalIds: nil, readAccessExternalIds: nil)
}

/**
Repository constructor from JSON object.

- parameter json: JSON dictionary representing repository.

- returns: Initialized repository struct.
*/
public required init(json: NSDictionary) {
self.name = json.stringForKey("name")

self.httpAccess = HTTPAccessType(rawValue: json.intForKey("httpAccessType"))!
self.sshAccess = SSHAccessType(rawValue: json.intForKey("posixPermissions"))!

self.writeAccessExternalIds = json.arrayForKey("writeAccessExternalIDs")
self.readAccessExternalIds = json.arrayForKey("readAccessExternalIDs")
}

/**
Method for returning object in form of Dictionary.

- returns: Dictionary representing JSON value of Repository object.
*/
public func dictionarify() -> NSMutableDictionary {
let dict = NSMutableDictionary()

dict["name"] = self.name
dict["httpAccessType"] = self.httpAccess.rawValue
dict["posixPermissions"] = self.sshAccess.rawValue
dict["writeAccessExternalIDs"] = self.writeAccessExternalIds
dict["readAccessExternalIDs"] = self.readAccessExternalIds

return dict
}

}
Loading