diff --git a/fastly/account_events.go b/fastly/account_events.go index 39f89a79f..4de5705c2 100644 --- a/fastly/account_events.go +++ b/fastly/account_events.go @@ -95,7 +95,8 @@ func (c *Client) GetAPIEvent(i *GetAPIEventInput) (*Event, error) { return nil, ErrMissingEventID } - path := fmt.Sprintf("/events/%s", i.EventID) + path := ToSafeURL("events", i.EventID) + resp, err := c.Get(path, nil) if err != nil { return nil, err diff --git a/fastly/acl.go b/fastly/acl.go index 563617f90..f14723e28 100644 --- a/fastly/acl.go +++ b/fastly/acl.go @@ -2,7 +2,7 @@ package fastly import ( "fmt" - "net/url" + "strconv" "time" ) @@ -34,7 +34,8 @@ func (c *Client) ListACLs(i *ListACLsInput) ([]*ACL, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/acl", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "acl") + resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -67,7 +68,8 @@ func (c *Client) CreateACL(i *CreateACLInput) (*ACL, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/acl", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "acl") + resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -103,7 +105,8 @@ func (c *Client) DeleteACL(i *DeleteACLInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/acl/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "acl", i.Name) + resp, err := c.Delete(path, nil) if err != nil { return err @@ -142,7 +145,8 @@ func (c *Client) GetACL(i *GetACLInput) (*ACL, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/acl/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "acl", i.Name) + resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -180,7 +184,8 @@ func (c *Client) UpdateACL(i *UpdateACLInput) (*ACL, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/acl/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "acl", i.Name) + resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err diff --git a/fastly/acl_entry.go b/fastly/acl_entry.go index 105709c19..7b25a9575 100644 --- a/fastly/acl_entry.go +++ b/fastly/acl_entry.go @@ -19,8 +19,6 @@ type ACLEntry struct { UpdatedAt *time.Time `mapstructure:"updated_at"` } -const aclEntriesPath = "/service/%s/acl/%s/entries" - // GetACLEntriesInput is the input parameter to GetACLEntries function. type GetACLEntriesInput struct { // ACLID is an alphanumeric string identifying a ACL (required). @@ -52,7 +50,7 @@ func (c *Client) GetACLEntries(i *GetACLEntriesInput) *ListPaginator[ACLEntry] { if i.PerPage != nil { input.PerPage = *i.PerPage } - path := fmt.Sprintf(aclEntriesPath, i.ServiceID, i.ACLID) + path := ToSafeURL("service", i.ServiceID, "acl", i.ACLID, "entries") return NewPaginator[ACLEntry](c, input, path) } @@ -115,7 +113,7 @@ func (c *Client) GetACLEntry(i *GetACLEntryInput) (*ACLEntry, error) { return nil, ErrMissingServiceID } - path := fmt.Sprintf("/service/%s/acl/%s/entry/%s", i.ServiceID, i.ACLID, i.EntryID) + path := ToSafeURL("service", i.ServiceID, "acl", i.ACLID, "entry", i.EntryID) resp, err := c.Get(path, nil) if err != nil { @@ -194,7 +192,7 @@ func (c *Client) DeleteACLEntry(i *DeleteACLEntryInput) error { return ErrMissingServiceID } - path := fmt.Sprintf("/service/%s/acl/%s/entry/%s", i.ServiceID, i.ACLID, i.EntryID) + path := ToSafeURL("service", i.ServiceID, "acl", i.ACLID, "entry", i.EntryID) resp, err := c.Delete(path, nil) if err != nil { @@ -244,7 +242,7 @@ func (c *Client) UpdateACLEntry(i *UpdateACLEntryInput) (*ACLEntry, error) { return nil, ErrMissingServiceID } - path := fmt.Sprintf("/service/%s/acl/%s/entry/%s", i.ServiceID, i.ACLID, i.EntryID) + path := ToSafeURL("service", i.ServiceID, "acl", i.ACLID, "entry", i.EntryID) resp, err := c.RequestForm("PATCH", path, i, nil) if err != nil { @@ -299,7 +297,8 @@ func (c *Client) BatchModifyACLEntries(i *BatchModifyACLEntriesInput) error { return ErrMaxExceededEntries } - path := fmt.Sprintf(aclEntriesPath, i.ServiceID, i.ACLID) + path := ToSafeURL("service", i.ServiceID, "acl", i.ACLID, "entries") + resp, err := c.PatchJSON(path, i, nil) if err != nil { return err diff --git a/fastly/alerts.go b/fastly/alerts.go index 8ef210813..396f72cce 100644 --- a/fastly/alerts.go +++ b/fastly/alerts.go @@ -2,7 +2,6 @@ package fastly import ( "encoding/json" - "fmt" "net/http" "strconv" "time" @@ -151,7 +150,8 @@ func (c *Client) GetAlertDefinition(i *GetAlertDefinitionInput) (*AlertDefinitio return nil, ErrMissingID } - path := fmt.Sprintf("/alerts/definitions/%s", *i.ID) + path := ToSafeURL("alerts", "definitions", *i.ID) + resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -190,7 +190,8 @@ func (c *Client) UpdateAlertDefinition(i *UpdateAlertDefinitionInput) (*AlertDef return nil, ErrMissingID } - path := fmt.Sprintf("/alerts/definitions/%s", *i.ID) + path := ToSafeURL("alerts", "definitions", *i.ID) + resp, err := c.PutJSON(path, i, nil) if err != nil { return nil, err @@ -216,7 +217,8 @@ func (c *Client) DeleteAlertDefinition(i *DeleteAlertDefinitionInput) error { return ErrMissingID } - path := fmt.Sprintf("/alerts/definitions/%s", *i.ID) + path := ToSafeURL("alerts", "definitions", *i.ID) + resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/backend.go b/fastly/backend.go index 6015ed81a..4f041d159 100644 --- a/fastly/backend.go +++ b/fastly/backend.go @@ -2,7 +2,7 @@ package fastly import ( "fmt" - "net/url" + "strconv" "time" ) @@ -64,7 +64,8 @@ func (c *Client) ListBackends(i *ListBackendsInput) ([]*Backend, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/backend", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "backend") + resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -157,7 +158,8 @@ func (c *Client) CreateBackend(i *CreateBackendInput) (*Backend, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/backend", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "backend") + resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -193,7 +195,8 @@ func (c *Client) GetBackend(i *GetBackendInput) (*Backend, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/backend/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "backend", i.Name) + resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -291,7 +294,8 @@ func (c *Client) UpdateBackend(i *UpdateBackendInput) (*Backend, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/backend/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "backend", i.Name) + resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -327,7 +331,8 @@ func (c *Client) DeleteBackend(i *DeleteBackendInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/backend/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "backend", i.Name) + resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/billing.go b/fastly/billing.go index ae7f52a3f..2e8923262 100644 --- a/fastly/billing.go +++ b/fastly/billing.go @@ -2,6 +2,7 @@ package fastly import ( "fmt" + "strconv" "time" ) @@ -68,7 +69,8 @@ func (c *Client) GetBilling(i *GetBillingInput) (*Billing, error) { return nil, ErrMissingMonth } - path := fmt.Sprintf("/billing/year/%d/month/%02d", i.Year, i.Month) + path := ToSafeURL("billing", "year", strconv.Itoa(int(i.Year)), "month", fmt.Sprintf("%02d", i.Month)) + resp, err := c.Get(path, nil) if err != nil { return nil, err diff --git a/fastly/compute_package.go b/fastly/compute_package.go index ab29e62c4..1d543c5f6 100644 --- a/fastly/compute_package.go +++ b/fastly/compute_package.go @@ -3,8 +3,8 @@ package fastly import ( "bytes" "errors" - "fmt" "io" + "strconv" "time" ) @@ -107,7 +107,7 @@ func MakePackagePath(serviceID string, serviceVersion int) (string, error) { if serviceVersion == 0 { return "", ErrMissingServiceVersion } - return fmt.Sprintf("/service/%s/version/%d/package", serviceID, serviceVersion), nil + return ToSafeURL("service", serviceID, "version", strconv.Itoa(serviceVersion), "package"), nil } // PopulatePackage encapsulates the decoding of returned package data. diff --git a/fastly/config_store.go b/fastly/config_store.go index 20d363e0d..32d740ec2 100644 --- a/fastly/config_store.go +++ b/fastly/config_store.go @@ -2,7 +2,6 @@ package fastly import ( "encoding/json" - "fmt" "sort" "time" ) @@ -68,7 +67,8 @@ func (c *Client) DeleteConfigStore(i *DeleteConfigStoreInput) error { return ErrMissingStoreID } - path := fmt.Sprintf("/resources/stores/config/%s", i.StoreID) + path := ToSafeURL("resources", "stores", "config", i.StoreID) + resp, err := c.Delete(path, &RequestOptions{ Headers: map[string]string{ "Accept": "application/json", @@ -97,7 +97,8 @@ func (c *Client) GetConfigStore(i *GetConfigStoreInput) (*ConfigStore, error) { return nil, ErrMissingStoreID } - path := fmt.Sprintf("/resources/stores/config/%s", i.StoreID) + path := ToSafeURL("resources", "stores", "config", i.StoreID) + resp, err := c.Get(path, &RequestOptions{ Headers: map[string]string{ "Accept": "application/json", @@ -129,7 +130,8 @@ func (c *Client) GetConfigStoreMetadata(i *GetConfigStoreMetadataInput) (*Config return nil, ErrMissingStoreID } - path := fmt.Sprintf("/resources/stores/config/%s/info", i.StoreID) + path := ToSafeURL("resources", "stores", "config", i.StoreID, "info") + resp, err := c.Get(path, &RequestOptions{ Headers: map[string]string{ "Accept": "application/json", @@ -200,7 +202,8 @@ func (c *Client) ListConfigStoreServices(i *ListConfigStoreServicesInput) ([]*Se return nil, ErrMissingStoreID } - path := fmt.Sprintf("/resources/stores/config/%s/services", i.StoreID) + path := ToSafeURL("resources", "stores", "config", i.StoreID, "services") + resp, err := c.Get(path, &RequestOptions{ Headers: map[string]string{ "Accept": "application/json", @@ -235,7 +238,8 @@ func (c *Client) UpdateConfigStore(i *UpdateConfigStoreInput) (*ConfigStore, err return nil, ErrMissingStoreID } - path := fmt.Sprintf("/resources/stores/config/%s", i.StoreID) + path := ToSafeURL("resources", "stores", "config", i.StoreID) + resp, err := c.PutForm(path, i, &RequestOptions{ Headers: map[string]string{ // PutForm adds the appropriate Content-Type header. diff --git a/fastly/config_store_item.go b/fastly/config_store_item.go index d7f4d3a53..9f870a518 100644 --- a/fastly/config_store_item.go +++ b/fastly/config_store_item.go @@ -2,9 +2,7 @@ package fastly import ( "encoding/json" - "fmt" "net/http" - "net/url" "sort" "time" ) @@ -38,7 +36,8 @@ func (c *Client) CreateConfigStoreItem(i *CreateConfigStoreItemInput) (*ConfigSt return nil, ErrMissingStoreID } - path := fmt.Sprintf("/resources/stores/config/%s/item", i.StoreID) + path := ToSafeURL("resources", "stores", "config", i.StoreID, "item") + resp, err := c.PostForm(path, i, &RequestOptions{ Headers: map[string]string{ // PostForm adds the appropriate Content-Type header. @@ -76,7 +75,8 @@ func (c *Client) DeleteConfigStoreItem(i *DeleteConfigStoreItemInput) error { return ErrMissingKey } - path := fmt.Sprintf("/resources/stores/config/%s/item/%s", i.StoreID, url.PathEscape(i.Key)) + path := ToSafeURL("resources", "stores", "config", i.StoreID, "item", i.Key) + resp, err := c.Delete(path, &RequestOptions{ Headers: map[string]string{ "Accept": "application/json", @@ -110,7 +110,8 @@ func (c *Client) GetConfigStoreItem(i *GetConfigStoreItemInput) (*ConfigStoreIte return nil, ErrMissingKey } - path := fmt.Sprintf("/resources/stores/config/%s/item/%s", i.StoreID, url.PathEscape(i.Key)) + path := ToSafeURL("resources", "stores", "config", i.StoreID, "item", i.Key) + resp, err := c.Get(path, &RequestOptions{ Headers: map[string]string{ "Accept": "application/json", @@ -142,7 +143,8 @@ func (c *Client) ListConfigStoreItems(i *ListConfigStoreItemsInput) ([]*ConfigSt return nil, ErrMissingStoreID } - path := fmt.Sprintf("/resources/stores/config/%s/items", i.StoreID) + path := ToSafeURL("resources", "stores", "config", i.StoreID, "items") + resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -181,7 +183,7 @@ func (c *Client) UpdateConfigStoreItem(i *UpdateConfigStoreItemInput) (*ConfigSt return nil, ErrMissingKey } - path := fmt.Sprintf("/resources/stores/config/%s/item/%s", i.StoreID, url.PathEscape(i.Key)) + path := ToSafeURL("resources", "stores", "config", i.StoreID, "item", i.Key) var httpMethod string if i.Upsert { @@ -240,7 +242,8 @@ func (c *Client) BatchModifyConfigStoreItems(i *BatchModifyConfigStoreItemsInput return ErrMaxExceededItems } - path := fmt.Sprintf("/resources/stores/config/%s/items", i.StoreID) + path := ToSafeURL("resources", "stores", "config", i.StoreID, "items") + resp, err := c.PatchJSON(path, i, nil) if err != nil { return err diff --git a/fastly/dictionary.go b/fastly/dictionary.go index aa31ea77d..ffba312a6 100644 --- a/fastly/dictionary.go +++ b/fastly/dictionary.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -35,7 +34,8 @@ func (c *Client) ListDictionaries(i *ListDictionariesInput) ([]*Dictionary, erro return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/dictionary", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "dictionary") + resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -70,7 +70,8 @@ func (c *Client) CreateDictionary(i *CreateDictionaryInput) (*Dictionary, error) return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/dictionary", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "dictionary") + resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -106,7 +107,8 @@ func (c *Client) GetDictionary(i *GetDictionaryInput) (*Dictionary, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/dictionary/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "dictionary", i.Name) + resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -146,7 +148,8 @@ func (c *Client) UpdateDictionary(i *UpdateDictionaryInput) (*Dictionary, error) return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/dictionary/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "dictionary", i.Name) + resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -182,7 +185,8 @@ func (c *Client) DeleteDictionary(i *DeleteDictionaryInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/dictionary/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "dictionary", i.Name) + resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/dictionary_info.go b/fastly/dictionary_info.go index b2253312e..deecd8929 100644 --- a/fastly/dictionary_info.go +++ b/fastly/dictionary_info.go @@ -1,7 +1,7 @@ package fastly import ( - "fmt" + "strconv" "time" ) @@ -37,7 +37,8 @@ func (c *Client) GetDictionaryInfo(i *GetDictionaryInfoInput) (*DictionaryInfo, return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/dictionary/%s/info", i.ServiceID, i.ServiceVersion, i.DictionaryID) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "dictionary", i.DictionaryID, "info") + resp, err := c.Get(path, nil) if err != nil { return nil, err diff --git a/fastly/dictionary_item.go b/fastly/dictionary_item.go index 90e45c547..a3ad348ac 100644 --- a/fastly/dictionary_item.go +++ b/fastly/dictionary_item.go @@ -2,12 +2,9 @@ package fastly import ( "fmt" - "net/url" "time" ) -const dictionaryItemsPath = "/service/%s/dictionary/%s/items" - // DictionaryItem represents a dictionary item response from the Fastly API. type DictionaryItem struct { CreatedAt *time.Time `mapstructure:"created_at"` @@ -50,7 +47,9 @@ func (c *Client) GetDictionaryItems(i *GetDictionaryItemsInput) *ListPaginator[D if i.PerPage != nil { input.PerPage = *i.PerPage } - path := fmt.Sprintf(dictionaryItemsPath, i.ServiceID, i.DictionaryID) + + path := ToSafeURL("service", i.ServiceID, "dictionary", i.DictionaryID, "items") + return NewPaginator[DictionaryItem](c, input, path) } @@ -113,7 +112,8 @@ func (c *Client) CreateDictionaryItem(i *CreateDictionaryItemInput) (*Dictionary return nil, ErrMissingServiceID } - path := fmt.Sprintf("/service/%s/dictionary/%s/item", i.ServiceID, i.DictionaryID) + path := ToSafeURL("service", i.ServiceID, "dictionary", i.DictionaryID, "item") + resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -166,7 +166,8 @@ func (c *Client) GetDictionaryItem(i *GetDictionaryItemInput) (*DictionaryItem, return nil, ErrMissingServiceID } - path := fmt.Sprintf("/service/%s/dictionary/%s/item/%s", i.ServiceID, i.DictionaryID, url.PathEscape(i.ItemKey)) + path := ToSafeURL("service", i.ServiceID, "dictionary", i.DictionaryID, "item", i.ItemKey) + resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -204,7 +205,8 @@ func (c *Client) UpdateDictionaryItem(i *UpdateDictionaryItemInput) (*Dictionary return nil, ErrMissingServiceID } - path := fmt.Sprintf("/service/%s/dictionary/%s/item/%s", i.ServiceID, i.DictionaryID, url.PathEscape(i.ItemKey)) + path := ToSafeURL("service", i.ServiceID, "dictionary", i.DictionaryID, "item", i.ItemKey) + resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -251,7 +253,8 @@ func (c *Client) BatchModifyDictionaryItems(i *BatchModifyDictionaryItemsInput) return ErrMissingServiceID } - path := fmt.Sprintf(dictionaryItemsPath, i.ServiceID, i.DictionaryID) + path := ToSafeURL("service", i.ServiceID, "dictionary", i.DictionaryID, "items") + resp, err := c.PatchJSON(path, i, nil) if err != nil { return err @@ -284,7 +287,8 @@ func (c *Client) DeleteDictionaryItem(i *DeleteDictionaryItemInput) error { return ErrMissingServiceID } - path := fmt.Sprintf("/service/%s/dictionary/%s/item/%s", i.ServiceID, i.DictionaryID, url.PathEscape(i.ItemKey)) + path := ToSafeURL("service", i.ServiceID, "dictionary", i.DictionaryID, "item", i.ItemKey) + resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/diff.go b/fastly/diff.go index c9df4aca8..67e43117e 100644 --- a/fastly/diff.go +++ b/fastly/diff.go @@ -1,6 +1,6 @@ package fastly -import "fmt" +import "strconv" // Diff represents a diff of two versions as a response from the Fastly API. type Diff struct { @@ -40,7 +40,8 @@ func (c *Client) GetDiff(i *GetDiffInput) (*Diff, error) { return nil, ErrMissingTo } - path := fmt.Sprintf("service/%s/diff/from/%d/to/%d", i.ServiceID, i.From, i.To) + path := ToSafeURL("service", i.ServiceID, "diff", "from", strconv.Itoa(i.From), "to", strconv.Itoa(i.To)) + resp, err := c.Get(path, nil) if err != nil { return nil, err diff --git a/fastly/domain.go b/fastly/domain.go index dd0d867bd..4481ce577 100644 --- a/fastly/domain.go +++ b/fastly/domain.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" "io" - "net/url" + "strconv" "time" ) @@ -36,7 +36,8 @@ func (c *Client) ListDomains(i *ListDomainsInput) ([]*Domain, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/domain", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "domain") + resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -71,7 +72,8 @@ func (c *Client) CreateDomain(i *CreateDomainInput) (*Domain, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/domain", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "domain") + resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -107,7 +109,8 @@ func (c *Client) GetDomain(i *GetDomainInput) (*Domain, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/domain/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "domain", i.Name) + resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -147,7 +150,8 @@ func (c *Client) UpdateDomain(i *UpdateDomainInput) (*Domain, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/domain/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "domain", i.Name) + resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -183,7 +187,8 @@ func (c *Client) DeleteDomain(i *DeleteDomainInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/domain/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "domain", i.Name) + _, err := c.Delete(path, nil) return err } @@ -210,7 +215,8 @@ func (c *Client) ValidateDomain(i *ValidateDomainInput) (*DomainValidationResult return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/domain/%s/check", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "domain", i.Name, "check") + resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -294,7 +300,8 @@ func (c *Client) ValidateAllDomains(i *ValidateAllDomainsInput) (results []*Doma return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/domain/check_all", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "domain", "check_all") + resp, err := c.Get(path, nil) if err != nil { return nil, err diff --git a/fastly/health_check.go b/fastly/health_check.go index 02eb44ace..12550fa98 100644 --- a/fastly/health_check.go +++ b/fastly/health_check.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -45,7 +44,8 @@ func (c *Client) ListHealthChecks(i *ListHealthChecksInput) ([]*HealthCheck, err return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/healthcheck", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "healthcheck") + resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -105,7 +105,8 @@ func (c *Client) CreateHealthCheck(i *CreateHealthCheckInput) (*HealthCheck, err ro := new(RequestOptions) ro.HealthCheckHeaders = true - path := fmt.Sprintf("/service/%s/version/%d/healthcheck", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "healthcheck") + resp, err := c.PostForm(path, i, ro) if err != nil { return nil, err @@ -141,7 +142,8 @@ func (c *Client) GetHealthCheck(i *GetHealthCheckInput) (*HealthCheck, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/healthcheck/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "healthcheck", i.Name) + resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -206,7 +208,8 @@ func (c *Client) UpdateHealthCheck(i *UpdateHealthCheckInput) (*HealthCheck, err ro := new(RequestOptions) ro.HealthCheckHeaders = true - path := fmt.Sprintf("/service/%s/version/%d/healthcheck/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "healthcheck", i.Name) + resp, err := c.PutForm(path, i, ro) if err != nil { return nil, err @@ -242,7 +245,8 @@ func (c *Client) DeleteHealthCheck(i *DeleteHealthCheckInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/healthcheck/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "healthcheck", i.Name) + resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/helpers.go b/fastly/helpers.go index 3b5bb684c..e2fffb6a9 100644 --- a/fastly/helpers.go +++ b/fastly/helpers.go @@ -1,5 +1,7 @@ package fastly +import "net/url" + // MultiConstraint is a generic constraint for ToPointer/ToValue. type MultiConstraint interface { []string | ~string | ~int | int32 | ~int64 | uint | uint8 | uint32 | uint64 | float64 | ~bool @@ -31,3 +33,22 @@ func NullString(v string) *string { } return &v } + +// ToSafeURL produces a safe (no path traversal, no unsafe characters) URL +// from the path components passed in. +func ToSafeURL(components ...string) string { + for idx, component := range components { + if component == ".." { + components[idx] = "" + } else { + components[idx] = url.PathEscape(component) + } + } + + // it is safe to ignore the error returned from JoinPath + // because the only time it will be non-nil is if parsing + // the base path fails, but that will not fail since it is + // a constant "/" string + result, _ := url.JoinPath("/", components...) + return result +} diff --git a/fastly/image_optimizer_default_settings.go b/fastly/image_optimizer_default_settings.go index 0e352547c..fee2647f3 100644 --- a/fastly/image_optimizer_default_settings.go +++ b/fastly/image_optimizer_default_settings.go @@ -2,7 +2,7 @@ package fastly import ( "encoding/json" - "fmt" + "strconv" ) // ImageOptimizerResizeFilter is a base for the different ImageOptimizerResizeFilter variants. @@ -132,7 +132,7 @@ func (c *Client) GetImageOptimizerDefaultSettings(i *GetImageOptimizerDefaultSet return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/image_optimizer_default_settings", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "image_optimizer_default_settings") resp, err := c.Get(path, nil) if err != nil { @@ -170,7 +170,7 @@ func (c *Client) UpdateImageOptimizerDefaultSettings(i *UpdateImageOptimizerDefa return nil, ErrMissingImageOptimizerDefaultSetting } - path := fmt.Sprintf("/service/%s/version/%d/image_optimizer_default_settings", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "image_optimizer_default_settings") resp, err := c.PatchJSON(path, i, nil) if err != nil { diff --git a/fastly/load_balance_pool.go b/fastly/load_balance_pool.go index 14e7fac54..9621ff9a2 100644 --- a/fastly/load_balance_pool.go +++ b/fastly/load_balance_pool.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -68,7 +67,8 @@ func (c *Client) ListPools(i *ListPoolsInput) ([]*Pool, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/pool", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "pool") + resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -141,7 +141,7 @@ func (c *Client) CreatePool(i *CreatePoolInput) (*Pool, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/pool", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "pool") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -177,7 +177,8 @@ func (c *Client) GetPool(i *GetPoolInput) (*Pool, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/pool/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "pool", i.Name) + resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -255,7 +256,8 @@ func (c *Client) UpdatePool(i *UpdatePoolInput) (*Pool, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/pool/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "pool", i.Name) + resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -291,7 +293,8 @@ func (c *Client) DeletePool(i *DeletePoolInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/pool/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "pool", i.Name) + resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/load_balancer_director.go b/fastly/load_balancer_director.go index 043746b30..fbe275cd8 100644 --- a/fastly/load_balancer_director.go +++ b/fastly/load_balancer_director.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -57,7 +56,7 @@ func (c *Client) ListDirectors(i *ListDirectorsInput) ([]*Director, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/director", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "director") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -100,7 +99,7 @@ func (c *Client) CreateDirector(i *CreateDirectorInput) (*Director, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/director", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "director") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -136,7 +135,7 @@ func (c *Client) GetDirector(i *GetDirectorInput) (*Director, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/director/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "director", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -184,7 +183,7 @@ func (c *Client) UpdateDirector(i *UpdateDirectorInput) (*Director, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/director/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "director", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -220,7 +219,7 @@ func (c *Client) DeleteDirector(i *DeleteDirectorInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/director/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "director", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/load_balancer_director_backend.go b/fastly/load_balancer_director_backend.go index 0bfc6ea7d..d38fcacd3 100644 --- a/fastly/load_balancer_director_backend.go +++ b/fastly/load_balancer_director_backend.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -46,8 +45,7 @@ func (c *Client) CreateDirectorBackend(i *CreateDirectorBackendInput) (*Director return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/director/%s/backend/%s", - i.ServiceID, i.ServiceVersion, url.PathEscape(i.Director), url.PathEscape(i.Backend)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "director", i.Director, "backend", i.Backend) resp, err := c.PostForm(path, i, nil) if err != nil { @@ -89,8 +87,7 @@ func (c *Client) GetDirectorBackend(i *GetDirectorBackendInput) (*DirectorBacken return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/director/%s/backend/%s", - i.ServiceID, i.ServiceVersion, url.PathEscape(i.Director), url.PathEscape(i.Backend)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "director", i.Director, "backend", i.Backend) resp, err := c.Get(path, nil) if err != nil { @@ -132,8 +129,7 @@ func (c *Client) DeleteDirectorBackend(i *DeleteDirectorBackendInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/director/%s/backend/%s", - i.ServiceID, i.ServiceVersion, url.PathEscape(i.Director), url.PathEscape(i.Backend)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "director", i.Director, "backend", i.Backend) resp, err := c.Delete(path, nil) if err != nil { diff --git a/fastly/logging_bigquery.go b/fastly/logging_bigquery.go index 1ae9110da..7d454f0c3 100644 --- a/fastly/logging_bigquery.go +++ b/fastly/logging_bigquery.go @@ -2,7 +2,7 @@ package fastly import ( "fmt" - "net/url" + "strconv" "time" ) @@ -44,7 +44,7 @@ func (c *Client) ListBigQueries(i *ListBigQueriesInput) ([]*BigQuery, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "bigquery") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -99,7 +99,7 @@ func (c *Client) CreateBigQuery(i *CreateBigQueryInput) (*BigQuery, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "bigquery") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -135,7 +135,7 @@ func (c *Client) GetBigQuery(i *GetBigQueryInput) (*BigQuery, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "bigquery", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -195,7 +195,7 @@ func (c *Client) UpdateBigQuery(i *UpdateBigQueryInput) (*BigQuery, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "bigquery", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -231,7 +231,7 @@ func (c *Client) DeleteBigQuery(i *DeleteBigQueryInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "bigquery", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_blobstorage.go b/fastly/logging_blobstorage.go index da8123825..a8fc9e83a 100644 --- a/fastly/logging_blobstorage.go +++ b/fastly/logging_blobstorage.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -48,7 +47,7 @@ func (c *Client) ListBlobStorages(i *ListBlobStoragesInput) ([]*BlobStorage, err return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "azureblob") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -111,7 +110,7 @@ func (c *Client) CreateBlobStorage(i *CreateBlobStorageInput) (*BlobStorage, err return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "azureblob") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -147,7 +146,7 @@ func (c *Client) GetBlobStorage(i *GetBlobStorageInput) (*BlobStorage, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "azureblob", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -215,7 +214,7 @@ func (c *Client) UpdateBlobStorage(i *UpdateBlobStorageInput) (*BlobStorage, err return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "azureblob", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -251,7 +250,7 @@ func (c *Client) DeleteBlobStorage(i *DeleteBlobStorageInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "azureblob", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_cloudfiles.go b/fastly/logging_cloudfiles.go index b7662b95d..6cc6fab08 100644 --- a/fastly/logging_cloudfiles.go +++ b/fastly/logging_cloudfiles.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -48,7 +47,7 @@ func (c *Client) ListCloudfiles(i *ListCloudfilesInput) ([]*Cloudfiles, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/cloudfiles", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "cloudfiles") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -111,7 +110,7 @@ func (c *Client) CreateCloudfiles(i *CreateCloudfilesInput) (*Cloudfiles, error) return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/cloudfiles", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "cloudfiles") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -147,7 +146,7 @@ func (c *Client) GetCloudfiles(i *GetCloudfilesInput) (*Cloudfiles, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/cloudfiles/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "cloudfiles", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -215,7 +214,7 @@ func (c *Client) UpdateCloudfiles(i *UpdateCloudfilesInput) (*Cloudfiles, error) return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/cloudfiles/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "cloudfiles", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -251,7 +250,7 @@ func (c *Client) DeleteCloudfiles(i *DeleteCloudfilesInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/cloudfiles/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "cloudfiles", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_datadog.go b/fastly/logging_datadog.go index 5dc424158..e9fc96462 100644 --- a/fastly/logging_datadog.go +++ b/fastly/logging_datadog.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -39,7 +38,7 @@ func (c *Client) ListDatadog(i *ListDatadogInput) ([]*Datadog, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/datadog", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "datadog") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -84,7 +83,7 @@ func (c *Client) CreateDatadog(i *CreateDatadogInput) (*Datadog, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/datadog", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "datadog") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -120,7 +119,7 @@ func (c *Client) GetDatadog(i *GetDatadogInput) (*Datadog, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/datadog/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "datadog", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -170,7 +169,7 @@ func (c *Client) UpdateDatadog(i *UpdateDatadogInput) (*Datadog, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/datadog/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "datadog", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -206,7 +205,7 @@ func (c *Client) DeleteDatadog(i *DeleteDatadogInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/datadog/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "datadog", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_digitalocean.go b/fastly/logging_digitalocean.go index 3f1cdf08a..db2e57a36 100644 --- a/fastly/logging_digitalocean.go +++ b/fastly/logging_digitalocean.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -48,7 +47,7 @@ func (c *Client) ListDigitalOceans(i *ListDigitalOceansInput) ([]*DigitalOcean, return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/digitalocean", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "digitalocean") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -111,7 +110,7 @@ func (c *Client) CreateDigitalOcean(i *CreateDigitalOceanInput) (*DigitalOcean, return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/digitalocean", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "digitalocean") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -147,7 +146,7 @@ func (c *Client) GetDigitalOcean(i *GetDigitalOceanInput) (*DigitalOcean, error) return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/digitalocean/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "digitalocean", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -215,7 +214,7 @@ func (c *Client) UpdateDigitalOcean(i *UpdateDigitalOceanInput) (*DigitalOcean, return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/digitalocean/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "digitalocean", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -251,7 +250,7 @@ func (c *Client) DeleteDigitalOcean(i *DeleteDigitalOceanInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/digitalocean/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "digitalocean", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_elasticsearch.go b/fastly/logging_elasticsearch.go index 8ddca69db..20b3e0338 100644 --- a/fastly/logging_elasticsearch.go +++ b/fastly/logging_elasticsearch.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -48,7 +47,7 @@ func (c *Client) ListElasticsearch(i *ListElasticsearchInput) ([]*Elasticsearch, return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/elasticsearch", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "elasticsearch") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -111,7 +110,7 @@ func (c *Client) CreateElasticsearch(i *CreateElasticsearchInput) (*Elasticsearc return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/elasticsearch", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "elasticsearch") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -147,7 +146,7 @@ func (c *Client) GetElasticsearch(i *GetElasticsearchInput) (*Elasticsearch, err return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/elasticsearch/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "elasticsearch", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -217,7 +216,7 @@ func (c *Client) UpdateElasticsearch(i *UpdateElasticsearchInput) (*Elasticsearc return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/elasticsearch/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "elasticsearch", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -254,7 +253,7 @@ func (c *Client) DeleteElasticsearch(i *DeleteElasticsearchInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/elasticsearch/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "elasticsearch", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_ftp.go b/fastly/logging_ftp.go index 08a210157..04ca012e0 100644 --- a/fastly/logging_ftp.go +++ b/fastly/logging_ftp.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -48,7 +47,7 @@ func (c *Client) ListFTPs(i *ListFTPsInput) ([]*FTP, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/ftp", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "ftp") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -111,7 +110,7 @@ func (c *Client) CreateFTP(i *CreateFTPInput) (*FTP, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/ftp", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "ftp") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -147,7 +146,7 @@ func (c *Client) GetFTP(i *GetFTPInput) (*FTP, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/ftp/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "ftp", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -215,7 +214,7 @@ func (c *Client) UpdateFTP(i *UpdateFTPInput) (*FTP, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/ftp/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "ftp", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -251,7 +250,7 @@ func (c *Client) DeleteFTP(i *DeleteFTPInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/ftp/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "ftp", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_gcs.go b/fastly/logging_gcs.go index e96eb059b..d93592b5e 100644 --- a/fastly/logging_gcs.go +++ b/fastly/logging_gcs.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -48,7 +47,7 @@ func (c *Client) ListGCSs(i *ListGCSsInput) ([]*GCS, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/gcs", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "gcs") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -111,7 +110,7 @@ func (c *Client) CreateGCS(i *CreateGCSInput) (*GCS, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/gcs", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "gcs") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -147,7 +146,7 @@ func (c *Client) GetGCS(i *GetGCSInput) (*GCS, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/gcs/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "gcs", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -215,7 +214,7 @@ func (c *Client) UpdateGCS(i *UpdateGCSInput) (*GCS, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/gcs/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "gcs", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -251,7 +250,7 @@ func (c *Client) DeleteGCS(i *DeleteGCSInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/gcs/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "gcs", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_heroku.go b/fastly/logging_heroku.go index b6cbaf33c..12c06bbcc 100644 --- a/fastly/logging_heroku.go +++ b/fastly/logging_heroku.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -39,7 +38,7 @@ func (c *Client) ListHerokus(i *ListHerokusInput) ([]*Heroku, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/heroku", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "heroku") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -84,7 +83,7 @@ func (c *Client) CreateHeroku(i *CreateHerokuInput) (*Heroku, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/heroku", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "heroku") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -120,7 +119,7 @@ func (c *Client) GetHeroku(i *GetHerokuInput) (*Heroku, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/heroku/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "heroku", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -170,7 +169,7 @@ func (c *Client) UpdateHeroku(i *UpdateHerokuInput) (*Heroku, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/heroku/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "heroku", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -206,7 +205,7 @@ func (c *Client) DeleteHeroku(i *DeleteHerokuInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/heroku/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "heroku", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_honeycomb.go b/fastly/logging_honeycomb.go index ad5393cdd..0bd6555f9 100644 --- a/fastly/logging_honeycomb.go +++ b/fastly/logging_honeycomb.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -39,7 +38,7 @@ func (c *Client) ListHoneycombs(i *ListHoneycombsInput) ([]*Honeycomb, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/honeycomb", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "honeycomb") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -84,7 +83,7 @@ func (c *Client) CreateHoneycomb(i *CreateHoneycombInput) (*Honeycomb, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/honeycomb", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "honeycomb") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -120,7 +119,7 @@ func (c *Client) GetHoneycomb(i *GetHoneycombInput) (*Honeycomb, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/honeycomb/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "honeycomb", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -170,7 +169,7 @@ func (c *Client) UpdateHoneycomb(i *UpdateHoneycombInput) (*Honeycomb, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/honeycomb/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "honeycomb", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -206,7 +205,7 @@ func (c *Client) DeleteHoneycomb(i *DeleteHoneycombInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/honeycomb/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "honeycomb", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_https.go b/fastly/logging_https.go index b2d17306d..5f1befc5b 100644 --- a/fastly/logging_https.go +++ b/fastly/logging_https.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -50,7 +49,7 @@ func (c *Client) ListHTTPS(i *ListHTTPSInput) ([]*HTTPS, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/https", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "https") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -117,7 +116,7 @@ func (c *Client) CreateHTTPS(i *CreateHTTPSInput) (*HTTPS, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/https", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "https") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -153,7 +152,7 @@ func (c *Client) GetHTTPS(i *GetHTTPSInput) (*HTTPS, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/https/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "https", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -226,7 +225,7 @@ func (c *Client) UpdateHTTPS(i *UpdateHTTPSInput) (*HTTPS, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/https/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "https", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -262,7 +261,7 @@ func (c *Client) DeleteHTTPS(i *DeleteHTTPSInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/https/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "https", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_kafka.go b/fastly/logging_kafka.go index c333053ee..9bab65bff 100644 --- a/fastly/logging_kafka.go +++ b/fastly/logging_kafka.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -51,7 +50,7 @@ func (c *Client) ListKafkas(i *ListKafkasInput) ([]*Kafka, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/kafka", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "kafka") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -120,7 +119,7 @@ func (c *Client) CreateKafka(i *CreateKafkaInput) (*Kafka, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/kafka", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "kafka") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -156,7 +155,7 @@ func (c *Client) GetKafka(i *GetKafkaInput) (*Kafka, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/kafka/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "kafka", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -230,7 +229,7 @@ func (c *Client) UpdateKafka(i *UpdateKafkaInput) (*Kafka, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/kafka/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "kafka", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -266,7 +265,7 @@ func (c *Client) DeleteKafka(i *DeleteKafkaInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/kafka/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "kafka", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_kinesis.go b/fastly/logging_kinesis.go index 6a2bfdd7f..12adc274e 100644 --- a/fastly/logging_kinesis.go +++ b/fastly/logging_kinesis.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -42,7 +41,7 @@ func (c *Client) ListKinesis(i *ListKinesisInput) ([]*Kinesis, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/kinesis", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "kinesis") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -93,7 +92,7 @@ func (c *Client) CreateKinesis(i *CreateKinesisInput) (*Kinesis, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/kinesis", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "kinesis") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -129,7 +128,7 @@ func (c *Client) GetKinesis(i *GetKinesisInput) (*Kinesis, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/kinesis/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "kinesis", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -185,7 +184,7 @@ func (c *Client) UpdateKinesis(i *UpdateKinesisInput) (*Kinesis, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/kinesis/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "kinesis", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -221,7 +220,7 @@ func (c *Client) DeleteKinesis(i *DeleteKinesisInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/kinesis/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "kinesis", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_logentries.go b/fastly/logging_logentries.go index 36957027a..f349b41d1 100644 --- a/fastly/logging_logentries.go +++ b/fastly/logging_logentries.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -41,7 +40,7 @@ func (c *Client) ListLogentries(i *ListLogentriesInput) ([]*Logentries, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/logentries", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "logentries") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -90,7 +89,7 @@ func (c *Client) CreateLogentries(i *CreateLogentriesInput) (*Logentries, error) return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/logentries", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "logentries") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -126,7 +125,7 @@ func (c *Client) GetLogentries(i *GetLogentriesInput) (*Logentries, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/logentries/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "logentries", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -180,7 +179,7 @@ func (c *Client) UpdateLogentries(i *UpdateLogentriesInput) (*Logentries, error) return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/logentries/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "logentries", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -216,7 +215,7 @@ func (c *Client) DeleteLogentries(i *DeleteLogentriesInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/logentries/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "logentries", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_loggly.go b/fastly/logging_loggly.go index 49138fc2f..2c033d67a 100644 --- a/fastly/logging_loggly.go +++ b/fastly/logging_loggly.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -38,7 +37,7 @@ func (c *Client) ListLoggly(i *ListLogglyInput) ([]*Loggly, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/loggly", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "loggly") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -81,7 +80,7 @@ func (c *Client) CreateLoggly(i *CreateLogglyInput) (*Loggly, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/loggly", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "loggly") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -117,7 +116,7 @@ func (c *Client) GetLoggly(i *GetLogglyInput) (*Loggly, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/loggly/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "loggly", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -165,7 +164,7 @@ func (c *Client) UpdateLoggly(i *UpdateLogglyInput) (*Loggly, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/loggly/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "loggly", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -201,7 +200,7 @@ func (c *Client) DeleteLoggly(i *DeleteLogglyInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/loggly/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "loggly", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_logshuttle.go b/fastly/logging_logshuttle.go index 579927a65..0fa83a88a 100644 --- a/fastly/logging_logshuttle.go +++ b/fastly/logging_logshuttle.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -39,7 +38,7 @@ func (c *Client) ListLogshuttles(i *ListLogshuttlesInput) ([]*Logshuttle, error) return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/logshuttle", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "logshuttle") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -84,7 +83,7 @@ func (c *Client) CreateLogshuttle(i *CreateLogshuttleInput) (*Logshuttle, error) return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/logshuttle", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "logshuttle") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -120,7 +119,7 @@ func (c *Client) GetLogshuttle(i *GetLogshuttleInput) (*Logshuttle, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/logshuttle/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "logshuttle", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -170,7 +169,7 @@ func (c *Client) UpdateLogshuttle(i *UpdateLogshuttleInput) (*Logshuttle, error) return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/logshuttle/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "logshuttle", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -206,7 +205,7 @@ func (c *Client) DeleteLogshuttle(i *DeleteLogshuttleInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/logshuttle/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "logshuttle", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_newrelic.go b/fastly/logging_newrelic.go index edc3e45b7..fb923449e 100644 --- a/fastly/logging_newrelic.go +++ b/fastly/logging_newrelic.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -39,7 +38,7 @@ func (c *Client) ListNewRelic(i *ListNewRelicInput) ([]*NewRelic, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/newrelic", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "newrelic") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -84,7 +83,7 @@ func (c *Client) CreateNewRelic(i *CreateNewRelicInput) (*NewRelic, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/newrelic", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "newrelic") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -120,7 +119,7 @@ func (c *Client) GetNewRelic(i *GetNewRelicInput) (*NewRelic, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/newrelic/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "newrelic", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -170,7 +169,7 @@ func (c *Client) UpdateNewRelic(i *UpdateNewRelicInput) (*NewRelic, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/newrelic/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "newrelic", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -206,7 +205,7 @@ func (c *Client) DeleteNewRelic(i *DeleteNewRelicInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/newrelic/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "newrelic", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_newrelicotlp.go b/fastly/logging_newrelicotlp.go index 2ebec06d5..a85adc94d 100644 --- a/fastly/logging_newrelicotlp.go +++ b/fastly/logging_newrelicotlp.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -42,7 +41,7 @@ func (c *Client) ListNewRelicOTLP(i *ListNewRelicOTLPInput) ([]*NewRelicOTLP, er return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/newrelicotlp", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "newrelicotlp") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -90,7 +89,7 @@ func (c *Client) CreateNewRelicOTLP(i *CreateNewRelicOTLPInput) (*NewRelicOTLP, return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/newrelicotlp", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "newrelicotlp") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -126,7 +125,7 @@ func (c *Client) GetNewRelicOTLP(i *GetNewRelicOTLPInput) (*NewRelicOTLP, error) return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/newrelicotlp/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "newrelicotlp", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -179,7 +178,7 @@ func (c *Client) UpdateNewRelicOTLP(i *UpdateNewRelicOTLPInput) (*NewRelicOTLP, return nil, ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/newrelicotlp/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "newrelicotlp", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -215,7 +214,7 @@ func (c *Client) DeleteNewRelicOTLP(i *DeleteNewRelicOTLPInput) error { return ErrMissingName } - path := fmt.Sprintf("/service/%s/version/%d/logging/newrelicotlp/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "newrelicotlp", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_openstack.go b/fastly/logging_openstack.go index 5d47b0622..7ce544c6c 100644 --- a/fastly/logging_openstack.go +++ b/fastly/logging_openstack.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -48,7 +47,7 @@ func (c *Client) ListOpenstack(i *ListOpenstackInput) ([]*Openstack, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/openstack", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "openstack") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -111,7 +110,7 @@ func (c *Client) CreateOpenstack(i *CreateOpenstackInput) (*Openstack, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/openstack", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "openstack") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -147,7 +146,7 @@ func (c *Client) GetOpenstack(i *GetOpenstackInput) (*Openstack, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/openstack/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "openstack", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -215,7 +214,7 @@ func (c *Client) UpdateOpenstack(i *UpdateOpenstackInput) (*Openstack, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/openstack/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "openstack", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -251,7 +250,7 @@ func (c *Client) DeleteOpenstack(i *DeleteOpenstackInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/openstack/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "openstack", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_papertrail.go b/fastly/logging_papertrail.go index 3e7c13d7f..739c0914f 100644 --- a/fastly/logging_papertrail.go +++ b/fastly/logging_papertrail.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -39,7 +38,7 @@ func (c *Client) ListPapertrails(i *ListPapertrailsInput) ([]*Papertrail, error) return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "papertrail") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -84,7 +83,7 @@ func (c *Client) CreatePapertrail(i *CreatePapertrailInput) (*Papertrail, error) return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "papertrail") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -120,7 +119,7 @@ func (c *Client) GetPapertrail(i *GetPapertrailInput) (*Papertrail, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "papertrail", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -170,7 +169,7 @@ func (c *Client) UpdatePapertrail(i *UpdatePapertrailInput) (*Papertrail, error) return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "papertrail", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -206,7 +205,7 @@ func (c *Client) DeletePapertrail(i *DeletePapertrailInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "papertrail", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_pubsub.go b/fastly/logging_pubsub.go index a148b9c59..5f21218d5 100644 --- a/fastly/logging_pubsub.go +++ b/fastly/logging_pubsub.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -42,7 +41,7 @@ func (c *Client) ListPubsubs(i *ListPubsubsInput) ([]*Pubsub, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/pubsub", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "pubsub") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -93,7 +92,7 @@ func (c *Client) CreatePubsub(i *CreatePubsubInput) (*Pubsub, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/pubsub", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "pubsub") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -129,7 +128,7 @@ func (c *Client) GetPubsub(i *GetPubsubInput) (*Pubsub, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/pubsub/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "pubsub", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -185,7 +184,7 @@ func (c *Client) UpdatePubsub(i *UpdatePubsubInput) (*Pubsub, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/pubsub/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "pubsub", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -221,7 +220,7 @@ func (c *Client) DeletePubsub(i *DeletePubsubInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/pubsub/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "pubsub", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_s3.go b/fastly/logging_s3.go index f397962c3..ecb2c1988 100644 --- a/fastly/logging_s3.go +++ b/fastly/logging_s3.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -102,7 +101,7 @@ func (c *Client) ListS3s(i *ListS3sInput) ([]*S3, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/s3", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "s3") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -183,7 +182,7 @@ func (c *Client) CreateS3(i *CreateS3Input) (*S3, error) { return nil, ErrMissingServerSideEncryptionKMSKeyID } - path := fmt.Sprintf("/service/%s/version/%d/logging/s3", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "s3") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -219,7 +218,7 @@ func (c *Client) GetS3(i *GetS3Input) (*S3, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/s3/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "s3", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -305,7 +304,7 @@ func (c *Client) UpdateS3(i *UpdateS3Input) (*S3, error) { return nil, ErrMissingServerSideEncryptionKMSKeyID } - path := fmt.Sprintf("/service/%s/version/%d/logging/s3/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "s3", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -341,7 +340,7 @@ func (c *Client) DeleteS3(i *DeleteS3Input) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/s3/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "s3", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_scalyr.go b/fastly/logging_scalyr.go index 6ddedfaa9..a83148963 100644 --- a/fastly/logging_scalyr.go +++ b/fastly/logging_scalyr.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -40,7 +39,7 @@ func (c *Client) ListScalyrs(i *ListScalyrsInput) ([]*Scalyr, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/scalyr", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "scalyr") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -87,7 +86,7 @@ func (c *Client) CreateScalyr(i *CreateScalyrInput) (*Scalyr, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/scalyr", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "scalyr") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -123,7 +122,7 @@ func (c *Client) GetScalyr(i *GetScalyrInput) (*Scalyr, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/scalyr/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "scalyr", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -175,7 +174,7 @@ func (c *Client) UpdateScalyr(i *UpdateScalyrInput) (*Scalyr, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/scalyr/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "scalyr", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -211,7 +210,7 @@ func (c *Client) DeleteScalyr(i *DeleteScalyrInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/scalyr/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "scalyr", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_sftp.go b/fastly/logging_sftp.go index 2ad7861d4..6bef274fc 100644 --- a/fastly/logging_sftp.go +++ b/fastly/logging_sftp.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -50,7 +49,7 @@ func (c *Client) ListSFTPs(i *ListSFTPsInput) ([]*SFTP, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/sftp", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "sftp") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -117,7 +116,7 @@ func (c *Client) CreateSFTP(i *CreateSFTPInput) (*SFTP, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/sftp", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "sftp") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -153,7 +152,7 @@ func (c *Client) GetSFTP(i *GetSFTPInput) (*SFTP, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/sftp/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "sftp", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -225,7 +224,7 @@ func (c *Client) UpdateSFTP(i *UpdateSFTPInput) (*SFTP, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/sftp/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "sftp", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -261,7 +260,7 @@ func (c *Client) DeleteSFTP(i *DeleteSFTPInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/sftp/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "sftp", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_splunk.go b/fastly/logging_splunk.go index 9e9faffdf..a3f9340ad 100644 --- a/fastly/logging_splunk.go +++ b/fastly/logging_splunk.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -46,7 +45,7 @@ func (c *Client) ListSplunks(i *ListSplunksInput) ([]*Splunk, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/splunk", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "splunk") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -105,7 +104,7 @@ func (c *Client) CreateSplunk(i *CreateSplunkInput) (*Splunk, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/splunk", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "splunk") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -141,7 +140,7 @@ func (c *Client) GetSplunk(i *GetSplunkInput) (*Splunk, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/splunk/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "splunk", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -205,7 +204,7 @@ func (c *Client) UpdateSplunk(i *UpdateSplunkInput) (*Splunk, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/splunk/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "splunk", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -241,7 +240,7 @@ func (c *Client) DeleteSplunk(i *DeleteSplunkInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/splunk/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "splunk", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_sumologic.go b/fastly/logging_sumologic.go index f9c2386d5..cfab88217 100644 --- a/fastly/logging_sumologic.go +++ b/fastly/logging_sumologic.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -40,7 +39,7 @@ func (c *Client) ListSumologics(i *ListSumologicsInput) ([]*Sumologic, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "sumologic") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -85,7 +84,7 @@ func (c *Client) CreateSumologic(i *CreateSumologicInput) (*Sumologic, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "sumologic") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -121,7 +120,7 @@ func (c *Client) GetSumologic(i *GetSumologicInput) (*Sumologic, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "sumologic", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -172,7 +171,7 @@ func (c *Client) UpdateSumologic(i *UpdateSumologicInput) (*Sumologic, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "sumologic", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -208,7 +207,7 @@ func (c *Client) DeleteSumologic(i *DeleteSumologicInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "sumologic", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/logging_syslog.go b/fastly/logging_syslog.go index 881925fe0..efd2bfa31 100644 --- a/fastly/logging_syslog.go +++ b/fastly/logging_syslog.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -48,7 +47,7 @@ func (c *Client) ListSyslogs(i *ListSyslogsInput) ([]*Syslog, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/syslog", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "syslog") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -111,7 +110,7 @@ func (c *Client) CreateSyslog(i *CreateSyslogInput) (*Syslog, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/syslog", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "syslog") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -147,7 +146,7 @@ func (c *Client) GetSyslog(i *GetSyslogInput) (*Syslog, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/syslog/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "syslog", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -215,7 +214,7 @@ func (c *Client) UpdateSyslog(i *UpdateSyslogInput) (*Syslog, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/syslog/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "syslog", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -251,7 +250,7 @@ func (c *Client) DeleteSyslog(i *DeleteSyslogInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/logging/syslog/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "logging", "syslog", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/resource.go b/fastly/resource.go index 1de8d8414..4cc3bda62 100644 --- a/fastly/resource.go +++ b/fastly/resource.go @@ -2,7 +2,7 @@ package fastly import ( "fmt" - "net/url" + "strconv" "time" ) @@ -47,7 +47,7 @@ func (c *Client) ListResources(i *ListResourcesInput) ([]*Resource, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/resource", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "resource") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -87,7 +87,7 @@ func (c *Client) CreateResource(i *CreateResourceInput) (*Resource, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/resource", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "resource") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -123,7 +123,7 @@ func (c *Client) GetResource(i *GetResourceInput) (*Resource, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/resource/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.ResourceID)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "resource", i.ResourceID) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -161,7 +161,7 @@ func (c *Client) UpdateResource(i *UpdateResourceInput) (*Resource, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/resource/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.ResourceID)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "resource", i.ResourceID) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -197,7 +197,7 @@ func (c *Client) DeleteResource(i *DeleteResourceInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/resource/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.ResourceID)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "resource", i.ResourceID) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/service_version.go b/fastly/service_version.go index dd92b053c..81a0b7619 100644 --- a/fastly/service_version.go +++ b/fastly/service_version.go @@ -2,6 +2,7 @@ package fastly import ( "fmt" + "strconv" "time" ) @@ -121,7 +122,7 @@ func (c *Client) GetVersion(i *GetVersionInput) (*Version, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion)) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -154,7 +155,7 @@ func (c *Client) UpdateVersion(i *UpdateVersionInput) (*Version, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion)) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -185,7 +186,7 @@ func (c *Client) ActivateVersion(i *ActivateVersionInput) (*Version, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/activate", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "activate") resp, err := c.Put(path, nil) if err != nil { return nil, err @@ -216,7 +217,7 @@ func (c *Client) DeactivateVersion(i *DeactivateVersionInput) (*Version, error) return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/deactivate", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "deactivate") resp, err := c.Put(path, nil) if err != nil { return nil, err @@ -250,7 +251,7 @@ func (c *Client) CloneVersion(i *CloneVersionInput) (*Version, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/clone", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "clone") resp, err := c.Put(path, nil) if err != nil { return nil, err @@ -283,7 +284,7 @@ func (c *Client) ValidateVersion(i *ValidateVersionInput) (bool, string, error) return false, msg, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/validate", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "validate") resp, err := c.Get(path, nil) if err != nil { return false, msg, err @@ -316,7 +317,7 @@ func (c *Client) LockVersion(i *LockVersionInput) (*Version, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/lock", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "lock") resp, err := c.Put(path, nil) if err != nil { return nil, err diff --git a/fastly/vcl_cache_setting.go b/fastly/vcl_cache_setting.go index a7dd4bbde..27ac409d3 100644 --- a/fastly/vcl_cache_setting.go +++ b/fastly/vcl_cache_setting.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -51,7 +50,7 @@ func (c *Client) ListCacheSettings(i *ListCacheSettingsInput) ([]*CacheSetting, return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/cache_settings", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "cache_settings") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -92,7 +91,7 @@ func (c *Client) CreateCacheSetting(i *CreateCacheSettingInput) (*CacheSetting, return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/cache_settings", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "cache_settings") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -128,7 +127,7 @@ func (c *Client) GetCacheSetting(i *GetCacheSettingInput) (*CacheSetting, error) return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/cache_settings/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "cache_settings", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -174,7 +173,7 @@ func (c *Client) UpdateCacheSetting(i *UpdateCacheSettingInput) (*CacheSetting, return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/cache_settings/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "cache_settings", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -210,7 +209,7 @@ func (c *Client) DeleteCacheSetting(i *DeleteCacheSettingInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/cache_settings/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "cache_settings", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/vcl_condition.go b/fastly/vcl_condition.go index 003ae3e96..307060b28 100644 --- a/fastly/vcl_condition.go +++ b/fastly/vcl_condition.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -37,7 +36,7 @@ func (c *Client) ListConditions(i *ListConditionsInput) ([]*Condition, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/condition", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "condition") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -76,7 +75,7 @@ func (c *Client) CreateCondition(i *CreateConditionInput) (*Condition, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/condition", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "condition") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -112,7 +111,7 @@ func (c *Client) GetCondition(i *GetConditionInput) (*Condition, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/condition/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "condition", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -156,7 +155,7 @@ func (c *Client) UpdateCondition(i *UpdateConditionInput) (*Condition, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/condition/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "condition", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -192,7 +191,7 @@ func (c *Client) DeleteCondition(i *DeleteConditionInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/condition/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "condition", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/vcl_custom.go b/fastly/vcl_custom.go index a65d0b103..8fd6f612a 100644 --- a/fastly/vcl_custom.go +++ b/fastly/vcl_custom.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -35,7 +34,7 @@ func (c *Client) ListVCLs(i *ListVCLsInput) ([]*VCL, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/vcl", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "vcl") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -71,7 +70,7 @@ func (c *Client) GetVCL(i *GetVCLInput) (*VCL, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/vcl/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "vcl", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -102,7 +101,7 @@ func (c *Client) GetGeneratedVCL(i *GetGeneratedVCLInput) (*VCL, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/generated_vcl", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "generated_vcl") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -139,7 +138,7 @@ func (c *Client) CreateVCL(i *CreateVCLInput) (*VCL, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/vcl", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "vcl") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -179,7 +178,7 @@ func (c *Client) UpdateVCL(i *UpdateVCLInput) (*VCL, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/vcl/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "vcl", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -215,7 +214,7 @@ func (c *Client) ActivateVCL(i *ActivateVCLInput) (*VCL, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/vcl/%s/main", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "vcl", i.Name, "main") resp, err := c.Put(path, nil) if err != nil { return nil, err @@ -251,7 +250,7 @@ func (c *Client) DeleteVCL(i *DeleteVCLInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/vcl/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "vcl", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/vcl_gzip.go b/fastly/vcl_gzip.go index b610ace84..31f534cb2 100644 --- a/fastly/vcl_gzip.go +++ b/fastly/vcl_gzip.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -36,7 +35,7 @@ func (c *Client) ListGzips(i *ListGzipsInput) ([]*Gzip, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/gzip", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "gzip") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -75,7 +74,7 @@ func (c *Client) CreateGzip(i *CreateGzipInput) (*Gzip, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/gzip", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "gzip") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -111,7 +110,7 @@ func (c *Client) GetGzip(i *GetGzipInput) (*Gzip, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/gzip/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "gzip", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -155,7 +154,7 @@ func (c *Client) UpdateGzip(i *UpdateGzipInput) (*Gzip, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/gzip/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "gzip", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -191,7 +190,7 @@ func (c *Client) DeleteGzip(i *DeleteGzipInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/gzip/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "gzip", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/vcl_header.go b/fastly/vcl_header.go index d010fdcb6..da50779ff 100644 --- a/fastly/vcl_header.go +++ b/fastly/vcl_header.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -87,7 +86,7 @@ func (c *Client) ListHeaders(i *ListHeadersInput) ([]*Header, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/header", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "header") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -142,7 +141,7 @@ func (c *Client) CreateHeader(i *CreateHeaderInput) (*Header, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/header", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "header") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -178,7 +177,7 @@ func (c *Client) GetHeader(i *GetHeaderInput) (*Header, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/header/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "header", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -238,7 +237,7 @@ func (c *Client) UpdateHeader(i *UpdateHeaderInput) (*Header, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/header/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "header", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -274,7 +273,7 @@ func (c *Client) DeleteHeader(i *DeleteHeaderInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/header/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "header", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/vcl_http3.go b/fastly/vcl_http3.go index 63499912f..4b942da82 100644 --- a/fastly/vcl_http3.go +++ b/fastly/vcl_http3.go @@ -1,7 +1,7 @@ package fastly import ( - "fmt" + "strconv" "time" ) @@ -32,7 +32,7 @@ func (c *Client) GetHTTP3(i *GetHTTP3Input) (*HTTP3, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/http3", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "http3") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -66,7 +66,7 @@ func (c *Client) EnableHTTP3(i *EnableHTTP3Input) (*HTTP3, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/http3", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "http3") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -97,7 +97,7 @@ func (c *Client) DisableHTTP3(i *DisableHTTP3Input) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/http3", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "http3") resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/vcl_rate_limiter.go b/fastly/vcl_rate_limiter.go index a3cfb1bd5..e67ec7e72 100644 --- a/fastly/vcl_rate_limiter.go +++ b/fastly/vcl_rate_limiter.go @@ -5,6 +5,7 @@ package fastly import ( "fmt" + "strconv" "time" ) @@ -198,7 +199,7 @@ func (c *Client) ListERLs(i *ListERLsInput) ([]*ERL, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/rate-limiters", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "rate-limiters") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -254,7 +255,7 @@ func (c *Client) CreateERL(i *CreateERLInput) (*ERL, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/rate-limiters", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "rate-limiters") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err diff --git a/fastly/vcl_request_setting.go b/fastly/vcl_request_setting.go index 828f2800e..d8f678099 100644 --- a/fastly/vcl_request_setting.go +++ b/fastly/vcl_request_setting.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -80,7 +79,7 @@ func (c *Client) ListRequestSettings(i *ListRequestSettingsInput) ([]*RequestSet return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/request_settings", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "request_settings") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -136,7 +135,7 @@ func (c *Client) CreateRequestSetting(i *CreateRequestSettingInput) (*RequestSet return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/request_settings", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "request_settings") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -172,7 +171,7 @@ func (c *Client) GetRequestSetting(i *GetRequestSettingInput) (*RequestSetting, return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/request_settings/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "request_settings", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -233,7 +232,7 @@ func (c *Client) UpdateRequestSetting(i *UpdateRequestSettingInput) (*RequestSet return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/request_settings/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "request_settings", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -269,7 +268,7 @@ func (c *Client) DeleteRequestSetting(i *DeleteRequestSettingInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/request_settings/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "request_settings", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/vcl_response_object.go b/fastly/vcl_response_object.go index 0fc4f9436..c6b2e657b 100644 --- a/fastly/vcl_response_object.go +++ b/fastly/vcl_response_object.go @@ -1,8 +1,7 @@ package fastly import ( - "fmt" - "net/url" + "strconv" "time" ) @@ -40,7 +39,7 @@ func (c *Client) ListResponseObjects(i *ListResponseObjectsInput) ([]*ResponseOb return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/response_object", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "response_object") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -86,7 +85,7 @@ func (c *Client) CreateResponseObject(i *CreateResponseObjectInput) (*ResponseOb return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/response_object", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "response_object") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -122,7 +121,7 @@ func (c *Client) GetResponseObject(i *GetResponseObjectInput) (*ResponseObject, return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/response_object/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "response_object", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -173,7 +172,7 @@ func (c *Client) UpdateResponseObject(i *UpdateResponseObjectInput) (*ResponseOb return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/response_object/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "response_object", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -209,7 +208,7 @@ func (c *Client) DeleteResponseObject(i *DeleteResponseObjectInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/response_object/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "response_object", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err diff --git a/fastly/vcl_settings.go b/fastly/vcl_settings.go index 03e3f51b7..61c1feb01 100644 --- a/fastly/vcl_settings.go +++ b/fastly/vcl_settings.go @@ -1,8 +1,6 @@ package fastly -import ( - "fmt" -) +import "strconv" // Settings represents a backend response from the Fastly API. type Settings struct { @@ -31,7 +29,7 @@ func (c *Client) GetSettings(i *GetSettingsInput) (*Settings, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/settings", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "settings") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -70,7 +68,7 @@ func (c *Client) UpdateSettings(i *UpdateSettingsInput) (*Settings, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/settings", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "settings") resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err diff --git a/fastly/vcl_snippets.go b/fastly/vcl_snippets.go index 5494a9b1a..0f46f1dcc 100644 --- a/fastly/vcl_snippets.go +++ b/fastly/vcl_snippets.go @@ -2,7 +2,7 @@ package fastly import ( "fmt" - "net/url" + "strconv" "time" ) @@ -86,7 +86,7 @@ func (c *Client) CreateSnippet(i *CreateSnippetInput) (*Snippet, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/snippet", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "snippet") resp, err := c.PostForm(path, i, nil) if err != nil { return nil, err @@ -130,7 +130,7 @@ func (c *Client) UpdateSnippet(i *UpdateSnippetInput) (*Snippet, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/snippet/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "snippet", i.Name) resp, err := c.PutForm(path, i, nil) if err != nil { return nil, err @@ -209,7 +209,7 @@ func (c *Client) DeleteSnippet(i *DeleteSnippetInput) error { return ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/snippet/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "snippet", i.Name) resp, err := c.Delete(path, nil) if err != nil { return err @@ -246,7 +246,7 @@ func (c *Client) ListSnippets(i *ListSnippetsInput) ([]*Snippet, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/snippet", i.ServiceID, i.ServiceVersion) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "snippet") resp, err := c.Get(path, nil) if err != nil { return nil, err @@ -285,7 +285,7 @@ func (c *Client) GetSnippet(i *GetSnippetInput) (*Snippet, error) { return nil, ErrMissingServiceVersion } - path := fmt.Sprintf("/service/%s/version/%d/snippet/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name)) + path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "snippet", i.Name) resp, err := c.Get(path, nil) if err != nil { return nil, err