Created
October 10, 2011 16:05
-
-
Save greenisus/1275693 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (CKRequest *)actionRequest { | |
// TODO: self.id needs to be a string instead of an int | |
CKRequest *request = [CKRequest requestWithRemotePath:$S(@"/servers/%@/action", self.id)]; | |
NSLog(@"request url: %@", request.remoteURL); | |
request.method = CKRequestMethodPOST; | |
[request addHeaders:[NSDictionary dictionaryWithObject:[[RSAccount activeAccount] api_auth_token] forKey:@"X-Auth-Token"]]; | |
return request; | |
} | |
- (BOOL)reboot:(RSServerRebootType)rebootType result:(CKResult **)returnResult { | |
CKRequest *request = [self actionRequest]; | |
NSString *type = rebootType == RSServerRebootTypeSoft ? @"SOFT" : @"HARD"; | |
NSDictionary *dict = $D($D(type, @"type"), @"reboot"); | |
[request setBody:[NSJSONSerialization dataWithJSONObject:dict options:0 error:nil]]; | |
RSNSURLConnection *connection = [[RSNSURLConnection alloc] init]; | |
__autoreleasing CKResult *result = [connection sendSyncronously:request]; | |
returnResult = &result; | |
return [result isSuccess]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment