/
DirectoryBinding.swift
87 lines (64 loc) · 2.38 KB
/
DirectoryBinding.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
// DirectoryBinding.swift
// JamfKit
//
// Copyright © 2017-present JamfKit. All rights reserved.
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
//
/// Represents a logical binding between a computer and an active directory user.
@objc(JMFKDirectoryBinding)
public final class DirectoryBinding: BaseObject, Endpoint {
// MARK: - Constants
public static let Endpoint: String = "directorybindings"
static let PriorityKey = "priority"
static let DomainKey = "domain"
static let UsernameKey = "username"
static let PasswordKey = "password"
static let ComputerOrganisationalUnitKey = "computer_ou"
static let TypeKey = "type"
// MARK: - Properties
@objc
public var priority: UInt = 0
@objc
public var domain = ""
@objc
public var username = ""
@objc
public var password = ""
@objc
public var computerOrganisationalUnit = ""
@objc
public var type = ""
// MARK: - Initialization
public required init?(json: [String: Any], node: String = "") {
priority = json[DirectoryBinding.PriorityKey] as? UInt ?? 0
domain = json[DirectoryBinding.DomainKey] as? String ?? ""
username = json[DirectoryBinding.UsernameKey] as? String ?? ""
password = json[DirectoryBinding.PasswordKey] as? String ?? ""
computerOrganisationalUnit = json[DirectoryBinding.ComputerOrganisationalUnitKey] as? String ?? ""
type = json[DirectoryBinding.TypeKey] as? String ?? ""
super.init(json: json)
}
public override init?(identifier: UInt, name: String) {
super.init(identifier: identifier, name: name)
}
// MARK: - Functions
public override func toJSON() -> [String: Any] {
var json = super.toJSON()
json[DirectoryBinding.PriorityKey] = priority
json[DirectoryBinding.DomainKey] = domain
json[DirectoryBinding.UsernameKey] = username
json[DirectoryBinding.PasswordKey] = password
json[DirectoryBinding.ComputerOrganisationalUnitKey] = computerOrganisationalUnit
json[DirectoryBinding.TypeKey] = type
return json
}
}
// MARK: - Creatable
extension DirectoryBinding: Creatable {
public func create() -> URLRequest? {
return self.createRequest()
}
}
// MARK: - Protocols
extension DirectoryBinding: Readable, Updatable, Deletable { }