~andychilton/goamz/aws-fix-for-r60

« back to all changes in this revision

Viewing changes to ec2.go

  • Committer: Gustavo Niemeyer
  • Date: 2011-02-01 12:45:59 UTC
  • Revision ID: gustavo@niemeyer.net-20110201124559-mkuol9axpel46fhi
Expanding names again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
153
153
    MinCount              int
154
154
    MaxCount              int
155
155
    InstanceType          string
156
 
    SecGroups             []string
 
156
    SecurityGroups        []string
157
157
    KernelId              string
158
158
    RamdiskId             string
159
159
    UserData              []byte
170
170
//
171
171
// See http://goo.gl/Mcm3b for more details.
172
172
type EC2RunInstancesResp struct {
173
 
    RequestId     string
174
 
    ReservationId string
175
 
    OwnerId       string
176
 
    SecGroups     []string      "GroupSet>Item>GroupId"
177
 
    Instances     []EC2Instance "InstancesSet>Item"
 
173
    RequestId      string
 
174
    ReservationId  string
 
175
    OwnerId        string
 
176
    SecurityGroups []string      "GroupSet>Item>GroupId"
 
177
    Instances      []EC2Instance "InstancesSet>Item"
178
178
}
179
179
 
180
180
// EC2Instance encapsulates a running instance in EC2.
215
215
    }
216
216
    params["MinCount"] = strconv.Itoa(min)
217
217
    params["MaxCount"] = strconv.Itoa(max)
218
 
    for i, name := range options.SecGroups {
 
218
    for i, name := range options.SecurityGroups {
219
219
        params["SecurityGroup."+strconv.Itoa(i+1)] = name
220
220
    }
221
221
    params["ClientToken"] = strconv.Itoa64(time.Nanoseconds()) // XXX Fix this.
313
313
//
314
314
// See http://goo.gl/0ItPT for more details.
315
315
type EC2Reservation struct {
316
 
    ReservationId string
317
 
    OwnerId       string
318
 
    RequesterId   string
319
 
    SecGroups     []string      "GroupSet>Item>GroupId"
320
 
    Instances     []EC2Instance "InstancesSet>Item"
 
316
    ReservationId  string
 
317
    OwnerId        string
 
318
    RequesterId    string
 
319
    SecurityGroups []string      "GroupSet>Item>GroupId"
 
320
    Instances      []EC2Instance "InstancesSet>Item"
321
321
}
322
322
 
323
323
// Instances returns details about instances in EC2.  Both parameters
349
349
    RequestId string
350
350
}
351
351
 
352
 
// CreateSecGroup run a CreateSecurityGroup request in EC2, with the provided
 
352
// CreateSecurityGroup run a CreateSecurityGroup request in EC2, with the provided
353
353
// name and description.
354
354
//
355
355
// See http://goo.gl/Eo7Yl for more details.
356
 
