| 1 |
package calls |
| 2 |
|
| 3 |
import ( |
| 4 |
"time" |
| 5 |
|
| 6 |
"github.com/mesos/mesos-go/api/v1/lib" |
| 7 |
"github.com/mesos/mesos-go/api/v1/lib/maintenance" |
| 8 |
"github.com/mesos/mesos-go/api/v1/lib/master" |
| 9 |
"github.com/mesos/mesos-go/api/v1/lib/quota" |
| 10 |
) |
| 11 |
|
| 12 |
|
| 13 |
func GetHealth() *master.Call { |
| 14 |
return &master.Call{ |
| 15 |
Type: master.Call_GET_HEALTH, |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
|
| 20 |
func GetFlags() *master.Call { |
| 21 |
return &master.Call{ |
| 22 |
Type: master.Call_GET_FLAGS, |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
func GetVersion() *master.Call { |
| 28 |
return &master.Call{ |
| 29 |
Type: master.Call_GET_VERSION, |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
func GetMetrics(d *time.Duration) (call *master.Call) { |
| 37 |
call = &master.Call{ |
| 38 |
Type: master.Call_GET_METRICS, |
| 39 |
GetMetrics: &master.Call_GetMetrics{}, |
| 40 |
} |
| 41 |
if d != nil { |
| 42 |
call.GetMetrics.Timeout = &mesos.DurationInfo{ |
| 43 |
Nanoseconds: d.Nanoseconds(), |
| 44 |
} |
| 45 |
} |
| 46 |
return |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
func GetLoggingLevel() *master.Call { |
| 51 |
return &master.Call{ |
| 52 |
Type: master.Call_GET_LOGGING_LEVEL, |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
func SetLoggingLevel(level uint32, d time.Duration) *master.Call { |
| 60 |
return &master.Call{ |
| 61 |
Type: master.Call_SET_LOGGING_LEVEL, |
| 62 |
SetLoggingLevel: &master.Call_SetLoggingLevel{ |
| 63 |
Level: level, |
| 64 |
Duration: mesos.DurationInfo{ |
| 65 |
Nanoseconds: d.Nanoseconds(), |
| 66 |
}, |
| 67 |
}, |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
func ListFiles(path string) *master.Call { |
| 73 |
return &master.Call{ |
| 74 |
Type: master.Call_LIST_FILES, |
| 75 |
ListFiles: &master.Call_ListFiles{ |
| 76 |
Path: path, |
| 77 |
}, |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
func ReadFile(path string, offset uint64) *master.Call { |
| 84 |
return &master.Call{ |
| 85 |
Type: master.Call_READ_FILE, |
| 86 |
ReadFile: &master.Call_ReadFile{ |
| 87 |
Path: path, |
| 88 |
Offset: offset, |
| 89 |
}, |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
func ReadFileWithLength(path string, offset, length uint64) *master.Call { |
| 95 |
call := ReadFile(path, offset) |
| 96 |
call.ReadFile.Length = &length |
| 97 |
return call |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
func GetState() *master.Call { |
| 102 |
return &master.Call{ |
| 103 |
Type: master.Call_GET_STATE, |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
func GetAgents() *master.Call { |
| 109 |
return &master.Call{ |
| 110 |
Type: master.Call_GET_AGENTS, |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
|
| 115 |
func GetFrameworks() *master.Call { |
| 116 |
return &master.Call{ |
| 117 |
Type: master.Call_GET_FRAMEWORKS, |
| 118 |
} |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
func GetExecutors() *master.Call { |
| 123 |
return &master.Call{ |
| 124 |
Type: master.Call_GET_EXECUTORS, |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
func GetTasks() *master.Call { |
| 130 |
return &master.Call{ |
| 131 |
Type: master.Call_GET_TASKS, |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
func GetRoles() *master.Call { |
| 137 |
return &master.Call{ |
| 138 |
Type: master.Call_GET_ROLES, |
| 139 |
} |
| 140 |
} |
| 141 |
|
| 142 |
|
| 143 |
func GetWeights() *master.Call { |
| 144 |
return &master.Call{ |
| 145 |
Type: master.Call_GET_WEIGHTS, |
| 146 |
} |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
func UpdateWeights(weights ...mesos.WeightInfo) *master.Call { |
| 151 |
return &master.Call{ |
| 152 |
Type: master.Call_UPDATE_WEIGHTS, |
| 153 |
UpdateWeights: &master.Call_UpdateWeights{ |
| 154 |
WeightInfos: weights, |
| 155 |
}, |
| 156 |
} |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
func GetMaster() *master.Call { |
| 161 |
return &master.Call{ |
| 162 |
Type: master.Call_GET_MASTER, |
| 163 |
} |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
func Subscribe() *master.Call { |
| 172 |
return &master.Call{ |
| 173 |
Type: master.Call_SUBSCRIBE, |
| 174 |
} |
| 175 |
} |
| 176 |
|
| 177 |
|
| 178 |
func ReserveResources(a mesos.AgentID, r ...mesos.Resource) *master.Call { |
| 179 |
return &master.Call{ |
| 180 |
Type: master.Call_RESERVE_RESOURCES, |
| 181 |
ReserveResources: &master.Call_ReserveResources{ |
| 182 |
AgentID: a, |
| 183 |
Resources: r, |
| 184 |
}, |
| 185 |
} |
| 186 |
} |
| 187 |
|
| 188 |
|
| 189 |
func UnreserveResources(a mesos.AgentID, r ...mesos.Resource) *master.Call { |
| 190 |
return &master.Call{ |
| 191 |
Type: master.Call_UNRESERVE_RESOURCES, |
| 192 |
UnreserveResources: &master.Call_UnreserveResources{ |
| 193 |
AgentID: a, |
| 194 |
Resources: r, |
| 195 |
}, |
| 196 |
} |
| 197 |
} |
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
func CreateVolumes(a mesos.AgentID, v ...mesos.Resource) *master.Call { |
| 203 |
return &master.Call{ |
| 204 |
Type: master.Call_CREATE_VOLUMES, |
| 205 |
CreateVolumes: &master.Call_CreateVolumes{ |
| 206 |
AgentID: a, |
| 207 |
Volumes: v, |
| 208 |
}, |
| 209 |
} |
| 210 |
} |
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
func DestroyVolumes(a mesos.AgentID, v ...mesos.Resource) *master.Call { |
| 215 |
return &master.Call{ |
| 216 |
Type: master.Call_DESTROY_VOLUMES, |
| 217 |
DestroyVolumes: &master.Call_DestroyVolumes{ |
| 218 |
AgentID: a, |
| 219 |
Volumes: v, |
| 220 |
}, |
| 221 |
} |
| 222 |
} |
| 223 |
|
| 224 |
|
| 225 |
func GetMaintenanceStatus() *master.Call { |
| 226 |
return &master.Call{ |
| 227 |
Type: master.Call_GET_MAINTENANCE_STATUS, |
| 228 |
} |
| 229 |
} |
| 230 |
|
| 231 |
|
| 232 |
func GetMaintenanceSchedule() *master.Call { |
| 233 |
return &master.Call{ |
| 234 |
Type: master.Call_GET_MAINTENANCE_SCHEDULE, |
| 235 |
} |
| 236 |
} |
| 237 |
|
| 238 |
|
| 239 |
func UpdateMaintenanceSchedule(s maintenance.Schedule) *master.Call { |
| 240 |
return &master.Call{ |
| 241 |
Type: master.Call_UPDATE_MAINTENANCE_SCHEDULE, |
| 242 |
UpdateMaintenanceSchedule: &master.Call_UpdateMaintenanceSchedule{ |
| 243 |
Schedule: s, |
| 244 |
}, |
| 245 |
} |
| 246 |
} |
| 247 |
|
| 248 |
|
| 249 |
func StartMaintenance(m ...mesos.MachineID) *master.Call { |
| 250 |
return &master.Call{ |
| 251 |
Type: master.Call_START_MAINTENANCE, |
| 252 |
StartMaintenance: &master.Call_StartMaintenance{ |
| 253 |
Machines: m, |
| 254 |
}, |
| 255 |
} |
| 256 |
} |
| 257 |
|
| 258 |
|
| 259 |
func StopMaintenance(m ...mesos.MachineID) *master.Call { |
| 260 |
return &master.Call{ |
| 261 |
Type: master.Call_STOP_MAINTENANCE, |
| 262 |
StopMaintenance: &master.Call_StopMaintenance{ |
| 263 |
Machines: m, |
| 264 |
}, |
| 265 |
} |
| 266 |
} |
| 267 |
|
| 268 |
|
| 269 |
func GetQuota() *master.Call { |
| 270 |
return &master.Call{ |
| 271 |
Type: master.Call_GET_QUOTA, |
| 272 |
} |
| 273 |
} |
| 274 |
|
| 275 |
|
| 276 |
func SetQuota(qr quota.QuotaRequest) *master.Call { |
| 277 |
return &master.Call{ |
| 278 |
Type: master.Call_SET_QUOTA, |
| 279 |
SetQuota: &master.Call_SetQuota{ |
| 280 |
QuotaRequest: qr, |
| 281 |
}, |
| 282 |
} |
| 283 |
} |
| 284 |
|
| 285 |
|
| 286 |
func RemoveQuota(role string) *master.Call { |
| 287 |
return &master.Call{ |
| 288 |
Type: master.Call_REMOVE_QUOTA, |
| 289 |
RemoveQuota: &master.Call_RemoveQuota{ |
| 290 |
Role: role, |
| 291 |
}, |
| 292 |
} |
| 293 |
} |