Skip to content

Commit 91c1061

Browse files
committed
100% api implemented + random stuff
1 parent 7e60a17 commit 91c1061

File tree

3 files changed

+116
-103
lines changed

3 files changed

+116
-103
lines changed

Source/Client.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,15 @@ public class Client {
149149
/// :return: JSON Object in the block in the form:
150150
/// { "items": [ {"name": "contacts", "createdAt": "2013-01-18T15:33:13.556Z"},
151151
/// {"name": "notes", "createdAt": "2013-01-18T15:33:13.556Z"}]}
152-
public func listIndexes(block: CompletionHandlerType? = nil) {
152+
public func listIndexes(block: CompletionHandler? = nil) {
153153
performHTTPQuery("1/indexes", method: .GET, body: nil, block: block)
154154
}
155155

156156
/// Move an existing index.
157157
///
158158
/// :param: srcIndexName the name of index to move.
159159
/// :param: dstIndexName the new index name that will contains sourceIndexName (destination will be overriten if it already exist).
160-
public func moveIndex(srcIndexName: String, dstIndexName: String, block: CompletionHandlerType? = nil) {
160+
public func moveIndex(srcIndexName: String, dstIndexName: String, block: CompletionHandler? = nil) {
161161
let path = "1/indexes/\(srcIndexName.urlEncode())/operation"
162162
let request = [
163163
"destination": dstIndexName,
@@ -171,7 +171,7 @@ public class Client {
171171
///
172172
/// :param: srcIndexName the name of index to copy.
173173
/// :param: dstIndexName the new index name that will contains a copy of sourceIndexName (destination will be overriten if it already exist).
174-
public func copyIndex(srcIndexName: String, dstIndexName: String, block: CompletionHandlerType? = nil) {
174+
public func copyIndex(srcIndexName: String, dstIndexName: String, block: CompletionHandler? = nil) {
175175
let path = "1/indexes/\(srcIndexName.urlEncode())/operation"
176176
let request = [
177177
"destination": dstIndexName,
@@ -185,21 +185,21 @@ public class Client {
185185
///
186186
/// :param: indexName the name of index to delete
187187
/// :return: JSON Object in the block in the form: { "deletedAt": "2013-01-18T15:33:13.556Z", "taskID": 721 }
188-
public func deleteIndex(indexName: String, block: CompletionHandlerType? = nil) {
188+
public func deleteIndex(indexName: String, block: CompletionHandler? = nil) {
189189
let path = "1/indexes/\(indexName.urlEncode())"
190190
performHTTPQuery(path, method: .DELETE, body: nil, block: block)
191191
}
192192

193193
/// Return 10 last log entries.
194-
public func getLogs(block: CompletionHandlerType) {
194+
public func getLogs(block: CompletionHandler) {
195195
performHTTPQuery("1/logs", method: .GET, body: nil, block: block)
196196
}
197197

198198
/// Return last logs entries.
199199
///
200200
/// :param: offset Specify the first entry to retrieve (0-based, 0 is the most recent log entry).
201201
/// :param: length Specify the maximum number of entries to retrieve starting at offset. Maximum allowed value: 1000.
202-
public func getLogsWithOffset(offset: UInt, lenght: UInt, block: CompletionHandlerType) {
202+
public func getLogsWithOffset(offset: UInt, lenght: UInt, block: CompletionHandler) {
203203
let path = "1/logs?offset=\(offset)&lenght=\(lenght)"
204204
performHTTPQuery(path, method: .GET, body: nil, block: block)
205205
}
@@ -208,34 +208,34 @@ public class Client {
208208
///
209209
/// :param: offset Specify the first entry to retrieve (0-based, 0 is the most recent log entry).
210210
/// :param: length Specify the maximum number of entries to retrieve starting at offset. Maximum allowed value: 1000.
211-
public func getLogsWithType(type: String, offset: UInt, lenght: UInt, block: CompletionHandlerType) {
211+
public func getLogsWithType(type: String, offset: UInt, lenght: UInt, block: CompletionHandler) {
212212
let path = "1/logs?offset=\(offset)&lenght=\(lenght)&type=\(type)"
213213
performHTTPQuery(path, method: .GET, body: nil, block: block)
214214
}
215215

216216
/// List all existing user keys with their associated ACLs
217-
public func listUserKeys(block: CompletionHandlerType) {
217+
public func listUserKeys(block: CompletionHandler) {
218218
performHTTPQuery("1/keys", method: .GET, body: nil, block: block)
219219
}
220220

221221
/// Get ACL of a user key
222-
public func getUserKeyACL(key: String, block: CompletionHandlerType) {
222+
public func getUserKeyACL(key: String, block: CompletionHandler) {
223223
let path = "1/keys/\(key)"
224224
performHTTPQuery(path, method: .GET, body: nil, block: block)
225225
}
226226

227227
/// Delete an existing user key
228-
public func deleteUserKey(key: String, block: CompletionHandlerType? = nil) {
228+
public func deleteUserKey(key: String, block: CompletionHandler? = nil) {
229229
let path = "1/keys/\(key)"
230230
performHTTPQuery(path, method: .DELETE, body: nil, block: block)
231231
}
232232

233-
public func addUserKey(acls: [String], block: CompletionHandlerType? = nil) {
233+
public func addUserKey(acls: [String], block: CompletionHandler? = nil) {
234234
let request = ["acl": acls]
235235
performHTTPQuery("1/keys", method: .POST, body: request, block: block)
236236
}
237237

238-
public func addUserKey(acls: [String], withValidity validity: UInt, maxQueriesPerIPPerHour maxQueries: UInt, maxHitsPerQuery maxHits: UInt, block: CompletionHandlerType? = nil) {
238+
public func addUserKey(acls: [String], withValidity validity: UInt, maxQueriesPerIPPerHour maxQueries: UInt, maxHitsPerQuery maxHits: UInt, block: CompletionHandler? = nil) {
239239
let request: [String: AnyObject] = [
240240
"acl": acls,
241241
"validity": validity,
@@ -246,7 +246,7 @@ public class Client {
246246
performHTTPQuery("1/keys", method: .POST, body: request, block: block)
247247
}
248248

249-
public func addUserKey(acls: [String], withIndexes indexes: [String], withValidity validity: UInt, maxQueriesPerIPPerHour maxQueries: UInt, maxHitsPerQuery maxHits: UInt, block: CompletionHandlerType? = nil) {
249+
public func addUserKey(acls: [String], withIndexes indexes: [String], withValidity validity: UInt, maxQueriesPerIPPerHour maxQueries: UInt, maxHitsPerQuery maxHits: UInt, block: CompletionHandler? = nil) {
250250
let request: [String: AnyObject] = [
251251
"acl": acls,
252252
"indexes": indexes,
@@ -258,13 +258,13 @@ public class Client {
258258
performHTTPQuery("1/keys", method: .POST, body: request, block: block)
259259
}
260260

261-
public func updateUserKey(key: String, withACL acls: [String], block: CompletionHandlerType? = nil) {
261+
public func updateUserKey(key: String, withACL acls: [String], block: CompletionHandler? = nil) {
262262
let path = "1/keys/\(key)"
263263
let request = ["acl": acls]
264264
performHTTPQuery(path, method: .PUT, body: request, block: block)
265265
}
266266

267-
public func updateUserKey(key: String, withACL acls: [String], andValidity validity: UInt, maxQueriesPerIPPerHour maxQueries: UInt, maxHitsPerQuery maxHits: UInt, block: CompletionHandlerType? = nil) {
267+
public func updateUserKey(key: String, withACL acls: [String], andValidity validity: UInt, maxQueriesPerIPPerHour maxQueries: UInt, maxHitsPerQuery maxHits: UInt, block: CompletionHandler? = nil) {
268268
let path = "1/keys/\(key)"
269269
let request: [String: AnyObject] = [
270270
"acl": acls,
@@ -276,7 +276,7 @@ public class Client {
276276
performHTTPQuery(path, method: .PUT, body: request, block: block)
277277
}
278278

279-
public func updateUserKey(key: String, withACL acls: [String], withIndexes indexes: [String], andValidity validity: UInt, maxQueriesPerIPPerHour maxQueries: UInt, maxHitsPerQuery maxHits: UInt, block: CompletionHandlerType? = nil) {
279+
public func updateUserKey(key: String, withACL acls: [String], withIndexes indexes: [String], andValidity validity: UInt, maxQueriesPerIPPerHour maxQueries: UInt, maxHitsPerQuery maxHits: UInt, block: CompletionHandler? = nil) {
280280
let path = "1/keys/\(key)"
281281
let request: [String: AnyObject] = [
282282
"acl": acls,
@@ -299,7 +299,7 @@ public class Client {
299299
/// Query multiple indexes with one API call
300300
///
301301
/// :param: queries An array of queries with the associated index (Array of Dictionnary object ["indexName": "targettedIndex", "query": "theASQuery"]).
302-
public func multipleQueries(queries: [AnyObject], block: CompletionHandlerType?) {
302+
public func multipleQueries(queries: [AnyObject], block: CompletionHandler?) {
303303
let path = "1/indexes/*/queries"
304304

305305
var convertedQueries = [AnyObject]()
@@ -320,7 +320,7 @@ public class Client {
320320
// MARK: - Network
321321

322322
/// Perform an HTTP Query
323-
func performHTTPQuery(path: String, method: Alamofire.Method, body: [String: AnyObject]?, index: Int = 0, block: CompletionHandlerType? = nil) {
323+
func performHTTPQuery(path: String, method: Alamofire.Method, body: [String: AnyObject]?, index: Int = 0, block: CompletionHandler? = nil) {
324324
assert(index < hostnames.count, "\(index) < \(hostnames.count) !")
325325

326326
let request = Alamofire.request(method, "https://\(hostnames[index])/\(path)", parameters: body).responseJSON {

0 commit comments

Comments
 (0)