From 966c2a77f251c02cebb682b8aab2062ce7d32998 Mon Sep 17 00:00:00 2001 From: Lena Garber Date: Thu, 5 Jan 2023 14:58:31 -0500 Subject: [PATCH] Include opts as part of cached endpoint key --- client.go | 45 +-- databases.go | 42 +-- kernels.go | 21 +- lke_clusters.go | 21 +- pagination.go | 16 + regions.go | 21 +- .../fixtures/TestCache_Expiration.yaml | 354 +++++++++--------- .../fixtures/TestCache_RegionList.yaml | 8 +- types.go | 21 +- 9 files changed, 283 insertions(+), 266 deletions(-) diff --git a/client.go b/client.go index 3492b070b..1a6577778 100644 --- a/client.go +++ b/client.go @@ -207,14 +207,9 @@ func (c *Client) addRetryConditional(retryConditional RetryConditional) *Client return c } -func (c *Client) addCachedResponse(endpoint string, response any, expiry *time.Duration) error { +func (c *Client) addCachedResponse(endpoint string, response any, expiry *time.Duration) { if !c.shouldCache { - return nil - } - - u, err := url.Parse(endpoint) - if err != nil { - return fmt.Errorf("failed to parse URL for caching: %s", err) + return } responseValue := reflect.ValueOf(response) @@ -236,19 +231,12 @@ func (c *Client) addCachedResponse(endpoint string, response any, expiry *time.D c.cachedEntryLock.Lock() defer c.cachedEntryLock.Unlock() - c.cachedEntries[u.Path] = entry - - return nil + c.cachedEntries[endpoint] = entry } -func (c *Client) getCachedResponse(endpoint string) (any, error) { +func (c *Client) getCachedResponse(endpoint string) any { if !c.shouldCache { - return nil, nil - } - - u, err := url.Parse(endpoint) - if err != nil { - return nil, fmt.Errorf("failed to parse URL for caching: %s", err) + return nil } c.cachedEntryLock.RLock() @@ -265,9 +253,9 @@ func (c *Client) getCachedResponse(endpoint string) (any, error) { } }() - entry, ok := c.cachedEntries[u.Path] + entry, ok := c.cachedEntries[endpoint] if !ok { - return nil, nil + return nil } // Handle expired entries @@ -286,11 +274,11 @@ func (c *Client) getCachedResponse(endpoint string) (any, error) { c.cachedEntryLock.Lock() defer c.cachedEntryLock.Unlock() - delete(c.cachedEntries, u.Path) - return nil, nil + delete(c.cachedEntries, endpoint) + return nil } - return c.cachedEntries[u.Path].Data, nil + return c.cachedEntries[endpoint].Data } // InvalidateCache clears all cached responses for all endpoints. @@ -523,3 +511,16 @@ func copyTime(tPtr *time.Time) *time.Time { return &t } + +func generateListCacheURL(endpoint string, opts *ListOptions) (string, error) { + if opts == nil { + return "", nil + } + + hashedOpts, err := opts.Hash() + if err != nil { + return "", err + } + + return fmt.Sprintf("%s:%s", endpoint, hashedOpts), nil +} diff --git a/databases.go b/databases.go index a4926b74d..eace5fdc9 100644 --- a/databases.go +++ b/databases.go @@ -216,20 +216,21 @@ func (c *Client) ListDatabases(ctx context.Context, opts *ListOptions) ([]Databa func (c *Client) ListDatabaseEngines(ctx context.Context, opts *ListOptions) ([]DatabaseEngine, error) { response := DatabaseEnginesPagedResponse{} - if result, err := c.getCachedResponse(response.endpoint()); err != nil { + endpoint, err := generateListCacheURL(response.endpoint(), opts) + if err != nil { return nil, err - } else if result != nil { + } + + if result := c.getCachedResponse(endpoint); result != nil { return result.([]DatabaseEngine), nil } - err := c.listHelper(ctx, &response, opts) + err = c.listHelper(ctx, &response, opts) if err != nil { return nil, err } - if err := c.addCachedResponse(response.endpoint(), response.Data, &cacheExpiryTime); err != nil { - return nil, err - } + c.addCachedResponse(endpoint, response.Data, &cacheExpiryTime) return response.Data, nil } @@ -238,9 +239,7 @@ func (c *Client) ListDatabaseEngines(ctx context.Context, opts *ListOptions) ([] func (c *Client) GetDatabaseEngine(ctx context.Context, opts *ListOptions, engineID string) (*DatabaseEngine, error) { e := fmt.Sprintf("databases/engines/%s", engineID) - if result, err := c.getCachedResponse(e); err != nil { - return nil, err - } else if result != nil { + if result := c.getCachedResponse(e); result != nil { result := result.(DatabaseEngine) return &result, nil } @@ -251,9 +250,7 @@ func (c *Client) GetDatabaseEngine(ctx context.Context, opts *ListOptions, engin return nil, err } - if err := c.addCachedResponse(e, r.Result(), &cacheExpiryTime); err != nil { - return nil, err - } + c.addCachedResponse(e, r.Result(), &cacheExpiryTime) return r.Result().(*DatabaseEngine), nil } @@ -262,20 +259,21 @@ func (c *Client) GetDatabaseEngine(ctx context.Context, opts *ListOptions, engin func (c *Client) ListDatabaseTypes(ctx context.Context, opts *ListOptions) ([]DatabaseType, error) { response := DatabaseTypesPagedResponse{} - if result, err := c.getCachedResponse(response.endpoint()); err != nil { + endpoint, err := generateListCacheURL(response.endpoint(), opts) + if err != nil { return nil, err - } else if result != nil { + } + + if result := c.getCachedResponse(endpoint); result != nil { return result.([]DatabaseType), nil } - err := c.listHelper(ctx, &response, opts) + err = c.listHelper(ctx, &response, opts) if err != nil { return nil, err } - if err := c.addCachedResponse(response.endpoint(), response.Data, &cacheExpiryTime); err != nil { - return nil, err - } + c.addCachedResponse(endpoint, response.Data, &cacheExpiryTime) return response.Data, nil } @@ -284,9 +282,7 @@ func (c *Client) ListDatabaseTypes(ctx context.Context, opts *ListOptions) ([]Da func (c *Client) GetDatabaseType(ctx context.Context, opts *ListOptions, typeID string) (*DatabaseType, error) { e := fmt.Sprintf("databases/types/%s", typeID) - if result, err := c.getCachedResponse(e); err != nil { - return nil, err - } else if result != nil { + if result := c.getCachedResponse(e); result != nil { result := result.(DatabaseType) return &result, nil } @@ -297,9 +293,7 @@ func (c *Client) GetDatabaseType(ctx context.Context, opts *ListOptions, typeID return nil, err } - if err := c.addCachedResponse(e, r.Result(), &cacheExpiryTime); err != nil { - return nil, err - } + c.addCachedResponse(e, r.Result(), &cacheExpiryTime) return r.Result().(*DatabaseType), nil } diff --git a/kernels.go b/kernels.go index 7b6b6777f..06c2fc600 100644 --- a/kernels.go +++ b/kernels.go @@ -43,20 +43,21 @@ func (resp *LinodeKernelsPagedResponse) castResult(r *resty.Request, e string) ( func (c *Client) ListKernels(ctx context.Context, opts *ListOptions) ([]LinodeKernel, error) { response := LinodeKernelsPagedResponse{} - if result, err := c.getCachedResponse(response.endpoint()); err != nil { + endpoint, err := generateListCacheURL(response.endpoint(), opts) + if err != nil { return nil, err - } else if result != nil { + } + + if result := c.getCachedResponse(endpoint); result != nil { return result.([]LinodeKernel), nil } - err := c.listHelper(ctx, &response, opts) + err = c.listHelper(ctx, &response, opts) if err != nil { return nil, err } - if err := c.addCachedResponse(response.endpoint(), response.Data, nil); err != nil { - return nil, err - } + c.addCachedResponse(endpoint, response.Data, nil) return response.Data, nil } @@ -65,9 +66,7 @@ func (c *Client) ListKernels(ctx context.Context, opts *ListOptions) ([]LinodeKe func (c *Client) GetKernel(ctx context.Context, kernelID string) (*LinodeKernel, error) { e := fmt.Sprintf("linode/kernels/%s", kernelID) - if result, err := c.getCachedResponse(e); err != nil { - return nil, err - } else if result != nil { + if result := c.getCachedResponse(e); result != nil { result := result.(LinodeKernel) return &result, nil } @@ -78,9 +77,7 @@ func (c *Client) GetKernel(ctx context.Context, kernelID string) (*LinodeKernel, return nil, err } - if err := c.addCachedResponse(e, r.Result(), nil); err != nil { - return nil, err - } + c.addCachedResponse(e, r.Result(), nil) return r.Result().(*LinodeKernel), nil } diff --git a/lke_clusters.go b/lke_clusters.go index aabe739f5..6e9570d5b 100644 --- a/lke_clusters.go +++ b/lke_clusters.go @@ -142,20 +142,21 @@ func (resp *LKEVersionsPagedResponse) castResult(r *resty.Request, e string) (in func (c *Client) ListLKEVersions(ctx context.Context, opts *ListOptions) ([]LKEVersion, error) { response := LKEVersionsPagedResponse{} - if result, err := c.getCachedResponse(response.endpoint()); err != nil { + endpoint, err := generateListCacheURL(response.endpoint(), opts) + if err != nil { return nil, err - } else if result != nil { + } + + if result := c.getCachedResponse(endpoint); result != nil { return result.([]LKEVersion), nil } - err := c.listHelper(ctx, &response, opts) + err = c.listHelper(ctx, &response, opts) if err != nil { return nil, err } - if err := c.addCachedResponse(response.endpoint(), response.Data, &cacheExpiryTime); err != nil { - return nil, err - } + c.addCachedResponse(endpoint, response.Data, &cacheExpiryTime) return response.Data, nil } @@ -164,9 +165,7 @@ func (c *Client) ListLKEVersions(ctx context.Context, opts *ListOptions) ([]LKEV func (c *Client) GetLKEVersion(ctx context.Context, version string) (*LKEVersion, error) { e := fmt.Sprintf("lke/versions/%s", version) - if result, err := c.getCachedResponse(e); err != nil { - return nil, err - } else if result != nil { + if result := c.getCachedResponse(e); result != nil { result := result.(LKEVersion) return &result, nil } @@ -177,9 +176,7 @@ func (c *Client) GetLKEVersion(ctx context.Context, version string) (*LKEVersion return nil, err } - if err := c.addCachedResponse(e, r.Result(), &cacheExpiryTime); err != nil { - return nil, err - } + c.addCachedResponse(e, r.Result(), &cacheExpiryTime) return r.Result().(*LKEVersion), nil } diff --git a/pagination.go b/pagination.go index c76ec6634..3dc4d6131 100644 --- a/pagination.go +++ b/pagination.go @@ -6,6 +6,9 @@ package linodego import ( "context" + "crypto/sha256" + "encoding/json" + "fmt" "strconv" "github.com/go-resty/resty/v2" @@ -31,6 +34,19 @@ func NewListOptions(page int, filter string) *ListOptions { return &ListOptions{PageOptions: &PageOptions{Page: page}, Filter: filter} } +// Hash returns the sha256 hash of the provided ListOptions. +// This is necessary for caching purposes. +func (l ListOptions) Hash() (string, error) { + data, err := json.Marshal(l) + if err != nil { + return "", fmt.Errorf("failed to cache ListOptions: %s", err) + } + + h := sha256.New() + + return string(h.Sum(data)), nil +} + func applyListOptionsToRequest(opts *ListOptions, req *resty.Request) { if opts != nil { if opts.PageOptions != nil && opts.Page > 0 { diff --git a/regions.go b/regions.go index 7ac72b957..0e4565af5 100644 --- a/regions.go +++ b/regions.go @@ -52,20 +52,21 @@ func (resp *RegionsPagedResponse) castResult(r *resty.Request, e string) (int, i func (c *Client) ListRegions(ctx context.Context, opts *ListOptions) ([]Region, error) { response := RegionsPagedResponse{} - if result, err := c.getCachedResponse(response.endpoint()); err != nil { + endpoint, err := generateListCacheURL(response.endpoint(), opts) + if err != nil { return nil, err - } else if result != nil { + } + + if result := c.getCachedResponse(endpoint); result != nil { return result.([]Region), nil } - err := c.listHelper(ctx, &response, opts) + err = c.listHelper(ctx, &response, opts) if err != nil { return nil, err } - if err := c.addCachedResponse(response.endpoint(), response.Data, &cacheExpiryTime); err != nil { - return nil, err - } + c.addCachedResponse(endpoint, response.Data, &cacheExpiryTime) return response.Data, nil } @@ -74,9 +75,7 @@ func (c *Client) ListRegions(ctx context.Context, opts *ListOptions) ([]Region, func (c *Client) GetRegion(ctx context.Context, regionID string) (*Region, error) { e := fmt.Sprintf("regions/%s", regionID) - if result, err := c.getCachedResponse(e); err != nil { - return nil, err - } else if result != nil { + if result := c.getCachedResponse(e); result != nil { result := result.(Region) return &result, nil } @@ -87,9 +86,7 @@ func (c *Client) GetRegion(ctx context.Context, regionID string) (*Region, error return nil, err } - if err := c.addCachedResponse(e, r.Result(), &cacheExpiryTime); err != nil { - return nil, err - } + c.addCachedResponse(e, r.Result(), &cacheExpiryTime) return r.Result().(*Region), nil } diff --git a/test/integration/fixtures/TestCache_Expiration.yaml b/test/integration/fixtures/TestCache_Expiration.yaml index 8f4e688c1..cb518bf78 100644 --- a/test/integration/fixtures/TestCache_Expiration.yaml +++ b/test/integration/fixtures/TestCache_Expiration.yaml @@ -19,11 +19,21 @@ interactions: true, "built": "2018-01-02T03:04:05"}, {"id": "linode/latest-2.6", "label": "Latest 2.6 Stable (2.6.23.17-linode44)", "version": "2.6.24", "kvm": false, "architecture": "i386", "pvops": false, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/latest-32bit", "label": "Latest 32 bit (5.19.2-x86-linode176)", - "version": "5.19.2", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": + {"id": "linode/latest-32bit", "label": "Latest 32 bit (6.0.2-x86-linode177)", + "version": "6.0.2", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": false, "built": "2018-01-02T03:04:05"}, {"id": "linode/2.6.18.8-linode22", "label": "Latest Legacy (2.6.18.8-linode22)", "version": "2.6.18", "kvm": false, "architecture": "i386", "pvops": false, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/6.0.10-x86_64-linode158", "label": "6.0.10-x86_64-linode158", + "version": "6.0.10", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": + false, "built": "2018-01-02T03:04:05"}, {"id": "linode/6.0.10-x86-linode178", + "label": "6.0.10-x86-linode178", "version": "6.0.10", "kvm": true, "architecture": + "i386", "pvops": true, "deprecated": false, "built": "2018-01-02T03:04:05"}, + {"id": "linode/6.0.2-x86_64-linode157", "label": "6.0.2-x86_64-linode157", "version": + "6.0.2", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": + false, "built": "2018-01-02T03:04:05"}, {"id": "linode/6.0.2-x86-linode177", + "label": "6.0.2-x86-linode177", "version": "6.0.2", "kvm": true, "architecture": + "i386", "pvops": true, "deprecated": false, "built": "2018-01-02T03:04:05"}, {"id": "linode/5.19.2-x86_64-linode156", "label": "5.19.2-x86_64-linode156", "version": "5.19.2", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": false, "built": "2018-01-02T03:04:05"}, {"id": "linode/5.19.2-x86-linode176", @@ -252,17 +262,7 @@ interactions: "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.9.7-x86-linode99", "label": "4.9.7-x86-linode99", "version": "4.9.7", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, - "built": "2018-01-02T03:04:05"}, {"id": "linode/4.9.0-x86-linode98", "label": - "4.9.0-x86-linode98", "version": "4.9.0", "kvm": true, "architecture": "i386", - "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.8.6-x86-linode97", - "label": "4.8.6-x86-linode97", "version": "4.8.6", "kvm": true, "architecture": - "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/4.8.4-x86-linode96", "label": "4.8.4-x86-linode96", "version": - "4.8.4", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, - "built": "2018-01-02T03:04:05"}, {"id": "linode/4.8.3-x86-linode95", "label": - "4.8.3-x86-linode95", "version": "4.8.3", "kvm": true, "architecture": "i386", - "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}], "page": - 1, "pages": 4, "results": 314}' + "built": "2018-01-02T03:04:05"}], "page": 1, "pages": 4, "results": 318}' headers: Access-Control-Allow-Credentials: - "true" @@ -317,50 +317,59 @@ interactions: url: https://api.linode.com/v4beta/linode/kernels?page=2 method: GET response: - body: '{"data": [{"id": "linode/4.8.1-x86-linode94", "label": "4.8.1-x86-linode94", - "version": "4.8.1", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": - true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.7.3-x86-linode92", "label": - "4.7.3-x86-linode92", "version": "4.7.3", "kvm": true, "architecture": "i386", - "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.7.0-x86-linode90", - "label": "4.7.0-x86-linode90", "version": "4.7.0", "kvm": true, "architecture": - "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/4.6.5-x86-linode89", "label": "4.6.5-x86-linode89", "version": - "4.6.5", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, - "built": "2018-01-02T03:04:05"}, {"id": "linode/4.5.5-x86-linode88", "label": - "4.5.5-x86-linode88", "version": "4.5.5", "kvm": true, "architecture": "i386", - "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.5.3-x86-linode86", - "label": "4.5.3-x86-linode86", "version": "4.5.3", "kvm": true, "architecture": - "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/4.5.0-x86-linode84", "label": "4.5.0-x86-linode84", "version": - "4.5.0", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, - "built": "2018-01-02T03:04:05"}, {"id": "linode/4.4.4-x86-linode83", "label": - "4.4.4-x86-linode83", "version": "4.4.4", "kvm": true, "architecture": "i386", - "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.4.0-x86-linode82", - "label": "4.4.0-x86-linode82", "version": "4.4.0", "kvm": true, "architecture": - "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/4.1.5-x86-linode80", "label": "4.1.5-x86-linode80", "version": - "4.1.5", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, - "built": "2018-01-02T03:04:05"}, {"id": "linode/4.1.5-x86-linode79", "label": - "4.1.5-x86-linode79", "version": "4.1.5", "kvm": true, "architecture": "i386", - "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.1.0-x86-linode78", - "label": "4.1.0-x86-linode78", "version": "4.1.0", "kvm": true, "architecture": - "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/4.0.5-x86-linode77", "label": "4.0.5-x86-linode77", "version": - "4.0.5", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, - "built": "2018-01-02T03:04:05"}, {"id": "linode/4.0.5-x86-linode76", "label": - "4.0.5-x86-linode76", "version": "4.0.5", "kvm": false, "architecture": "i386", - "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.0.4-x86-linode75", - "label": "4.0.4-x86-linode75", "version": "4.0.4", "kvm": false, "architecture": - "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/4.0.2-x86-linode74", "label": "4.0.2-x86-linode74", "version": - "4.0.2", "kvm": false, "architecture": "i386", "pvops": true, "deprecated": - true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.0-x86-linode73", "label": - "4.0.1-x86-linode73", "version": "4.0.1", "kvm": false, "architecture": "i386", - "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.0-x86-linode72", - "label": "4.0-x86-linode72", "version": "4.0", "kvm": false, "architecture": - "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/3.19.1-x86-linode71", "label": "3.19.1-x86-linode71", "version": - "3.19.1", "kvm": false, "architecture": "i386", "pvops": true, "deprecated": + body: '{"data": [{"id": "linode/4.9.0-x86-linode98", "label": "4.9.0-x86-linode98", + "version": "4.9.0", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": + true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.8.6-x86-linode97", "label": + "4.8.6-x86-linode97", "version": "4.8.6", "kvm": true, "architecture": "i386", + "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.8.4-x86-linode96", + "label": "4.8.4-x86-linode96", "version": "4.8.4", "kvm": true, "architecture": + "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.8.3-x86-linode95", "label": "4.8.3-x86-linode95", "version": + "4.8.3", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, + "built": "2018-01-02T03:04:05"}, {"id": "linode/4.8.1-x86-linode94", "label": + "4.8.1-x86-linode94", "version": "4.8.1", "kvm": true, "architecture": "i386", + "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.7.3-x86-linode92", + "label": "4.7.3-x86-linode92", "version": "4.7.3", "kvm": true, "architecture": + "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.7.0-x86-linode90", "label": "4.7.0-x86-linode90", "version": + "4.7.0", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, + "built": "2018-01-02T03:04:05"}, {"id": "linode/4.6.5-x86-linode89", "label": + "4.6.5-x86-linode89", "version": "4.6.5", "kvm": true, "architecture": "i386", + "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.5.5-x86-linode88", + "label": "4.5.5-x86-linode88", "version": "4.5.5", "kvm": true, "architecture": + "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.5.3-x86-linode86", "label": "4.5.3-x86-linode86", "version": + "4.5.3", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, + "built": "2018-01-02T03:04:05"}, {"id": "linode/4.5.0-x86-linode84", "label": + "4.5.0-x86-linode84", "version": "4.5.0", "kvm": true, "architecture": "i386", + "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.4.4-x86-linode83", + "label": "4.4.4-x86-linode83", "version": "4.4.4", "kvm": true, "architecture": + "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.4.0-x86-linode82", "label": "4.4.0-x86-linode82", "version": + "4.4.0", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, + "built": "2018-01-02T03:04:05"}, {"id": "linode/4.1.5-x86-linode80", "label": + "4.1.5-x86-linode80", "version": "4.1.5", "kvm": true, "architecture": "i386", + "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.1.5-x86-linode79", + "label": "4.1.5-x86-linode79", "version": "4.1.5", "kvm": true, "architecture": + "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.1.0-x86-linode78", "label": "4.1.0-x86-linode78", "version": + "4.1.0", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, + "built": "2018-01-02T03:04:05"}, {"id": "linode/4.0.5-x86-linode77", "label": + "4.0.5-x86-linode77", "version": "4.0.5", "kvm": true, "architecture": "i386", + "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.0.5-x86-linode76", + "label": "4.0.5-x86-linode76", "version": "4.0.5", "kvm": false, "architecture": + "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.0.4-x86-linode75", "label": "4.0.4-x86-linode75", "version": + "4.0.4", "kvm": false, "architecture": "i386", "pvops": true, "deprecated": + true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.0.2-x86-linode74", "label": + "4.0.2-x86-linode74", "version": "4.0.2", "kvm": false, "architecture": "i386", + "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.0-x86-linode73", + "label": "4.0.1-x86-linode73", "version": "4.0.1", "kvm": false, "architecture": + "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.0-x86-linode72", "label": "4.0-x86-linode72", "version": "4.0", + "kvm": false, "architecture": "i386", "pvops": true, "deprecated": true, "built": + "2018-01-02T03:04:05"}, {"id": "linode/3.19.1-x86-linode71", "label": "3.19.1-x86-linode71", + "version": "3.19.1", "kvm": false, "architecture": "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/3.18.5-x86-linode70", "label": "3.18.5-x86-linode70", "version": "3.18.5", "kvm": false, "architecture": "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, @@ -510,8 +519,8 @@ interactions: true, "built": null}, {"id": "linode/latest-2.6-64bit", "label": "Latest 2.6 (2.6.39.1-x86_64-linode19)", "version": "2.6.39", "kvm": false, "architecture": "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/latest-64bit", "label": "Latest 64 bit (5.19.2-x86_64-linode156)", - "version": "5.19.2", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": + {"id": "linode/latest-64bit", "label": "Latest 64 bit (6.0.2-x86_64-linode157)", + "version": "6.0.2", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": false, "built": "2018-01-02T03:04:05"}, {"id": "linode/2.6.18.8-x86_64-linode10", "label": "Latest Legacy (2.6.18.8-x86_64-linode10)", "version": "2.6.18", "kvm": false, "architecture": "x86_64", "pvops": false, "deprecated": true, "built": @@ -544,18 +553,8 @@ interactions: "version": "4.14.120", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/5.1.2-x86_64-linode124", "label": "5.1.2-x86_64-linode124", "version": "5.1.2", "kvm": true, "architecture": - "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/5.0.8-x86_64-linode123", "label": "5.0.8-x86_64-linode123", "version": - "5.0.8", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": - true, "built": "2018-01-02T03:04:05"}, {"id": "linode/5.0.1-x86_64-linode122", - "label": "5.0.1-x86_64-linode122", "version": "5.0.1", "kvm": true, "architecture": - "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/4.20.4-x86_64-linode121", "label": "4.20.4-x86_64-linode121", - "version": "4.20.4", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": - true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.19.8-x86_64-linode120", - "label": "4.19.8-x86_64-linode120", "version": "4.19.8", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}], - "page": 2, "pages": 4, "results": 314}' + "page": 2, "pages": 4, "results": 318}' headers: Access-Control-Allow-Credentials: - "true" @@ -610,7 +609,17 @@ interactions: url: https://api.linode.com/v4beta/linode/kernels?page=3 method: GET response: - body: '{"data": [{"id": "linode/4.19.5-x86_64-linode119", "label": "4.19.5-x86_64-linode119", + body: '{"data": [{"id": "linode/5.0.8-x86_64-linode123", "label": "5.0.8-x86_64-linode123", + "version": "5.0.8", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": + true, "built": "2018-01-02T03:04:05"}, {"id": "linode/5.0.1-x86_64-linode122", + "label": "5.0.1-x86_64-linode122", "version": "5.0.1", "kvm": true, "architecture": + "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.20.4-x86_64-linode121", "label": "4.20.4-x86_64-linode121", + "version": "4.20.4", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": + true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.19.8-x86_64-linode120", + "label": "4.19.8-x86_64-linode120", "version": "4.19.8", "kvm": true, "architecture": + "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.19.5-x86_64-linode119", "label": "4.19.5-x86_64-linode119", "version": "4.19.5", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.18.16-x86_64-linode118", "label": "4.18.16-x86_64-linode118", "version": "4.18.16", "kvm": true, "architecture": @@ -849,18 +858,8 @@ interactions: "2.6.34", "kvm": false, "architecture": "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/2.6.34-x86_64-linode14", "label": "2.6.34-x86_64-linode14", "version": "2.6.34", "kvm": false, "architecture": - "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/2.6.32.12-x86_64-linode12", "label": "2.6.32.12-x86_64-linode12", - "version": "2.6.32", "kvm": false, "architecture": "x86_64", "pvops": true, - "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/2.6.32-x86_64-linode11", - "label": "2.6.32-x86_64-linode11", "version": "2.6.32", "kvm": false, "architecture": - "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/2.6.18.8-x86_64-linode10", "label": "2.6.18.8-x86_64-linode10", - "version": "2.6.18", "kvm": false, "architecture": "x86_64", "pvops": false, - "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/2.6.31.5-x86_64-linode9", - "label": "2.6.31.5-x86_64-linode9", "version": "2.6.31", "kvm": false, "architecture": "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}], - "page": 3, "pages": 4, "results": 314}' + "page": 3, "pages": 4, "results": 318}' headers: Access-Control-Allow-Credentials: - "true" @@ -915,7 +914,17 @@ interactions: url: https://api.linode.com/v4beta/linode/kernels?page=4 method: GET response: - body: '{"data": [{"id": "linode/2.6.30.5-x86_64-linode8", "label": "2.6.30.5-x86_64-linode8", + body: '{"data": [{"id": "linode/2.6.32.12-x86_64-linode12", "label": "2.6.32.12-x86_64-linode12", + "version": "2.6.32", "kvm": false, "architecture": "x86_64", "pvops": true, + "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/2.6.32-x86_64-linode11", + "label": "2.6.32-x86_64-linode11", "version": "2.6.32", "kvm": false, "architecture": + "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/2.6.18.8-x86_64-linode10", "label": "2.6.18.8-x86_64-linode10", + "version": "2.6.18", "kvm": false, "architecture": "x86_64", "pvops": false, + "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/2.6.31.5-x86_64-linode9", + "label": "2.6.31.5-x86_64-linode9", "version": "2.6.31", "kvm": false, "architecture": + "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/2.6.30.5-x86_64-linode8", "label": "2.6.30.5-x86_64-linode8", "version": "2.6.30", "kvm": false, "architecture": "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/2.6.18.8-x86_64-linode7", "label": "2.6.18.8-x86_64-linode7", "version": "2.6.18", "kvm": false, "architecture": @@ -949,7 +958,7 @@ interactions: "2018-01-02T03:04:05"}, {"id": "linode/pv-grub_x86_64", "label": "pv-grub-x86_64", "version": "2.6.26", "kvm": false, "architecture": "x86_64", "pvops": false, "deprecated": false, "built": "2018-01-02T03:04:05"}], "page": 4, "pages": 4, - "results": 314}' + "results": 318}' headers: Access-Control-Allow-Credentials: - "true" @@ -1009,11 +1018,21 @@ interactions: true, "built": "2018-01-02T03:04:05"}, {"id": "linode/latest-2.6", "label": "Latest 2.6 Stable (2.6.23.17-linode44)", "version": "2.6.24", "kvm": false, "architecture": "i386", "pvops": false, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/latest-32bit", "label": "Latest 32 bit (5.19.2-x86-linode176)", - "version": "5.19.2", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": + {"id": "linode/latest-32bit", "label": "Latest 32 bit (6.0.2-x86-linode177)", + "version": "6.0.2", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": false, "built": "2018-01-02T03:04:05"}, {"id": "linode/2.6.18.8-linode22", "label": "Latest Legacy (2.6.18.8-linode22)", "version": "2.6.18", "kvm": false, "architecture": "i386", "pvops": false, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/6.0.10-x86_64-linode158", "label": "6.0.10-x86_64-linode158", + "version": "6.0.10", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": + false, "built": "2018-01-02T03:04:05"}, {"id": "linode/6.0.10-x86-linode178", + "label": "6.0.10-x86-linode178", "version": "6.0.10", "kvm": true, "architecture": + "i386", "pvops": true, "deprecated": false, "built": "2018-01-02T03:04:05"}, + {"id": "linode/6.0.2-x86_64-linode157", "label": "6.0.2-x86_64-linode157", "version": + "6.0.2", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": + false, "built": "2018-01-02T03:04:05"}, {"id": "linode/6.0.2-x86-linode177", + "label": "6.0.2-x86-linode177", "version": "6.0.2", "kvm": true, "architecture": + "i386", "pvops": true, "deprecated": false, "built": "2018-01-02T03:04:05"}, {"id": "linode/5.19.2-x86_64-linode156", "label": "5.19.2-x86_64-linode156", "version": "5.19.2", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": false, "built": "2018-01-02T03:04:05"}, {"id": "linode/5.19.2-x86-linode176", @@ -1242,17 +1261,7 @@ interactions: "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.9.7-x86-linode99", "label": "4.9.7-x86-linode99", "version": "4.9.7", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, - "built": "2018-01-02T03:04:05"}, {"id": "linode/4.9.0-x86-linode98", "label": - "4.9.0-x86-linode98", "version": "4.9.0", "kvm": true, "architecture": "i386", - "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.8.6-x86-linode97", - "label": "4.8.6-x86-linode97", "version": "4.8.6", "kvm": true, "architecture": - "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/4.8.4-x86-linode96", "label": "4.8.4-x86-linode96", "version": - "4.8.4", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, - "built": "2018-01-02T03:04:05"}, {"id": "linode/4.8.3-x86-linode95", "label": - "4.8.3-x86-linode95", "version": "4.8.3", "kvm": true, "architecture": "i386", - "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}], "page": - 1, "pages": 4, "results": 314}' + "built": "2018-01-02T03:04:05"}], "page": 1, "pages": 4, "results": 318}' headers: Access-Control-Allow-Credentials: - "true" @@ -1307,50 +1316,59 @@ interactions: url: https://api.linode.com/v4beta/linode/kernels?page=2 method: GET response: - body: '{"data": [{"id": "linode/4.8.1-x86-linode94", "label": "4.8.1-x86-linode94", - "version": "4.8.1", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": - true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.7.3-x86-linode92", "label": - "4.7.3-x86-linode92", "version": "4.7.3", "kvm": true, "architecture": "i386", - "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.7.0-x86-linode90", - "label": "4.7.0-x86-linode90", "version": "4.7.0", "kvm": true, "architecture": - "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/4.6.5-x86-linode89", "label": "4.6.5-x86-linode89", "version": - "4.6.5", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, - "built": "2018-01-02T03:04:05"}, {"id": "linode/4.5.5-x86-linode88", "label": - "4.5.5-x86-linode88", "version": "4.5.5", "kvm": true, "architecture": "i386", - "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.5.3-x86-linode86", - "label": "4.5.3-x86-linode86", "version": "4.5.3", "kvm": true, "architecture": - "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/4.5.0-x86-linode84", "label": "4.5.0-x86-linode84", "version": - "4.5.0", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, - "built": "2018-01-02T03:04:05"}, {"id": "linode/4.4.4-x86-linode83", "label": - "4.4.4-x86-linode83", "version": "4.4.4", "kvm": true, "architecture": "i386", - "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.4.0-x86-linode82", - "label": "4.4.0-x86-linode82", "version": "4.4.0", "kvm": true, "architecture": - "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/4.1.5-x86-linode80", "label": "4.1.5-x86-linode80", "version": - "4.1.5", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, - "built": "2018-01-02T03:04:05"}, {"id": "linode/4.1.5-x86-linode79", "label": - "4.1.5-x86-linode79", "version": "4.1.5", "kvm": true, "architecture": "i386", - "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.1.0-x86-linode78", - "label": "4.1.0-x86-linode78", "version": "4.1.0", "kvm": true, "architecture": - "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/4.0.5-x86-linode77", "label": "4.0.5-x86-linode77", "version": - "4.0.5", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, - "built": "2018-01-02T03:04:05"}, {"id": "linode/4.0.5-x86-linode76", "label": - "4.0.5-x86-linode76", "version": "4.0.5", "kvm": false, "architecture": "i386", - "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.0.4-x86-linode75", - "label": "4.0.4-x86-linode75", "version": "4.0.4", "kvm": false, "architecture": - "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/4.0.2-x86-linode74", "label": "4.0.2-x86-linode74", "version": - "4.0.2", "kvm": false, "architecture": "i386", "pvops": true, "deprecated": - true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.0-x86-linode73", "label": - "4.0.1-x86-linode73", "version": "4.0.1", "kvm": false, "architecture": "i386", - "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.0-x86-linode72", - "label": "4.0-x86-linode72", "version": "4.0", "kvm": false, "architecture": - "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/3.19.1-x86-linode71", "label": "3.19.1-x86-linode71", "version": - "3.19.1", "kvm": false, "architecture": "i386", "pvops": true, "deprecated": + body: '{"data": [{"id": "linode/4.9.0-x86-linode98", "label": "4.9.0-x86-linode98", + "version": "4.9.0", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": + true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.8.6-x86-linode97", "label": + "4.8.6-x86-linode97", "version": "4.8.6", "kvm": true, "architecture": "i386", + "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.8.4-x86-linode96", + "label": "4.8.4-x86-linode96", "version": "4.8.4", "kvm": true, "architecture": + "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.8.3-x86-linode95", "label": "4.8.3-x86-linode95", "version": + "4.8.3", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, + "built": "2018-01-02T03:04:05"}, {"id": "linode/4.8.1-x86-linode94", "label": + "4.8.1-x86-linode94", "version": "4.8.1", "kvm": true, "architecture": "i386", + "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.7.3-x86-linode92", + "label": "4.7.3-x86-linode92", "version": "4.7.3", "kvm": true, "architecture": + "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.7.0-x86-linode90", "label": "4.7.0-x86-linode90", "version": + "4.7.0", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, + "built": "2018-01-02T03:04:05"}, {"id": "linode/4.6.5-x86-linode89", "label": + "4.6.5-x86-linode89", "version": "4.6.5", "kvm": true, "architecture": "i386", + "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.5.5-x86-linode88", + "label": "4.5.5-x86-linode88", "version": "4.5.5", "kvm": true, "architecture": + "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.5.3-x86-linode86", "label": "4.5.3-x86-linode86", "version": + "4.5.3", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, + "built": "2018-01-02T03:04:05"}, {"id": "linode/4.5.0-x86-linode84", "label": + "4.5.0-x86-linode84", "version": "4.5.0", "kvm": true, "architecture": "i386", + "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.4.4-x86-linode83", + "label": "4.4.4-x86-linode83", "version": "4.4.4", "kvm": true, "architecture": + "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.4.0-x86-linode82", "label": "4.4.0-x86-linode82", "version": + "4.4.0", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, + "built": "2018-01-02T03:04:05"}, {"id": "linode/4.1.5-x86-linode80", "label": + "4.1.5-x86-linode80", "version": "4.1.5", "kvm": true, "architecture": "i386", + "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.1.5-x86-linode79", + "label": "4.1.5-x86-linode79", "version": "4.1.5", "kvm": true, "architecture": + "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.1.0-x86-linode78", "label": "4.1.0-x86-linode78", "version": + "4.1.0", "kvm": true, "architecture": "i386", "pvops": true, "deprecated": true, + "built": "2018-01-02T03:04:05"}, {"id": "linode/4.0.5-x86-linode77", "label": + "4.0.5-x86-linode77", "version": "4.0.5", "kvm": true, "architecture": "i386", + "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.0.5-x86-linode76", + "label": "4.0.5-x86-linode76", "version": "4.0.5", "kvm": false, "architecture": + "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.0.4-x86-linode75", "label": "4.0.4-x86-linode75", "version": + "4.0.4", "kvm": false, "architecture": "i386", "pvops": true, "deprecated": + true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.0.2-x86-linode74", "label": + "4.0.2-x86-linode74", "version": "4.0.2", "kvm": false, "architecture": "i386", + "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.0-x86-linode73", + "label": "4.0.1-x86-linode73", "version": "4.0.1", "kvm": false, "architecture": + "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.0-x86-linode72", "label": "4.0-x86-linode72", "version": "4.0", + "kvm": false, "architecture": "i386", "pvops": true, "deprecated": true, "built": + "2018-01-02T03:04:05"}, {"id": "linode/3.19.1-x86-linode71", "label": "3.19.1-x86-linode71", + "version": "3.19.1", "kvm": false, "architecture": "i386", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/3.18.5-x86-linode70", "label": "3.18.5-x86-linode70", "version": "3.18.5", "kvm": false, "architecture": "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, @@ -1500,8 +1518,8 @@ interactions: true, "built": null}, {"id": "linode/latest-2.6-64bit", "label": "Latest 2.6 (2.6.39.1-x86_64-linode19)", "version": "2.6.39", "kvm": false, "architecture": "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/latest-64bit", "label": "Latest 64 bit (5.19.2-x86_64-linode156)", - "version": "5.19.2", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": + {"id": "linode/latest-64bit", "label": "Latest 64 bit (6.0.2-x86_64-linode157)", + "version": "6.0.2", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": false, "built": "2018-01-02T03:04:05"}, {"id": "linode/2.6.18.8-x86_64-linode10", "label": "Latest Legacy (2.6.18.8-x86_64-linode10)", "version": "2.6.18", "kvm": false, "architecture": "x86_64", "pvops": false, "deprecated": true, "built": @@ -1534,18 +1552,8 @@ interactions: "version": "4.14.120", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/5.1.2-x86_64-linode124", "label": "5.1.2-x86_64-linode124", "version": "5.1.2", "kvm": true, "architecture": - "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/5.0.8-x86_64-linode123", "label": "5.0.8-x86_64-linode123", "version": - "5.0.8", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": - true, "built": "2018-01-02T03:04:05"}, {"id": "linode/5.0.1-x86_64-linode122", - "label": "5.0.1-x86_64-linode122", "version": "5.0.1", "kvm": true, "architecture": - "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/4.20.4-x86_64-linode121", "label": "4.20.4-x86_64-linode121", - "version": "4.20.4", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": - true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.19.8-x86_64-linode120", - "label": "4.19.8-x86_64-linode120", "version": "4.19.8", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}], - "page": 2, "pages": 4, "results": 314}' + "page": 2, "pages": 4, "results": 318}' headers: Access-Control-Allow-Credentials: - "true" @@ -1600,7 +1608,17 @@ interactions: url: https://api.linode.com/v4beta/linode/kernels?page=3 method: GET response: - body: '{"data": [{"id": "linode/4.19.5-x86_64-linode119", "label": "4.19.5-x86_64-linode119", + body: '{"data": [{"id": "linode/5.0.8-x86_64-linode123", "label": "5.0.8-x86_64-linode123", + "version": "5.0.8", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": + true, "built": "2018-01-02T03:04:05"}, {"id": "linode/5.0.1-x86_64-linode122", + "label": "5.0.1-x86_64-linode122", "version": "5.0.1", "kvm": true, "architecture": + "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.20.4-x86_64-linode121", "label": "4.20.4-x86_64-linode121", + "version": "4.20.4", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": + true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.19.8-x86_64-linode120", + "label": "4.19.8-x86_64-linode120", "version": "4.19.8", "kvm": true, "architecture": + "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/4.19.5-x86_64-linode119", "label": "4.19.5-x86_64-linode119", "version": "4.19.5", "kvm": true, "architecture": "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/4.18.16-x86_64-linode118", "label": "4.18.16-x86_64-linode118", "version": "4.18.16", "kvm": true, "architecture": @@ -1839,18 +1857,8 @@ interactions: "2.6.34", "kvm": false, "architecture": "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/2.6.34-x86_64-linode14", "label": "2.6.34-x86_64-linode14", "version": "2.6.34", "kvm": false, "architecture": - "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/2.6.32.12-x86_64-linode12", "label": "2.6.32.12-x86_64-linode12", - "version": "2.6.32", "kvm": false, "architecture": "x86_64", "pvops": true, - "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/2.6.32-x86_64-linode11", - "label": "2.6.32-x86_64-linode11", "version": "2.6.32", "kvm": false, "architecture": - "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, - {"id": "linode/2.6.18.8-x86_64-linode10", "label": "2.6.18.8-x86_64-linode10", - "version": "2.6.18", "kvm": false, "architecture": "x86_64", "pvops": false, - "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/2.6.31.5-x86_64-linode9", - "label": "2.6.31.5-x86_64-linode9", "version": "2.6.31", "kvm": false, "architecture": "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}], - "page": 3, "pages": 4, "results": 314}' + "page": 3, "pages": 4, "results": 318}' headers: Access-Control-Allow-Credentials: - "true" @@ -1905,7 +1913,17 @@ interactions: url: https://api.linode.com/v4beta/linode/kernels?page=4 method: GET response: - body: '{"data": [{"id": "linode/2.6.30.5-x86_64-linode8", "label": "2.6.30.5-x86_64-linode8", + body: '{"data": [{"id": "linode/2.6.32.12-x86_64-linode12", "label": "2.6.32.12-x86_64-linode12", + "version": "2.6.32", "kvm": false, "architecture": "x86_64", "pvops": true, + "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/2.6.32-x86_64-linode11", + "label": "2.6.32-x86_64-linode11", "version": "2.6.32", "kvm": false, "architecture": + "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/2.6.18.8-x86_64-linode10", "label": "2.6.18.8-x86_64-linode10", + "version": "2.6.18", "kvm": false, "architecture": "x86_64", "pvops": false, + "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/2.6.31.5-x86_64-linode9", + "label": "2.6.31.5-x86_64-linode9", "version": "2.6.31", "kvm": false, "architecture": + "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, + {"id": "linode/2.6.30.5-x86_64-linode8", "label": "2.6.30.5-x86_64-linode8", "version": "2.6.30", "kvm": false, "architecture": "x86_64", "pvops": true, "deprecated": true, "built": "2018-01-02T03:04:05"}, {"id": "linode/2.6.18.8-x86_64-linode7", "label": "2.6.18.8-x86_64-linode7", "version": "2.6.18", "kvm": false, "architecture": @@ -1939,7 +1957,7 @@ interactions: "2018-01-02T03:04:05"}, {"id": "linode/pv-grub_x86_64", "label": "pv-grub-x86_64", "version": "2.6.26", "kvm": false, "architecture": "x86_64", "pvops": false, "deprecated": false, "built": "2018-01-02T03:04:05"}], "page": 4, "pages": 4, - "results": 314}' + "results": 318}' headers: Access-Control-Allow-Credentials: - "true" diff --git a/test/integration/fixtures/TestCache_RegionList.yaml b/test/integration/fixtures/TestCache_RegionList.yaml index 561024a30..723e27bc1 100644 --- a/test/integration/fixtures/TestCache_RegionList.yaml +++ b/test/integration/fixtures/TestCache_RegionList.yaml @@ -51,7 +51,7 @@ interactions: "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}}, {"id": "ap-south", "country": "sg", "capabilities": ["Linodes", "NodeBalancers", "Block Storage", "Object Storage", "GPU Linodes", "Kubernetes", "Cloud Firewall", - "Block Storage Migrations", "Managed Databases"], "status": "ok", "resolvers": + "Vlans", "Block Storage Migrations", "Managed Databases"], "status": "ok", "resolvers": {"ipv4": "139.162.11.5,139.162.13.5,139.162.14.5,139.162.15.5,139.162.16.5,139.162.21.5,139.162.27.5,103.3.60.18,103.3.60.19,103.3.60.20", "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}}, {"id": "eu-central", "country": "de", "capabilities": ["Linodes", "NodeBalancers", @@ -155,7 +155,7 @@ interactions: "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}}, {"id": "ap-south", "country": "sg", "capabilities": ["Linodes", "NodeBalancers", "Block Storage", "Object Storage", "GPU Linodes", "Kubernetes", "Cloud Firewall", - "Block Storage Migrations", "Managed Databases"], "status": "ok", "resolvers": + "Vlans", "Block Storage Migrations", "Managed Databases"], "status": "ok", "resolvers": {"ipv4": "139.162.11.5,139.162.13.5,139.162.14.5,139.162.15.5,139.162.16.5,139.162.21.5,139.162.27.5,103.3.60.18,103.3.60.19,103.3.60.20", "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}}, {"id": "eu-central", "country": "de", "capabilities": ["Linodes", "NodeBalancers", @@ -259,7 +259,7 @@ interactions: "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}}, {"id": "ap-south", "country": "sg", "capabilities": ["Linodes", "NodeBalancers", "Block Storage", "Object Storage", "GPU Linodes", "Kubernetes", "Cloud Firewall", - "Block Storage Migrations", "Managed Databases"], "status": "ok", "resolvers": + "Vlans", "Block Storage Migrations", "Managed Databases"], "status": "ok", "resolvers": {"ipv4": "139.162.11.5,139.162.13.5,139.162.14.5,139.162.15.5,139.162.16.5,139.162.21.5,139.162.27.5,103.3.60.18,103.3.60.19,103.3.60.20", "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}}, {"id": "eu-central", "country": "de", "capabilities": ["Linodes", "NodeBalancers", @@ -363,7 +363,7 @@ interactions: "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}}, {"id": "ap-south", "country": "sg", "capabilities": ["Linodes", "NodeBalancers", "Block Storage", "Object Storage", "GPU Linodes", "Kubernetes", "Cloud Firewall", - "Block Storage Migrations", "Managed Databases"], "status": "ok", "resolvers": + "Vlans", "Block Storage Migrations", "Managed Databases"], "status": "ok", "resolvers": {"ipv4": "139.162.11.5,139.162.13.5,139.162.14.5,139.162.15.5,139.162.16.5,139.162.21.5,139.162.27.5,103.3.60.18,103.3.60.19,103.3.60.20", "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}}, {"id": "eu-central", "country": "de", "capabilities": ["Linodes", "NodeBalancers", diff --git a/types.go b/types.go index c5895e2f2..ee6e4c8ca 100644 --- a/types.go +++ b/types.go @@ -72,20 +72,21 @@ func (resp *LinodeTypesPagedResponse) castResult(r *resty.Request, e string) (in func (c *Client) ListTypes(ctx context.Context, opts *ListOptions) ([]LinodeType, error) { response := LinodeTypesPagedResponse{} - if result, err := c.getCachedResponse(response.endpoint()); err != nil { + endpoint, err := generateListCacheURL(response.endpoint(), opts) + if err != nil { return nil, err - } else if result != nil { + } + + if result := c.getCachedResponse(endpoint); result != nil { return result.([]LinodeType), nil } - err := c.listHelper(ctx, &response, opts) + err = c.listHelper(ctx, &response, opts) if err != nil { return nil, err } - if err := c.addCachedResponse(response.endpoint(), response.Data, &cacheExpiryTime); err != nil { - return nil, err - } + c.addCachedResponse(endpoint, response.Data, &cacheExpiryTime) return response.Data, nil } @@ -94,9 +95,7 @@ func (c *Client) ListTypes(ctx context.Context, opts *ListOptions) ([]LinodeType func (c *Client) GetType(ctx context.Context, typeID string) (*LinodeType, error) { e := fmt.Sprintf("linode/types/%s", typeID) - if result, err := c.getCachedResponse(e); err != nil { - return nil, err - } else if result != nil { + if result := c.getCachedResponse(e); result != nil { result := result.(LinodeType) return &result, nil } @@ -107,9 +106,7 @@ func (c *Client) GetType(ctx context.Context, typeID string) (*LinodeType, error return nil, err } - if err := c.addCachedResponse(e, r.Result(), &cacheExpiryTime); err != nil { - return nil, err - } + c.addCachedResponse(e, r.Result(), &cacheExpiryTime) return r.Result().(*LinodeType), nil }