Skip to content

Commit

Permalink
add stubs for remaining endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
displague committed Apr 26, 2018
1 parent d0e51de commit b3bf689
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 50 deletions.
1 change: 1 addition & 0 deletions account.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package golinode
81 changes: 51 additions & 30 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,23 @@ type Client struct {
resty *resty.Client
resources map[string]*Resource

Images *Resource
Disks *Resource
Configs *Resource
Backups *Resource
Instances *Resource
Regions *Resource
StackScripts *Resource
Volumes *Resource
Kernels *Resource
Types *Resource
Images *Resource
Disks *Resource
Configs *Resource
Backups *Resource
Instances *Resource
Regions *Resource
StackScripts *Resource
Volumes *Resource
Kernels *Resource
Types *Resource
Domains *Resource
Longview *Resource
NodeBalancers *Resource
Support *Resource
Account *Resource
Profile *Resource
Managed *Resource
}

// R wraps resty's R method
Expand Down Expand Up @@ -94,32 +101,46 @@ func NewClient(codeAPIKey *string, transport http.RoundTripper) (*Client, error)
SetHeader("User-Agent", fmt.Sprintf("go-linode %s https://github.com/chiefy/go-linode", Version))

resources := map[string]*Resource{
stackscriptsName: NewResource(stackscriptsName, stackscriptsEndpoint, false),
imagesName: NewResource(imagesName, imagesEndpoint, false),
instancesName: NewResource(instancesName, instancesEndpoint, false),
regionsName: NewResource(regionsName, regionsEndpoint, false),
disksName: NewResource(disksName, disksEndpoint, true),
configsName: NewResource(configsName, configsEndpoint, true),
backupsName: NewResource(backupsName, backupsEndpoint, true),
volumesName: NewResource(volumesName, volumesEndpoint, false),
kernelsName: NewResource(kernelsName, kernelsEndpoint, false),
typesName: NewResource(typesName, typesEndpoint, false),
stackscriptsName: NewResource(stackscriptsName, stackscriptsEndpoint, false),
imagesName: NewResource(imagesName, imagesEndpoint, false),
instancesName: NewResource(instancesName, instancesEndpoint, false),
regionsName: NewResource(regionsName, regionsEndpoint, false),
disksName: NewResource(disksName, disksEndpoint, true),
configsName: NewResource(configsName, configsEndpoint, true),
backupsName: NewResource(backupsName, backupsEndpoint, true),
volumesName: NewResource(volumesName, volumesEndpoint, false),
kernelsName: NewResource(kernelsName, kernelsEndpoint, false),
typesName: NewResource(typesName, typesEndpoint, false),
domainsName: NewResource(domainsName, domainsEndpoint, false),
longviewName: NewResource(longviewName, longviewEndpoint, false),
nodebalancersName: NewResource(nodebalancersName, nodebalancersEndpoint, false),
supportName: NewResource(supportName, supportEndpoint, false),
accountName: NewResource(accountName, accountEndpoint, false),
profileName: NewResource(profileName, profileEndpoint, false),
managedName: NewResource(managedName, managedEndpoint, false),
}

return &Client{
apiKey: linodeAPIKey,
resty: restyClient,
resources: resources,

Images: resources[imagesName],
StackScripts: resources[stackscriptsName],
Instances: resources[instancesName],
Regions: resources[regionsName],
Disks: resources[disksName],
Configs: resources[configsName],
Backups: resources[backupsName],
Volumes: resources[volumesName],
Kernels: resources[kernelsName],
Types: resources[typesName],
Images: resources[imagesName],
StackScripts: resources[stackscriptsName],
Instances: resources[instancesName],
Regions: resources[regionsName],
Disks: resources[disksName],
Configs: resources[configsName],
Backups: resources[backupsName],
Volumes: resources[volumesName],
Kernels: resources[kernelsName],
Types: resources[typesName],
Domains: resources[domainsName],
Longview: resources[longviewName],
NodeBalancers: resources[nodebalancersName],
Support: resources[supportName],
Account: resources[accountName],
Profile: resources[profileName],
Managed: resources[managedName],
}, nil
}
1 change: 1 addition & 0 deletions domains.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package golinode
1 change: 1 addition & 0 deletions longview.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package golinode
1 change: 1 addition & 0 deletions managed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package golinode
1 change: 1 addition & 0 deletions nodebalancer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package golinode
1 change: 1 addition & 0 deletions profile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package golinode
54 changes: 34 additions & 20 deletions resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,41 @@ import (
)

const (
stackscriptsName = "stackscripts"
imagesName = "images"
instancesName = "instances"
regionsName = "regions"
disksName = "disks"
configsName = "configs"
backupsName = "backups"
volumesName = "volumes"
kernelsName = "kernels"
typesName = "types"
stackscriptsName = "stackscripts"
imagesName = "images"
instancesName = "instances"
regionsName = "regions"
disksName = "disks"
configsName = "configs"
backupsName = "backups"
volumesName = "volumes"
kernelsName = "kernels"
typesName = "types"
domainsName = "domains"
longviewName = "longview"
nodebalancersName = "nodebalancers"
supportName = "support"
accountName = "account"
profileName = "profile"
managedName = "managed"

stackscriptsEndpoint = "linode/stackscripts"
imagesEndpoint = "images"
instancesEndpoint = "linode/instances"
regionsEndpoint = "regions"
configsEndpoint = "linode/instances/{{ .ID }}/configs"
disksEndpoint = "linode/instances/{{ .ID }}/disks"
backupsEndpoint = "linode/instances/{{ .ID }}/backups"
volumesEndpoint = "volumes"
kernelsEndpoint = "linode/kernels"
typesEndpoint = "linode/types"
stackscriptsEndpoint = "linode/stackscripts"
imagesEndpoint = "images"
instancesEndpoint = "linode/instances"
regionsEndpoint = "regions"
configsEndpoint = "linode/instances/{{ .ID }}/configs"
disksEndpoint = "linode/instances/{{ .ID }}/disks"
backupsEndpoint = "linode/instances/{{ .ID }}/backups"
volumesEndpoint = "volumes"
kernelsEndpoint = "linode/kernels"
typesEndpoint = "linode/types"
domainsEndpoint = "domains"
longviewEndpoint = "longview"
nodebalancersEndpoint = "nodebalancer"
supportEndpoint = "support"
accountEndpoint = "account"
profileEndpoint = "profile"
managedEndpoint = "managed"
)

// Resource represents a linode API resource
Expand Down
1 change: 1 addition & 0 deletions support.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package golinode

0 comments on commit b3bf689

Please sign in to comment.