Skip to content

Instantly share code, notes, and snippets.

@greenisus
greenisus / gist:1246318
Created September 27, 2011 21:36
view controller
//
// RSAccountsViewController.m
// Rackspace
//
// Created by Michael Mayo on 9/27/11.
// Copyright (c) 2011 Rackspace, US Inc. All rights reserved.
//
#import "RSAccountsViewController.h"
#import "RSAccount.h"
@greenisus
greenisus / gist:1246320
Created September 27, 2011 21:37
data source
//
// RSAccountsDataSource.m
// Rackspace
//
// Created by Michael Mayo on 9/27/11.
// Copyright (c) 2011 Rackspace, US Inc. All rights reserved.
//
#import "RSAccountsDataSource.h"
#import "RSAccount.h"
@greenisus
greenisus / gist:1248574
Created September 28, 2011 17:27
shorter data source
//
// RSAccountsDataSource.m
// Rackspace
//
// Created by Michael Mayo on 9/27/11.
// Copyright (c) 2011 Rackspace, US Inc. All rights reserved.
//
#import "RSAccountsDataSource.h"
#import "RSAccount.h"
@greenisus
greenisus / gist:1248581
Created September 28, 2011 17:30
short vc
//
// RSAccountsViewController.m
// Rackspace
//
// Created by Michael Mayo on 9/27/11.
// Copyright (c) 2011 Rackspace, US Inc. All rights reserved.
//
#import "RSAccountsViewController.h"
#import "RSAccountsDataSource.h"
@greenisus
greenisus / gist:1254563
Created September 30, 2011 18:19
saving an account
- (IBAction)loginButtonPressed:(id)sender {
// this is obviously temporary until we decide on UI for this :)
self.navigationItem.title = @"Authenticating...";
RSAccount *account = [RSAccount blank];
account.provider = self.provider;
account.username = self.usernameTextField.text;
account.api_key = self.apiKeyTextField.text;
@greenisus
greenisus / gist:1254603
Created September 30, 2011 18:37
nice and neat
- (IBAction)loginButtonPressed:(id)sender {
// this is obviously temporary until we decide on UI for this :)
self.navigationItem.title = @"Authenticating...";
RSAccount *account = [RSAccount blank];
account.provider = self.provider;
account.username = self.usernameTextField.text;
account.api_key = self.apiKeyTextField.text;
@greenisus
greenisus / gist:1254957
Created September 30, 2011 20:58
account vc
//
// RSAccountsViewController.m
// Rackspace
//
// Created by Michael Mayo on 9/27/11.
// Copyright (c) 2011 Rackspace, US Inc. All rights reserved.
//
#import "RSAccountsViewController.h"
#import "RSAccountsDataSource.h"
@greenisus
greenisus / gist:1254963
Created September 30, 2011 21:00
account data source
//
// RSAccountsDataSource.m
// Rackspace
//
// Created by Michael Mayo on 9/27/11.
// Copyright (c) 2011 Rackspace, US Inc. All rights reserved.
//
#import "RSAccountsDataSource.h"
#import "RSAccount.h"
- (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;
}
- (void)rebuildWithImage:(RSImage *)image success:(CKBasicBlock)successBlock failure:(void (^)(CKResult *result))failureBlock {
CKRequest *request = [self actionRequest];
[request setBodyWithJSONDict:$D($D(image.id, @"imageId"), @"rebuild")];
[self send:request success:successBlock failure:failureBlock];
}