Skip to content

Commit

Permalink
List*: use slice of thing, not slice of pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
displague committed Sep 6, 2018
1 parent 251edec commit f701f1a
Show file tree
Hide file tree
Showing 27 changed files with 81 additions and 81 deletions.
6 changes: 3 additions & 3 deletions account_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ type EventEntity struct {
// EventsPagedResponse represents a paginated Events API response
type EventsPagedResponse struct {
*PageOptions
Data []*Event `json:"data"`
Data []Event `json:"data"`
}

// endpoint gets the endpoint URL for Event
Expand All @@ -165,13 +165,13 @@ func (e Event) endpointWithID(c *Client) string {

// appendData appends Events when processing paginated Event responses
func (resp *EventsPagedResponse) appendData(r *EventsPagedResponse) {
(*resp).Data = append(resp.Data, r.Data...)
resp.Data = append(resp.Data, r.Data...)
}

// ListEvents gets a collection of Event objects representing actions taken
// on the Account. The Events returned depend on the token grants and the grants
// of the associated user.
func (c *Client) ListEvents(ctx context.Context, opts *ListOptions) ([]*Event, error) {
func (c *Client) ListEvents(ctx context.Context, opts *ListOptions) ([]Event, error) {
response := EventsPagedResponse{}
err := c.listHelper(ctx, &response, opts)
for _, el := range response.Data {
Expand Down
12 changes: 6 additions & 6 deletions account_invoices.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type InvoiceItem struct {
// InvoicesPagedResponse represents a paginated Invoice API response
type InvoicesPagedResponse struct {
*PageOptions
Data []*Invoice `json:"data"`
Data []Invoice `json:"data"`
}

// endpoint gets the endpoint URL for Invoice
Expand All @@ -47,11 +47,11 @@ func (InvoicesPagedResponse) endpoint(c *Client) string {

// appendData appends Invoices when processing paginated Invoice responses
func (resp *InvoicesPagedResponse) appendData(r *InvoicesPagedResponse) {
(*resp).Data = append(resp.Data, r.Data...)
resp.Data = append(resp.Data, r.Data...)
}

// ListInvoices gets a paginated list of Invoices against the Account
func (c *Client) ListInvoices(ctx context.Context, opts *ListOptions) ([]*Invoice, error) {
func (c *Client) ListInvoices(ctx context.Context, opts *ListOptions) ([]Invoice, error) {
response := InvoicesPagedResponse{}
err := c.listHelper(ctx, &response, opts)
for _, el := range response.Data {
Expand Down Expand Up @@ -94,7 +94,7 @@ func (c *Client) GetInvoice(ctx context.Context, id int) (*Invoice, error) {
// InvoiceItemsPagedResponse represents a paginated Invoice Item API response
type InvoiceItemsPagedResponse struct {
*PageOptions
Data []*InvoiceItem `json:"data"`
Data []InvoiceItem `json:"data"`
}

// endpointWithID gets the endpoint URL for InvoiceItems associated with a specific Invoice
Expand All @@ -108,11 +108,11 @@ func (InvoiceItemsPagedResponse) endpointWithID(c *Client, id int) string {

// appendData appends InvoiceItems when processing paginated Invoice Item responses
func (resp *InvoiceItemsPagedResponse) appendData(r *InvoiceItemsPagedResponse) {
(*resp).Data = append(resp.Data, r.Data...)
resp.Data = append(resp.Data, r.Data...)
}

// ListInvoiceItems gets the invoice items associated with a specific Invoice
func (c *Client) ListInvoiceItems(ctx context.Context, id int, opts *ListOptions) ([]*InvoiceItem, error) {
func (c *Client) ListInvoiceItems(ctx context.Context, id int, opts *ListOptions) ([]InvoiceItem, error) {
response := InvoiceItemsPagedResponse{}
err := c.listHelperWithID(ctx, &response, id, opts)
for _, el := range response.Data {
Expand Down
6 changes: 3 additions & 3 deletions account_notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type NotificationEntity struct {
// NotificationsPagedResponse represents a paginated Notifications API response
type NotificationsPagedResponse struct {
*PageOptions
Data []*Notification `json:"data"`
Data []Notification `json:"data"`
}

// endpoint gets the endpoint URL for Notification
Expand All @@ -45,15 +45,15 @@ func (NotificationsPagedResponse) endpoint(c *Client) string {

// appendData appends Notifications when processing paginated Notification responses
func (resp *NotificationsPagedResponse) appendData(r *NotificationsPagedResponse) {
(*resp).Data = append(resp.Data, r.Data...)
resp.Data = append(resp.Data, r.Data...)
}

// ListNotifications gets a collection of Notification objects representing important,
// often time-sensitive items related to the Account. An account cannot interact directly with
// Notifications, and a Notification will disappear when the circumstances causing it
// have been resolved. For example, if the account has an important Ticket open, a response
// to the Ticket will dismiss the Notification.
func (c *Client) ListNotifications(ctx context.Context, opts *ListOptions) ([]*Notification, error) {
func (c *Client) ListNotifications(ctx context.Context, opts *ListOptions) ([]Notification, error) {
response := NotificationsPagedResponse{}
err := c.listHelper(ctx, &response, opts)
for _, el := range response.Data {
Expand Down
6 changes: 3 additions & 3 deletions domain_records.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func copyString(sPtr *string) *string {
// DomainRecordsPagedResponse represents a paginated DomainRecord API response
type DomainRecordsPagedResponse struct {
*PageOptions
Data []*DomainRecord `json:"data"`
Data []DomainRecord `json:"data"`
}

// endpoint gets the endpoint URL for InstanceConfig
Expand All @@ -113,11 +113,11 @@ func (DomainRecordsPagedResponse) endpointWithID(c *Client, id int) string {

// appendData appends DomainRecords when processing paginated DomainRecord responses
func (resp *DomainRecordsPagedResponse) appendData(r *DomainRecordsPagedResponse) {
(*resp).Data = append(resp.Data, r.Data...)
resp.Data = append(resp.Data, r.Data...)
}

// ListDomainRecords lists DomainRecords
func (c *Client) ListDomainRecords(ctx context.Context, domainID int, opts *ListOptions) ([]*DomainRecord, error) {
func (c *Client) ListDomainRecords(ctx context.Context, domainID int, opts *ListOptions) ([]DomainRecord, error) {
response := DomainRecordsPagedResponse{}
err := c.listHelperWithID(ctx, &response, domainID, opts)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion domain_records_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestListDomainRecordsMultiplePages(t *testing.T) {
t.Errorf("Error listing domains records, expected array, got error %v", err)
}
if len(records) != 2 {
t.Errorf("Expected ListDomainRecords to match one result")
t.Errorf("Expected ListDomainRecords to match two results")
}
}

Expand Down
6 changes: 3 additions & 3 deletions domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (d Domain) GetUpdateOptions() (du DomainUpdateOptions) {
// DomainsPagedResponse represents a paginated Domain API response
type DomainsPagedResponse struct {
*PageOptions
Data []*Domain `json:"data"`
Data []Domain `json:"data"`
}

// endpoint gets the endpoint URL for Domain
Expand All @@ -187,11 +187,11 @@ func (DomainsPagedResponse) endpoint(c *Client) string {

// appendData appends Domains when processing paginated Domain responses
func (resp *DomainsPagedResponse) appendData(r *DomainsPagedResponse) {
(*resp).Data = append(resp.Data, r.Data...)
resp.Data = append(resp.Data, r.Data...)
}

// ListDomains lists Domains
func (c *Client) ListDomains(ctx context.Context, opts *ListOptions) ([]*Domain, error) {
func (c *Client) ListDomains(ctx context.Context, opts *ListOptions) ([]Domain, error) {
response := DomainsPagedResponse{}
err := c.listHelper(ctx, &response, opts)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions images.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (i Image) GetUpdateOptions() (iu ImageUpdateOptions) {
// ImagesPagedResponse represents a linode API response for listing of images
type ImagesPagedResponse struct {
*PageOptions
Data []*Image `json:"data"`
Data []Image `json:"data"`
}

func (ImagesPagedResponse) endpoint(c *Client) string {
Expand All @@ -66,11 +66,11 @@ func (ImagesPagedResponse) endpoint(c *Client) string {
}

func (resp *ImagesPagedResponse) appendData(r *ImagesPagedResponse) {
(*resp).Data = append(resp.Data, r.Data...)
resp.Data = append(resp.Data, r.Data...)
}

// ListImages lists Images
func (c *Client) ListImages(ctx context.Context, opts *ListOptions) ([]*Image, error) {
func (c *Client) ListImages(ctx context.Context, opts *ListOptions) ([]Image, error) {
response := ImagesPagedResponse{}
err := c.listHelper(ctx, &response, opts)
for _, el := range response.Data {
Expand Down
6 changes: 3 additions & 3 deletions instance_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type InstanceConfigHelpers struct {
// InstanceConfigsPagedResponse represents a paginated InstanceConfig API response
type InstanceConfigsPagedResponse struct {
*PageOptions
Data []*InstanceConfig `json:"data"`
Data []InstanceConfig `json:"data"`
}

// InstanceConfigCreateOptions are InstanceConfig settings that can be used at creation
Expand Down Expand Up @@ -133,11 +133,11 @@ func (InstanceConfigsPagedResponse) endpointWithID(c *Client, id int) string {

// appendData appends InstanceConfigs when processing paginated InstanceConfig responses
func (resp *InstanceConfigsPagedResponse) appendData(r *InstanceConfigsPagedResponse) {
(*resp).Data = append(resp.Data, r.Data...)
resp.Data = append(resp.Data, r.Data...)
}

// ListInstanceConfigs lists InstanceConfigs
func (c *Client) ListInstanceConfigs(ctx context.Context, linodeID int, opts *ListOptions) ([]*InstanceConfig, error) {
func (c *Client) ListInstanceConfigs(ctx context.Context, linodeID int, opts *ListOptions) ([]InstanceConfig, error) {
response := InstanceConfigsPagedResponse{}
err := c.listHelperWithID(ctx, &response, linodeID, opts)
for _, el := range response.Data {
Expand Down
6 changes: 3 additions & 3 deletions instance_disks.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const (
// InstanceDisksPagedResponse represents a paginated InstanceDisk API response
type InstanceDisksPagedResponse struct {
*PageOptions
Data []*InstanceDisk `json:"data"`
Data []InstanceDisk `json:"data"`
}

// InstanceDiskCreateOptions are InstanceDisk settings that can be used at creation
Expand Down Expand Up @@ -72,11 +72,11 @@ func (InstanceDisksPagedResponse) endpointWithID(c *Client, id int) string {

// appendData appends InstanceDisks when processing paginated InstanceDisk responses
func (resp *InstanceDisksPagedResponse) appendData(r *InstanceDisksPagedResponse) {
(*resp).Data = append(resp.Data, r.Data...)
resp.Data = append(resp.Data, r.Data...)
}

// ListInstanceDisks lists InstanceDisks
func (c *Client) ListInstanceDisks(ctx context.Context, linodeID int, opts *ListOptions) ([]*InstanceDisk, error) {
func (c *Client) ListInstanceDisks(ctx context.Context, linodeID int, opts *ListOptions) ([]InstanceDisk, error) {
response := InstanceDisksPagedResponse{}
err := c.listHelperWithID(ctx, &response, linodeID, opts)
for _, el := range response.Data {
Expand Down
6 changes: 3 additions & 3 deletions instance_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
// InstanceVolumesPagedResponse represents a paginated InstanceVolume API response
type InstanceVolumesPagedResponse struct {
*PageOptions
Data []*Volume `json:"data"`
Data []Volume `json:"data"`
}

// endpoint gets the endpoint URL for InstanceVolume
Expand All @@ -21,11 +21,11 @@ func (InstanceVolumesPagedResponse) endpointWithID(c *Client, id int) string {

// appendData appends InstanceVolumes when processing paginated InstanceVolume responses
func (resp *InstanceVolumesPagedResponse) appendData(r *InstanceVolumesPagedResponse) {
(*resp).Data = append(resp.Data, r.Data...)
resp.Data = append(resp.Data, r.Data...)
}

// ListInstanceVolumes lists InstanceVolumes
func (c *Client) ListInstanceVolumes(ctx context.Context, linodeID int, opts *ListOptions) ([]*Volume, error) {
func (c *Client) ListInstanceVolumes(ctx context.Context, linodeID int, opts *ListOptions) ([]Volume, error) {
response := InstanceVolumesPagedResponse{}
err := c.listHelperWithID(ctx, &response, linodeID, opts)
for _, el := range response.Data {
Expand Down
6 changes: 3 additions & 3 deletions instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (l *Instance) fixDates() *Instance {
// InstancesPagedResponse represents a linode API response for listing
type InstancesPagedResponse struct {
*PageOptions
Data []*Instance `json:"data"`
Data []Instance `json:"data"`
}

// endpoint gets the endpoint URL for Instance
Expand All @@ -145,11 +145,11 @@ func (InstancesPagedResponse) endpoint(c *Client) string {

// appendData appends Instances when processing paginated Instance responses
func (resp *InstancesPagedResponse) appendData(r *InstancesPagedResponse) {
(*resp).Data = append(resp.Data, r.Data...)
resp.Data = append(resp.Data, r.Data...)
}

// ListInstances lists linode instances
func (c *Client) ListInstances(ctx context.Context, opts *ListOptions) ([]*Instance, error) {
func (c *Client) ListInstances(ctx context.Context, opts *ListOptions) ([]Instance, error) {
response := InstancesPagedResponse{}
err := c.listHelper(ctx, &response, opts)
for _, el := range response.Data {
Expand Down
6 changes: 3 additions & 3 deletions kernels.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ type LinodeKernel struct {
// LinodeKernelsPagedResponse represents a Linode kernels API response for listing
type LinodeKernelsPagedResponse struct {
*PageOptions
Data []*LinodeKernel `json:"data"`
Data []LinodeKernel `json:"data"`
}

// ListKernels lists linode kernels
func (c *Client) ListKernels(ctx context.Context, opts *ListOptions) ([]*LinodeKernel, error) {
func (c *Client) ListKernels(ctx context.Context, opts *ListOptions) ([]LinodeKernel, error) {
response := LinodeKernelsPagedResponse{}
err := c.listHelper(ctx, &response, opts)
if err != nil {
Expand All @@ -41,7 +41,7 @@ func (LinodeKernelsPagedResponse) endpoint(c *Client) string {
}

func (resp *LinodeKernelsPagedResponse) appendData(r *LinodeKernelsPagedResponse) {
(*resp).Data = append(resp.Data, r.Data...)
resp.Data = append(resp.Data, r.Data...)
}

// GetKernel gets the kernel with the provided ID
Expand Down
6 changes: 3 additions & 3 deletions longview.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type LongviewClient struct {
// LongviewClientsPagedResponse represents a paginated LongviewClient API response
type LongviewClientsPagedResponse struct {
*PageOptions
Data []*LongviewClient `json:"data"`
Data []LongviewClient `json:"data"`
}

// endpoint gets the endpoint URL for LongviewClient
Expand All @@ -29,11 +29,11 @@ func (LongviewClientsPagedResponse) endpoint(c *Client) string {

// appendData appends LongviewClients when processing paginated LongviewClient responses
func (resp *LongviewClientsPagedResponse) appendData(r *LongviewClientsPagedResponse) {
(*resp).Data = append(resp.Data, r.Data...)
resp.Data = append(resp.Data, r.Data...)
}

// ListLongviewClients lists LongviewClients
func (c *Client) ListLongviewClients(ctx context.Context, opts *ListOptions) ([]*LongviewClient, error) {
func (c *Client) ListLongviewClients(ctx context.Context, opts *ListOptions) ([]LongviewClient, error) {
response := LongviewClientsPagedResponse{}
err := c.listHelper(ctx, &response, opts)
for _, el := range response.Data {
Expand Down
6 changes: 3 additions & 3 deletions longview_subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type LongviewSubscription struct {
// LongviewSubscriptionsPagedResponse represents a paginated LongviewSubscription API response
type LongviewSubscriptionsPagedResponse struct {
*PageOptions
Data []*LongviewSubscription `json:"data"`
Data []LongviewSubscription `json:"data"`
}

// endpoint gets the endpoint URL for LongviewSubscription
Expand All @@ -32,11 +32,11 @@ func (LongviewSubscriptionsPagedResponse) endpoint(c *Client) string {

// appendData appends LongviewSubscriptions when processing paginated LongviewSubscription responses
func (resp *LongviewSubscriptionsPagedResponse) appendData(r *LongviewSubscriptionsPagedResponse) {
(*resp).Data = append(resp.Data, r.Data...)
resp.Data = append(resp.Data, r.Data...)
}

// ListLongviewSubscriptions lists LongviewSubscriptions
func (c *Client) ListLongviewSubscriptions(ctx context.Context, opts *ListOptions) ([]*LongviewSubscription, error) {
func (c *Client) ListLongviewSubscriptions(ctx context.Context, opts *ListOptions) ([]LongviewSubscription, error) {
response := LongviewSubscriptionsPagedResponse{}
err := c.listHelper(ctx, &response, opts)
for _, el := range response.Data {
Expand Down
6 changes: 3 additions & 3 deletions network_ips.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// IPAddressesPagedResponse represents a paginated IPAddress API response
type IPAddressesPagedResponse struct {
*PageOptions
Data []*InstanceIP `json:"data"`
Data []InstanceIP `json:"data"`
}

// endpoint gets the endpoint URL for IPAddress
Expand All @@ -22,11 +22,11 @@ func (IPAddressesPagedResponse) endpoint(c *Client) string {

// appendData appends IPAddresses when processing paginated InstanceIPAddress responses
func (resp *IPAddressesPagedResponse) appendData(r *IPAddressesPagedResponse) {
(*resp).Data = append(resp.Data, r.Data...)
resp.Data = append(resp.Data, r.Data...)
}

// ListIPAddresses lists IPAddresses
func (c *Client) ListIPAddresses(ctx context.Context, opts *ListOptions) ([]*InstanceIP, error) {
func (c *Client) ListIPAddresses(ctx context.Context, opts *ListOptions) ([]InstanceIP, error) {
response := IPAddressesPagedResponse{}
err := c.listHelper(ctx, &response, opts)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions network_pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// IPv6PoolsPagedResponse represents a paginated IPv6Pool API response
type IPv6PoolsPagedResponse struct {
*PageOptions
Data []*IPv6Range `json:"data"`
Data []IPv6Range `json:"data"`
}

// endpoint gets the endpoint URL for IPv6Pool
Expand All @@ -22,11 +22,11 @@ func (IPv6PoolsPagedResponse) endpoint(c *Client) string {

// appendData appends IPv6Pools when processing paginated IPv6Pool responses
func (resp *IPv6PoolsPagedResponse) appendData(r *IPv6PoolsPagedResponse) {
(*resp).Data = append(resp.Data, r.Data...)
resp.Data = append(resp.Data, r.Data...)
}

// ListIPv6Pools lists IPv6Pools
func (c *Client) ListIPv6Pools(ctx context.Context, opts *ListOptions) ([]*IPv6Range, error) {
func (c *Client) ListIPv6Pools(ctx context.Context, opts *ListOptions) ([]IPv6Range, error) {
response := IPv6PoolsPagedResponse{}
err := c.listHelper(ctx, &response, opts)
if err != nil {
Expand Down
Loading

0 comments on commit f701f1a

Please sign in to comment.