func (ec2 *EC2) CreateSecGroup(name, description string) (resp *EC2SimpleResp, err os.Error) {
 
356
func (ec2 *EC2) CreateSecurityGroup(name, description string) (resp *EC2SimpleResp, err os.Error) {
357
357
    params := makeParams("CreateSecurityGroup")
358
358
    params["GroupName"] = name
359
359
    params["GroupDescription"] = description
366
366
    return resp, nil
367
367
}
368
368
 
369
 
// EC2SecGroupsResp represents a response to a DescribeSecurityGroups
 
369
// EC2SecurityGroupsResp represents a response to a DescribeSecurityGroups
370
370
// request in EC2.
371
371
//
372
372
// See http://goo.gl/k12Uy for more details.
373
 
type EC2SecGroupsResp struct {
374
 
    RequestId string
375
 
    SecGroups []EC2SecGroup "SecurityGroupInfo>Item"
 
373
type EC2SecurityGroupsResp struct {
 
374
    RequestId      string
 
375
    SecurityGroups []EC2SecurityGroup "SecurityGroupInfo>Item"
376
376
}
377
377
 
378
 
// EC2SecGroup encapsulates details for a security group in EC2. 
 
378
// EC2SecurityGroup encapsulates details for a security group in EC2. 
379
379
//
380
380
// See http://goo.gl/CIdyP for more details.
381
 
type EC2SecGroup struct {
 
381
type EC2SecurityGroup struct {
382
382
    OwnerId    string
383
383
    GroupName  string      "GroupName>"
384
384
    GroupDescr string      "GroupDescription>"
392
392
    Protocol     string "IPProtocol>"
393
393
    FromPort     int
394
394
    ToPort       int
395
 
    SourceIPs    []string        "IPRanges>Item>CIDRIP"
396
 
    SourceGroups []EC2SecGroupId "Groups>Item"
 
395
    SourceIPs    []string             "IPRanges>Item>CIDRIP"
 
396
    SourceGroups []EC2SecurityGroupId "Groups>Item"
397
397
}
398
398
 
399
 
// EC2SecGroupId is a globally unique identification for an EC2 security group.
400
 
type EC2SecGroupId struct {
 
399
// EC2SecurityGroupId is a globally unique identification for an EC2 security group.
 
400
type EC2SecurityGroupId struct {
401
401
    OwnerId   string "UserId>"
402
402
    GroupName string
403
403
}
404
404
 
405
 
// SecGroups returns details about security groups in EC2.  Both parameters
 
405
// SecurityGroups returns details about security groups in EC2.  Both parameters
406
406
// are optional, and if provied will limit the security groups returned to those
407
407
// matching the given names or filtering rules.
408
408
//
409
409
// See http://goo.gl/k12Uy for more details.
410
 
func (ec2 *EC2) SecGroups(names []string, filter *Filter) (resp *EC2SecGroupsResp, err os.Error) {
 
410
func (ec2 *EC2) SecurityGroups(names []string, filter *Filter) (resp *EC2SecurityGroupsResp, err os.Error) {
411
411
    params := makeParams("DescribeSecurityGroups")
412
412
    for i, name := range names {
413
413
        params["GroupName."+strconv.Itoa(i+1)] = name
414
414
    }
415
415
    filter.addParams(params)
416
416
 
417
 
    resp = &EC2SecGroupsResp{}
 
417
    resp = &EC2SecurityGroupsResp{}
418
418
    err = ec2.query(params, resp)
419
419
    if err != nil {
420
420
        return nil, err
422
422
    return resp, nil
423
423
}
424
424
 
425
 
// DelSecGroup removes the security group with the provided name in EC2.
 
425
// DeleteSecurityGroup removes the security group with the provided name in EC2.
426
426
//
427
427
// See http://goo.gl/QJJDO for more details.
428
 
func (ec2 *EC2) DelSecGroup(name string) (resp *EC2SimpleResp, err os.Error) {
 
428
func (ec2 *EC2) DeleteSecurityGroup(name string) (resp *EC2SimpleResp, err os.Error) {
429
429
    params := makeParams("DeleteSecurityGroup")
430
430
    params["GroupName"] = name
431
431
 
437
437
    return resp, nil
438
438
}
439
439
 
440
 
// AuthorizeSecGroup creates an allowance for clients matching the provided
 
440
// AuthorizeSecurityGroup creates an allowance for clients matching the provided
441
441
// rules to access instances within the named security group.
442
442
//
443
443
// See http://goo.gl/u2sDJ for more details.
444
 
func (ec2 *EC2) AuthorizeSecGroup(groupName string, perms []EC2IPPerm) (resp *EC2SimpleResp, err os.Error) {
 
444
func (ec2 *EC2) AuthorizeSecurityGroup(groupName string, perms []EC2IPPerm) (resp *EC2SimpleResp, err os.Error) {
445
445
    params := makeParams("AuthorizeSecurityGroupIngress")
446
446
    params["GroupName"] = groupName
447
447