id
int32 0
167k
| repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
sequence | docstring
stringlengths 6
2.61k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
10,300 | sethvargo/go-fastly | fastly/splunk.go | GetSplunk | func (c *Client) GetSplunk(i *GetSplunkInput) (*Splunk, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/splunk/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var s *Splunk
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | go | func (c *Client) GetSplunk(i *GetSplunkInput) (*Splunk, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/splunk/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var s *Splunk
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetSplunk",
"(",
"i",
"*",
"GetSplunkInput",
")",
"(",
"*",
"Splunk",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"s",
"*",
"Splunk",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"s",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] | // GetSplunk gets the splunk configuration with the given parameters. | [
"GetSplunk",
"gets",
"the",
"splunk",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/splunk.go#L120-L144 |
10,301 | sethvargo/go-fastly | fastly/splunk.go | UpdateSplunk | func (c *Client) UpdateSplunk(i *UpdateSplunkInput) (*Splunk, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/splunk/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var s *Splunk
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | go | func (c *Client) UpdateSplunk(i *UpdateSplunkInput) (*Splunk, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/splunk/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var s *Splunk
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateSplunk",
"(",
"i",
"*",
"UpdateSplunkInput",
")",
"(",
"*",
"Splunk",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"s",
"*",
"Splunk",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"s",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] | // UpdateSplunk updates a specific splunk. | [
"UpdateSplunk",
"updates",
"a",
"specific",
"splunk",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/splunk.go#L166-L190 |
10,302 | sethvargo/go-fastly | fastly/health_check.go | ListHealthChecks | func (c *Client) ListHealthChecks(i *ListHealthChecksInput) ([]*HealthCheck, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/healthcheck", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var hcs []*HealthCheck
if err := decodeJSON(&hcs, resp.Body); err != nil {
return nil, err
}
sort.Stable(healthChecksByName(hcs))
return hcs, nil
} | go | func (c *Client) ListHealthChecks(i *ListHealthChecksInput) ([]*HealthCheck, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/healthcheck", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var hcs []*HealthCheck
if err := decodeJSON(&hcs, resp.Body); err != nil {
return nil, err
}
sort.Stable(healthChecksByName(hcs))
return hcs, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListHealthChecks",
"(",
"i",
"*",
"ListHealthChecksInput",
")",
"(",
"[",
"]",
"*",
"HealthCheck",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"hcs",
"[",
"]",
"*",
"HealthCheck",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"hcs",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"healthChecksByName",
"(",
"hcs",
")",
")",
"\n",
"return",
"hcs",
",",
"nil",
"\n",
"}"
] | // ListHealthChecks returns the list of health checks for the configuration
// version. | [
"ListHealthChecks",
"returns",
"the",
"list",
"of",
"health",
"checks",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/health_check.go#L48-L69 |
10,303 | sethvargo/go-fastly | fastly/health_check.go | CreateHealthCheck | func (c *Client) CreateHealthCheck(i *CreateHealthCheckInput) (*HealthCheck, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/healthcheck", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var h *HealthCheck
if err := decodeJSON(&h, resp.Body); err != nil {
return nil, err
}
return h, nil
} | go | func (c *Client) CreateHealthCheck(i *CreateHealthCheckInput) (*HealthCheck, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/healthcheck", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var h *HealthCheck
if err := decodeJSON(&h, resp.Body); err != nil {
return nil, err
}
return h, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateHealthCheck",
"(",
"i",
"*",
"CreateHealthCheckInput",
")",
"(",
"*",
"HealthCheck",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"h",
"*",
"HealthCheck",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"h",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"h",
",",
"nil",
"\n",
"}"
] | // CreateHealthCheck creates a new Fastly health check. | [
"CreateHealthCheck",
"creates",
"a",
"new",
"Fastly",
"health",
"check",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/health_check.go#L93-L113 |
10,304 | sethvargo/go-fastly | fastly/health_check.go | GetHealthCheck | func (c *Client) GetHealthCheck(i *GetHealthCheckInput) (*HealthCheck, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/healthcheck/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var h *HealthCheck
if err := decodeJSON(&h, resp.Body); err != nil {
return nil, err
}
return h, nil
} | go | func (c *Client) GetHealthCheck(i *GetHealthCheckInput) (*HealthCheck, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/healthcheck/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var h *HealthCheck
if err := decodeJSON(&h, resp.Body); err != nil {
return nil, err
}
return h, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetHealthCheck",
"(",
"i",
"*",
"GetHealthCheckInput",
")",
"(",
"*",
"HealthCheck",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"h",
"*",
"HealthCheck",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"h",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"h",
",",
"nil",
"\n",
"}"
] | // GetHealthCheck gets the health check configuration with the given parameters. | [
"GetHealthCheck",
"gets",
"the",
"health",
"check",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/health_check.go#L127-L151 |
10,305 | sethvargo/go-fastly | fastly/health_check.go | UpdateHealthCheck | func (c *Client) UpdateHealthCheck(i *UpdateHealthCheckInput) (*HealthCheck, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/healthcheck/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var h *HealthCheck
if err := decodeJSON(&h, resp.Body); err != nil {
return nil, err
}
return h, nil
} | go | func (c *Client) UpdateHealthCheck(i *UpdateHealthCheckInput) (*HealthCheck, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/healthcheck/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var h *HealthCheck
if err := decodeJSON(&h, resp.Body); err != nil {
return nil, err
}
return h, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateHealthCheck",
"(",
"i",
"*",
"UpdateHealthCheckInput",
")",
"(",
"*",
"HealthCheck",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"h",
"*",
"HealthCheck",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"h",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"h",
",",
"nil",
"\n",
"}"
] | // UpdateHealthCheck updates a specific health check. | [
"UpdateHealthCheck",
"updates",
"a",
"specific",
"health",
"check",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/health_check.go#L178-L202 |
10,306 | sethvargo/go-fastly | fastly/condition.go | ListConditions | func (c *Client) ListConditions(i *ListConditionsInput) ([]*Condition, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/condition", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var cs []*Condition
if err := decodeJSON(&cs, resp.Body); err != nil {
return nil, err
}
sort.Stable(conditionsByName(cs))
return cs, nil
} | go | func (c *Client) ListConditions(i *ListConditionsInput) ([]*Condition, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/condition", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var cs []*Condition
if err := decodeJSON(&cs, resp.Body); err != nil {
return nil, err
}
sort.Stable(conditionsByName(cs))
return cs, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListConditions",
"(",
"i",
"*",
"ListConditionsInput",
")",
"(",
"[",
"]",
"*",
"Condition",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"cs",
"[",
"]",
"*",
"Condition",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"cs",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"conditionsByName",
"(",
"cs",
")",
")",
"\n",
"return",
"cs",
",",
"nil",
"\n",
"}"
] | // ListConditions returns the list of conditions for the configuration version. | [
"ListConditions",
"returns",
"the",
"list",
"of",
"conditions",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/condition.go#L41-L62 |
10,307 | sethvargo/go-fastly | fastly/condition.go | CreateCondition | func (c *Client) CreateCondition(i *CreateConditionInput) (*Condition, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/condition", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var co *Condition
if err := decodeJSON(&co, resp.Body); err != nil {
return nil, err
}
return co, nil
} | go | func (c *Client) CreateCondition(i *CreateConditionInput) (*Condition, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/condition", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var co *Condition
if err := decodeJSON(&co, resp.Body); err != nil {
return nil, err
}
return co, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateCondition",
"(",
"i",
"*",
"CreateConditionInput",
")",
"(",
"*",
"Condition",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"co",
"*",
"Condition",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"co",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"co",
",",
"nil",
"\n",
"}"
] | // CreateCondition creates a new Fastly condition. | [
"CreateCondition",
"creates",
"a",
"new",
"Fastly",
"condition",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/condition.go#L78-L98 |
10,308 | sethvargo/go-fastly | fastly/condition.go | GetCondition | func (c *Client) GetCondition(i *GetConditionInput) (*Condition, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/condition/%s", i.Service, i.Version, url.PathEscape(i.Name))
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var co *Condition
if err := decodeJSON(&co, resp.Body); err != nil {
return nil, err
}
return co, nil
} | go | func (c *Client) GetCondition(i *GetConditionInput) (*Condition, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/condition/%s", i.Service, i.Version, url.PathEscape(i.Name))
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var co *Condition
if err := decodeJSON(&co, resp.Body); err != nil {
return nil, err
}
return co, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetCondition",
"(",
"i",
"*",
"GetConditionInput",
")",
"(",
"*",
"Condition",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"url",
".",
"PathEscape",
"(",
"i",
".",
"Name",
")",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"co",
"*",
"Condition",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"co",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"co",
",",
"nil",
"\n",
"}"
] | // GetCondition gets the condition configuration with the given parameters. | [
"GetCondition",
"gets",
"the",
"condition",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/condition.go#L112-L136 |
10,309 | sethvargo/go-fastly | fastly/condition.go | UpdateCondition | func (c *Client) UpdateCondition(i *UpdateConditionInput) (*Condition, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/condition/%s", i.Service, i.Version, url.PathEscape(i.Name))
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var co *Condition
if err := decodeJSON(&co, resp.Body); err != nil {
return nil, err
}
return co, nil
} | go | func (c *Client) UpdateCondition(i *UpdateConditionInput) (*Condition, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/condition/%s", i.Service, i.Version, url.PathEscape(i.Name))
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var co *Condition
if err := decodeJSON(&co, resp.Body); err != nil {
return nil, err
}
return co, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateCondition",
"(",
"i",
"*",
"UpdateConditionInput",
")",
"(",
"*",
"Condition",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"url",
".",
"PathEscape",
"(",
"i",
".",
"Name",
")",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"co",
"*",
"Condition",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"co",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"co",
",",
"nil",
"\n",
"}"
] | // UpdateCondition updates a specific condition. | [
"UpdateCondition",
"updates",
"a",
"specific",
"condition",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/condition.go#L156-L180 |
10,310 | sethvargo/go-fastly | fastly/condition.go | DeleteCondition | func (c *Client) DeleteCondition(i *DeleteConditionInput) error {
if i.Service == "" {
return ErrMissingService
}
if i.Version == 0 {
return ErrMissingVersion
}
if i.Name == "" {
return ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/condition/%s", i.Service, i.Version, url.PathEscape(i.Name))
resp, err := c.Delete(path, nil)
if err != nil {
return err
}
var r *statusResp
if err := decodeJSON(&r, resp.Body); err != nil {
return err
}
if !r.Ok() {
return fmt.Errorf("Not Ok")
}
return nil
} | go | func (c *Client) DeleteCondition(i *DeleteConditionInput) error {
if i.Service == "" {
return ErrMissingService
}
if i.Version == 0 {
return ErrMissingVersion
}
if i.Name == "" {
return ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/condition/%s", i.Service, i.Version, url.PathEscape(i.Name))
resp, err := c.Delete(path, nil)
if err != nil {
return err
}
var r *statusResp
if err := decodeJSON(&r, resp.Body); err != nil {
return err
}
if !r.Ok() {
return fmt.Errorf("Not Ok")
}
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteCondition",
"(",
"i",
"*",
"DeleteConditionInput",
")",
"error",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"url",
".",
"PathEscape",
"(",
"i",
".",
"Name",
")",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Delete",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"var",
"r",
"*",
"statusResp",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"r",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"!",
"r",
".",
"Ok",
"(",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // DeleteCondition deletes the given condition version. | [
"DeleteCondition",
"deletes",
"the",
"given",
"condition",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/condition.go#L194-L221 |
10,311 | sethvargo/go-fastly | fastly/billing.go | GetBilling | func (c *Client) GetBilling(i *GetBillingInput) (*Billing, error) {
if i.Year == 0 {
return nil, ErrMissingYear
}
if i.Month == 0 {
return nil, ErrMissingMonth
}
path := fmt.Sprintf("/billing/year/%d/month/%02d", i.Year, i.Month)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *Billing
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) GetBilling(i *GetBillingInput) (*Billing, error) {
if i.Year == 0 {
return nil, ErrMissingYear
}
if i.Month == 0 {
return nil, ErrMissingMonth
}
path := fmt.Sprintf("/billing/year/%d/month/%02d", i.Year, i.Month)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *Billing
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetBilling",
"(",
"i",
"*",
"GetBillingInput",
")",
"(",
"*",
"Billing",
",",
"error",
")",
"{",
"if",
"i",
".",
"Year",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingYear",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Month",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingMonth",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Year",
",",
"i",
".",
"Month",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"b",
"*",
"Billing",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // GetBilling returns the billing information for the current account. | [
"GetBilling",
"returns",
"the",
"billing",
"information",
"for",
"the",
"current",
"account",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/billing.go#L61-L81 |
10,312 | sethvargo/go-fastly | fastly/vcl_snippets.go | CreateSnippet | func (c *Client) CreateSnippet(i *CreateSnippetInput) (*Snippet, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
if i.Dynamic == 0 && i.Content == "" {
return nil, ErrMissingContent
}
path := fmt.Sprintf("/service/%s/version/%d/snippet", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var snippet *Snippet
if err := decodeJSON(&snippet, resp.Body); err != nil {
return nil, err
}
return snippet, err
} | go | func (c *Client) CreateSnippet(i *CreateSnippetInput) (*Snippet, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
if i.Dynamic == 0 && i.Content == "" {
return nil, ErrMissingContent
}
path := fmt.Sprintf("/service/%s/version/%d/snippet", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var snippet *Snippet
if err := decodeJSON(&snippet, resp.Body); err != nil {
return nil, err
}
return snippet, err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateSnippet",
"(",
"i",
"*",
"CreateSnippetInput",
")",
"(",
"*",
"Snippet",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Dynamic",
"==",
"0",
"&&",
"i",
".",
"Content",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingContent",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"snippet",
"*",
"Snippet",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"snippet",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"snippet",
",",
"err",
"\n",
"}"
] | // CreateSnippet creates a new snippet or dynamic snippet on a unlocked version | [
"CreateSnippet",
"creates",
"a",
"new",
"snippet",
"or",
"dynamic",
"snippet",
"on",
"a",
"unlocked",
"version"
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/vcl_snippets.go#L99-L127 |
10,313 | sethvargo/go-fastly | fastly/vcl_snippets.go | UpdateSnippet | func (c *Client) UpdateSnippet(i *UpdateSnippetInput) (*Snippet, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
if i.Dynamic == 0 && i.Content == "" {
return nil, ErrMissingContent
}
path := fmt.Sprintf("/service/%s/version/%d/snippet/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var snippet *Snippet
if err := decodeJSON(&snippet, resp.Body); err != nil {
return nil, err
}
return snippet, err
} | go | func (c *Client) UpdateSnippet(i *UpdateSnippetInput) (*Snippet, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
if i.Dynamic == 0 && i.Content == "" {
return nil, ErrMissingContent
}
path := fmt.Sprintf("/service/%s/version/%d/snippet/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var snippet *Snippet
if err := decodeJSON(&snippet, resp.Body); err != nil {
return nil, err
}
return snippet, err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateSnippet",
"(",
"i",
"*",
"UpdateSnippetInput",
")",
"(",
"*",
"Snippet",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Dynamic",
"==",
"0",
"&&",
"i",
".",
"Content",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingContent",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"snippet",
"*",
"Snippet",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"snippet",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"snippet",
",",
"err",
"\n",
"}"
] | // UpdateSnippet updates a snippet on a unlocked version | [
"UpdateSnippet",
"updates",
"a",
"snippet",
"on",
"a",
"unlocked",
"version"
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/vcl_snippets.go#L156-L184 |
10,314 | sethvargo/go-fastly | fastly/vcl_snippets.go | UpdateDynamicSnippet | func (c *Client) UpdateDynamicSnippet(i *UpdateDynamicSnippetInput) (*DynamicSnippet, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.ID == "" {
return nil, ErrMissingID
}
path := fmt.Sprintf("/service/%s/snippet/%s", i.Service, i.ID)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var updateSnippet *DynamicSnippet
if err := decodeJSON(&updateSnippet, resp.Body); err != nil {
return nil, err
}
return updateSnippet, err
} | go | func (c *Client) UpdateDynamicSnippet(i *UpdateDynamicSnippetInput) (*DynamicSnippet, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.ID == "" {
return nil, ErrMissingID
}
path := fmt.Sprintf("/service/%s/snippet/%s", i.Service, i.ID)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var updateSnippet *DynamicSnippet
if err := decodeJSON(&updateSnippet, resp.Body); err != nil {
return nil, err
}
return updateSnippet, err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateDynamicSnippet",
"(",
"i",
"*",
"UpdateDynamicSnippetInput",
")",
"(",
"*",
"DynamicSnippet",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"ID",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingID",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"ID",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"updateSnippet",
"*",
"DynamicSnippet",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"updateSnippet",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"updateSnippet",
",",
"err",
"\n",
"}"
] | // UpdateDynamicSnippet replaces the content of a Dynamic Snippet | [
"UpdateDynamicSnippet",
"replaces",
"the",
"content",
"of",
"a",
"Dynamic",
"Snippet"
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/vcl_snippets.go#L214-L234 |
10,315 | sethvargo/go-fastly | fastly/vcl_snippets.go | ListSnippets | func (c *Client) ListSnippets(i *ListSnippetsInput) ([]*Snippet, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/snippet", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var snippets []*Snippet
if err := decodeJSON(&snippets, resp.Body); err != nil {
return nil, err
}
sort.Stable(snippetsByName(snippets))
return snippets, nil
} | go | func (c *Client) ListSnippets(i *ListSnippetsInput) ([]*Snippet, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/snippet", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var snippets []*Snippet
if err := decodeJSON(&snippets, resp.Body); err != nil {
return nil, err
}
sort.Stable(snippetsByName(snippets))
return snippets, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListSnippets",
"(",
"i",
"*",
"ListSnippetsInput",
")",
"(",
"[",
"]",
"*",
"Snippet",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"snippets",
"[",
"]",
"*",
"Snippet",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"snippets",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"snippetsByName",
"(",
"snippets",
")",
")",
"\n",
"return",
"snippets",
",",
"nil",
"\n",
"}"
] | // ListSnippets returns the list of Snippets for the configuration version. Content is not displayed for Dynmanic Snippets due to them being
// versionless, use the GetDynamicSnippet function to show current content. | [
"ListSnippets",
"returns",
"the",
"list",
"of",
"Snippets",
"for",
"the",
"configuration",
"version",
".",
"Content",
"is",
"not",
"displayed",
"for",
"Dynmanic",
"Snippets",
"due",
"to",
"them",
"being",
"versionless",
"use",
"the",
"GetDynamicSnippet",
"function",
"to",
"show",
"current",
"content",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/vcl_snippets.go#L297-L318 |
10,316 | sethvargo/go-fastly | fastly/vcl_snippets.go | GetSnippet | func (c *Client) GetSnippet(i *GetSnippetInput) (*Snippet, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/snippet/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var snippet *Snippet
if err := decodeJSON(&snippet, resp.Body); err != nil {
return nil, err
}
return snippet, nil
} | go | func (c *Client) GetSnippet(i *GetSnippetInput) (*Snippet, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/snippet/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var snippet *Snippet
if err := decodeJSON(&snippet, resp.Body); err != nil {
return nil, err
}
return snippet, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetSnippet",
"(",
"i",
"*",
"GetSnippetInput",
")",
"(",
"*",
"Snippet",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"snippet",
"*",
"Snippet",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"snippet",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"snippet",
",",
"nil",
"\n",
"}"
] | // GetSnippet gets the Snippet configuration with the given parameters. Dynamic Snippets will not show content due to them
// being versionless, use GetDynamicSnippet to see content. | [
"GetSnippet",
"gets",
"the",
"Snippet",
"configuration",
"with",
"the",
"given",
"parameters",
".",
"Dynamic",
"Snippets",
"will",
"not",
"show",
"content",
"due",
"to",
"them",
"being",
"versionless",
"use",
"GetDynamicSnippet",
"to",
"see",
"content",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/vcl_snippets.go#L333-L357 |
10,317 | sethvargo/go-fastly | fastly/vcl_snippets.go | GetDynamicSnippet | func (c *Client) GetDynamicSnippet(i *GetDynamicSnippetInput) (*DynamicSnippet, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.ID == "" {
return nil, ErrMissingID
}
path := fmt.Sprintf("/service/%s/snippet/%s", i.Service, i.ID)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var snippet *DynamicSnippet
if err := decodeJSON(&snippet, resp.Body); err != nil {
return nil, err
}
return snippet, nil
} | go | func (c *Client) GetDynamicSnippet(i *GetDynamicSnippetInput) (*DynamicSnippet, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.ID == "" {
return nil, ErrMissingID
}
path := fmt.Sprintf("/service/%s/snippet/%s", i.Service, i.ID)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var snippet *DynamicSnippet
if err := decodeJSON(&snippet, resp.Body); err != nil {
return nil, err
}
return snippet, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetDynamicSnippet",
"(",
"i",
"*",
"GetDynamicSnippetInput",
")",
"(",
"*",
"DynamicSnippet",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"ID",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingID",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"ID",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"snippet",
"*",
"DynamicSnippet",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"snippet",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"snippet",
",",
"nil",
"\n",
"}"
] | // GetDynamicSnippet gets the Snippet configuration with the given parameters. This will show the current content
// associated with a Dynamic Snippet. | [
"GetDynamicSnippet",
"gets",
"the",
"Snippet",
"configuration",
"with",
"the",
"given",
"parameters",
".",
"This",
"will",
"show",
"the",
"current",
"content",
"associated",
"with",
"a",
"Dynamic",
"Snippet",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/vcl_snippets.go#L370-L390 |
10,318 | sethvargo/go-fastly | fastly/cache_setting.go | ListCacheSettings | func (c *Client) ListCacheSettings(i *ListCacheSettingsInput) ([]*CacheSetting, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/cache_settings", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var cs []*CacheSetting
if err := decodeJSON(&cs, resp.Body); err != nil {
return nil, err
}
sort.Stable(cacheSettingsByName(cs))
return cs, nil
} | go | func (c *Client) ListCacheSettings(i *ListCacheSettingsInput) ([]*CacheSetting, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/cache_settings", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var cs []*CacheSetting
if err := decodeJSON(&cs, resp.Body); err != nil {
return nil, err
}
sort.Stable(cacheSettingsByName(cs))
return cs, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListCacheSettings",
"(",
"i",
"*",
"ListCacheSettingsInput",
")",
"(",
"[",
"]",
"*",
"CacheSetting",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"cs",
"[",
"]",
"*",
"CacheSetting",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"cs",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"cacheSettingsByName",
"(",
"cs",
")",
")",
"\n",
"return",
"cs",
",",
"nil",
"\n",
"}"
] | // ListCacheSettings returns the list of cache settings for the configuration
// version. | [
"ListCacheSettings",
"returns",
"the",
"list",
"of",
"cache",
"settings",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/cache_setting.go#L55-L76 |
10,319 | sethvargo/go-fastly | fastly/cache_setting.go | CreateCacheSetting | func (c *Client) CreateCacheSetting(i *CreateCacheSettingInput) (*CacheSetting, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/cache_settings", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var cs *CacheSetting
if err := decodeJSON(&cs, resp.Body); err != nil {
return nil, err
}
return cs, nil
} | go | func (c *Client) CreateCacheSetting(i *CreateCacheSettingInput) (*CacheSetting, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/cache_settings", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var cs *CacheSetting
if err := decodeJSON(&cs, resp.Body); err != nil {
return nil, err
}
return cs, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateCacheSetting",
"(",
"i",
"*",
"CreateCacheSettingInput",
")",
"(",
"*",
"CacheSetting",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"cs",
"*",
"CacheSetting",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"cs",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"cs",
",",
"nil",
"\n",
"}"
] | // CreateCacheSetting creates a new Fastly cache setting. | [
"CreateCacheSetting",
"creates",
"a",
"new",
"Fastly",
"cache",
"setting",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/cache_setting.go#L93-L113 |
10,320 | sethvargo/go-fastly | fastly/cache_setting.go | GetCacheSetting | func (c *Client) GetCacheSetting(i *GetCacheSettingInput) (*CacheSetting, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/cache_settings/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var cs *CacheSetting
if err := decodeJSON(&cs, resp.Body); err != nil {
return nil, err
}
return cs, nil
} | go | func (c *Client) GetCacheSetting(i *GetCacheSettingInput) (*CacheSetting, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/cache_settings/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var cs *CacheSetting
if err := decodeJSON(&cs, resp.Body); err != nil {
return nil, err
}
return cs, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetCacheSetting",
"(",
"i",
"*",
"GetCacheSettingInput",
")",
"(",
"*",
"CacheSetting",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"cs",
"*",
"CacheSetting",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"cs",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"cs",
",",
"nil",
"\n",
"}"
] | // GetCacheSetting gets the cache setting configuration with the given
// parameters. | [
"GetCacheSetting",
"gets",
"the",
"cache",
"setting",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/cache_setting.go#L128-L152 |
10,321 | sethvargo/go-fastly | fastly/cache_setting.go | UpdateCacheSetting | func (c *Client) UpdateCacheSetting(i *UpdateCacheSettingInput) (*CacheSetting, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/cache_settings/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var cs *CacheSetting
if err := decodeJSON(&cs, resp.Body); err != nil {
return nil, err
}
return cs, nil
} | go | func (c *Client) UpdateCacheSetting(i *UpdateCacheSettingInput) (*CacheSetting, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/cache_settings/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var cs *CacheSetting
if err := decodeJSON(&cs, resp.Body); err != nil {
return nil, err
}
return cs, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateCacheSetting",
"(",
"i",
"*",
"UpdateCacheSettingInput",
")",
"(",
"*",
"CacheSetting",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"cs",
"*",
"CacheSetting",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"cs",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"cs",
",",
"nil",
"\n",
"}"
] | // UpdateCacheSetting updates a specific cache setting. | [
"UpdateCacheSetting",
"updates",
"a",
"specific",
"cache",
"setting",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/cache_setting.go#L172-L196 |
10,322 | sethvargo/go-fastly | fastly/blobstorage.go | ListBlobStorages | func (c *Client) ListBlobStorages(i *ListBlobStoragesInput) ([]*BlobStorage, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var as []*BlobStorage
if err := decodeJSON(&as, resp.Body); err != nil {
return nil, err
}
sort.Stable(blobStorageByName(as))
return as, nil
} | go | func (c *Client) ListBlobStorages(i *ListBlobStoragesInput) ([]*BlobStorage, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var as []*BlobStorage
if err := decodeJSON(&as, resp.Body); err != nil {
return nil, err
}
sort.Stable(blobStorageByName(as))
return as, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListBlobStorages",
"(",
"i",
"*",
"ListBlobStoragesInput",
")",
"(",
"[",
"]",
"*",
"BlobStorage",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"as",
"[",
"]",
"*",
"BlobStorage",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"as",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"blobStorageByName",
"(",
"as",
")",
")",
"\n",
"return",
"as",
",",
"nil",
"\n",
"}"
] | // ListBlobStorages returns the list of blob storages for the configuration version. | [
"ListBlobStorages",
"returns",
"the",
"list",
"of",
"blob",
"storages",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/blobstorage.go#L53-L74 |
10,323 | sethvargo/go-fastly | fastly/blobstorage.go | CreateBlobStorage | func (c *Client) CreateBlobStorage(i *CreateBlobStorageInput) (*BlobStorage, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var a *BlobStorage
if err := decodeJSON(&a, resp.Body); err != nil {
return nil, err
}
return a, nil
} | go | func (c *Client) CreateBlobStorage(i *CreateBlobStorageInput) (*BlobStorage, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var a *BlobStorage
if err := decodeJSON(&a, resp.Body); err != nil {
return nil, err
}
return a, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateBlobStorage",
"(",
"i",
"*",
"CreateBlobStorageInput",
")",
"(",
"*",
"BlobStorage",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"a",
"*",
"BlobStorage",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"a",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"a",
",",
"nil",
"\n",
"}"
] | // CreateBlobStorage creates a new Fastly blob storage. | [
"CreateBlobStorage",
"creates",
"a",
"new",
"Fastly",
"blob",
"storage",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/blobstorage.go#L100-L120 |
10,324 | sethvargo/go-fastly | fastly/blobstorage.go | GetBlobStorage | func (c *Client) GetBlobStorage(i *GetBlobStorageInput) (*BlobStorage, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var a *BlobStorage
if err := decodeJSON(&a, resp.Body); err != nil {
return nil, err
}
return a, nil
} | go | func (c *Client) GetBlobStorage(i *GetBlobStorageInput) (*BlobStorage, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var a *BlobStorage
if err := decodeJSON(&a, resp.Body); err != nil {
return nil, err
}
return a, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetBlobStorage",
"(",
"i",
"*",
"GetBlobStorageInput",
")",
"(",
"*",
"BlobStorage",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"a",
"*",
"BlobStorage",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"a",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"a",
",",
"nil",
"\n",
"}"
] | // GetBlobStorage gets the blob storage configuration with the given parameters. | [
"GetBlobStorage",
"gets",
"the",
"blob",
"storage",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/blobstorage.go#L134-L158 |
10,325 | sethvargo/go-fastly | fastly/blobstorage.go | UpdateBlobStorage | func (c *Client) UpdateBlobStorage(i *UpdateBlobStorageInput) (*BlobStorage, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var a *BlobStorage
if err := decodeJSON(&a, resp.Body); err != nil {
return nil, err
}
return a, nil
} | go | func (c *Client) UpdateBlobStorage(i *UpdateBlobStorageInput) (*BlobStorage, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var a *BlobStorage
if err := decodeJSON(&a, resp.Body); err != nil {
return nil, err
}
return a, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateBlobStorage",
"(",
"i",
"*",
"UpdateBlobStorageInput",
")",
"(",
"*",
"BlobStorage",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"a",
"*",
"BlobStorage",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"a",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"a",
",",
"nil",
"\n",
"}"
] | // UpdateBlobStorage updates a specific blob storage. | [
"UpdateBlobStorage",
"updates",
"a",
"specific",
"blob",
"storage",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/blobstorage.go#L187-L211 |
10,326 | sethvargo/go-fastly | fastly/papertrail.go | ListPapertrails | func (c *Client) ListPapertrails(i *ListPapertrailsInput) ([]*Papertrail, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ps []*Papertrail
if err := decodeJSON(&ps, resp.Body); err != nil {
return nil, err
}
sort.Stable(papertrailsByName(ps))
return ps, nil
} | go | func (c *Client) ListPapertrails(i *ListPapertrailsInput) ([]*Papertrail, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ps []*Papertrail
if err := decodeJSON(&ps, resp.Body); err != nil {
return nil, err
}
sort.Stable(papertrailsByName(ps))
return ps, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListPapertrails",
"(",
"i",
"*",
"ListPapertrailsInput",
")",
"(",
"[",
"]",
"*",
"Papertrail",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"ps",
"[",
"]",
"*",
"Papertrail",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"ps",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"papertrailsByName",
"(",
"ps",
")",
")",
"\n",
"return",
"ps",
",",
"nil",
"\n",
"}"
] | // ListPapertrails returns the list of papertrails for the configuration version. | [
"ListPapertrails",
"returns",
"the",
"list",
"of",
"papertrails",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/papertrail.go#L45-L66 |
10,327 | sethvargo/go-fastly | fastly/papertrail.go | CreatePapertrail | func (c *Client) CreatePapertrail(i *CreatePapertrailInput) (*Papertrail, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var p *Papertrail
if err := decodeJSON(&p, resp.Body); err != nil {
return nil, err
}
return p, nil
} | go | func (c *Client) CreatePapertrail(i *CreatePapertrailInput) (*Papertrail, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var p *Papertrail
if err := decodeJSON(&p, resp.Body); err != nil {
return nil, err
}
return p, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreatePapertrail",
"(",
"i",
"*",
"CreatePapertrailInput",
")",
"(",
"*",
"Papertrail",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"p",
"*",
"Papertrail",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"p",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"p",
",",
"nil",
"\n",
"}"
] | // CreatePapertrail creates a new Fastly papertrail. | [
"CreatePapertrail",
"creates",
"a",
"new",
"Fastly",
"papertrail",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/papertrail.go#L87-L107 |
10,328 | sethvargo/go-fastly | fastly/papertrail.go | GetPapertrail | func (c *Client) GetPapertrail(i *GetPapertrailInput) (*Papertrail, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var p *Papertrail
if err := decodeJSON(&p, resp.Body); err != nil {
return nil, err
}
return p, nil
} | go | func (c *Client) GetPapertrail(i *GetPapertrailInput) (*Papertrail, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var p *Papertrail
if err := decodeJSON(&p, resp.Body); err != nil {
return nil, err
}
return p, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetPapertrail",
"(",
"i",
"*",
"GetPapertrailInput",
")",
"(",
"*",
"Papertrail",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"p",
"*",
"Papertrail",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"p",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"p",
",",
"nil",
"\n",
"}"
] | // GetPapertrail gets the papertrail configuration with the given parameters. | [
"GetPapertrail",
"gets",
"the",
"papertrail",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/papertrail.go#L121-L145 |
10,329 | sethvargo/go-fastly | fastly/papertrail.go | UpdatePapertrail | func (c *Client) UpdatePapertrail(i *UpdatePapertrailInput) (*Papertrail, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var p *Papertrail
if err := decodeJSON(&p, resp.Body); err != nil {
return nil, err
}
return p, nil
} | go | func (c *Client) UpdatePapertrail(i *UpdatePapertrailInput) (*Papertrail, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/papertrail/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var p *Papertrail
if err := decodeJSON(&p, resp.Body); err != nil {
return nil, err
}
return p, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdatePapertrail",
"(",
"i",
"*",
"UpdatePapertrailInput",
")",
"(",
"*",
"Papertrail",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"p",
"*",
"Papertrail",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"p",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"p",
",",
"nil",
"\n",
"}"
] | // UpdatePapertrail updates a specific papertrail. | [
"UpdatePapertrail",
"updates",
"a",
"specific",
"papertrail",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/papertrail.go#L169-L193 |
10,330 | sethvargo/go-fastly | fastly/version.go | ListVersions | func (c *Client) ListVersions(i *ListVersionsInput) ([]*Version, error) {
if i.Service == "" {
return nil, ErrMissingService
}
path := fmt.Sprintf("/service/%s/version", i.Service)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var e []*Version
if err := decodeJSON(&e, resp.Body); err != nil {
return nil, err
}
sort.Sort(versionsByNumber(e))
return e, nil
} | go | func (c *Client) ListVersions(i *ListVersionsInput) ([]*Version, error) {
if i.Service == "" {
return nil, ErrMissingService
}
path := fmt.Sprintf("/service/%s/version", i.Service)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var e []*Version
if err := decodeJSON(&e, resp.Body); err != nil {
return nil, err
}
sort.Sort(versionsByNumber(e))
return e, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListVersions",
"(",
"i",
"*",
"ListVersionsInput",
")",
"(",
"[",
"]",
"*",
"Version",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"e",
"[",
"]",
"*",
"Version",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"e",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Sort",
"(",
"versionsByNumber",
"(",
"e",
")",
")",
"\n\n",
"return",
"e",
",",
"nil",
"\n",
"}"
] | // ListVersions returns the full list of all versions of the given service. | [
"ListVersions",
"returns",
"the",
"full",
"list",
"of",
"all",
"versions",
"of",
"the",
"given",
"service",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/version.go#L38-L56 |
10,331 | sethvargo/go-fastly | fastly/version.go | GetVersion | func (c *Client) GetVersion(i *GetVersionInput) (*Version, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var e *Version
if err := decodeJSON(&e, resp.Body); err != nil {
return nil, err
}
return e, nil
} | go | func (c *Client) GetVersion(i *GetVersionInput) (*Version, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var e *Version
if err := decodeJSON(&e, resp.Body); err != nil {
return nil, err
}
return e, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetVersion",
"(",
"i",
"*",
"GetVersionInput",
")",
"(",
"*",
"Version",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"e",
"*",
"Version",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"e",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"e",
",",
"nil",
"\n",
"}"
] | // GetVersion fetches a version with the given information. | [
"GetVersion",
"fetches",
"a",
"version",
"with",
"the",
"given",
"information",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/version.go#L123-L143 |
10,332 | sethvargo/go-fastly | fastly/version.go | UpdateVersion | func (c *Client) UpdateVersion(i *UpdateVersionInput) (*Version, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d", i.Service, i.Version)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var e *Version
if err := decodeJSON(&e, resp.Body); err != nil {
return nil, err
}
return e, nil
} | go | func (c *Client) UpdateVersion(i *UpdateVersionInput) (*Version, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d", i.Service, i.Version)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var e *Version
if err := decodeJSON(&e, resp.Body); err != nil {
return nil, err
}
return e, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateVersion",
"(",
"i",
"*",
"UpdateVersionInput",
")",
"(",
"*",
"Version",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"e",
"*",
"Version",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"e",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"e",
",",
"nil",
"\n",
"}"
] | // UpdateVersion updates the given version | [
"UpdateVersion",
"updates",
"the",
"given",
"version"
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/version.go#L157-L177 |
10,333 | sethvargo/go-fastly | fastly/version.go | ValidateVersion | func (c *Client) ValidateVersion(i *ValidateVersionInput) (bool, string, error) {
var msg string
if i.Service == "" {
return false, msg, ErrMissingService
}
if i.Version == 0 {
return false, msg, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/validate", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return false, msg, err
}
var r *statusResp
if err := decodeJSON(&r, resp.Body); err != nil {
return false, msg, err
}
msg = r.Msg
return r.Ok(), msg, nil
} | go | func (c *Client) ValidateVersion(i *ValidateVersionInput) (bool, string, error) {
var msg string
if i.Service == "" {
return false, msg, ErrMissingService
}
if i.Version == 0 {
return false, msg, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/validate", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return false, msg, err
}
var r *statusResp
if err := decodeJSON(&r, resp.Body); err != nil {
return false, msg, err
}
msg = r.Msg
return r.Ok(), msg, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ValidateVersion",
"(",
"i",
"*",
"ValidateVersionInput",
")",
"(",
"bool",
",",
"string",
",",
"error",
")",
"{",
"var",
"msg",
"string",
"\n\n",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"false",
",",
"msg",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"false",
",",
"msg",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"msg",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"r",
"*",
"statusResp",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"r",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"msg",
",",
"err",
"\n",
"}",
"\n\n",
"msg",
"=",
"r",
".",
"Msg",
"\n",
"return",
"r",
".",
"Ok",
"(",
")",
",",
"msg",
",",
"nil",
"\n",
"}"
] | // ValidateVersion validates if the given version is okay. | [
"ValidateVersion",
"validates",
"if",
"the",
"given",
"version",
"is",
"okay",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/version.go#L283-L307 |
10,334 | sethvargo/go-fastly | fastly/version.go | LockVersion | func (c *Client) LockVersion(i *LockVersionInput) (*Version, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/lock", i.Service, i.Version)
resp, err := c.Put(path, nil)
if err != nil {
return nil, err
}
var e *Version
if err := decodeJSON(&e, resp.Body); err != nil {
return nil, err
}
return e, nil
} | go | func (c *Client) LockVersion(i *LockVersionInput) (*Version, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/lock", i.Service, i.Version)
resp, err := c.Put(path, nil)
if err != nil {
return nil, err
}
var e *Version
if err := decodeJSON(&e, resp.Body); err != nil {
return nil, err
}
return e, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"LockVersion",
"(",
"i",
"*",
"LockVersionInput",
")",
"(",
"*",
"Version",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Put",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"e",
"*",
"Version",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"e",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"e",
",",
"nil",
"\n",
"}"
] | // LockVersion locks the specified version. | [
"LockVersion",
"locks",
"the",
"specified",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/version.go#L318-L338 |
10,335 | sethvargo/go-fastly | fastly/purge.go | Purge | func (c *Client) Purge(i *PurgeInput) (*Purge, error) {
if i.URL == "" {
return nil, ErrMissingURL
}
req, err := c.RawRequest("PURGE", i.URL, nil)
if err != nil {
return nil, err
}
if i.Soft {
req.Header.Set("Fastly-Soft-Purge", "1")
}
resp, err := checkResp(c.HTTPClient.Do(req))
if err != nil {
return nil, err
}
var r *Purge
if err := decodeJSON(&r, resp.Body); err != nil {
return nil, err
}
return r, nil
} | go | func (c *Client) Purge(i *PurgeInput) (*Purge, error) {
if i.URL == "" {
return nil, ErrMissingURL
}
req, err := c.RawRequest("PURGE", i.URL, nil)
if err != nil {
return nil, err
}
if i.Soft {
req.Header.Set("Fastly-Soft-Purge", "1")
}
resp, err := checkResp(c.HTTPClient.Do(req))
if err != nil {
return nil, err
}
var r *Purge
if err := decodeJSON(&r, resp.Body); err != nil {
return nil, err
}
return r, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Purge",
"(",
"i",
"*",
"PurgeInput",
")",
"(",
"*",
"Purge",
",",
"error",
")",
"{",
"if",
"i",
".",
"URL",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingURL",
"\n",
"}",
"\n\n",
"req",
",",
"err",
":=",
"c",
".",
"RawRequest",
"(",
"\"",
"\"",
",",
"i",
".",
"URL",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Soft",
"{",
"req",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"resp",
",",
"err",
":=",
"checkResp",
"(",
"c",
".",
"HTTPClient",
".",
"Do",
"(",
"req",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"r",
"*",
"Purge",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"r",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"r",
",",
"nil",
"\n",
"}"
] | // Purge instantly purges an individual URL. | [
"Purge",
"instantly",
"purges",
"an",
"individual",
"URL",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/purge.go#L24-L48 |
10,336 | sethvargo/go-fastly | fastly/purge.go | PurgeAll | func (c *Client) PurgeAll(i *PurgeAllInput) (*Purge, error) {
if i.Service == "" {
return nil, ErrMissingService
}
path := fmt.Sprintf("/service/%s/purge_all", i.Service)
req, err := c.RawRequest("POST", path, nil)
if err != nil {
return nil, err
}
if i.Soft {
req.Header.Set("Fastly-Soft-Purge", "1")
}
resp, err := checkResp(c.HTTPClient.Do(req))
if err != nil {
return nil, err
}
var r *Purge
if err := decodeJSON(&r, resp.Body); err != nil {
return nil, err
}
return r, nil
} | go | func (c *Client) PurgeAll(i *PurgeAllInput) (*Purge, error) {
if i.Service == "" {
return nil, ErrMissingService
}
path := fmt.Sprintf("/service/%s/purge_all", i.Service)
req, err := c.RawRequest("POST", path, nil)
if err != nil {
return nil, err
}
if i.Soft {
req.Header.Set("Fastly-Soft-Purge", "1")
}
resp, err := checkResp(c.HTTPClient.Do(req))
if err != nil {
return nil, err
}
var r *Purge
if err := decodeJSON(&r, resp.Body); err != nil {
return nil, err
}
return r, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"PurgeAll",
"(",
"i",
"*",
"PurgeAllInput",
")",
"(",
"*",
"Purge",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
")",
"\n",
"req",
",",
"err",
":=",
"c",
".",
"RawRequest",
"(",
"\"",
"\"",
",",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Soft",
"{",
"req",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"resp",
",",
"err",
":=",
"checkResp",
"(",
"c",
".",
"HTTPClient",
".",
"Do",
"(",
"req",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"r",
"*",
"Purge",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"r",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"r",
",",
"nil",
"\n\n",
"}"
] | // PurgeAll instantly purges everything from a service. | [
"PurgeAll",
"instantly",
"purges",
"everything",
"from",
"a",
"service",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/purge.go#L104-L130 |
10,337 | sethvargo/go-fastly | fastly/ftp.go | ListFTPs | func (c *Client) ListFTPs(i *ListFTPsInput) ([]*FTP, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/ftp", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ftps []*FTP
if err := decodeJSON(&ftps, resp.Body); err != nil {
return nil, err
}
sort.Stable(ftpsByName(ftps))
return ftps, nil
} | go | func (c *Client) ListFTPs(i *ListFTPsInput) ([]*FTP, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/ftp", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ftps []*FTP
if err := decodeJSON(&ftps, resp.Body); err != nil {
return nil, err
}
sort.Stable(ftpsByName(ftps))
return ftps, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListFTPs",
"(",
"i",
"*",
"ListFTPsInput",
")",
"(",
"[",
"]",
"*",
"FTP",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"ftps",
"[",
"]",
"*",
"FTP",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"ftps",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"ftpsByName",
"(",
"ftps",
")",
")",
"\n",
"return",
"ftps",
",",
"nil",
"\n",
"}"
] | // ListFTPs returns the list of ftps for the configuration version. | [
"ListFTPs",
"returns",
"the",
"list",
"of",
"ftps",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/ftp.go#L51-L72 |
10,338 | sethvargo/go-fastly | fastly/ftp.go | CreateFTP | func (c *Client) CreateFTP(i *CreateFTPInput) (*FTP, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/ftp", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var ftp *FTP
if err := decodeJSON(&ftp, resp.Body); err != nil {
return nil, err
}
return ftp, nil
} | go | func (c *Client) CreateFTP(i *CreateFTPInput) (*FTP, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/ftp", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var ftp *FTP
if err := decodeJSON(&ftp, resp.Body); err != nil {
return nil, err
}
return ftp, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateFTP",
"(",
"i",
"*",
"CreateFTPInput",
")",
"(",
"*",
"FTP",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"ftp",
"*",
"FTP",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"ftp",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"ftp",
",",
"nil",
"\n",
"}"
] | // CreateFTP creates a new Fastly FTP. | [
"CreateFTP",
"creates",
"a",
"new",
"Fastly",
"FTP",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/ftp.go#L96-L116 |
10,339 | sethvargo/go-fastly | fastly/ftp.go | GetFTP | func (c *Client) GetFTP(i *GetFTPInput) (*FTP, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/ftp/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *FTP
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) GetFTP(i *GetFTPInput) (*FTP, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/ftp/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *FTP
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetFTP",
"(",
"i",
"*",
"GetFTPInput",
")",
"(",
"*",
"FTP",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"b",
"*",
"FTP",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // GetFTP gets the FTP configuration with the given parameters. | [
"GetFTP",
"gets",
"the",
"FTP",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/ftp.go#L130-L154 |
10,340 | sethvargo/go-fastly | fastly/ftp.go | UpdateFTP | func (c *Client) UpdateFTP(i *UpdateFTPInput) (*FTP, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/ftp/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var b *FTP
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) UpdateFTP(i *UpdateFTPInput) (*FTP, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/ftp/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var b *FTP
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateFTP",
"(",
"i",
"*",
"UpdateFTPInput",
")",
"(",
"*",
"FTP",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"b",
"*",
"FTP",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // UpdateFTP updates a specific FTP. | [
"UpdateFTP",
"updates",
"a",
"specific",
"FTP",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/ftp.go#L181-L205 |
10,341 | sethvargo/go-fastly | fastly/gcs.go | ListGCSs | func (c *Client) ListGCSs(i *ListGCSsInput) ([]*GCS, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/gcs", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var gcses []*GCS
if err := decodeJSON(&gcses, resp.Body); err != nil {
return nil, err
}
sort.Stable(gcsesByName(gcses))
return gcses, nil
} | go | func (c *Client) ListGCSs(i *ListGCSsInput) ([]*GCS, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/gcs", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var gcses []*GCS
if err := decodeJSON(&gcses, resp.Body); err != nil {
return nil, err
}
sort.Stable(gcsesByName(gcses))
return gcses, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListGCSs",
"(",
"i",
"*",
"ListGCSsInput",
")",
"(",
"[",
"]",
"*",
"GCS",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"gcses",
"[",
"]",
"*",
"GCS",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"gcses",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"gcsesByName",
"(",
"gcses",
")",
")",
"\n",
"return",
"gcses",
",",
"nil",
"\n",
"}"
] | // ListGCSs returns the list of gcses for the configuration version. | [
"ListGCSs",
"returns",
"the",
"list",
"of",
"gcses",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/gcs.go#L47-L68 |
10,342 | sethvargo/go-fastly | fastly/gcs.go | CreateGCS | func (c *Client) CreateGCS(i *CreateGCSInput) (*GCS, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/gcs", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var gcs *GCS
if err := decodeJSON(&gcs, resp.Body); err != nil {
return nil, err
}
return gcs, nil
} | go | func (c *Client) CreateGCS(i *CreateGCSInput) (*GCS, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/gcs", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var gcs *GCS
if err := decodeJSON(&gcs, resp.Body); err != nil {
return nil, err
}
return gcs, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateGCS",
"(",
"i",
"*",
"CreateGCSInput",
")",
"(",
"*",
"GCS",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"gcs",
"*",
"GCS",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"gcs",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"gcs",
",",
"nil",
"\n",
"}"
] | // CreateGCS creates a new Fastly GCS. | [
"CreateGCS",
"creates",
"a",
"new",
"Fastly",
"GCS",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/gcs.go#L92-L112 |
10,343 | sethvargo/go-fastly | fastly/gcs.go | GetGCS | func (c *Client) GetGCS(i *GetGCSInput) (*GCS, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/gcs/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *GCS
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) GetGCS(i *GetGCSInput) (*GCS, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/gcs/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *GCS
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetGCS",
"(",
"i",
"*",
"GetGCSInput",
")",
"(",
"*",
"GCS",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"b",
"*",
"GCS",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // GetGCS gets the GCS configuration with the given parameters. | [
"GetGCS",
"gets",
"the",
"GCS",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/gcs.go#L126-L150 |
10,344 | sethvargo/go-fastly | fastly/gcs.go | UpdateGCS | func (c *Client) UpdateGCS(i *UpdateGCSInput) (*GCS, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/gcs/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var b *GCS
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) UpdateGCS(i *UpdateGCSInput) (*GCS, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/gcs/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var b *GCS
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateGCS",
"(",
"i",
"*",
"UpdateGCSInput",
")",
"(",
"*",
"GCS",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"b",
"*",
"GCS",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // UpdateGCS updates a specific GCS. | [
"UpdateGCS",
"updates",
"a",
"specific",
"GCS",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/gcs.go#L176-L200 |
10,345 | sethvargo/go-fastly | fastly/diff.go | GetDiff | func (c *Client) GetDiff(i *GetDiffInput) (*Diff, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.From == 0 {
return nil, ErrMissingFrom
}
if i.To == 0 {
return nil, ErrMissingTo
}
path := fmt.Sprintf("service/%s/diff/from/%d/to/%d", i.Service, i.From, i.To)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var d *Diff
if err := decodeJSON(&d, resp.Body); err != nil {
return nil, err
}
return d, nil
} | go | func (c *Client) GetDiff(i *GetDiffInput) (*Diff, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.From == 0 {
return nil, ErrMissingFrom
}
if i.To == 0 {
return nil, ErrMissingTo
}
path := fmt.Sprintf("service/%s/diff/from/%d/to/%d", i.Service, i.From, i.To)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var d *Diff
if err := decodeJSON(&d, resp.Body); err != nil {
return nil, err
}
return d, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetDiff",
"(",
"i",
"*",
"GetDiffInput",
")",
"(",
"*",
"Diff",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"From",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingFrom",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"To",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingTo",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"From",
",",
"i",
".",
"To",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"d",
"*",
"Diff",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"d",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"d",
",",
"nil",
"\n",
"}"
] | // GetDiff returns the diff of the given versions. | [
"GetDiff",
"returns",
"the",
"diff",
"of",
"the",
"given",
"versions",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/diff.go#L33-L57 |
10,346 | sethvargo/go-fastly | fastly/domain.go | ListDomains | func (c *Client) ListDomains(i *ListDomainsInput) ([]*Domain, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/domain", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ds []*Domain
if err := decodeJSON(&ds, resp.Body); err != nil {
return nil, err
}
sort.Stable(domainsByName(ds))
return ds, nil
} | go | func (c *Client) ListDomains(i *ListDomainsInput) ([]*Domain, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/domain", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ds []*Domain
if err := decodeJSON(&ds, resp.Body); err != nil {
return nil, err
}
sort.Stable(domainsByName(ds))
return ds, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListDomains",
"(",
"i",
"*",
"ListDomainsInput",
")",
"(",
"[",
"]",
"*",
"Domain",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"ds",
"[",
"]",
"*",
"Domain",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"ds",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"domainsByName",
"(",
"ds",
")",
")",
"\n",
"return",
"ds",
",",
"nil",
"\n",
"}"
] | // ListDomains returns the list of domains for this Service. | [
"ListDomains",
"returns",
"the",
"list",
"of",
"domains",
"for",
"this",
"Service",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/domain.go#L36-L57 |
10,347 | sethvargo/go-fastly | fastly/domain.go | CreateDomain | func (c *Client) CreateDomain(i *CreateDomainInput) (*Domain, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/domain", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var d *Domain
if err := decodeJSON(&d, resp.Body); err != nil {
return nil, err
}
return d, nil
} | go | func (c *Client) CreateDomain(i *CreateDomainInput) (*Domain, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/domain", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var d *Domain
if err := decodeJSON(&d, resp.Body); err != nil {
return nil, err
}
return d, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateDomain",
"(",
"i",
"*",
"CreateDomainInput",
")",
"(",
"*",
"Domain",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"d",
"*",
"Domain",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"d",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"d",
",",
"nil",
"\n",
"}"
] | // CreateDomain creates a new domain with the given information. | [
"CreateDomain",
"creates",
"a",
"new",
"domain",
"with",
"the",
"given",
"information",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/domain.go#L74-L94 |
10,348 | sethvargo/go-fastly | fastly/domain.go | GetDomain | func (c *Client) GetDomain(i *GetDomainInput) (*Domain, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/domain/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var d *Domain
if err := decodeJSON(&d, resp.Body); err != nil {
return nil, err
}
return d, nil
} | go | func (c *Client) GetDomain(i *GetDomainInput) (*Domain, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/domain/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var d *Domain
if err := decodeJSON(&d, resp.Body); err != nil {
return nil, err
}
return d, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetDomain",
"(",
"i",
"*",
"GetDomainInput",
")",
"(",
"*",
"Domain",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"d",
"*",
"Domain",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"d",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"d",
",",
"nil",
"\n",
"}"
] | // GetDomain retrieves information about the given domain name. | [
"GetDomain",
"retrieves",
"information",
"about",
"the",
"given",
"domain",
"name",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/domain.go#L108-L132 |
10,349 | sethvargo/go-fastly | fastly/domain.go | UpdateDomain | func (c *Client) UpdateDomain(i *UpdateDomainInput) (*Domain, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/domain/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var d *Domain
if err := decodeJSON(&d, resp.Body); err != nil {
return nil, err
}
return d, nil
} | go | func (c *Client) UpdateDomain(i *UpdateDomainInput) (*Domain, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/domain/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var d *Domain
if err := decodeJSON(&d, resp.Body); err != nil {
return nil, err
}
return d, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateDomain",
"(",
"i",
"*",
"UpdateDomainInput",
")",
"(",
"*",
"Domain",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"d",
"*",
"Domain",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"d",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"d",
",",
"nil",
"\n",
"}"
] | // UpdateDomain updates a single domain for the current service. The only allowed
// parameters are `Name` and `Comment`. | [
"UpdateDomain",
"updates",
"a",
"single",
"domain",
"for",
"the",
"current",
"service",
".",
"The",
"only",
"allowed",
"parameters",
"are",
"Name",
"and",
"Comment",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/domain.go#L153-L177 |
10,350 | sethvargo/go-fastly | fastly/domain.go | DeleteDomain | func (c *Client) DeleteDomain(i *DeleteDomainInput) error {
if i.Service == "" {
return ErrMissingService
}
if i.Version == 0 {
return ErrMissingVersion
}
if i.Name == "" {
return ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/domain/%s", i.Service, i.Version, i.Name)
_, err := c.Delete(path, nil)
if err != nil {
return err
}
return nil
} | go | func (c *Client) DeleteDomain(i *DeleteDomainInput) error {
if i.Service == "" {
return ErrMissingService
}
if i.Version == 0 {
return ErrMissingVersion
}
if i.Name == "" {
return ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/domain/%s", i.Service, i.Version, i.Name)
_, err := c.Delete(path, nil)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteDomain",
"(",
"i",
"*",
"DeleteDomainInput",
")",
"error",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"_",
",",
"err",
":=",
"c",
".",
"Delete",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // DeleteDomain removes a single domain by the given name. | [
"DeleteDomain",
"removes",
"a",
"single",
"domain",
"by",
"the",
"given",
"name",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/domain.go#L191-L210 |
10,351 | sethvargo/go-fastly | fastly/errors.go | NewHTTPError | func NewHTTPError(resp *http.Response) *HTTPError {
var e HTTPError
e.StatusCode = resp.StatusCode
if resp.Body == nil {
return &e
}
// If this is a jsonapi response, decode it accordingly
if resp.Header.Get("Content-Type") == jsonapi.MediaType {
if err := decodeJSON(&e, resp.Body); err != nil {
panic(err)
}
} else {
var lerr *legacyError
decodeJSON(&lerr, resp.Body)
if lerr != nil {
e.Errors = append(e.Errors, &ErrorObject{
Title: lerr.Message,
Detail: lerr.Detail,
})
}
}
return &e
} | go | func NewHTTPError(resp *http.Response) *HTTPError {
var e HTTPError
e.StatusCode = resp.StatusCode
if resp.Body == nil {
return &e
}
// If this is a jsonapi response, decode it accordingly
if resp.Header.Get("Content-Type") == jsonapi.MediaType {
if err := decodeJSON(&e, resp.Body); err != nil {
panic(err)
}
} else {
var lerr *legacyError
decodeJSON(&lerr, resp.Body)
if lerr != nil {
e.Errors = append(e.Errors, &ErrorObject{
Title: lerr.Message,
Detail: lerr.Detail,
})
}
}
return &e
} | [
"func",
"NewHTTPError",
"(",
"resp",
"*",
"http",
".",
"Response",
")",
"*",
"HTTPError",
"{",
"var",
"e",
"HTTPError",
"\n",
"e",
".",
"StatusCode",
"=",
"resp",
".",
"StatusCode",
"\n\n",
"if",
"resp",
".",
"Body",
"==",
"nil",
"{",
"return",
"&",
"e",
"\n",
"}",
"\n\n",
"// If this is a jsonapi response, decode it accordingly",
"if",
"resp",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
"==",
"jsonapi",
".",
"MediaType",
"{",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"e",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"var",
"lerr",
"*",
"legacyError",
"\n",
"decodeJSON",
"(",
"&",
"lerr",
",",
"resp",
".",
"Body",
")",
"\n",
"if",
"lerr",
"!=",
"nil",
"{",
"e",
".",
"Errors",
"=",
"append",
"(",
"e",
".",
"Errors",
",",
"&",
"ErrorObject",
"{",
"Title",
":",
"lerr",
".",
"Message",
",",
"Detail",
":",
"lerr",
".",
"Detail",
",",
"}",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"&",
"e",
"\n",
"}"
] | // NewHTTPError creates a new HTTP error from the given code. | [
"NewHTTPError",
"creates",
"a",
"new",
"HTTP",
"error",
"from",
"the",
"given",
"code",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/errors.go#L167-L192 |
10,352 | sethvargo/go-fastly | fastly/errors.go | Error | func (e *HTTPError) Error() string {
var b bytes.Buffer
fmt.Fprintf(&b, "%d - %s:", e.StatusCode, http.StatusText(e.StatusCode))
for _, e := range e.Errors {
fmt.Fprintf(&b, "\n")
if e.ID != "" {
fmt.Fprintf(&b, "\n ID: %s", e.ID)
}
if e.Title != "" {
fmt.Fprintf(&b, "\n Title: %s", e.Title)
}
if e.Detail != "" {
fmt.Fprintf(&b, "\n Detail: %s", e.Detail)
}
if e.Code != "" {
fmt.Fprintf(&b, "\n Code: %s", e.Code)
}
if e.Meta != nil {
fmt.Fprintf(&b, "\n Meta: %v", *e.Meta)
}
}
return b.String()
} | go | func (e *HTTPError) Error() string {
var b bytes.Buffer
fmt.Fprintf(&b, "%d - %s:", e.StatusCode, http.StatusText(e.StatusCode))
for _, e := range e.Errors {
fmt.Fprintf(&b, "\n")
if e.ID != "" {
fmt.Fprintf(&b, "\n ID: %s", e.ID)
}
if e.Title != "" {
fmt.Fprintf(&b, "\n Title: %s", e.Title)
}
if e.Detail != "" {
fmt.Fprintf(&b, "\n Detail: %s", e.Detail)
}
if e.Code != "" {
fmt.Fprintf(&b, "\n Code: %s", e.Code)
}
if e.Meta != nil {
fmt.Fprintf(&b, "\n Meta: %v", *e.Meta)
}
}
return b.String()
} | [
"func",
"(",
"e",
"*",
"HTTPError",
")",
"Error",
"(",
")",
"string",
"{",
"var",
"b",
"bytes",
".",
"Buffer",
"\n\n",
"fmt",
".",
"Fprintf",
"(",
"&",
"b",
",",
"\"",
"\"",
",",
"e",
".",
"StatusCode",
",",
"http",
".",
"StatusText",
"(",
"e",
".",
"StatusCode",
")",
")",
"\n\n",
"for",
"_",
",",
"e",
":=",
"range",
"e",
".",
"Errors",
"{",
"fmt",
".",
"Fprintf",
"(",
"&",
"b",
",",
"\"",
"\\n",
"\"",
")",
"\n\n",
"if",
"e",
".",
"ID",
"!=",
"\"",
"\"",
"{",
"fmt",
".",
"Fprintf",
"(",
"&",
"b",
",",
"\"",
"\\n",
"\"",
",",
"e",
".",
"ID",
")",
"\n",
"}",
"\n\n",
"if",
"e",
".",
"Title",
"!=",
"\"",
"\"",
"{",
"fmt",
".",
"Fprintf",
"(",
"&",
"b",
",",
"\"",
"\\n",
"\"",
",",
"e",
".",
"Title",
")",
"\n",
"}",
"\n\n",
"if",
"e",
".",
"Detail",
"!=",
"\"",
"\"",
"{",
"fmt",
".",
"Fprintf",
"(",
"&",
"b",
",",
"\"",
"\\n",
"\"",
",",
"e",
".",
"Detail",
")",
"\n",
"}",
"\n\n",
"if",
"e",
".",
"Code",
"!=",
"\"",
"\"",
"{",
"fmt",
".",
"Fprintf",
"(",
"&",
"b",
",",
"\"",
"\\n",
"\"",
",",
"e",
".",
"Code",
")",
"\n",
"}",
"\n\n",
"if",
"e",
".",
"Meta",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintf",
"(",
"&",
"b",
",",
"\"",
"\\n",
"\"",
",",
"*",
"e",
".",
"Meta",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"b",
".",
"String",
"(",
")",
"\n",
"}"
] | // Error implements the error interface and returns the string representing the
// error text that includes the status code and the corresponding status text. | [
"Error",
"implements",
"the",
"error",
"interface",
"and",
"returns",
"the",
"string",
"representing",
"the",
"error",
"text",
"that",
"includes",
"the",
"status",
"code",
"and",
"the",
"corresponding",
"status",
"text",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/errors.go#L196-L226 |
10,353 | sethvargo/go-fastly | fastly/event_logs.go | GetAPIEvents | func (c *Client) GetAPIEvents(i *GetAPIEventsFilterInput) (GetAPIEventsResponse, error) {
eventsResponse := GetAPIEventsResponse{
Events: []*Event{},
Links: EventsPaginationInfo{},
}
path := fmt.Sprintf("/events")
filters := &RequestOptions{Params: i.formatEventFilters()}
resp, err := c.Get(path, filters)
if err != nil {
return eventsResponse, err
}
err = c.interpretAPIEventsPage(&eventsResponse, i.PageNumber, resp)
// NOTE: It's possible for eventsResponse to be partially completed before an error
// was encountered, so the presence of a statusResponse doesn't preclude the presence of
// an error.
// }
return eventsResponse, err
} | go | func (c *Client) GetAPIEvents(i *GetAPIEventsFilterInput) (GetAPIEventsResponse, error) {
eventsResponse := GetAPIEventsResponse{
Events: []*Event{},
Links: EventsPaginationInfo{},
}
path := fmt.Sprintf("/events")
filters := &RequestOptions{Params: i.formatEventFilters()}
resp, err := c.Get(path, filters)
if err != nil {
return eventsResponse, err
}
err = c.interpretAPIEventsPage(&eventsResponse, i.PageNumber, resp)
// NOTE: It's possible for eventsResponse to be partially completed before an error
// was encountered, so the presence of a statusResponse doesn't preclude the presence of
// an error.
// }
return eventsResponse, err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetAPIEvents",
"(",
"i",
"*",
"GetAPIEventsFilterInput",
")",
"(",
"GetAPIEventsResponse",
",",
"error",
")",
"{",
"eventsResponse",
":=",
"GetAPIEventsResponse",
"{",
"Events",
":",
"[",
"]",
"*",
"Event",
"{",
"}",
",",
"Links",
":",
"EventsPaginationInfo",
"{",
"}",
",",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
")",
"\n\n",
"filters",
":=",
"&",
"RequestOptions",
"{",
"Params",
":",
"i",
".",
"formatEventFilters",
"(",
")",
"}",
"\n\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"filters",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"eventsResponse",
",",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"c",
".",
"interpretAPIEventsPage",
"(",
"&",
"eventsResponse",
",",
"i",
".",
"PageNumber",
",",
"resp",
")",
"\n",
"// NOTE: It's possible for eventsResponse to be partially completed before an error",
"// was encountered, so the presence of a statusResponse doesn't preclude the presence of",
"// an error.",
"// }",
"return",
"eventsResponse",
",",
"err",
"\n",
"}"
] | // GetAPIEvents lists all the events for a particular customer | [
"GetAPIEvents",
"lists",
"all",
"the",
"events",
"for",
"a",
"particular",
"customer"
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/event_logs.go#L72-L94 |
10,354 | sethvargo/go-fastly | fastly/event_logs.go | GetAPIEvent | func (c *Client) GetAPIEvent(i *GetAPIEventInput) (*Event, error) {
if i.EventID == "" {
return nil, ErrMissingEventID
}
path := fmt.Sprintf("/events/%s", i.EventID)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var event Event
if err := jsonapi.UnmarshalPayload(resp.Body, &event); err != nil {
return nil, err
}
return &event, nil
} | go | func (c *Client) GetAPIEvent(i *GetAPIEventInput) (*Event, error) {
if i.EventID == "" {
return nil, ErrMissingEventID
}
path := fmt.Sprintf("/events/%s", i.EventID)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var event Event
if err := jsonapi.UnmarshalPayload(resp.Body, &event); err != nil {
return nil, err
}
return &event, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetAPIEvent",
"(",
"i",
"*",
"GetAPIEventInput",
")",
"(",
"*",
"Event",
",",
"error",
")",
"{",
"if",
"i",
".",
"EventID",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingEventID",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"EventID",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"event",
"Event",
"\n",
"if",
"err",
":=",
"jsonapi",
".",
"UnmarshalPayload",
"(",
"resp",
".",
"Body",
",",
"&",
"event",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"event",
",",
"nil",
"\n",
"}"
] | // GetAPIEvent gets a specific event | [
"GetAPIEvent",
"gets",
"a",
"specific",
"event"
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/event_logs.go#L103-L119 |
10,355 | sethvargo/go-fastly | fastly/event_logs.go | interpretAPIEventsPage | func (c *Client) interpretAPIEventsPage(answer *GetAPIEventsResponse, pageNum int, received *http.Response) error {
// before we pull the status info out of the response body, fetch
// pagination info from it:
pages, body, err := getEventsPages(received.Body)
if err != nil {
return err
}
answer.Links = pages
data, err := jsonapi.UnmarshalManyPayload(body, reflect.TypeOf(new(Event)))
if err != nil {
return err
}
for i := range data {
typed, ok := data[i].(*Event)
if !ok {
return fmt.Errorf("got back response of unexpected type")
}
answer.Events = append(answer.Events, typed)
}
if pageNum == 0 {
if pages.Next != "" {
// NOTE: pages.Next URL includes filters already
resp, err := c.SimpleGet(pages.Next)
if err != nil {
return err
}
c.interpretAPIEventsPage(answer, pageNum, resp)
}
return nil
}
return nil
} | go | func (c *Client) interpretAPIEventsPage(answer *GetAPIEventsResponse, pageNum int, received *http.Response) error {
// before we pull the status info out of the response body, fetch
// pagination info from it:
pages, body, err := getEventsPages(received.Body)
if err != nil {
return err
}
answer.Links = pages
data, err := jsonapi.UnmarshalManyPayload(body, reflect.TypeOf(new(Event)))
if err != nil {
return err
}
for i := range data {
typed, ok := data[i].(*Event)
if !ok {
return fmt.Errorf("got back response of unexpected type")
}
answer.Events = append(answer.Events, typed)
}
if pageNum == 0 {
if pages.Next != "" {
// NOTE: pages.Next URL includes filters already
resp, err := c.SimpleGet(pages.Next)
if err != nil {
return err
}
c.interpretAPIEventsPage(answer, pageNum, resp)
}
return nil
}
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"interpretAPIEventsPage",
"(",
"answer",
"*",
"GetAPIEventsResponse",
",",
"pageNum",
"int",
",",
"received",
"*",
"http",
".",
"Response",
")",
"error",
"{",
"// before we pull the status info out of the response body, fetch",
"// pagination info from it:",
"pages",
",",
"body",
",",
"err",
":=",
"getEventsPages",
"(",
"received",
".",
"Body",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"answer",
".",
"Links",
"=",
"pages",
"\n",
"data",
",",
"err",
":=",
"jsonapi",
".",
"UnmarshalManyPayload",
"(",
"body",
",",
"reflect",
".",
"TypeOf",
"(",
"new",
"(",
"Event",
")",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"for",
"i",
":=",
"range",
"data",
"{",
"typed",
",",
"ok",
":=",
"data",
"[",
"i",
"]",
".",
"(",
"*",
"Event",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"answer",
".",
"Events",
"=",
"append",
"(",
"answer",
".",
"Events",
",",
"typed",
")",
"\n",
"}",
"\n",
"if",
"pageNum",
"==",
"0",
"{",
"if",
"pages",
".",
"Next",
"!=",
"\"",
"\"",
"{",
"// NOTE: pages.Next URL includes filters already",
"resp",
",",
"err",
":=",
"c",
".",
"SimpleGet",
"(",
"pages",
".",
"Next",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"c",
".",
"interpretAPIEventsPage",
"(",
"answer",
",",
"pageNum",
",",
"resp",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // interpretAPIEventsPage accepts a Fastly response for a set of WAF rule statuses
// and unmarshals the results. If there are more pages of results, it fetches the next
// page, adds that response to the array of results, and repeats until all results have
// been fetched. | [
"interpretAPIEventsPage",
"accepts",
"a",
"Fastly",
"response",
"for",
"a",
"set",
"of",
"WAF",
"rule",
"statuses",
"and",
"unmarshals",
"the",
"results",
".",
"If",
"there",
"are",
"more",
"pages",
"of",
"results",
"it",
"fetches",
"the",
"next",
"page",
"adds",
"that",
"response",
"to",
"the",
"array",
"of",
"results",
"and",
"repeats",
"until",
"all",
"results",
"have",
"been",
"fetched",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/event_logs.go#L125-L157 |
10,356 | sethvargo/go-fastly | fastly/event_logs.go | getEventsPages | func getEventsPages(body io.Reader) (EventsPaginationInfo, io.Reader, error) {
var buf bytes.Buffer
tee := io.TeeReader(body, &buf)
bodyBytes, err := ioutil.ReadAll(tee)
if err != nil {
return EventsPaginationInfo{}, nil, err
}
var pages *GetAPIEventsResponse
json.Unmarshal(bodyBytes, &pages)
return pages.Links, bytes.NewReader(buf.Bytes()), nil
} | go | func getEventsPages(body io.Reader) (EventsPaginationInfo, io.Reader, error) {
var buf bytes.Buffer
tee := io.TeeReader(body, &buf)
bodyBytes, err := ioutil.ReadAll(tee)
if err != nil {
return EventsPaginationInfo{}, nil, err
}
var pages *GetAPIEventsResponse
json.Unmarshal(bodyBytes, &pages)
return pages.Links, bytes.NewReader(buf.Bytes()), nil
} | [
"func",
"getEventsPages",
"(",
"body",
"io",
".",
"Reader",
")",
"(",
"EventsPaginationInfo",
",",
"io",
".",
"Reader",
",",
"error",
")",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"tee",
":=",
"io",
".",
"TeeReader",
"(",
"body",
",",
"&",
"buf",
")",
"\n\n",
"bodyBytes",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"tee",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"EventsPaginationInfo",
"{",
"}",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"pages",
"*",
"GetAPIEventsResponse",
"\n",
"json",
".",
"Unmarshal",
"(",
"bodyBytes",
",",
"&",
"pages",
")",
"\n",
"return",
"pages",
".",
"Links",
",",
"bytes",
".",
"NewReader",
"(",
"buf",
".",
"Bytes",
"(",
")",
")",
",",
"nil",
"\n",
"}"
] | // getEventsPages parses a response to get the pagination data without destroying
// the reader we receive as "resp.Body"; this essentially copies resp.Body
// and returns it so we can use it again. | [
"getEventsPages",
"parses",
"a",
"response",
"to",
"get",
"the",
"pagination",
"data",
"without",
"destroying",
"the",
"reader",
"we",
"receive",
"as",
"resp",
".",
"Body",
";",
"this",
"essentially",
"copies",
"resp",
".",
"Body",
"and",
"returns",
"it",
"so",
"we",
"can",
"use",
"it",
"again",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/event_logs.go#L162-L174 |
10,357 | sethvargo/go-fastly | fastly/event_logs.go | formatEventFilters | func (i *GetAPIEventsFilterInput) formatEventFilters() map[string]string {
result := map[string]string{}
pairings := map[string]interface{}{
"filter[customer_id]": i.CustomerID,
"filter[service_id]": i.ServiceID,
"filter[event_type]": i.EventType,
"filter[user_id]": i.UserID,
"page[size]": i.MaxResults,
"page[number]": i.PageNumber, // starts at 1, not 0
}
// NOTE: This setup means we will not be able to send the zero value
// of any of these filters. It doesn't appear we would need to at present.
for key, value := range pairings {
switch t := reflect.TypeOf(value).String(); t {
case "string":
if value != "" {
result[key] = value.(string)
}
case "int":
if value != 0 {
result[key] = strconv.Itoa(value.(int))
}
}
}
return result
} | go | func (i *GetAPIEventsFilterInput) formatEventFilters() map[string]string {
result := map[string]string{}
pairings := map[string]interface{}{
"filter[customer_id]": i.CustomerID,
"filter[service_id]": i.ServiceID,
"filter[event_type]": i.EventType,
"filter[user_id]": i.UserID,
"page[size]": i.MaxResults,
"page[number]": i.PageNumber, // starts at 1, not 0
}
// NOTE: This setup means we will not be able to send the zero value
// of any of these filters. It doesn't appear we would need to at present.
for key, value := range pairings {
switch t := reflect.TypeOf(value).String(); t {
case "string":
if value != "" {
result[key] = value.(string)
}
case "int":
if value != 0 {
result[key] = strconv.Itoa(value.(int))
}
}
}
return result
} | [
"func",
"(",
"i",
"*",
"GetAPIEventsFilterInput",
")",
"formatEventFilters",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"result",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"pairings",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"i",
".",
"CustomerID",
",",
"\"",
"\"",
":",
"i",
".",
"ServiceID",
",",
"\"",
"\"",
":",
"i",
".",
"EventType",
",",
"\"",
"\"",
":",
"i",
".",
"UserID",
",",
"\"",
"\"",
":",
"i",
".",
"MaxResults",
",",
"\"",
"\"",
":",
"i",
".",
"PageNumber",
",",
"// starts at 1, not 0",
"}",
"\n",
"// NOTE: This setup means we will not be able to send the zero value",
"// of any of these filters. It doesn't appear we would need to at present.",
"for",
"key",
",",
"value",
":=",
"range",
"pairings",
"{",
"switch",
"t",
":=",
"reflect",
".",
"TypeOf",
"(",
"value",
")",
".",
"String",
"(",
")",
";",
"t",
"{",
"case",
"\"",
"\"",
":",
"if",
"value",
"!=",
"\"",
"\"",
"{",
"result",
"[",
"key",
"]",
"=",
"value",
".",
"(",
"string",
")",
"\n",
"}",
"\n",
"case",
"\"",
"\"",
":",
"if",
"value",
"!=",
"0",
"{",
"result",
"[",
"key",
"]",
"=",
"strconv",
".",
"Itoa",
"(",
"value",
".",
"(",
"int",
")",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"\n",
"return",
"result",
"\n",
"}"
] | // formatEventFilters converts user input into query parameters for filtering
// Fastly events. | [
"formatEventFilters",
"converts",
"user",
"input",
"into",
"query",
"parameters",
"for",
"filtering",
"Fastly",
"events",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/event_logs.go#L178-L205 |
10,358 | sethvargo/go-fastly | fastly/content.go | EdgeCheck | func (c *Client) EdgeCheck(i *EdgeCheckInput) ([]*EdgeCheck, error) {
resp, err := c.Get("/content/edge_check", &RequestOptions{
Params: map[string]string{
"url": i.URL,
},
})
if err != nil {
return nil, err
}
var e []*EdgeCheck
if err := decodeJSON(&e, resp.Body); err != nil {
return nil, err
}
return e, nil
} | go | func (c *Client) EdgeCheck(i *EdgeCheckInput) ([]*EdgeCheck, error) {
resp, err := c.Get("/content/edge_check", &RequestOptions{
Params: map[string]string{
"url": i.URL,
},
})
if err != nil {
return nil, err
}
var e []*EdgeCheck
if err := decodeJSON(&e, resp.Body); err != nil {
return nil, err
}
return e, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"EdgeCheck",
"(",
"i",
"*",
"EdgeCheckInput",
")",
"(",
"[",
"]",
"*",
"EdgeCheck",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"\"",
"\"",
",",
"&",
"RequestOptions",
"{",
"Params",
":",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"i",
".",
"URL",
",",
"}",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"e",
"[",
"]",
"*",
"EdgeCheck",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"e",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"e",
",",
"nil",
"\n",
"}"
] | // EdgeCheck queries the edge cache for all of Fastly's servers for the given
// URL. | [
"EdgeCheck",
"queries",
"the",
"edge",
"cache",
"for",
"all",
"of",
"Fastly",
"s",
"servers",
"for",
"the",
"given",
"URL",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/content.go#L34-L49 |
10,359 | sethvargo/go-fastly | fastly/logentries.go | ListLogentries | func (c *Client) ListLogentries(i *ListLogentriesInput) ([]*Logentries, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/logentries", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ls []*Logentries
if err := decodeJSON(&ls, resp.Body); err != nil {
return nil, err
}
sort.Stable(logentriesByName(ls))
return ls, nil
} | go | func (c *Client) ListLogentries(i *ListLogentriesInput) ([]*Logentries, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/logentries", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ls []*Logentries
if err := decodeJSON(&ls, resp.Body); err != nil {
return nil, err
}
sort.Stable(logentriesByName(ls))
return ls, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListLogentries",
"(",
"i",
"*",
"ListLogentriesInput",
")",
"(",
"[",
"]",
"*",
"Logentries",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"ls",
"[",
"]",
"*",
"Logentries",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"ls",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"logentriesByName",
"(",
"ls",
")",
")",
"\n",
"return",
"ls",
",",
"nil",
"\n",
"}"
] | // ListLogentries returns the list of logentries for the configuration version. | [
"ListLogentries",
"returns",
"the",
"list",
"of",
"logentries",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/logentries.go#L47-L68 |
10,360 | sethvargo/go-fastly | fastly/logentries.go | CreateLogentries | func (c *Client) CreateLogentries(i *CreateLogentriesInput) (*Logentries, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/logentries", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var l *Logentries
if err := decodeJSON(&l, resp.Body); err != nil {
return nil, err
}
return l, nil
} | go | func (c *Client) CreateLogentries(i *CreateLogentriesInput) (*Logentries, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/logentries", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var l *Logentries
if err := decodeJSON(&l, resp.Body); err != nil {
return nil, err
}
return l, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateLogentries",
"(",
"i",
"*",
"CreateLogentriesInput",
")",
"(",
"*",
"Logentries",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"l",
"*",
"Logentries",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"l",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"l",
",",
"nil",
"\n",
"}"
] | // CreateLogentries creates a new Fastly logentries. | [
"CreateLogentries",
"creates",
"a",
"new",
"Fastly",
"logentries",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/logentries.go#L88-L108 |
10,361 | sethvargo/go-fastly | fastly/logentries.go | GetLogentries | func (c *Client) GetLogentries(i *GetLogentriesInput) (*Logentries, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/logentries/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var l *Logentries
if err := decodeJSON(&l, resp.Body); err != nil {
return nil, err
}
return l, nil
} | go | func (c *Client) GetLogentries(i *GetLogentriesInput) (*Logentries, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/logentries/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var l *Logentries
if err := decodeJSON(&l, resp.Body); err != nil {
return nil, err
}
return l, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetLogentries",
"(",
"i",
"*",
"GetLogentriesInput",
")",
"(",
"*",
"Logentries",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"l",
"*",
"Logentries",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"l",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"l",
",",
"nil",
"\n",
"}"
] | // GetLogentries gets the logentries configuration with the given parameters. | [
"GetLogentries",
"gets",
"the",
"logentries",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/logentries.go#L122-L146 |
10,362 | sethvargo/go-fastly | fastly/logentries.go | UpdateLogentries | func (c *Client) UpdateLogentries(i *UpdateLogentriesInput) (*Logentries, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/logentries/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var l *Logentries
if err := decodeJSON(&l, resp.Body); err != nil {
return nil, err
}
return l, nil
} | go | func (c *Client) UpdateLogentries(i *UpdateLogentriesInput) (*Logentries, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/logentries/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var l *Logentries
if err := decodeJSON(&l, resp.Body); err != nil {
return nil, err
}
return l, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateLogentries",
"(",
"i",
"*",
"UpdateLogentriesInput",
")",
"(",
"*",
"Logentries",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"l",
"*",
"Logentries",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"l",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"l",
",",
"nil",
"\n",
"}"
] | // UpdateLogentries updates a specific logentries. | [
"UpdateLogentries",
"updates",
"a",
"specific",
"logentries",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/logentries.go#L169-L193 |
10,363 | sethvargo/go-fastly | fastly/director_backend.go | CreateDirectorBackend | func (c *Client) CreateDirectorBackend(i *CreateDirectorBackendInput) (*DirectorBackend, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Director == "" {
return nil, ErrMissingDirector
}
if i.Backend == "" {
return nil, ErrMissingBackend
}
path := fmt.Sprintf("/service/%s/version/%d/director/%s/backend/%s",
i.Service, i.Version, i.Director, i.Backend)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var b *DirectorBackend
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) CreateDirectorBackend(i *CreateDirectorBackendInput) (*DirectorBackend, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Director == "" {
return nil, ErrMissingDirector
}
if i.Backend == "" {
return nil, ErrMissingBackend
}
path := fmt.Sprintf("/service/%s/version/%d/director/%s/backend/%s",
i.Service, i.Version, i.Director, i.Backend)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var b *DirectorBackend
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateDirectorBackend",
"(",
"i",
"*",
"CreateDirectorBackendInput",
")",
"(",
"*",
"DirectorBackend",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Director",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingDirector",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Backend",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingBackend",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Director",
",",
"i",
".",
"Backend",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"b",
"*",
"DirectorBackend",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // CreateDirectorBackend creates a new Fastly backend. | [
"CreateDirectorBackend",
"creates",
"a",
"new",
"Fastly",
"backend",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/director_backend.go#L37-L66 |
10,364 | sethvargo/go-fastly | fastly/director_backend.go | GetDirectorBackend | func (c *Client) GetDirectorBackend(i *GetDirectorBackendInput) (*DirectorBackend, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Director == "" {
return nil, ErrMissingDirector
}
if i.Backend == "" {
return nil, ErrMissingBackend
}
path := fmt.Sprintf("/service/%s/version/%d/director/%s/backend/%s",
i.Service, i.Version, i.Director, i.Backend)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *DirectorBackend
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) GetDirectorBackend(i *GetDirectorBackendInput) (*DirectorBackend, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Director == "" {
return nil, ErrMissingDirector
}
if i.Backend == "" {
return nil, ErrMissingBackend
}
path := fmt.Sprintf("/service/%s/version/%d/director/%s/backend/%s",
i.Service, i.Version, i.Director, i.Backend)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *DirectorBackend
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetDirectorBackend",
"(",
"i",
"*",
"GetDirectorBackendInput",
")",
"(",
"*",
"DirectorBackend",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Director",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingDirector",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Backend",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingBackend",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Director",
",",
"i",
".",
"Backend",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"b",
"*",
"DirectorBackend",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // GetDirectorBackend gets the backend configuration with the given parameters. | [
"GetDirectorBackend",
"gets",
"the",
"backend",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/director_backend.go#L83-L112 |
10,365 | sethvargo/go-fastly | fastly/director_backend.go | DeleteDirectorBackend | func (c *Client) DeleteDirectorBackend(i *DeleteDirectorBackendInput) error {
if i.Service == "" {
return ErrMissingService
}
if i.Version == 0 {
return ErrMissingVersion
}
if i.Director == "" {
return ErrMissingDirector
}
if i.Backend == "" {
return ErrMissingBackend
}
path := fmt.Sprintf("/service/%s/version/%d/director/%s/backend/%s",
i.Service, i.Version, i.Director, i.Backend)
resp, err := c.Delete(path, nil)
if err != nil {
return err
}
var r *statusResp
if err := decodeJSON(&r, resp.Body); err != nil {
return err
}
if !r.Ok() {
return fmt.Errorf("Not Ok")
}
return nil
} | go | func (c *Client) DeleteDirectorBackend(i *DeleteDirectorBackendInput) error {
if i.Service == "" {
return ErrMissingService
}
if i.Version == 0 {
return ErrMissingVersion
}
if i.Director == "" {
return ErrMissingDirector
}
if i.Backend == "" {
return ErrMissingBackend
}
path := fmt.Sprintf("/service/%s/version/%d/director/%s/backend/%s",
i.Service, i.Version, i.Director, i.Backend)
resp, err := c.Delete(path, nil)
if err != nil {
return err
}
var r *statusResp
if err := decodeJSON(&r, resp.Body); err != nil {
return err
}
if !r.Ok() {
return fmt.Errorf("Not Ok")
}
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteDirectorBackend",
"(",
"i",
"*",
"DeleteDirectorBackendInput",
")",
"error",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Director",
"==",
"\"",
"\"",
"{",
"return",
"ErrMissingDirector",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Backend",
"==",
"\"",
"\"",
"{",
"return",
"ErrMissingBackend",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Director",
",",
"i",
".",
"Backend",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Delete",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"var",
"r",
"*",
"statusResp",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"r",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"!",
"r",
".",
"Ok",
"(",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // DeleteDirectorBackend deletes the given backend version. | [
"DeleteDirectorBackend",
"deletes",
"the",
"given",
"backend",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/director_backend.go#L129-L161 |
10,366 | sethvargo/go-fastly | fastly/syslog.go | ListSyslogs | func (c *Client) ListSyslogs(i *ListSyslogsInput) ([]*Syslog, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/syslog", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ss []*Syslog
if err := decodeJSON(&ss, resp.Body); err != nil {
return nil, err
}
sort.Stable(syslogsByName(ss))
return ss, nil
} | go | func (c *Client) ListSyslogs(i *ListSyslogsInput) ([]*Syslog, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/syslog", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ss []*Syslog
if err := decodeJSON(&ss, resp.Body); err != nil {
return nil, err
}
sort.Stable(syslogsByName(ss))
return ss, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListSyslogs",
"(",
"i",
"*",
"ListSyslogsInput",
")",
"(",
"[",
"]",
"*",
"Syslog",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"ss",
"[",
"]",
"*",
"Syslog",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"ss",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"syslogsByName",
"(",
"ss",
")",
")",
"\n",
"return",
"ss",
",",
"nil",
"\n",
"}"
] | // ListSyslogs returns the list of syslogs for the configuration version. | [
"ListSyslogs",
"returns",
"the",
"list",
"of",
"syslogs",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/syslog.go#L53-L74 |
10,367 | sethvargo/go-fastly | fastly/syslog.go | CreateSyslog | func (c *Client) CreateSyslog(i *CreateSyslogInput) (*Syslog, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/syslog", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var s *Syslog
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | go | func (c *Client) CreateSyslog(i *CreateSyslogInput) (*Syslog, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/syslog", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var s *Syslog
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateSyslog",
"(",
"i",
"*",
"CreateSyslogInput",
")",
"(",
"*",
"Syslog",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"s",
"*",
"Syslog",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"s",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] | // CreateSyslog creates a new Fastly syslog. | [
"CreateSyslog",
"creates",
"a",
"new",
"Fastly",
"syslog",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/syslog.go#L100-L120 |
10,368 | sethvargo/go-fastly | fastly/syslog.go | GetSyslog | func (c *Client) GetSyslog(i *GetSyslogInput) (*Syslog, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/syslog/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var s *Syslog
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | go | func (c *Client) GetSyslog(i *GetSyslogInput) (*Syslog, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/syslog/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var s *Syslog
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetSyslog",
"(",
"i",
"*",
"GetSyslogInput",
")",
"(",
"*",
"Syslog",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"s",
"*",
"Syslog",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"s",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] | // GetSyslog gets the syslog configuration with the given parameters. | [
"GetSyslog",
"gets",
"the",
"syslog",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/syslog.go#L134-L158 |
10,369 | sethvargo/go-fastly | fastly/syslog.go | UpdateSyslog | func (c *Client) UpdateSyslog(i *UpdateSyslogInput) (*Syslog, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/syslog/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var s *Syslog
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | go | func (c *Client) UpdateSyslog(i *UpdateSyslogInput) (*Syslog, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/syslog/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var s *Syslog
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateSyslog",
"(",
"i",
"*",
"UpdateSyslogInput",
")",
"(",
"*",
"Syslog",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"s",
"*",
"Syslog",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"s",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] | // UpdateSyslog updates a specific syslog. | [
"UpdateSyslog",
"updates",
"a",
"specific",
"syslog",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/syslog.go#L187-L211 |
10,370 | sethvargo/go-fastly | fastly/client.go | DefaultClient | func DefaultClient() *Client {
client, err := NewClient(os.Getenv(APIKeyEnvVar))
if err != nil {
panic(err)
}
return client
} | go | func DefaultClient() *Client {
client, err := NewClient(os.Getenv(APIKeyEnvVar))
if err != nil {
panic(err)
}
return client
} | [
"func",
"DefaultClient",
"(",
")",
"*",
"Client",
"{",
"client",
",",
"err",
":=",
"NewClient",
"(",
"os",
".",
"Getenv",
"(",
"APIKeyEnvVar",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"client",
"\n",
"}"
] | // DefaultClient instantiates a new Fastly API client. This function requires
// the environment variable `FASTLY_API_KEY` is set and contains a valid API key
// to authenticate with Fastly. | [
"DefaultClient",
"instantiates",
"a",
"new",
"Fastly",
"API",
"client",
".",
"This",
"function",
"requires",
"the",
"environment",
"variable",
"FASTLY_API_KEY",
"is",
"set",
"and",
"contains",
"a",
"valid",
"API",
"key",
"to",
"authenticate",
"with",
"Fastly",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/client.go#L68-L74 |
10,371 | sethvargo/go-fastly | fastly/client.go | NewClientForEndpoint | func NewClientForEndpoint(key string, endpoint string) (*Client, error) {
client := &Client{apiKey: key, Address: endpoint}
return client.init()
} | go | func NewClientForEndpoint(key string, endpoint string) (*Client, error) {
client := &Client{apiKey: key, Address: endpoint}
return client.init()
} | [
"func",
"NewClientForEndpoint",
"(",
"key",
"string",
",",
"endpoint",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"client",
":=",
"&",
"Client",
"{",
"apiKey",
":",
"key",
",",
"Address",
":",
"endpoint",
"}",
"\n",
"return",
"client",
".",
"init",
"(",
")",
"\n",
"}"
] | // NewClientForEndpoint creates a new API client with the given key and API
// endpoint. Because Fastly allows some requests without an API key, this
// function will not error if the API token is not supplied. Attempts to make a
// request that requires an API key will return a 403 response. | [
"NewClientForEndpoint",
"creates",
"a",
"new",
"API",
"client",
"with",
"the",
"given",
"key",
"and",
"API",
"endpoint",
".",
"Because",
"Fastly",
"allows",
"some",
"requests",
"without",
"an",
"API",
"key",
"this",
"function",
"will",
"not",
"error",
"if",
"the",
"API",
"token",
"is",
"not",
"supplied",
".",
"Attempts",
"to",
"make",
"a",
"request",
"that",
"requires",
"an",
"API",
"key",
"will",
"return",
"a",
"403",
"response",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/client.go#L88-L91 |
10,372 | sethvargo/go-fastly | fastly/client.go | NewRealtimeStatsClient | func NewRealtimeStatsClient() *RTSClient {
c, err := NewClientForEndpoint(os.Getenv(APIKeyEnvVar), RealtimeStatsEndpoint)
if err != nil {
panic(err)
}
return &RTSClient{client: c}
} | go | func NewRealtimeStatsClient() *RTSClient {
c, err := NewClientForEndpoint(os.Getenv(APIKeyEnvVar), RealtimeStatsEndpoint)
if err != nil {
panic(err)
}
return &RTSClient{client: c}
} | [
"func",
"NewRealtimeStatsClient",
"(",
")",
"*",
"RTSClient",
"{",
"c",
",",
"err",
":=",
"NewClientForEndpoint",
"(",
"os",
".",
"Getenv",
"(",
"APIKeyEnvVar",
")",
",",
"RealtimeStatsEndpoint",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"&",
"RTSClient",
"{",
"client",
":",
"c",
"}",
"\n",
"}"
] | // NewRealtimeStatsClient instantiates a new Fastly API client for the realtime stats.
// This function requires the environment variable `FASTLY_API_KEY` is set and contains
// a valid API key to authenticate with Fastly. | [
"NewRealtimeStatsClient",
"instantiates",
"a",
"new",
"Fastly",
"API",
"client",
"for",
"the",
"realtime",
"stats",
".",
"This",
"function",
"requires",
"the",
"environment",
"variable",
"FASTLY_API_KEY",
"is",
"set",
"and",
"contains",
"a",
"valid",
"API",
"key",
"to",
"authenticate",
"with",
"Fastly",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/client.go#L96-L102 |
10,373 | sethvargo/go-fastly | fastly/client.go | Get | func (c *Client) Get(p string, ro *RequestOptions) (*http.Response, error) {
return c.Request("GET", p, ro)
} | go | func (c *Client) Get(p string, ro *RequestOptions) (*http.Response, error) {
return c.Request("GET", p, ro)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Get",
"(",
"p",
"string",
",",
"ro",
"*",
"RequestOptions",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"return",
"c",
".",
"Request",
"(",
"\"",
"\"",
",",
"p",
",",
"ro",
")",
"\n",
"}"
] | // Get issues an HTTP GET request. | [
"Get",
"issues",
"an",
"HTTP",
"GET",
"request",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/client.go#L119-L121 |
10,374 | sethvargo/go-fastly | fastly/client.go | PatchForm | func (c *Client) PatchForm(p string, i interface{}, ro *RequestOptions) (*http.Response, error) {
return c.RequestForm("PATCH", p, i, ro)
} | go | func (c *Client) PatchForm(p string, i interface{}, ro *RequestOptions) (*http.Response, error) {
return c.RequestForm("PATCH", p, i, ro)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"PatchForm",
"(",
"p",
"string",
",",
"i",
"interface",
"{",
"}",
",",
"ro",
"*",
"RequestOptions",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"return",
"c",
".",
"RequestForm",
"(",
"\"",
"\"",
",",
"p",
",",
"i",
",",
"ro",
")",
"\n",
"}"
] | // PatchForm issues an HTTP PUT request with the given interface form-encoded. | [
"PatchForm",
"issues",
"an",
"HTTP",
"PUT",
"request",
"with",
"the",
"given",
"interface",
"form",
"-",
"encoded",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/client.go#L134-L136 |
10,375 | sethvargo/go-fastly | fastly/client.go | PatchJSONAPI | func (c *Client) PatchJSONAPI(p string, i interface{}, ro *RequestOptions) (*http.Response, error) {
return c.RequestJSONAPI("PATCH", p, i, ro)
} | go | func (c *Client) PatchJSONAPI(p string, i interface{}, ro *RequestOptions) (*http.Response, error) {
return c.RequestJSONAPI("PATCH", p, i, ro)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"PatchJSONAPI",
"(",
"p",
"string",
",",
"i",
"interface",
"{",
"}",
",",
"ro",
"*",
"RequestOptions",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"return",
"c",
".",
"RequestJSONAPI",
"(",
"\"",
"\"",
",",
"p",
",",
"i",
",",
"ro",
")",
"\n",
"}"
] | // PatchJSONAPI issues an HTTP PUT request with the given interface json-encoded. | [
"PatchJSONAPI",
"issues",
"an",
"HTTP",
"PUT",
"request",
"with",
"the",
"given",
"interface",
"json",
"-",
"encoded",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/client.go#L144-L146 |
10,376 | sethvargo/go-fastly | fastly/client.go | PutJSON | func (c *Client) PutJSON(p string, i interface{}, ro *RequestOptions) (*http.Response, error) {
return c.RequestJSON("PUT", p, i, ro)
} | go | func (c *Client) PutJSON(p string, i interface{}, ro *RequestOptions) (*http.Response, error) {
return c.RequestJSON("PUT", p, i, ro)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"PutJSON",
"(",
"p",
"string",
",",
"i",
"interface",
"{",
"}",
",",
"ro",
"*",
"RequestOptions",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"return",
"c",
".",
"RequestJSON",
"(",
"\"",
"\"",
",",
"p",
",",
"i",
",",
"ro",
")",
"\n",
"}"
] | // PutJSON issues an HTTP PUT request with the given interface json-encoded. | [
"PutJSON",
"issues",
"an",
"HTTP",
"PUT",
"request",
"with",
"the",
"given",
"interface",
"json",
"-",
"encoded",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/client.go#L179-L181 |
10,377 | sethvargo/go-fastly | fastly/client.go | Request | func (c *Client) Request(verb, p string, ro *RequestOptions) (*http.Response, error) {
req, err := c.RawRequest(verb, p, ro)
if err != nil {
return nil, err
}
resp, err := checkResp(c.HTTPClient.Do(req))
if err != nil {
return resp, err
}
return resp, nil
} | go | func (c *Client) Request(verb, p string, ro *RequestOptions) (*http.Response, error) {
req, err := c.RawRequest(verb, p, ro)
if err != nil {
return nil, err
}
resp, err := checkResp(c.HTTPClient.Do(req))
if err != nil {
return resp, err
}
return resp, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Request",
"(",
"verb",
",",
"p",
"string",
",",
"ro",
"*",
"RequestOptions",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"c",
".",
"RawRequest",
"(",
"verb",
",",
"p",
",",
"ro",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"resp",
",",
"err",
":=",
"checkResp",
"(",
"c",
".",
"HTTPClient",
".",
"Do",
"(",
"req",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"resp",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"resp",
",",
"nil",
"\n",
"}"
] | // Request makes an HTTP request against the HTTPClient using the given verb,
// Path, and request options. | [
"Request",
"makes",
"an",
"HTTP",
"request",
"against",
"the",
"HTTPClient",
"using",
"the",
"given",
"verb",
"Path",
"and",
"request",
"options",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/client.go#L195-L207 |
10,378 | sethvargo/go-fastly | fastly/client.go | RequestForm | func (c *Client) RequestForm(verb, p string, i interface{}, ro *RequestOptions) (*http.Response, error) {
if ro == nil {
ro = new(RequestOptions)
}
if ro.Headers == nil {
ro.Headers = make(map[string]string)
}
ro.Headers["Content-Type"] = "application/x-www-form-urlencoded"
buf := new(bytes.Buffer)
if err := form.NewEncoder(buf).KeepZeros(true).DelimitWith('|').Encode(i); err != nil {
return nil, err
}
body := buf.String()
ro.Body = strings.NewReader(body)
ro.BodyLength = int64(len(body))
return c.Request(verb, p, ro)
} | go | func (c *Client) RequestForm(verb, p string, i interface{}, ro *RequestOptions) (*http.Response, error) {
if ro == nil {
ro = new(RequestOptions)
}
if ro.Headers == nil {
ro.Headers = make(map[string]string)
}
ro.Headers["Content-Type"] = "application/x-www-form-urlencoded"
buf := new(bytes.Buffer)
if err := form.NewEncoder(buf).KeepZeros(true).DelimitWith('|').Encode(i); err != nil {
return nil, err
}
body := buf.String()
ro.Body = strings.NewReader(body)
ro.BodyLength = int64(len(body))
return c.Request(verb, p, ro)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"RequestForm",
"(",
"verb",
",",
"p",
"string",
",",
"i",
"interface",
"{",
"}",
",",
"ro",
"*",
"RequestOptions",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"if",
"ro",
"==",
"nil",
"{",
"ro",
"=",
"new",
"(",
"RequestOptions",
")",
"\n",
"}",
"\n\n",
"if",
"ro",
".",
"Headers",
"==",
"nil",
"{",
"ro",
".",
"Headers",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"}",
"\n",
"ro",
".",
"Headers",
"[",
"\"",
"\"",
"]",
"=",
"\"",
"\"",
"\n\n",
"buf",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"if",
"err",
":=",
"form",
".",
"NewEncoder",
"(",
"buf",
")",
".",
"KeepZeros",
"(",
"true",
")",
".",
"DelimitWith",
"(",
"'|'",
")",
".",
"Encode",
"(",
"i",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"body",
":=",
"buf",
".",
"String",
"(",
")",
"\n\n",
"ro",
".",
"Body",
"=",
"strings",
".",
"NewReader",
"(",
"body",
")",
"\n",
"ro",
".",
"BodyLength",
"=",
"int64",
"(",
"len",
"(",
"body",
")",
")",
"\n\n",
"return",
"c",
".",
"Request",
"(",
"verb",
",",
"p",
",",
"ro",
")",
"\n",
"}"
] | // RequestForm makes an HTTP request with the given interface being encoded as
// form data. | [
"RequestForm",
"makes",
"an",
"HTTP",
"request",
"with",
"the",
"given",
"interface",
"being",
"encoded",
"as",
"form",
"data",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/client.go#L211-L231 |
10,379 | sethvargo/go-fastly | fastly/client.go | checkResp | func checkResp(resp *http.Response, err error) (*http.Response, error) {
// If the err is already there, there was an error higher up the chain, so
// just return that.
if err != nil {
return resp, err
}
switch resp.StatusCode {
case 200, 201, 202, 204, 205, 206:
return resp, nil
default:
return resp, NewHTTPError(resp)
}
} | go | func checkResp(resp *http.Response, err error) (*http.Response, error) {
// If the err is already there, there was an error higher up the chain, so
// just return that.
if err != nil {
return resp, err
}
switch resp.StatusCode {
case 200, 201, 202, 204, 205, 206:
return resp, nil
default:
return resp, NewHTTPError(resp)
}
} | [
"func",
"checkResp",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"err",
"error",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"// If the err is already there, there was an error higher up the chain, so",
"// just return that.",
"if",
"err",
"!=",
"nil",
"{",
"return",
"resp",
",",
"err",
"\n",
"}",
"\n\n",
"switch",
"resp",
".",
"StatusCode",
"{",
"case",
"200",
",",
"201",
",",
"202",
",",
"204",
",",
"205",
",",
"206",
":",
"return",
"resp",
",",
"nil",
"\n",
"default",
":",
"return",
"resp",
",",
"NewHTTPError",
"(",
"resp",
")",
"\n",
"}",
"\n",
"}"
] | // checkResp wraps an HTTP request from the default client and verifies that the
// request was successful. A non-200 request returns an error formatted to
// included any validation problems or otherwise. | [
"checkResp",
"wraps",
"an",
"HTTP",
"request",
"from",
"the",
"default",
"client",
"and",
"verifies",
"that",
"the",
"request",
"was",
"successful",
".",
"A",
"non",
"-",
"200",
"request",
"returns",
"an",
"error",
"formatted",
"to",
"included",
"any",
"validation",
"problems",
"or",
"otherwise",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/client.go#L280-L293 |
10,380 | sethvargo/go-fastly | fastly/client.go | decodeJSON | func decodeJSON(out interface{}, body io.ReadCloser) error {
defer body.Close()
var parsed interface{}
dec := json.NewDecoder(body)
if err := dec.Decode(&parsed); err != nil {
return err
}
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
DecodeHook: mapstructure.ComposeDecodeHookFunc(
mapToHTTPHeaderHookFunc(),
stringToTimeHookFunc(),
),
WeaklyTypedInput: true,
Result: out,
})
if err != nil {
return err
}
return decoder.Decode(parsed)
} | go | func decodeJSON(out interface{}, body io.ReadCloser) error {
defer body.Close()
var parsed interface{}
dec := json.NewDecoder(body)
if err := dec.Decode(&parsed); err != nil {
return err
}
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
DecodeHook: mapstructure.ComposeDecodeHookFunc(
mapToHTTPHeaderHookFunc(),
stringToTimeHookFunc(),
),
WeaklyTypedInput: true,
Result: out,
})
if err != nil {
return err
}
return decoder.Decode(parsed)
} | [
"func",
"decodeJSON",
"(",
"out",
"interface",
"{",
"}",
",",
"body",
"io",
".",
"ReadCloser",
")",
"error",
"{",
"defer",
"body",
".",
"Close",
"(",
")",
"\n\n",
"var",
"parsed",
"interface",
"{",
"}",
"\n",
"dec",
":=",
"json",
".",
"NewDecoder",
"(",
"body",
")",
"\n",
"if",
"err",
":=",
"dec",
".",
"Decode",
"(",
"&",
"parsed",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"decoder",
",",
"err",
":=",
"mapstructure",
".",
"NewDecoder",
"(",
"&",
"mapstructure",
".",
"DecoderConfig",
"{",
"DecodeHook",
":",
"mapstructure",
".",
"ComposeDecodeHookFunc",
"(",
"mapToHTTPHeaderHookFunc",
"(",
")",
",",
"stringToTimeHookFunc",
"(",
")",
",",
")",
",",
"WeaklyTypedInput",
":",
"true",
",",
"Result",
":",
"out",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"decoder",
".",
"Decode",
"(",
"parsed",
")",
"\n",
"}"
] | // decodeJSON is used to decode an HTTP response body into an interface as JSON. | [
"decodeJSON",
"is",
"used",
"to",
"decode",
"an",
"HTTP",
"response",
"body",
"into",
"an",
"interface",
"as",
"JSON",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/client.go#L296-L317 |
10,381 | sethvargo/go-fastly | fastly/s3.go | ListS3s | func (c *Client) ListS3s(i *ListS3sInput) ([]*S3, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/s3", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var s3s []*S3
if err := decodeJSON(&s3s, resp.Body); err != nil {
return nil, err
}
sort.Stable(s3sByName(s3s))
return s3s, nil
} | go | func (c *Client) ListS3s(i *ListS3sInput) ([]*S3, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/s3", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var s3s []*S3
if err := decodeJSON(&s3s, resp.Body); err != nil {
return nil, err
}
sort.Stable(s3sByName(s3s))
return s3s, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListS3s",
"(",
"i",
"*",
"ListS3sInput",
")",
"(",
"[",
"]",
"*",
"S3",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"s3s",
"[",
"]",
"*",
"S3",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"s3s",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"s3sByName",
"(",
"s3s",
")",
")",
"\n",
"return",
"s3s",
",",
"nil",
"\n",
"}"
] | // ListS3s returns the list of S3s for the configuration version. | [
"ListS3s",
"returns",
"the",
"list",
"of",
"S3s",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/s3.go#L61-L82 |
10,382 | sethvargo/go-fastly | fastly/s3.go | CreateS3 | func (c *Client) CreateS3(i *CreateS3Input) (*S3, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/s3", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var s3 *S3
if err := decodeJSON(&s3, resp.Body); err != nil {
return nil, err
}
return s3, nil
} | go | func (c *Client) CreateS3(i *CreateS3Input) (*S3, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/s3", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var s3 *S3
if err := decodeJSON(&s3, resp.Body); err != nil {
return nil, err
}
return s3, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateS3",
"(",
"i",
"*",
"CreateS3Input",
")",
"(",
"*",
"S3",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"s3",
"*",
"S3",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"s3",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"s3",
",",
"nil",
"\n",
"}"
] | // CreateS3 creates a new Fastly S3. | [
"CreateS3",
"creates",
"a",
"new",
"Fastly",
"S3",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/s3.go#L109-L129 |
10,383 | sethvargo/go-fastly | fastly/s3.go | GetS3 | func (c *Client) GetS3(i *GetS3Input) (*S3, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/s3/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var s3 *S3
if err := decodeJSON(&s3, resp.Body); err != nil {
return nil, err
}
return s3, nil
} | go | func (c *Client) GetS3(i *GetS3Input) (*S3, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/s3/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var s3 *S3
if err := decodeJSON(&s3, resp.Body); err != nil {
return nil, err
}
return s3, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetS3",
"(",
"i",
"*",
"GetS3Input",
")",
"(",
"*",
"S3",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"s3",
"*",
"S3",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"s3",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"s3",
",",
"nil",
"\n",
"}"
] | // GetS3 gets the S3 configuration with the given parameters. | [
"GetS3",
"gets",
"the",
"S3",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/s3.go#L143-L167 |
10,384 | sethvargo/go-fastly | fastly/s3.go | UpdateS3 | func (c *Client) UpdateS3(i *UpdateS3Input) (*S3, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/s3/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var s3 *S3
if err := decodeJSON(&s3, resp.Body); err != nil {
return nil, err
}
return s3, nil
} | go | func (c *Client) UpdateS3(i *UpdateS3Input) (*S3, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/s3/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var s3 *S3
if err := decodeJSON(&s3, resp.Body); err != nil {
return nil, err
}
return s3, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateS3",
"(",
"i",
"*",
"UpdateS3Input",
")",
"(",
"*",
"S3",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"s3",
"*",
"S3",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"s3",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"s3",
",",
"nil",
"\n",
"}"
] | // UpdateS3 updates a specific S3. | [
"UpdateS3",
"updates",
"a",
"specific",
"S3",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/s3.go#L197-L221 |
10,385 | sethvargo/go-fastly | fastly/sumologic.go | ListSumologics | func (c *Client) ListSumologics(i *ListSumologicsInput) ([]*Sumologic, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ss []*Sumologic
if err := decodeJSON(&ss, resp.Body); err != nil {
return nil, err
}
sort.Stable(sumologicsByName(ss))
return ss, nil
} | go | func (c *Client) ListSumologics(i *ListSumologicsInput) ([]*Sumologic, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ss []*Sumologic
if err := decodeJSON(&ss, resp.Body); err != nil {
return nil, err
}
sort.Stable(sumologicsByName(ss))
return ss, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListSumologics",
"(",
"i",
"*",
"ListSumologicsInput",
")",
"(",
"[",
"]",
"*",
"Sumologic",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"ss",
"[",
"]",
"*",
"Sumologic",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"ss",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"sumologicsByName",
"(",
"ss",
")",
")",
"\n",
"return",
"ss",
",",
"nil",
"\n",
"}"
] | // ListSumologics returns the list of sumologics for the configuration version. | [
"ListSumologics",
"returns",
"the",
"list",
"of",
"sumologics",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/sumologic.go#L47-L68 |
10,386 | sethvargo/go-fastly | fastly/sumologic.go | CreateSumologic | func (c *Client) CreateSumologic(i *CreateSumologicInput) (*Sumologic, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var s *Sumologic
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | go | func (c *Client) CreateSumologic(i *CreateSumologicInput) (*Sumologic, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var s *Sumologic
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateSumologic",
"(",
"i",
"*",
"CreateSumologicInput",
")",
"(",
"*",
"Sumologic",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"s",
"*",
"Sumologic",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"s",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] | // CreateSumologic creates a new Fastly sumologic. | [
"CreateSumologic",
"creates",
"a",
"new",
"Fastly",
"sumologic",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/sumologic.go#L88-L108 |
10,387 | sethvargo/go-fastly | fastly/sumologic.go | GetSumologic | func (c *Client) GetSumologic(i *GetSumologicInput) (*Sumologic, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var s *Sumologic
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | go | func (c *Client) GetSumologic(i *GetSumologicInput) (*Sumologic, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var s *Sumologic
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetSumologic",
"(",
"i",
"*",
"GetSumologicInput",
")",
"(",
"*",
"Sumologic",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"s",
"*",
"Sumologic",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"s",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] | // GetSumologic gets the sumologic configuration with the given parameters. | [
"GetSumologic",
"gets",
"the",
"sumologic",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/sumologic.go#L122-L146 |
10,388 | sethvargo/go-fastly | fastly/sumologic.go | UpdateSumologic | func (c *Client) UpdateSumologic(i *UpdateSumologicInput) (*Sumologic, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var s *Sumologic
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | go | func (c *Client) UpdateSumologic(i *UpdateSumologicInput) (*Sumologic, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/logging/sumologic/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var s *Sumologic
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateSumologic",
"(",
"i",
"*",
"UpdateSumologicInput",
")",
"(",
"*",
"Sumologic",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"s",
"*",
"Sumologic",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"s",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] | // UpdateSumologic updates a specific sumologic. | [
"UpdateSumologic",
"updates",
"a",
"specific",
"sumologic",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/sumologic.go#L169-L193 |
10,389 | sethvargo/go-fastly | fastly/backend.go | ListBackends | func (c *Client) ListBackends(i *ListBackendsInput) ([]*Backend, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/backend", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var bs []*Backend
if err := decodeJSON(&bs, resp.Body); err != nil {
return nil, err
}
sort.Stable(backendsByName(bs))
return bs, nil
} | go | func (c *Client) ListBackends(i *ListBackendsInput) ([]*Backend, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/backend", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var bs []*Backend
if err := decodeJSON(&bs, resp.Body); err != nil {
return nil, err
}
sort.Stable(backendsByName(bs))
return bs, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListBackends",
"(",
"i",
"*",
"ListBackendsInput",
")",
"(",
"[",
"]",
"*",
"Backend",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"bs",
"[",
"]",
"*",
"Backend",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"bs",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"backendsByName",
"(",
"bs",
")",
")",
"\n",
"return",
"bs",
",",
"nil",
"\n",
"}"
] | // ListBackends returns the list of backends for the configuration version. | [
"ListBackends",
"returns",
"the",
"list",
"of",
"backends",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/backend.go#L61-L82 |
10,390 | sethvargo/go-fastly | fastly/backend.go | CreateBackend | func (c *Client) CreateBackend(i *CreateBackendInput) (*Backend, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/backend", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var b *Backend
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) CreateBackend(i *CreateBackendInput) (*Backend, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/backend", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var b *Backend
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateBackend",
"(",
"i",
"*",
"CreateBackendInput",
")",
"(",
"*",
"Backend",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"b",
"*",
"Backend",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // CreateBackend creates a new Fastly backend. | [
"CreateBackend",
"creates",
"a",
"new",
"Fastly",
"backend",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/backend.go#L119-L139 |
10,391 | sethvargo/go-fastly | fastly/backend.go | GetBackend | func (c *Client) GetBackend(i *GetBackendInput) (*Backend, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/backend/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *Backend
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) GetBackend(i *GetBackendInput) (*Backend, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/backend/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *Backend
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetBackend",
"(",
"i",
"*",
"GetBackendInput",
")",
"(",
"*",
"Backend",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"b",
"*",
"Backend",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // GetBackend gets the backend configuration with the given parameters. | [
"GetBackend",
"gets",
"the",
"backend",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/backend.go#L153-L177 |
10,392 | sethvargo/go-fastly | fastly/backend.go | UpdateBackend | func (c *Client) UpdateBackend(i *UpdateBackendInput) (*Backend, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/backend/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var b *Backend
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) UpdateBackend(i *UpdateBackendInput) (*Backend, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/backend/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var b *Backend
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateBackend",
"(",
"i",
"*",
"UpdateBackendInput",
")",
"(",
"*",
"Backend",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"b",
"*",
"Backend",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // UpdateBackend updates a specific backend. | [
"UpdateBackend",
"updates",
"a",
"specific",
"backend",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/backend.go#L217-L241 |
10,393 | sethvargo/go-fastly | fastly/acl.go | ListACLs | func (c *Client) ListACLs(i *ListACLsInput) ([]*ACL, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/acl", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var as []*ACL
if err := decodeJSON(&as, resp.Body); err != nil {
return nil, err
}
sort.Stable(ACLsByName(as))
return as, nil
} | go | func (c *Client) ListACLs(i *ListACLsInput) ([]*ACL, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/acl", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var as []*ACL
if err := decodeJSON(&as, resp.Body); err != nil {
return nil, err
}
sort.Stable(ACLsByName(as))
return as, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListACLs",
"(",
"i",
"*",
"ListACLsInput",
")",
"(",
"[",
"]",
"*",
"ACL",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"as",
"[",
"]",
"*",
"ACL",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"as",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"ACLsByName",
"(",
"as",
")",
")",
"\n",
"return",
"as",
",",
"nil",
"\n",
"}"
] | // ListACLs returns the list of ACLs for the configuration version. | [
"ListACLs",
"returns",
"the",
"list",
"of",
"ACLs",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/acl.go#L40-L61 |
10,394 | sethvargo/go-fastly | fastly/acl.go | GetACL | func (c *Client) GetACL(i *GetACLInput) (*ACL, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/acl/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var a *ACL
if err := decodeJSON(&a, resp.Body); err != nil {
return nil, err
}
return a, nil
} | go | func (c *Client) GetACL(i *GetACLInput) (*ACL, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/acl/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var a *ACL
if err := decodeJSON(&a, resp.Body); err != nil {
return nil, err
}
return a, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetACL",
"(",
"i",
"*",
"GetACLInput",
")",
"(",
"*",
"ACL",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"a",
"*",
"ACL",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"a",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"a",
",",
"nil",
"\n",
"}"
] | // GetACL gets the ACL configuration with the given parameters. | [
"GetACL",
"gets",
"the",
"ACL",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/acl.go#L149-L173 |
10,395 | sethvargo/go-fastly | fastly/acl.go | UpdateACL | func (c *Client) UpdateACL(i *UpdateACLInput) (*ACL, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
if i.NewName == "" {
return nil, ErrMissingNewName
}
path := fmt.Sprintf("/service/%s/version/%d/acl/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var a *ACL
if err := decodeJSON(&a, resp.Body); err != nil {
return nil, err
}
return a, nil
} | go | func (c *Client) UpdateACL(i *UpdateACLInput) (*ACL, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
if i.NewName == "" {
return nil, ErrMissingNewName
}
path := fmt.Sprintf("/service/%s/version/%d/acl/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var a *ACL
if err := decodeJSON(&a, resp.Body); err != nil {
return nil, err
}
return a, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateACL",
"(",
"i",
"*",
"UpdateACLInput",
")",
"(",
"*",
"ACL",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"NewName",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingNewName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"a",
"*",
"ACL",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"a",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"a",
",",
"nil",
"\n",
"}"
] | // UpdateACL updates the name of the ACL with the given parameters. | [
"UpdateACL",
"updates",
"the",
"name",
"of",
"the",
"ACL",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/acl.go#L190-L220 |
10,396 | sethvargo/go-fastly | fastly/gzip.go | ListGzips | func (c *Client) ListGzips(i *ListGzipsInput) ([]*Gzip, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/gzip", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var gzips []*Gzip
if err := decodeJSON(&gzips, resp.Body); err != nil {
return nil, err
}
sort.Stable(gzipsByName(gzips))
return gzips, nil
} | go | func (c *Client) ListGzips(i *ListGzipsInput) ([]*Gzip, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/gzip", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var gzips []*Gzip
if err := decodeJSON(&gzips, resp.Body); err != nil {
return nil, err
}
sort.Stable(gzipsByName(gzips))
return gzips, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListGzips",
"(",
"i",
"*",
"ListGzipsInput",
")",
"(",
"[",
"]",
"*",
"Gzip",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"gzips",
"[",
"]",
"*",
"Gzip",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"gzips",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"gzipsByName",
"(",
"gzips",
")",
")",
"\n",
"return",
"gzips",
",",
"nil",
"\n",
"}"
] | // ListGzips returns the list of gzips for the configuration version. | [
"ListGzips",
"returns",
"the",
"list",
"of",
"gzips",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/gzip.go#L39-L60 |
10,397 | sethvargo/go-fastly | fastly/gzip.go | CreateGzip | func (c *Client) CreateGzip(i *CreateGzipInput) (*Gzip, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/gzip", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var gzip *Gzip
if err := decodeJSON(&gzip, resp.Body); err != nil {
return nil, err
}
return gzip, nil
} | go | func (c *Client) CreateGzip(i *CreateGzipInput) (*Gzip, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/gzip", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var gzip *Gzip
if err := decodeJSON(&gzip, resp.Body); err != nil {
return nil, err
}
return gzip, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateGzip",
"(",
"i",
"*",
"CreateGzipInput",
")",
"(",
"*",
"Gzip",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"gzip",
"*",
"Gzip",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"gzip",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"gzip",
",",
"nil",
"\n",
"}"
] | // CreateGzip creates a new Fastly Gzip. | [
"CreateGzip",
"creates",
"a",
"new",
"Fastly",
"Gzip",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/gzip.go#L76-L96 |
10,398 | sethvargo/go-fastly | fastly/gzip.go | GetGzip | func (c *Client) GetGzip(i *GetGzipInput) (*Gzip, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/gzip/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *Gzip
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) GetGzip(i *GetGzipInput) (*Gzip, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/gzip/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *Gzip
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetGzip",
"(",
"i",
"*",
"GetGzipInput",
")",
"(",
"*",
"Gzip",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"b",
"*",
"Gzip",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // GetGzip gets the Gzip configuration with the given parameters. | [
"GetGzip",
"gets",
"the",
"Gzip",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/gzip.go#L110-L134 |
10,399 | sethvargo/go-fastly | fastly/gzip.go | UpdateGzip | func (c *Client) UpdateGzip(i *UpdateGzipInput) (*Gzip, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/gzip/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var b *Gzip
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) UpdateGzip(i *UpdateGzipInput) (*Gzip, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/gzip/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var b *Gzip
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateGzip",
"(",
"i",
"*",
"UpdateGzipInput",
")",
"(",
"*",
"Gzip",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Version",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrMissingVersion",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingName",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"b",
"*",
"Gzip",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // UpdateGzip updates a specific Gzip. | [
"UpdateGzip",
"updates",
"a",
"specific",
"Gzip",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/gzip.go#L153-L177 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.