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,200 | djherbis/buffer | wrapio/wrap.go | Read | func (r *WrapReader) Read(p []byte) (n int, err error) {
n, err = Wrap(r, p, r.off, r.wrapAt)
r.off = (r.off + int64(n)) % r.wrapAt
return n, err
} | go | func (r *WrapReader) Read(p []byte) (n int, err error) {
n, err = Wrap(r, p, r.off, r.wrapAt)
r.off = (r.off + int64(n)) % r.wrapAt
return n, err
} | [
"func",
"(",
"r",
"*",
"WrapReader",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"n",
",",
"err",
"=",
"Wrap",
"(",
"r",
",",
"p",
",",
"r",
".",
"off",
",",
"r",
".",
"wrapAt",
")",
"\n",
"r",
".",
"off",
"=",
"(",
"r",
".",
"off",
"+",
"int64",
"(",
"n",
")",
")",
"%",
"r",
".",
"wrapAt",
"\n",
"return",
"n",
",",
"err",
"\n",
"}"
] | // Read reads into p starting at the current offset, wrapping if it reaches the end.
// The current offset is shifted forward by the amount read. | [
"Read",
"reads",
"into",
"p",
"starting",
"at",
"the",
"current",
"offset",
"wrapping",
"if",
"it",
"reaches",
"the",
"end",
".",
"The",
"current",
"offset",
"is",
"shifted",
"forward",
"by",
"the",
"amount",
"read",
"."
] | 3c732ee9b562a82a6e1354ea29bbc7ddd9f333b3 | https://github.com/djherbis/buffer/blob/3c732ee9b562a82a6e1354ea29bbc7ddd9f333b3/wrapio/wrap.go#L87-L91 |
10,201 | djherbis/buffer | wrapio/wrap.go | ReadAt | func (r *WrapReader) ReadAt(p []byte, off int64) (n int, err error) {
return Wrap(r, p, off, r.wrapAt)
} | go | func (r *WrapReader) ReadAt(p []byte, off int64) (n int, err error) {
return Wrap(r, p, off, r.wrapAt)
} | [
"func",
"(",
"r",
"*",
"WrapReader",
")",
"ReadAt",
"(",
"p",
"[",
"]",
"byte",
",",
"off",
"int64",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"return",
"Wrap",
"(",
"r",
",",
"p",
",",
"off",
",",
"r",
".",
"wrapAt",
")",
"\n",
"}"
] | // ReadAt reads into p starting at the current offset, wrapping when it reaches the end. | [
"ReadAt",
"reads",
"into",
"p",
"starting",
"at",
"the",
"current",
"offset",
"wrapping",
"when",
"it",
"reaches",
"the",
"end",
"."
] | 3c732ee9b562a82a6e1354ea29bbc7ddd9f333b3 | https://github.com/djherbis/buffer/blob/3c732ee9b562a82a6e1354ea29bbc7ddd9f333b3/wrapio/wrap.go#L94-L96 |
10,202 | djherbis/buffer | spill.go | NewSpill | func NewSpill(buf Buffer, w io.Writer) Buffer {
if w == nil {
w = ioutil.Discard
}
return &spill{
Buffer: buf,
Spiller: w,
}
} | go | func NewSpill(buf Buffer, w io.Writer) Buffer {
if w == nil {
w = ioutil.Discard
}
return &spill{
Buffer: buf,
Spiller: w,
}
} | [
"func",
"NewSpill",
"(",
"buf",
"Buffer",
",",
"w",
"io",
".",
"Writer",
")",
"Buffer",
"{",
"if",
"w",
"==",
"nil",
"{",
"w",
"=",
"ioutil",
".",
"Discard",
"\n",
"}",
"\n",
"return",
"&",
"spill",
"{",
"Buffer",
":",
"buf",
",",
"Spiller",
":",
"w",
",",
"}",
"\n",
"}"
] | // NewSpill returns a Buffer which writes data to w when there's an error
// writing to buf. Such as when buf is full, or the disk is full, etc. | [
"NewSpill",
"returns",
"a",
"Buffer",
"which",
"writes",
"data",
"to",
"w",
"when",
"there",
"s",
"an",
"error",
"writing",
"to",
"buf",
".",
"Such",
"as",
"when",
"buf",
"is",
"full",
"or",
"the",
"disk",
"is",
"full",
"etc",
"."
] | 3c732ee9b562a82a6e1354ea29bbc7ddd9f333b3 | https://github.com/djherbis/buffer/blob/3c732ee9b562a82a6e1354ea29bbc7ddd9f333b3/spill.go#L17-L25 |
10,203 | djherbis/buffer | file.go | NewFile | func NewFile(N int64, file File) BufferAt {
return &fileBuffer{
file: file,
Wrapper: wrapio.NewWrapper(file, 0, 0, N),
}
} | go | func NewFile(N int64, file File) BufferAt {
return &fileBuffer{
file: file,
Wrapper: wrapio.NewWrapper(file, 0, 0, N),
}
} | [
"func",
"NewFile",
"(",
"N",
"int64",
",",
"file",
"File",
")",
"BufferAt",
"{",
"return",
"&",
"fileBuffer",
"{",
"file",
":",
"file",
",",
"Wrapper",
":",
"wrapio",
".",
"NewWrapper",
"(",
"file",
",",
"0",
",",
"0",
",",
"N",
")",
",",
"}",
"\n",
"}"
] | // NewFile returns a new BufferAt backed by "file" with max-size N. | [
"NewFile",
"returns",
"a",
"new",
"BufferAt",
"backed",
"by",
"file",
"with",
"max",
"-",
"size",
"N",
"."
] | 3c732ee9b562a82a6e1354ea29bbc7ddd9f333b3 | https://github.com/djherbis/buffer/blob/3c732ee9b562a82a6e1354ea29bbc7ddd9f333b3/file.go#L29-L34 |
10,204 | djherbis/buffer | mem.go | New | func New(n int64) BufferAt {
return &memory{
N: n,
Buffer: bytes.NewBuffer(nil),
}
} | go | func New(n int64) BufferAt {
return &memory{
N: n,
Buffer: bytes.NewBuffer(nil),
}
} | [
"func",
"New",
"(",
"n",
"int64",
")",
"BufferAt",
"{",
"return",
"&",
"memory",
"{",
"N",
":",
"n",
",",
"Buffer",
":",
"bytes",
".",
"NewBuffer",
"(",
"nil",
")",
",",
"}",
"\n",
"}"
] | // New returns a new in memory BufferAt with max size N.
// It's backed by a bytes.Buffer. | [
"New",
"returns",
"a",
"new",
"in",
"memory",
"BufferAt",
"with",
"max",
"size",
"N",
".",
"It",
"s",
"backed",
"by",
"a",
"bytes",
".",
"Buffer",
"."
] | 3c732ee9b562a82a6e1354ea29bbc7ddd9f333b3 | https://github.com/djherbis/buffer/blob/3c732ee9b562a82a6e1354ea29bbc7ddd9f333b3/mem.go#L19-L24 |
10,205 | djherbis/buffer | buffer.go | NewUnboundedBuffer | func NewUnboundedBuffer(mem, file int64) Buffer {
return NewMulti(New(mem), NewPartition(NewFilePool(file, os.TempDir())))
} | go | func NewUnboundedBuffer(mem, file int64) Buffer {
return NewMulti(New(mem), NewPartition(NewFilePool(file, os.TempDir())))
} | [
"func",
"NewUnboundedBuffer",
"(",
"mem",
",",
"file",
"int64",
")",
"Buffer",
"{",
"return",
"NewMulti",
"(",
"New",
"(",
"mem",
")",
",",
"NewPartition",
"(",
"NewFilePool",
"(",
"file",
",",
"os",
".",
"TempDir",
"(",
")",
")",
")",
")",
"\n",
"}"
] | // NewUnboundedBuffer returns a Buffer which buffers "mem" bytes to memory
// and then creates file's of size "file" to buffer above "mem" bytes. | [
"NewUnboundedBuffer",
"returns",
"a",
"Buffer",
"which",
"buffers",
"mem",
"bytes",
"to",
"memory",
"and",
"then",
"creates",
"file",
"s",
"of",
"size",
"file",
"to",
"buffer",
"above",
"mem",
"bytes",
"."
] | 3c732ee9b562a82a6e1354ea29bbc7ddd9f333b3 | https://github.com/djherbis/buffer/blob/3c732ee9b562a82a6e1354ea29bbc7ddd9f333b3/buffer.go#L46-L48 |
10,206 | djherbis/buffer | multi.go | NewMultiAt | func NewMultiAt(buffers ...BufferAt) BufferAt {
if len(buffers) == 0 {
return nil
} else if len(buffers) == 1 {
return buffers[0]
}
buf := &chain{
Buf: buffers[0],
Next: NewMultiAt(buffers[1:]...),
}
buf.Defrag()
return buf
} | go | func NewMultiAt(buffers ...BufferAt) BufferAt {
if len(buffers) == 0 {
return nil
} else if len(buffers) == 1 {
return buffers[0]
}
buf := &chain{
Buf: buffers[0],
Next: NewMultiAt(buffers[1:]...),
}
buf.Defrag()
return buf
} | [
"func",
"NewMultiAt",
"(",
"buffers",
"...",
"BufferAt",
")",
"BufferAt",
"{",
"if",
"len",
"(",
"buffers",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"else",
"if",
"len",
"(",
"buffers",
")",
"==",
"1",
"{",
"return",
"buffers",
"[",
"0",
"]",
"\n",
"}",
"\n\n",
"buf",
":=",
"&",
"chain",
"{",
"Buf",
":",
"buffers",
"[",
"0",
"]",
",",
"Next",
":",
"NewMultiAt",
"(",
"buffers",
"[",
"1",
":",
"]",
"...",
")",
",",
"}",
"\n\n",
"buf",
".",
"Defrag",
"(",
")",
"\n\n",
"return",
"buf",
"\n",
"}"
] | // NewMultiAt returns a BufferAt which is the logical concatenation of the passed BufferAts.
// The data in the buffers is shifted such that there is no non-empty buffer following
// a non-full buffer, this process is also run after every Read.
// If no buffers are passed, the returned Buffer is nil. | [
"NewMultiAt",
"returns",
"a",
"BufferAt",
"which",
"is",
"the",
"logical",
"concatenation",
"of",
"the",
"passed",
"BufferAts",
".",
"The",
"data",
"in",
"the",
"buffers",
"is",
"shifted",
"such",
"that",
"there",
"is",
"no",
"non",
"-",
"empty",
"buffer",
"following",
"a",
"non",
"-",
"full",
"buffer",
"this",
"process",
"is",
"also",
"run",
"after",
"every",
"Read",
".",
"If",
"no",
"buffers",
"are",
"passed",
"the",
"returned",
"Buffer",
"is",
"nil",
"."
] | 3c732ee9b562a82a6e1354ea29bbc7ddd9f333b3 | https://github.com/djherbis/buffer/blob/3c732ee9b562a82a6e1354ea29bbc7ddd9f333b3/multi.go#L36-L51 |
10,207 | djherbis/buffer | multi.go | NewMulti | func NewMulti(buffers ...Buffer) Buffer {
bufAt := make([]BufferAt, len(buffers))
for i, buf := range buffers {
bufAt[i] = toBufferAt(buf)
}
return NewMultiAt(bufAt...)
} | go | func NewMulti(buffers ...Buffer) Buffer {
bufAt := make([]BufferAt, len(buffers))
for i, buf := range buffers {
bufAt[i] = toBufferAt(buf)
}
return NewMultiAt(bufAt...)
} | [
"func",
"NewMulti",
"(",
"buffers",
"...",
"Buffer",
")",
"Buffer",
"{",
"bufAt",
":=",
"make",
"(",
"[",
"]",
"BufferAt",
",",
"len",
"(",
"buffers",
")",
")",
"\n",
"for",
"i",
",",
"buf",
":=",
"range",
"buffers",
"{",
"bufAt",
"[",
"i",
"]",
"=",
"toBufferAt",
"(",
"buf",
")",
"\n",
"}",
"\n",
"return",
"NewMultiAt",
"(",
"bufAt",
"...",
")",
"\n",
"}"
] | // NewMulti returns a Buffer which is the logical concatenation of the passed buffers.
// The data in the buffers is shifted such that there is no non-empty buffer following
// a non-full buffer, this process is also run after every Read.
// If no buffers are passed, the returned Buffer is nil. | [
"NewMulti",
"returns",
"a",
"Buffer",
"which",
"is",
"the",
"logical",
"concatenation",
"of",
"the",
"passed",
"buffers",
".",
"The",
"data",
"in",
"the",
"buffers",
"is",
"shifted",
"such",
"that",
"there",
"is",
"no",
"non",
"-",
"empty",
"buffer",
"following",
"a",
"non",
"-",
"full",
"buffer",
"this",
"process",
"is",
"also",
"run",
"after",
"every",
"Read",
".",
"If",
"no",
"buffers",
"are",
"passed",
"the",
"returned",
"Buffer",
"is",
"nil",
"."
] | 3c732ee9b562a82a6e1354ea29bbc7ddd9f333b3 | https://github.com/djherbis/buffer/blob/3c732ee9b562a82a6e1354ea29bbc7ddd9f333b3/multi.go#L57-L63 |
10,208 | gofn/gofn | iaas/tcp/tcp.go | New | func New(URL string) (p *Provider, err error) {
u, err := url.Parse(URL)
if err != nil {
return
}
if !strings.Contains(u.Scheme, "tcp") {
err = errInvalidURL
return
}
var clientPort int
if u.Port() != "" {
clientPort, err = strconv.Atoi(u.Port())
if err != nil {
return
}
}
p = &Provider{
Host: u.Hostname(),
Port: clientPort,
}
return
} | go | func New(URL string) (p *Provider, err error) {
u, err := url.Parse(URL)
if err != nil {
return
}
if !strings.Contains(u.Scheme, "tcp") {
err = errInvalidURL
return
}
var clientPort int
if u.Port() != "" {
clientPort, err = strconv.Atoi(u.Port())
if err != nil {
return
}
}
p = &Provider{
Host: u.Hostname(),
Port: clientPort,
}
return
} | [
"func",
"New",
"(",
"URL",
"string",
")",
"(",
"p",
"*",
"Provider",
",",
"err",
"error",
")",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"URL",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"if",
"!",
"strings",
".",
"Contains",
"(",
"u",
".",
"Scheme",
",",
"\"",
"\"",
")",
"{",
"err",
"=",
"errInvalidURL",
"\n",
"return",
"\n",
"}",
"\n",
"var",
"clientPort",
"int",
"\n",
"if",
"u",
".",
"Port",
"(",
")",
"!=",
"\"",
"\"",
"{",
"clientPort",
",",
"err",
"=",
"strconv",
".",
"Atoi",
"(",
"u",
".",
"Port",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"p",
"=",
"&",
"Provider",
"{",
"Host",
":",
"u",
".",
"Hostname",
"(",
")",
",",
"Port",
":",
"clientPort",
",",
"}",
"\n",
"return",
"\n",
"}"
] | // New create provider | [
"New",
"create",
"provider"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/iaas/tcp/tcp.go#L23-L44 |
10,209 | gofn/gofn | iaas/tcp/tcp.go | CreateMachine | func (p *Provider) CreateMachine() (*iaas.Machine, error) {
return &iaas.Machine{
IP: p.Host,
Port: p.Port,
Kind: "TCP",
}, nil
} | go | func (p *Provider) CreateMachine() (*iaas.Machine, error) {
return &iaas.Machine{
IP: p.Host,
Port: p.Port,
Kind: "TCP",
}, nil
} | [
"func",
"(",
"p",
"*",
"Provider",
")",
"CreateMachine",
"(",
")",
"(",
"*",
"iaas",
".",
"Machine",
",",
"error",
")",
"{",
"return",
"&",
"iaas",
".",
"Machine",
"{",
"IP",
":",
"p",
".",
"Host",
",",
"Port",
":",
"p",
".",
"Port",
",",
"Kind",
":",
"\"",
"\"",
",",
"}",
",",
"nil",
"\n",
"}"
] | // CreateMachine tcp iaas | [
"CreateMachine",
"tcp",
"iaas"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/iaas/tcp/tcp.go#L47-L53 |
10,210 | gofn/gofn | gofn.go | ProvideMachine | func ProvideMachine(ctx context.Context, service iaas.Iaas) (client *docker.Client, machine *iaas.Machine, err error) {
machine, err = service.CreateMachine()
if err != nil {
if machine != nil {
cerr := service.DeleteMachine()
if cerr != nil {
log.Errorln(cerr)
}
}
return
}
if machine.Port == 0 {
machine.Port = dockerPort
}
addr := fmt.Sprintf("%s:%d", machine.IP, machine.Port)
client, err = provision.FnClient(addr, machine.CertsDir)
return
} | go | func ProvideMachine(ctx context.Context, service iaas.Iaas) (client *docker.Client, machine *iaas.Machine, err error) {
machine, err = service.CreateMachine()
if err != nil {
if machine != nil {
cerr := service.DeleteMachine()
if cerr != nil {
log.Errorln(cerr)
}
}
return
}
if machine.Port == 0 {
machine.Port = dockerPort
}
addr := fmt.Sprintf("%s:%d", machine.IP, machine.Port)
client, err = provision.FnClient(addr, machine.CertsDir)
return
} | [
"func",
"ProvideMachine",
"(",
"ctx",
"context",
".",
"Context",
",",
"service",
"iaas",
".",
"Iaas",
")",
"(",
"client",
"*",
"docker",
".",
"Client",
",",
"machine",
"*",
"iaas",
".",
"Machine",
",",
"err",
"error",
")",
"{",
"machine",
",",
"err",
"=",
"service",
".",
"CreateMachine",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"machine",
"!=",
"nil",
"{",
"cerr",
":=",
"service",
".",
"DeleteMachine",
"(",
")",
"\n",
"if",
"cerr",
"!=",
"nil",
"{",
"log",
".",
"Errorln",
"(",
"cerr",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"machine",
".",
"Port",
"==",
"0",
"{",
"machine",
".",
"Port",
"=",
"dockerPort",
"\n",
"}",
"\n",
"addr",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"machine",
".",
"IP",
",",
"machine",
".",
"Port",
")",
"\n",
"client",
",",
"err",
"=",
"provision",
".",
"FnClient",
"(",
"addr",
",",
"machine",
".",
"CertsDir",
")",
"\n",
"return",
"\n",
"}"
] | // ProvideMachine provisioning a machine in the cloud | [
"ProvideMachine",
"provisioning",
"a",
"machine",
"in",
"the",
"cloud"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/gofn.go#L19-L36 |
10,211 | gofn/gofn | gofn.go | PrepareContainer | func PrepareContainer(ctx context.Context, client *docker.Client, buildOpts *provision.BuildOptions, containerOpts *provision.ContainerOptions) (container *docker.Container, err error) {
img, err := provision.FnFindImage(client, buildOpts.GetImageName())
if err != nil && err != provision.ErrImageNotFound {
return
}
var image string
if img.ID == "" {
image, _, err = provision.FnImageBuild(client, buildOpts)
if err != nil {
return
}
} else {
image = buildOpts.GetImageName()
}
if containerOpts == nil {
containerOpts = &provision.ContainerOptions{}
}
containerOpts.Image = image
container, err = provision.FnContainer(client, *containerOpts)
return
} | go | func PrepareContainer(ctx context.Context, client *docker.Client, buildOpts *provision.BuildOptions, containerOpts *provision.ContainerOptions) (container *docker.Container, err error) {
img, err := provision.FnFindImage(client, buildOpts.GetImageName())
if err != nil && err != provision.ErrImageNotFound {
return
}
var image string
if img.ID == "" {
image, _, err = provision.FnImageBuild(client, buildOpts)
if err != nil {
return
}
} else {
image = buildOpts.GetImageName()
}
if containerOpts == nil {
containerOpts = &provision.ContainerOptions{}
}
containerOpts.Image = image
container, err = provision.FnContainer(client, *containerOpts)
return
} | [
"func",
"PrepareContainer",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"*",
"docker",
".",
"Client",
",",
"buildOpts",
"*",
"provision",
".",
"BuildOptions",
",",
"containerOpts",
"*",
"provision",
".",
"ContainerOptions",
")",
"(",
"container",
"*",
"docker",
".",
"Container",
",",
"err",
"error",
")",
"{",
"img",
",",
"err",
":=",
"provision",
".",
"FnFindImage",
"(",
"client",
",",
"buildOpts",
".",
"GetImageName",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"err",
"!=",
"provision",
".",
"ErrImageNotFound",
"{",
"return",
"\n",
"}",
"\n\n",
"var",
"image",
"string",
"\n",
"if",
"img",
".",
"ID",
"==",
"\"",
"\"",
"{",
"image",
",",
"_",
",",
"err",
"=",
"provision",
".",
"FnImageBuild",
"(",
"client",
",",
"buildOpts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"}",
"else",
"{",
"image",
"=",
"buildOpts",
".",
"GetImageName",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"containerOpts",
"==",
"nil",
"{",
"containerOpts",
"=",
"&",
"provision",
".",
"ContainerOptions",
"{",
"}",
"\n",
"}",
"\n",
"containerOpts",
".",
"Image",
"=",
"image",
"\n",
"container",
",",
"err",
"=",
"provision",
".",
"FnContainer",
"(",
"client",
",",
"*",
"containerOpts",
")",
"\n",
"return",
"\n",
"}"
] | // PrepareContainer build an image if necessary and run the container | [
"PrepareContainer",
"build",
"an",
"image",
"if",
"necessary",
"and",
"run",
"the",
"container"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/gofn.go#L39-L61 |
10,212 | gofn/gofn | gofn.go | RunWait | func RunWait(ctx context.Context, client *docker.Client, container *docker.Container) (errors chan error, err error) {
err = provision.FnStart(client, container.ID)
if err != nil {
return
}
errors = provision.FnWaitContainer(client, container.ID)
return
} | go | func RunWait(ctx context.Context, client *docker.Client, container *docker.Container) (errors chan error, err error) {
err = provision.FnStart(client, container.ID)
if err != nil {
return
}
errors = provision.FnWaitContainer(client, container.ID)
return
} | [
"func",
"RunWait",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"*",
"docker",
".",
"Client",
",",
"container",
"*",
"docker",
".",
"Container",
")",
"(",
"errors",
"chan",
"error",
",",
"err",
"error",
")",
"{",
"err",
"=",
"provision",
".",
"FnStart",
"(",
"client",
",",
"container",
".",
"ID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"errors",
"=",
"provision",
".",
"FnWaitContainer",
"(",
"client",
",",
"container",
".",
"ID",
")",
"\n",
"return",
"\n",
"}"
] | // RunWait runs the conainer returning channels to control your status | [
"RunWait",
"runs",
"the",
"conainer",
"returning",
"channels",
"to",
"control",
"your",
"status"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/gofn.go#L64-L71 |
10,213 | gofn/gofn | gofn.go | Attach | func Attach(ctx context.Context, client *docker.Client, container *docker.Container, stdin io.Reader, stdout io.Writer, stderr io.Writer) (docker.CloseWaiter, error) {
return provision.FnAttach(client, container.ID, stdin, stdout, stderr)
} | go | func Attach(ctx context.Context, client *docker.Client, container *docker.Container, stdin io.Reader, stdout io.Writer, stderr io.Writer) (docker.CloseWaiter, error) {
return provision.FnAttach(client, container.ID, stdin, stdout, stderr)
} | [
"func",
"Attach",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"*",
"docker",
".",
"Client",
",",
"container",
"*",
"docker",
".",
"Container",
",",
"stdin",
"io",
".",
"Reader",
",",
"stdout",
"io",
".",
"Writer",
",",
"stderr",
"io",
".",
"Writer",
")",
"(",
"docker",
".",
"CloseWaiter",
",",
"error",
")",
"{",
"return",
"provision",
".",
"FnAttach",
"(",
"client",
",",
"container",
".",
"ID",
",",
"stdin",
",",
"stdout",
",",
"stderr",
")",
"\n",
"}"
] | // Attach allow to connect into a running container and interact using stdout, stderr and stdin | [
"Attach",
"allow",
"to",
"connect",
"into",
"a",
"running",
"container",
"and",
"interact",
"using",
"stdout",
"stderr",
"and",
"stdin"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/gofn.go#L74-L76 |
10,214 | gofn/gofn | gofn.go | Run | func Run(ctx context.Context, buildOpts *provision.BuildOptions, containerOpts *provision.ContainerOptions) (stdout string, stderr string, err error) {
var client *docker.Client
var container *docker.Container
var machine *iaas.Machine
done := make(chan struct{})
go func(ctx context.Context, done chan struct{}) {
client, err = provision.FnClient("", "")
if err != nil {
done <- struct{}{}
return
}
if buildOpts.Iaas != nil {
client, machine, err = ProvideMachine(ctx, buildOpts.Iaas)
if err != nil {
done <- struct{}{}
return
}
}
container, err = PrepareContainer(ctx, client, buildOpts, containerOpts)
if err != nil {
done <- struct{}{}
return
}
var buffout *bytes.Buffer
var bufferr *bytes.Buffer
buffout, bufferr, err = provision.FnRun(client, container.ID, buildOpts.StdIN)
stdout = buffout.String()
stderr = bufferr.String()
done <- struct{}{}
}(ctx, done)
select {
case <-ctx.Done():
log.Errorf("trying to destroy container %v\n", ctx.Err())
case <-done:
log.Debugln("trying to destroy container process done")
}
if machine != nil {
log.Debugf("trying to delete machine ID:%v\n", machine.ID)
deleteErr := buildOpts.Iaas.DeleteMachine()
if deleteErr != nil {
err = fmt.Errorf("error trying to delete machine %v", deleteErr)
}
return
}
if client != nil && container != nil {
for killAttempt := 0; killAttempt < 3; killAttempt++ {
if killAttempt > 0 {
<-time.After(time.Duration(3) * time.Second)
}
_, err = provision.FnFindContainerByID(client, container.ID)
if err != nil {
if err == provision.ErrContainerNotFound {
err = nil
}
return
}
if container.State.Running {
log.Debugf("destroying container ID:%v, attempt:%v\n", container.ID, killAttempt+1)
err = client.KillContainer(docker.KillContainerOptions{ID: container.ID})
if err != nil {
log.Errorf("error trying to kill container %v, %v, attempt:%v\n", container.ID, err.Error(), killAttempt+1)
}
}
err = client.RemoveContainer(docker.RemoveContainerOptions{
ID: container.ID,
Force: true,
})
if err != nil {
log.Errorf("error trying to remove container %v, %v, attempt:%v\n", container.ID, err.Error(), killAttempt+1)
}
}
err = fmt.Errorf("unable to kill container %v", container.ID)
}
return
} | go | func Run(ctx context.Context, buildOpts *provision.BuildOptions, containerOpts *provision.ContainerOptions) (stdout string, stderr string, err error) {
var client *docker.Client
var container *docker.Container
var machine *iaas.Machine
done := make(chan struct{})
go func(ctx context.Context, done chan struct{}) {
client, err = provision.FnClient("", "")
if err != nil {
done <- struct{}{}
return
}
if buildOpts.Iaas != nil {
client, machine, err = ProvideMachine(ctx, buildOpts.Iaas)
if err != nil {
done <- struct{}{}
return
}
}
container, err = PrepareContainer(ctx, client, buildOpts, containerOpts)
if err != nil {
done <- struct{}{}
return
}
var buffout *bytes.Buffer
var bufferr *bytes.Buffer
buffout, bufferr, err = provision.FnRun(client, container.ID, buildOpts.StdIN)
stdout = buffout.String()
stderr = bufferr.String()
done <- struct{}{}
}(ctx, done)
select {
case <-ctx.Done():
log.Errorf("trying to destroy container %v\n", ctx.Err())
case <-done:
log.Debugln("trying to destroy container process done")
}
if machine != nil {
log.Debugf("trying to delete machine ID:%v\n", machine.ID)
deleteErr := buildOpts.Iaas.DeleteMachine()
if deleteErr != nil {
err = fmt.Errorf("error trying to delete machine %v", deleteErr)
}
return
}
if client != nil && container != nil {
for killAttempt := 0; killAttempt < 3; killAttempt++ {
if killAttempt > 0 {
<-time.After(time.Duration(3) * time.Second)
}
_, err = provision.FnFindContainerByID(client, container.ID)
if err != nil {
if err == provision.ErrContainerNotFound {
err = nil
}
return
}
if container.State.Running {
log.Debugf("destroying container ID:%v, attempt:%v\n", container.ID, killAttempt+1)
err = client.KillContainer(docker.KillContainerOptions{ID: container.ID})
if err != nil {
log.Errorf("error trying to kill container %v, %v, attempt:%v\n", container.ID, err.Error(), killAttempt+1)
}
}
err = client.RemoveContainer(docker.RemoveContainerOptions{
ID: container.ID,
Force: true,
})
if err != nil {
log.Errorf("error trying to remove container %v, %v, attempt:%v\n", container.ID, err.Error(), killAttempt+1)
}
}
err = fmt.Errorf("unable to kill container %v", container.ID)
}
return
} | [
"func",
"Run",
"(",
"ctx",
"context",
".",
"Context",
",",
"buildOpts",
"*",
"provision",
".",
"BuildOptions",
",",
"containerOpts",
"*",
"provision",
".",
"ContainerOptions",
")",
"(",
"stdout",
"string",
",",
"stderr",
"string",
",",
"err",
"error",
")",
"{",
"var",
"client",
"*",
"docker",
".",
"Client",
"\n",
"var",
"container",
"*",
"docker",
".",
"Container",
"\n",
"var",
"machine",
"*",
"iaas",
".",
"Machine",
"\n",
"done",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"go",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"done",
"chan",
"struct",
"{",
"}",
")",
"{",
"client",
",",
"err",
"=",
"provision",
".",
"FnClient",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"done",
"<-",
"struct",
"{",
"}",
"{",
"}",
"\n",
"return",
"\n",
"}",
"\n\n",
"if",
"buildOpts",
".",
"Iaas",
"!=",
"nil",
"{",
"client",
",",
"machine",
",",
"err",
"=",
"ProvideMachine",
"(",
"ctx",
",",
"buildOpts",
".",
"Iaas",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"done",
"<-",
"struct",
"{",
"}",
"{",
"}",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n\n",
"container",
",",
"err",
"=",
"PrepareContainer",
"(",
"ctx",
",",
"client",
",",
"buildOpts",
",",
"containerOpts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"done",
"<-",
"struct",
"{",
"}",
"{",
"}",
"\n",
"return",
"\n",
"}",
"\n\n",
"var",
"buffout",
"*",
"bytes",
".",
"Buffer",
"\n",
"var",
"bufferr",
"*",
"bytes",
".",
"Buffer",
"\n\n",
"buffout",
",",
"bufferr",
",",
"err",
"=",
"provision",
".",
"FnRun",
"(",
"client",
",",
"container",
".",
"ID",
",",
"buildOpts",
".",
"StdIN",
")",
"\n",
"stdout",
"=",
"buffout",
".",
"String",
"(",
")",
"\n",
"stderr",
"=",
"bufferr",
".",
"String",
"(",
")",
"\n",
"done",
"<-",
"struct",
"{",
"}",
"{",
"}",
"\n",
"}",
"(",
"ctx",
",",
"done",
")",
"\n",
"select",
"{",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"log",
".",
"Errorf",
"(",
"\"",
"\\n",
"\"",
",",
"ctx",
".",
"Err",
"(",
")",
")",
"\n",
"case",
"<-",
"done",
":",
"log",
".",
"Debugln",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"machine",
"!=",
"nil",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\\n",
"\"",
",",
"machine",
".",
"ID",
")",
"\n",
"deleteErr",
":=",
"buildOpts",
".",
"Iaas",
".",
"DeleteMachine",
"(",
")",
"\n",
"if",
"deleteErr",
"!=",
"nil",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"deleteErr",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"client",
"!=",
"nil",
"&&",
"container",
"!=",
"nil",
"{",
"for",
"killAttempt",
":=",
"0",
";",
"killAttempt",
"<",
"3",
";",
"killAttempt",
"++",
"{",
"if",
"killAttempt",
">",
"0",
"{",
"<-",
"time",
".",
"After",
"(",
"time",
".",
"Duration",
"(",
"3",
")",
"*",
"time",
".",
"Second",
")",
"\n",
"}",
"\n",
"_",
",",
"err",
"=",
"provision",
".",
"FnFindContainerByID",
"(",
"client",
",",
"container",
".",
"ID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"err",
"==",
"provision",
".",
"ErrContainerNotFound",
"{",
"err",
"=",
"nil",
"\n",
"}",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"container",
".",
"State",
".",
"Running",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\\n",
"\"",
",",
"container",
".",
"ID",
",",
"killAttempt",
"+",
"1",
")",
"\n",
"err",
"=",
"client",
".",
"KillContainer",
"(",
"docker",
".",
"KillContainerOptions",
"{",
"ID",
":",
"container",
".",
"ID",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Errorf",
"(",
"\"",
"\\n",
"\"",
",",
"container",
".",
"ID",
",",
"err",
".",
"Error",
"(",
")",
",",
"killAttempt",
"+",
"1",
")",
"\n",
"}",
"\n",
"}",
"\n",
"err",
"=",
"client",
".",
"RemoveContainer",
"(",
"docker",
".",
"RemoveContainerOptions",
"{",
"ID",
":",
"container",
".",
"ID",
",",
"Force",
":",
"true",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Errorf",
"(",
"\"",
"\\n",
"\"",
",",
"container",
".",
"ID",
",",
"err",
".",
"Error",
"(",
")",
",",
"killAttempt",
"+",
"1",
")",
"\n",
"}",
"\n",
"}",
"\n",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"container",
".",
"ID",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // Run runs the designed image | [
"Run",
"runs",
"the",
"designed",
"image"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/gofn.go#L79-L157 |
10,215 | gofn/gofn | gofn.go | DestroyContainer | func DestroyContainer(ctx context.Context, client *docker.Client, container *docker.Container) error {
return provision.FnRemove(client, container.ID)
} | go | func DestroyContainer(ctx context.Context, client *docker.Client, container *docker.Container) error {
return provision.FnRemove(client, container.ID)
} | [
"func",
"DestroyContainer",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"*",
"docker",
".",
"Client",
",",
"container",
"*",
"docker",
".",
"Container",
")",
"error",
"{",
"return",
"provision",
".",
"FnRemove",
"(",
"client",
",",
"container",
".",
"ID",
")",
"\n",
"}"
] | // DestroyContainer remove by force a container | [
"DestroyContainer",
"remove",
"by",
"force",
"a",
"container"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/gofn.go#L160-L162 |
10,216 | gofn/gofn | provision/docker.go | GetImageName | func (opts BuildOptions) GetImageName() string {
if opts.DoNotUsePrefixImageName {
return opts.ImageName
}
return path.Join("gofn", opts.ImageName)
} | go | func (opts BuildOptions) GetImageName() string {
if opts.DoNotUsePrefixImageName {
return opts.ImageName
}
return path.Join("gofn", opts.ImageName)
} | [
"func",
"(",
"opts",
"BuildOptions",
")",
"GetImageName",
"(",
")",
"string",
"{",
"if",
"opts",
".",
"DoNotUsePrefixImageName",
"{",
"return",
"opts",
".",
"ImageName",
"\n",
"}",
"\n",
"return",
"path",
".",
"Join",
"(",
"\"",
"\"",
",",
"opts",
".",
"ImageName",
")",
"\n",
"}"
] | // GetImageName sets prefix gofn when needed | [
"GetImageName",
"sets",
"prefix",
"gofn",
"when",
"needed"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/provision/docker.go#L53-L58 |
10,217 | gofn/gofn | provision/docker.go | FnRemove | func FnRemove(client *docker.Client, containerID string) (err error) {
err = client.RemoveContainer(docker.RemoveContainerOptions{ID: containerID, Force: true})
return
} | go | func FnRemove(client *docker.Client, containerID string) (err error) {
err = client.RemoveContainer(docker.RemoveContainerOptions{ID: containerID, Force: true})
return
} | [
"func",
"FnRemove",
"(",
"client",
"*",
"docker",
".",
"Client",
",",
"containerID",
"string",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"client",
".",
"RemoveContainer",
"(",
"docker",
".",
"RemoveContainerOptions",
"{",
"ID",
":",
"containerID",
",",
"Force",
":",
"true",
"}",
")",
"\n",
"return",
"\n",
"}"
] | // FnRemove remove container | [
"FnRemove",
"remove",
"container"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/provision/docker.go#L61-L64 |
10,218 | gofn/gofn | provision/docker.go | FnContainer | func FnContainer(client *docker.Client, opts ContainerOptions) (container *docker.Container, err error) {
config := &docker.Config{
Image: opts.Image,
Cmd: opts.Cmd,
Env: opts.Env,
StdinOnce: true,
OpenStdin: true,
}
var uid uuid.UUID
uid, err = uuid.NewV4()
if err != nil {
return
}
container, err = client.CreateContainer(docker.CreateContainerOptions{
Name: fmt.Sprintf("gofn-%s", uid.String()),
HostConfig: &docker.HostConfig{Binds: opts.Volumes, Runtime: opts.Runtime},
Config: config,
})
return
} | go | func FnContainer(client *docker.Client, opts ContainerOptions) (container *docker.Container, err error) {
config := &docker.Config{
Image: opts.Image,
Cmd: opts.Cmd,
Env: opts.Env,
StdinOnce: true,
OpenStdin: true,
}
var uid uuid.UUID
uid, err = uuid.NewV4()
if err != nil {
return
}
container, err = client.CreateContainer(docker.CreateContainerOptions{
Name: fmt.Sprintf("gofn-%s", uid.String()),
HostConfig: &docker.HostConfig{Binds: opts.Volumes, Runtime: opts.Runtime},
Config: config,
})
return
} | [
"func",
"FnContainer",
"(",
"client",
"*",
"docker",
".",
"Client",
",",
"opts",
"ContainerOptions",
")",
"(",
"container",
"*",
"docker",
".",
"Container",
",",
"err",
"error",
")",
"{",
"config",
":=",
"&",
"docker",
".",
"Config",
"{",
"Image",
":",
"opts",
".",
"Image",
",",
"Cmd",
":",
"opts",
".",
"Cmd",
",",
"Env",
":",
"opts",
".",
"Env",
",",
"StdinOnce",
":",
"true",
",",
"OpenStdin",
":",
"true",
",",
"}",
"\n",
"var",
"uid",
"uuid",
".",
"UUID",
"\n",
"uid",
",",
"err",
"=",
"uuid",
".",
"NewV4",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"container",
",",
"err",
"=",
"client",
".",
"CreateContainer",
"(",
"docker",
".",
"CreateContainerOptions",
"{",
"Name",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"uid",
".",
"String",
"(",
")",
")",
",",
"HostConfig",
":",
"&",
"docker",
".",
"HostConfig",
"{",
"Binds",
":",
"opts",
".",
"Volumes",
",",
"Runtime",
":",
"opts",
".",
"Runtime",
"}",
",",
"Config",
":",
"config",
",",
"}",
")",
"\n",
"return",
"\n",
"}"
] | // FnContainer create container | [
"FnContainer",
"create",
"container"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/provision/docker.go#L67-L86 |
10,219 | gofn/gofn | provision/docker.go | FnImageBuild | func FnImageBuild(client *docker.Client, opts *BuildOptions) (Name string, Stdout *bytes.Buffer, err error) {
if opts.Dockerfile == "" {
opts.Dockerfile = "Dockerfile"
}
if opts.ContextDir == "" && opts.RemoteURI == "" {
opts.ContextDir = "./"
}
err = auth(client, opts)
if err != nil {
return
}
stdout := new(bytes.Buffer)
Name = opts.GetImageName()
if opts.ForcePull {
err = FnPull(client, opts)
return
}
err = client.BuildImage(docker.BuildImageOptions{
Name: Name,
Dockerfile: opts.Dockerfile,
SuppressOutput: true,
OutputStream: stdout,
ContextDir: opts.ContextDir,
Remote: opts.RemoteURI,
Auth: opts.Auth,
})
if err != nil {
if !strings.Contains(err.Error(), "Cannot locate specified Dockerfile:") { // the error is not exported so we need to verify using the message
return
}
err = FnPull(client, opts)
if err != nil {
return
}
}
Stdout = stdout
return
} | go | func FnImageBuild(client *docker.Client, opts *BuildOptions) (Name string, Stdout *bytes.Buffer, err error) {
if opts.Dockerfile == "" {
opts.Dockerfile = "Dockerfile"
}
if opts.ContextDir == "" && opts.RemoteURI == "" {
opts.ContextDir = "./"
}
err = auth(client, opts)
if err != nil {
return
}
stdout := new(bytes.Buffer)
Name = opts.GetImageName()
if opts.ForcePull {
err = FnPull(client, opts)
return
}
err = client.BuildImage(docker.BuildImageOptions{
Name: Name,
Dockerfile: opts.Dockerfile,
SuppressOutput: true,
OutputStream: stdout,
ContextDir: opts.ContextDir,
Remote: opts.RemoteURI,
Auth: opts.Auth,
})
if err != nil {
if !strings.Contains(err.Error(), "Cannot locate specified Dockerfile:") { // the error is not exported so we need to verify using the message
return
}
err = FnPull(client, opts)
if err != nil {
return
}
}
Stdout = stdout
return
} | [
"func",
"FnImageBuild",
"(",
"client",
"*",
"docker",
".",
"Client",
",",
"opts",
"*",
"BuildOptions",
")",
"(",
"Name",
"string",
",",
"Stdout",
"*",
"bytes",
".",
"Buffer",
",",
"err",
"error",
")",
"{",
"if",
"opts",
".",
"Dockerfile",
"==",
"\"",
"\"",
"{",
"opts",
".",
"Dockerfile",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"opts",
".",
"ContextDir",
"==",
"\"",
"\"",
"&&",
"opts",
".",
"RemoteURI",
"==",
"\"",
"\"",
"{",
"opts",
".",
"ContextDir",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"err",
"=",
"auth",
"(",
"client",
",",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"stdout",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"Name",
"=",
"opts",
".",
"GetImageName",
"(",
")",
"\n",
"if",
"opts",
".",
"ForcePull",
"{",
"err",
"=",
"FnPull",
"(",
"client",
",",
"opts",
")",
"\n",
"return",
"\n",
"}",
"\n",
"err",
"=",
"client",
".",
"BuildImage",
"(",
"docker",
".",
"BuildImageOptions",
"{",
"Name",
":",
"Name",
",",
"Dockerfile",
":",
"opts",
".",
"Dockerfile",
",",
"SuppressOutput",
":",
"true",
",",
"OutputStream",
":",
"stdout",
",",
"ContextDir",
":",
"opts",
".",
"ContextDir",
",",
"Remote",
":",
"opts",
".",
"RemoteURI",
",",
"Auth",
":",
"opts",
".",
"Auth",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"!",
"strings",
".",
"Contains",
"(",
"err",
".",
"Error",
"(",
")",
",",
"\"",
"\"",
")",
"{",
"// the error is not exported so we need to verify using the message",
"return",
"\n",
"}",
"\n",
"err",
"=",
"FnPull",
"(",
"client",
",",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"Stdout",
"=",
"stdout",
"\n",
"return",
"\n",
"}"
] | // FnImageBuild builds an image | [
"FnImageBuild",
"builds",
"an",
"image"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/provision/docker.go#L89-L126 |
10,220 | gofn/gofn | provision/docker.go | FnPull | func FnPull(client *docker.Client, opts *BuildOptions) (err error) {
repo, tag := parseDockerImage(opts.GetImageName())
err = client.PullImage(docker.PullImageOptions{
Repository: repo,
Tag: tag,
}, opts.Auth)
return
} | go | func FnPull(client *docker.Client, opts *BuildOptions) (err error) {
repo, tag := parseDockerImage(opts.GetImageName())
err = client.PullImage(docker.PullImageOptions{
Repository: repo,
Tag: tag,
}, opts.Auth)
return
} | [
"func",
"FnPull",
"(",
"client",
"*",
"docker",
".",
"Client",
",",
"opts",
"*",
"BuildOptions",
")",
"(",
"err",
"error",
")",
"{",
"repo",
",",
"tag",
":=",
"parseDockerImage",
"(",
"opts",
".",
"GetImageName",
"(",
")",
")",
"\n",
"err",
"=",
"client",
".",
"PullImage",
"(",
"docker",
".",
"PullImageOptions",
"{",
"Repository",
":",
"repo",
",",
"Tag",
":",
"tag",
",",
"}",
",",
"opts",
".",
"Auth",
")",
"\n",
"return",
"\n",
"}"
] | // FnPull pull image from registry | [
"FnPull",
"pull",
"image",
"from",
"registry"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/provision/docker.go#L144-L151 |
10,221 | gofn/gofn | provision/docker.go | FnFindImage | func FnFindImage(client *docker.Client, imageName string) (image docker.APIImages, err error) {
var imgs []docker.APIImages
imgs, err = client.ListImages(docker.ListImagesOptions{Filter: imageName})
if err != nil {
return
}
if len(imgs) == 0 {
err = ErrImageNotFound
return
}
image = imgs[0]
return
} | go | func FnFindImage(client *docker.Client, imageName string) (image docker.APIImages, err error) {
var imgs []docker.APIImages
imgs, err = client.ListImages(docker.ListImagesOptions{Filter: imageName})
if err != nil {
return
}
if len(imgs) == 0 {
err = ErrImageNotFound
return
}
image = imgs[0]
return
} | [
"func",
"FnFindImage",
"(",
"client",
"*",
"docker",
".",
"Client",
",",
"imageName",
"string",
")",
"(",
"image",
"docker",
".",
"APIImages",
",",
"err",
"error",
")",
"{",
"var",
"imgs",
"[",
"]",
"docker",
".",
"APIImages",
"\n",
"imgs",
",",
"err",
"=",
"client",
".",
"ListImages",
"(",
"docker",
".",
"ListImagesOptions",
"{",
"Filter",
":",
"imageName",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"if",
"len",
"(",
"imgs",
")",
"==",
"0",
"{",
"err",
"=",
"ErrImageNotFound",
"\n",
"return",
"\n",
"}",
"\n",
"image",
"=",
"imgs",
"[",
"0",
"]",
"\n",
"return",
"\n",
"}"
] | // FnFindImage returns image data by name | [
"FnFindImage",
"returns",
"image",
"data",
"by",
"name"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/provision/docker.go#L169-L181 |
10,222 | gofn/gofn | provision/docker.go | FnFindContainerByID | func FnFindContainerByID(client *docker.Client, ID string) (container docker.APIContainers, err error) {
var containers []docker.APIContainers
containers, err = client.ListContainers(docker.ListContainersOptions{All: true})
if err != nil {
return
}
for _, v := range containers {
if v.ID == ID {
container = v
return
}
}
err = ErrContainerNotFound
return
} | go | func FnFindContainerByID(client *docker.Client, ID string) (container docker.APIContainers, err error) {
var containers []docker.APIContainers
containers, err = client.ListContainers(docker.ListContainersOptions{All: true})
if err != nil {
return
}
for _, v := range containers {
if v.ID == ID {
container = v
return
}
}
err = ErrContainerNotFound
return
} | [
"func",
"FnFindContainerByID",
"(",
"client",
"*",
"docker",
".",
"Client",
",",
"ID",
"string",
")",
"(",
"container",
"docker",
".",
"APIContainers",
",",
"err",
"error",
")",
"{",
"var",
"containers",
"[",
"]",
"docker",
".",
"APIContainers",
"\n",
"containers",
",",
"err",
"=",
"client",
".",
"ListContainers",
"(",
"docker",
".",
"ListContainersOptions",
"{",
"All",
":",
"true",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"containers",
"{",
"if",
"v",
".",
"ID",
"==",
"ID",
"{",
"container",
"=",
"v",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"err",
"=",
"ErrContainerNotFound",
"\n",
"return",
"\n",
"}"
] | // FnFindContainerByID return container by ID | [
"FnFindContainerByID",
"return",
"container",
"by",
"ID"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/provision/docker.go#L184-L198 |
10,223 | gofn/gofn | provision/docker.go | FnFindContainer | func FnFindContainer(client *docker.Client, imageName string) (container docker.APIContainers, err error) {
var containers []docker.APIContainers
containers, err = client.ListContainers(docker.ListContainersOptions{All: true})
if err != nil {
return
}
if !strings.HasPrefix(imageName, "gofn") {
imageName = "gofn/" + imageName
}
for _, v := range containers {
if v.Image == imageName {
container = v
return
}
}
err = ErrContainerNotFound
return
} | go | func FnFindContainer(client *docker.Client, imageName string) (container docker.APIContainers, err error) {
var containers []docker.APIContainers
containers, err = client.ListContainers(docker.ListContainersOptions{All: true})
if err != nil {
return
}
if !strings.HasPrefix(imageName, "gofn") {
imageName = "gofn/" + imageName
}
for _, v := range containers {
if v.Image == imageName {
container = v
return
}
}
err = ErrContainerNotFound
return
} | [
"func",
"FnFindContainer",
"(",
"client",
"*",
"docker",
".",
"Client",
",",
"imageName",
"string",
")",
"(",
"container",
"docker",
".",
"APIContainers",
",",
"err",
"error",
")",
"{",
"var",
"containers",
"[",
"]",
"docker",
".",
"APIContainers",
"\n",
"containers",
",",
"err",
"=",
"client",
".",
"ListContainers",
"(",
"docker",
".",
"ListContainersOptions",
"{",
"All",
":",
"true",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"imageName",
",",
"\"",
"\"",
")",
"{",
"imageName",
"=",
"\"",
"\"",
"+",
"imageName",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"v",
":=",
"range",
"containers",
"{",
"if",
"v",
".",
"Image",
"==",
"imageName",
"{",
"container",
"=",
"v",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"err",
"=",
"ErrContainerNotFound",
"\n",
"return",
"\n",
"}"
] | // FnFindContainer return container by image name | [
"FnFindContainer",
"return",
"container",
"by",
"image",
"name"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/provision/docker.go#L201-L220 |
10,224 | gofn/gofn | provision/docker.go | FnKillContainer | func FnKillContainer(client *docker.Client, containerID string) (err error) {
err = client.KillContainer(docker.KillContainerOptions{ID: containerID})
return
} | go | func FnKillContainer(client *docker.Client, containerID string) (err error) {
err = client.KillContainer(docker.KillContainerOptions{ID: containerID})
return
} | [
"func",
"FnKillContainer",
"(",
"client",
"*",
"docker",
".",
"Client",
",",
"containerID",
"string",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"client",
".",
"KillContainer",
"(",
"docker",
".",
"KillContainerOptions",
"{",
"ID",
":",
"containerID",
"}",
")",
"\n",
"return",
"\n",
"}"
] | // FnKillContainer kill the container | [
"FnKillContainer",
"kill",
"the",
"container"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/provision/docker.go#L223-L226 |
10,225 | gofn/gofn | provision/docker.go | FnAttach | func FnAttach(client *docker.Client, containerID string, stdin io.Reader, stdout io.Writer, stderr io.Writer) (w docker.CloseWaiter, err error) {
return client.AttachToContainerNonBlocking(docker.AttachToContainerOptions{
Container: containerID,
RawTerminal: true,
Stream: true,
Stdin: true,
Stderr: true,
Stdout: true,
Logs: true,
InputStream: stdin,
ErrorStream: stderr,
OutputStream: stdout,
})
} | go | func FnAttach(client *docker.Client, containerID string, stdin io.Reader, stdout io.Writer, stderr io.Writer) (w docker.CloseWaiter, err error) {
return client.AttachToContainerNonBlocking(docker.AttachToContainerOptions{
Container: containerID,
RawTerminal: true,
Stream: true,
Stdin: true,
Stderr: true,
Stdout: true,
Logs: true,
InputStream: stdin,
ErrorStream: stderr,
OutputStream: stdout,
})
} | [
"func",
"FnAttach",
"(",
"client",
"*",
"docker",
".",
"Client",
",",
"containerID",
"string",
",",
"stdin",
"io",
".",
"Reader",
",",
"stdout",
"io",
".",
"Writer",
",",
"stderr",
"io",
".",
"Writer",
")",
"(",
"w",
"docker",
".",
"CloseWaiter",
",",
"err",
"error",
")",
"{",
"return",
"client",
".",
"AttachToContainerNonBlocking",
"(",
"docker",
".",
"AttachToContainerOptions",
"{",
"Container",
":",
"containerID",
",",
"RawTerminal",
":",
"true",
",",
"Stream",
":",
"true",
",",
"Stdin",
":",
"true",
",",
"Stderr",
":",
"true",
",",
"Stdout",
":",
"true",
",",
"Logs",
":",
"true",
",",
"InputStream",
":",
"stdin",
",",
"ErrorStream",
":",
"stderr",
",",
"OutputStream",
":",
"stdout",
",",
"}",
")",
"\n",
"}"
] | //FnAttach attach into a running container | [
"FnAttach",
"attach",
"into",
"a",
"running",
"container"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/provision/docker.go#L229-L242 |
10,226 | gofn/gofn | provision/docker.go | FnStart | func FnStart(client *docker.Client, containerID string) error {
return client.StartContainer(containerID, nil)
} | go | func FnStart(client *docker.Client, containerID string) error {
return client.StartContainer(containerID, nil)
} | [
"func",
"FnStart",
"(",
"client",
"*",
"docker",
".",
"Client",
",",
"containerID",
"string",
")",
"error",
"{",
"return",
"client",
".",
"StartContainer",
"(",
"containerID",
",",
"nil",
")",
"\n",
"}"
] | // FnStart start the container | [
"FnStart",
"start",
"the",
"container"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/provision/docker.go#L245-L247 |
10,227 | gofn/gofn | provision/docker.go | FnRun | func FnRun(client *docker.Client, containerID, input string) (Stdout *bytes.Buffer, Stderr *bytes.Buffer, err error) {
err = FnStart(client, containerID)
if err != nil {
return
}
// attach to write input
_, err = FnAttach(client, containerID, strings.NewReader(input), nil, nil)
if err != nil {
return
}
e := FnWaitContainer(client, containerID)
err = <-e
stdout := new(bytes.Buffer)
stderr := new(bytes.Buffer)
// omit logs because execution error is more important
_ = FnLogs(client, containerID, stdout, stderr) // nolint
Stdout = stdout
Stderr = stderr
return
} | go | func FnRun(client *docker.Client, containerID, input string) (Stdout *bytes.Buffer, Stderr *bytes.Buffer, err error) {
err = FnStart(client, containerID)
if err != nil {
return
}
// attach to write input
_, err = FnAttach(client, containerID, strings.NewReader(input), nil, nil)
if err != nil {
return
}
e := FnWaitContainer(client, containerID)
err = <-e
stdout := new(bytes.Buffer)
stderr := new(bytes.Buffer)
// omit logs because execution error is more important
_ = FnLogs(client, containerID, stdout, stderr) // nolint
Stdout = stdout
Stderr = stderr
return
} | [
"func",
"FnRun",
"(",
"client",
"*",
"docker",
".",
"Client",
",",
"containerID",
",",
"input",
"string",
")",
"(",
"Stdout",
"*",
"bytes",
".",
"Buffer",
",",
"Stderr",
"*",
"bytes",
".",
"Buffer",
",",
"err",
"error",
")",
"{",
"err",
"=",
"FnStart",
"(",
"client",
",",
"containerID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"// attach to write input",
"_",
",",
"err",
"=",
"FnAttach",
"(",
"client",
",",
"containerID",
",",
"strings",
".",
"NewReader",
"(",
"input",
")",
",",
"nil",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"e",
":=",
"FnWaitContainer",
"(",
"client",
",",
"containerID",
")",
"\n",
"err",
"=",
"<-",
"e",
"\n\n",
"stdout",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"stderr",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n\n",
"// omit logs because execution error is more important",
"_",
"=",
"FnLogs",
"(",
"client",
",",
"containerID",
",",
"stdout",
",",
"stderr",
")",
"// nolint",
"\n\n",
"Stdout",
"=",
"stdout",
"\n",
"Stderr",
"=",
"stderr",
"\n",
"return",
"\n",
"}"
] | // FnRun runs the container | [
"FnRun",
"runs",
"the",
"container"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/provision/docker.go#L250-L274 |
10,228 | gofn/gofn | provision/docker.go | FnLogs | func FnLogs(client *docker.Client, containerID string, stdout io.Writer, stderr io.Writer) error {
return client.Logs(docker.LogsOptions{
Container: containerID,
Stdout: true,
Stderr: true,
ErrorStream: stderr,
OutputStream: stdout,
})
} | go | func FnLogs(client *docker.Client, containerID string, stdout io.Writer, stderr io.Writer) error {
return client.Logs(docker.LogsOptions{
Container: containerID,
Stdout: true,
Stderr: true,
ErrorStream: stderr,
OutputStream: stdout,
})
} | [
"func",
"FnLogs",
"(",
"client",
"*",
"docker",
".",
"Client",
",",
"containerID",
"string",
",",
"stdout",
"io",
".",
"Writer",
",",
"stderr",
"io",
".",
"Writer",
")",
"error",
"{",
"return",
"client",
".",
"Logs",
"(",
"docker",
".",
"LogsOptions",
"{",
"Container",
":",
"containerID",
",",
"Stdout",
":",
"true",
",",
"Stderr",
":",
"true",
",",
"ErrorStream",
":",
"stderr",
",",
"OutputStream",
":",
"stdout",
",",
"}",
")",
"\n",
"}"
] | // FnLogs logs all container activity | [
"FnLogs",
"logs",
"all",
"container",
"activity"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/provision/docker.go#L277-L285 |
10,229 | gofn/gofn | provision/docker.go | FnWaitContainer | func FnWaitContainer(client *docker.Client, containerID string) chan error {
errs := make(chan error)
go func() {
code, err := client.WaitContainer(containerID)
if err != nil {
errs <- err
}
if code != 0 {
errs <- ErrContainerExecutionFailed
}
errs <- nil
}()
return errs
} | go | func FnWaitContainer(client *docker.Client, containerID string) chan error {
errs := make(chan error)
go func() {
code, err := client.WaitContainer(containerID)
if err != nil {
errs <- err
}
if code != 0 {
errs <- ErrContainerExecutionFailed
}
errs <- nil
}()
return errs
} | [
"func",
"FnWaitContainer",
"(",
"client",
"*",
"docker",
".",
"Client",
",",
"containerID",
"string",
")",
"chan",
"error",
"{",
"errs",
":=",
"make",
"(",
"chan",
"error",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"code",
",",
"err",
":=",
"client",
".",
"WaitContainer",
"(",
"containerID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"errs",
"<-",
"err",
"\n",
"}",
"\n",
"if",
"code",
"!=",
"0",
"{",
"errs",
"<-",
"ErrContainerExecutionFailed",
"\n",
"}",
"\n",
"errs",
"<-",
"nil",
"\n",
"}",
"(",
")",
"\n",
"return",
"errs",
"\n",
"}"
] | // FnWaitContainer wait until container finnish your processing | [
"FnWaitContainer",
"wait",
"until",
"container",
"finnish",
"your",
"processing"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/provision/docker.go#L288-L301 |
10,230 | gofn/gofn | provision/docker.go | FnListContainers | func FnListContainers(client *docker.Client) (containers []docker.APIContainers, err error) {
hostContainers, err := client.ListContainers(docker.ListContainersOptions{
All: true,
})
if err != nil {
containers = nil
return
}
for _, container := range hostContainers {
if strings.HasPrefix(container.Image, "gofn/") {
containers = append(containers, container)
}
}
return
} | go | func FnListContainers(client *docker.Client) (containers []docker.APIContainers, err error) {
hostContainers, err := client.ListContainers(docker.ListContainersOptions{
All: true,
})
if err != nil {
containers = nil
return
}
for _, container := range hostContainers {
if strings.HasPrefix(container.Image, "gofn/") {
containers = append(containers, container)
}
}
return
} | [
"func",
"FnListContainers",
"(",
"client",
"*",
"docker",
".",
"Client",
")",
"(",
"containers",
"[",
"]",
"docker",
".",
"APIContainers",
",",
"err",
"error",
")",
"{",
"hostContainers",
",",
"err",
":=",
"client",
".",
"ListContainers",
"(",
"docker",
".",
"ListContainersOptions",
"{",
"All",
":",
"true",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"containers",
"=",
"nil",
"\n",
"return",
"\n",
"}",
"\n",
"for",
"_",
",",
"container",
":=",
"range",
"hostContainers",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"container",
".",
"Image",
",",
"\"",
"\"",
")",
"{",
"containers",
"=",
"append",
"(",
"containers",
",",
"container",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // FnListContainers lists all the containers created by the gofn.
// It returns the APIContainers from the API, but have to be formatted for pretty printing | [
"FnListContainers",
"lists",
"all",
"the",
"containers",
"created",
"by",
"the",
"gofn",
".",
"It",
"returns",
"the",
"APIContainers",
"from",
"the",
"API",
"but",
"have",
"to",
"be",
"formatted",
"for",
"pretty",
"printing"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/provision/docker.go#L305-L319 |
10,231 | gofn/gofn | iaas/google/google.go | CreateMachine | func (p *Provider) CreateMachine() (machine *iaas.Machine, err error) {
err = p.Client.Create(p.Host)
if err != nil {
return
}
config, err := getConfig(p.Client.GetMachinesDir(), p.Name)
if err != nil {
return
}
ip, err := p.Host.Driver.GetIP()
if err != nil {
return
}
machine = &iaas.Machine{
ID: "",
IP: ip,
Image: config.Driver.MachineImage,
Kind: config.DriverName,
Name: p.Name,
SSHKeysID: []int{},
CertsDir: p.ClientPath + "/certs",
}
return
} | go | func (p *Provider) CreateMachine() (machine *iaas.Machine, err error) {
err = p.Client.Create(p.Host)
if err != nil {
return
}
config, err := getConfig(p.Client.GetMachinesDir(), p.Name)
if err != nil {
return
}
ip, err := p.Host.Driver.GetIP()
if err != nil {
return
}
machine = &iaas.Machine{
ID: "",
IP: ip,
Image: config.Driver.MachineImage,
Kind: config.DriverName,
Name: p.Name,
SSHKeysID: []int{},
CertsDir: p.ClientPath + "/certs",
}
return
} | [
"func",
"(",
"p",
"*",
"Provider",
")",
"CreateMachine",
"(",
")",
"(",
"machine",
"*",
"iaas",
".",
"Machine",
",",
"err",
"error",
")",
"{",
"err",
"=",
"p",
".",
"Client",
".",
"Create",
"(",
"p",
".",
"Host",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"config",
",",
"err",
":=",
"getConfig",
"(",
"p",
".",
"Client",
".",
"GetMachinesDir",
"(",
")",
",",
"p",
".",
"Name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"ip",
",",
"err",
":=",
"p",
".",
"Host",
".",
"Driver",
".",
"GetIP",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"machine",
"=",
"&",
"iaas",
".",
"Machine",
"{",
"ID",
":",
"\"",
"\"",
",",
"IP",
":",
"ip",
",",
"Image",
":",
"config",
".",
"Driver",
".",
"MachineImage",
",",
"Kind",
":",
"config",
".",
"DriverName",
",",
"Name",
":",
"p",
".",
"Name",
",",
"SSHKeysID",
":",
"[",
"]",
"int",
"{",
"}",
",",
"CertsDir",
":",
"p",
".",
"ClientPath",
"+",
"\"",
"\"",
",",
"}",
"\n",
"return",
"\n",
"}"
] | // CreateMachine on google | [
"CreateMachine",
"on",
"google"
] | 6c6d4df46796d123f15f960722dd418b5d06dda7 | https://github.com/gofn/gofn/blob/6c6d4df46796d123f15f960722dd418b5d06dda7/iaas/google/google.go#L102-L126 |
10,232 | russellhaering/goxmldsig | tls_keystore.go | GetKeyPair | func (d TLSCertKeyStore) GetKeyPair() (*rsa.PrivateKey, []byte, error) {
pk, ok := d.PrivateKey.(*rsa.PrivateKey)
if !ok {
return nil, nil, ErrNonRSAKey
}
if len(d.Certificate) < 1 {
return nil, nil, ErrMissingCertificates
}
crt := d.Certificate[0]
return pk, crt, nil
} | go | func (d TLSCertKeyStore) GetKeyPair() (*rsa.PrivateKey, []byte, error) {
pk, ok := d.PrivateKey.(*rsa.PrivateKey)
if !ok {
return nil, nil, ErrNonRSAKey
}
if len(d.Certificate) < 1 {
return nil, nil, ErrMissingCertificates
}
crt := d.Certificate[0]
return pk, crt, nil
} | [
"func",
"(",
"d",
"TLSCertKeyStore",
")",
"GetKeyPair",
"(",
")",
"(",
"*",
"rsa",
".",
"PrivateKey",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"pk",
",",
"ok",
":=",
"d",
".",
"PrivateKey",
".",
"(",
"*",
"rsa",
".",
"PrivateKey",
")",
"\n\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"nil",
",",
"ErrNonRSAKey",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"d",
".",
"Certificate",
")",
"<",
"1",
"{",
"return",
"nil",
",",
"nil",
",",
"ErrMissingCertificates",
"\n",
"}",
"\n\n",
"crt",
":=",
"d",
".",
"Certificate",
"[",
"0",
"]",
"\n\n",
"return",
"pk",
",",
"crt",
",",
"nil",
"\n",
"}"
] | //GetKeyPair implements X509KeyStore using the underlying tls.Certificate | [
"GetKeyPair",
"implements",
"X509KeyStore",
"using",
"the",
"underlying",
"tls",
".",
"Certificate"
] | 7acd5e4a6ef74fe1b082c20f119556adf70c3944 | https://github.com/russellhaering/goxmldsig/blob/7acd5e4a6ef74fe1b082c20f119556adf70c3944/tls_keystore.go#L20-L34 |
10,233 | russellhaering/goxmldsig | etreeutils/namespace.go | LookupPrefix | func (ctx NSContext) LookupPrefix(prefix string) (string, error) {
if namespace, ok := ctx.prefixes[prefix]; ok {
return namespace, nil
}
return "", ErrUndeclaredNSPrefix{
Prefix: prefix,
}
} | go | func (ctx NSContext) LookupPrefix(prefix string) (string, error) {
if namespace, ok := ctx.prefixes[prefix]; ok {
return namespace, nil
}
return "", ErrUndeclaredNSPrefix{
Prefix: prefix,
}
} | [
"func",
"(",
"ctx",
"NSContext",
")",
"LookupPrefix",
"(",
"prefix",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"namespace",
",",
"ok",
":=",
"ctx",
".",
"prefixes",
"[",
"prefix",
"]",
";",
"ok",
"{",
"return",
"namespace",
",",
"nil",
"\n",
"}",
"\n\n",
"return",
"\"",
"\"",
",",
"ErrUndeclaredNSPrefix",
"{",
"Prefix",
":",
"prefix",
",",
"}",
"\n",
"}"
] | // LookupPrefix attempts to find a declared namespace for the specified prefix. If the prefix
// is an empty string this will be the default namespace for this context. If the prefix is
// undeclared in this context an ErrUndeclaredNSPrefix will be returned. | [
"LookupPrefix",
"attempts",
"to",
"find",
"a",
"declared",
"namespace",
"for",
"the",
"specified",
"prefix",
".",
"If",
"the",
"prefix",
"is",
"an",
"empty",
"string",
"this",
"will",
"be",
"the",
"default",
"namespace",
"for",
"this",
"context",
".",
"If",
"the",
"prefix",
"is",
"undeclared",
"in",
"this",
"context",
"an",
"ErrUndeclaredNSPrefix",
"will",
"be",
"returned",
"."
] | 7acd5e4a6ef74fe1b082c20f119556adf70c3944 | https://github.com/russellhaering/goxmldsig/blob/7acd5e4a6ef74fe1b082c20f119556adf70c3944/etreeutils/namespace.go#L126-L134 |
10,234 | russellhaering/goxmldsig | etreeutils/namespace.go | NSDetatch | func NSDetatch(ctx NSContext, el *etree.Element) (*etree.Element, error) {
ctx, err := ctx.SubContext(el)
if err != nil {
return nil, err
}
el = el.Copy()
// Build a new attribute list
attrs := make([]etree.Attr, 0, len(el.Attr))
// First copy over anything that isn't a namespace declaration
for _, attr := range el.Attr {
if attr.Space == xmlnsPrefix {
continue
}
if attr.Space == defaultPrefix && attr.Key == xmlnsPrefix {
continue
}
attrs = append(attrs, attr)
}
// Append all in-context namespace declarations
for prefix, namespace := range ctx.prefixes {
// Skip the implicit "xml" and "xmlns" prefix declarations
if prefix == xmlnsPrefix || prefix == xmlPrefix {
continue
}
// Also skip declararing the default namespace as XMLNamespace
if prefix == defaultPrefix && namespace == XMLNamespace {
continue
}
if prefix != defaultPrefix {
attrs = append(attrs, etree.Attr{
Space: xmlnsPrefix,
Key: prefix,
Value: namespace,
})
} else {
attrs = append(attrs, etree.Attr{
Key: xmlnsPrefix,
Value: namespace,
})
}
}
sort.Sort(SortedAttrs(attrs))
el.Attr = attrs
return el, nil
} | go | func NSDetatch(ctx NSContext, el *etree.Element) (*etree.Element, error) {
ctx, err := ctx.SubContext(el)
if err != nil {
return nil, err
}
el = el.Copy()
// Build a new attribute list
attrs := make([]etree.Attr, 0, len(el.Attr))
// First copy over anything that isn't a namespace declaration
for _, attr := range el.Attr {
if attr.Space == xmlnsPrefix {
continue
}
if attr.Space == defaultPrefix && attr.Key == xmlnsPrefix {
continue
}
attrs = append(attrs, attr)
}
// Append all in-context namespace declarations
for prefix, namespace := range ctx.prefixes {
// Skip the implicit "xml" and "xmlns" prefix declarations
if prefix == xmlnsPrefix || prefix == xmlPrefix {
continue
}
// Also skip declararing the default namespace as XMLNamespace
if prefix == defaultPrefix && namespace == XMLNamespace {
continue
}
if prefix != defaultPrefix {
attrs = append(attrs, etree.Attr{
Space: xmlnsPrefix,
Key: prefix,
Value: namespace,
})
} else {
attrs = append(attrs, etree.Attr{
Key: xmlnsPrefix,
Value: namespace,
})
}
}
sort.Sort(SortedAttrs(attrs))
el.Attr = attrs
return el, nil
} | [
"func",
"NSDetatch",
"(",
"ctx",
"NSContext",
",",
"el",
"*",
"etree",
".",
"Element",
")",
"(",
"*",
"etree",
".",
"Element",
",",
"error",
")",
"{",
"ctx",
",",
"err",
":=",
"ctx",
".",
"SubContext",
"(",
"el",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"el",
"=",
"el",
".",
"Copy",
"(",
")",
"\n\n",
"// Build a new attribute list",
"attrs",
":=",
"make",
"(",
"[",
"]",
"etree",
".",
"Attr",
",",
"0",
",",
"len",
"(",
"el",
".",
"Attr",
")",
")",
"\n\n",
"// First copy over anything that isn't a namespace declaration",
"for",
"_",
",",
"attr",
":=",
"range",
"el",
".",
"Attr",
"{",
"if",
"attr",
".",
"Space",
"==",
"xmlnsPrefix",
"{",
"continue",
"\n",
"}",
"\n\n",
"if",
"attr",
".",
"Space",
"==",
"defaultPrefix",
"&&",
"attr",
".",
"Key",
"==",
"xmlnsPrefix",
"{",
"continue",
"\n",
"}",
"\n\n",
"attrs",
"=",
"append",
"(",
"attrs",
",",
"attr",
")",
"\n",
"}",
"\n\n",
"// Append all in-context namespace declarations",
"for",
"prefix",
",",
"namespace",
":=",
"range",
"ctx",
".",
"prefixes",
"{",
"// Skip the implicit \"xml\" and \"xmlns\" prefix declarations",
"if",
"prefix",
"==",
"xmlnsPrefix",
"||",
"prefix",
"==",
"xmlPrefix",
"{",
"continue",
"\n",
"}",
"\n\n",
"// Also skip declararing the default namespace as XMLNamespace",
"if",
"prefix",
"==",
"defaultPrefix",
"&&",
"namespace",
"==",
"XMLNamespace",
"{",
"continue",
"\n",
"}",
"\n\n",
"if",
"prefix",
"!=",
"defaultPrefix",
"{",
"attrs",
"=",
"append",
"(",
"attrs",
",",
"etree",
".",
"Attr",
"{",
"Space",
":",
"xmlnsPrefix",
",",
"Key",
":",
"prefix",
",",
"Value",
":",
"namespace",
",",
"}",
")",
"\n",
"}",
"else",
"{",
"attrs",
"=",
"append",
"(",
"attrs",
",",
"etree",
".",
"Attr",
"{",
"Key",
":",
"xmlnsPrefix",
",",
"Value",
":",
"namespace",
",",
"}",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"sort",
".",
"Sort",
"(",
"SortedAttrs",
"(",
"attrs",
")",
")",
"\n\n",
"el",
".",
"Attr",
"=",
"attrs",
"\n\n",
"return",
"el",
",",
"nil",
"\n",
"}"
] | // NSDetatch makes a copy of the passed element, and declares any namespaces in
// the passed context onto the new element before returning it. | [
"NSDetatch",
"makes",
"a",
"copy",
"of",
"the",
"passed",
"element",
"and",
"declares",
"any",
"namespaces",
"in",
"the",
"passed",
"context",
"onto",
"the",
"new",
"element",
"before",
"returning",
"it",
"."
] | 7acd5e4a6ef74fe1b082c20f119556adf70c3944 | https://github.com/russellhaering/goxmldsig/blob/7acd5e4a6ef74fe1b082c20f119556adf70c3944/etreeutils/namespace.go#L166-L221 |
10,235 | russellhaering/goxmldsig | etreeutils/namespace.go | NSSelectOne | func NSSelectOne(el *etree.Element, namespace, tag string) (*etree.Element, error) {
return NSSelectOneCtx(DefaultNSContext, el, namespace, tag)
} | go | func NSSelectOne(el *etree.Element, namespace, tag string) (*etree.Element, error) {
return NSSelectOneCtx(DefaultNSContext, el, namespace, tag)
} | [
"func",
"NSSelectOne",
"(",
"el",
"*",
"etree",
".",
"Element",
",",
"namespace",
",",
"tag",
"string",
")",
"(",
"*",
"etree",
".",
"Element",
",",
"error",
")",
"{",
"return",
"NSSelectOneCtx",
"(",
"DefaultNSContext",
",",
"el",
",",
"namespace",
",",
"tag",
")",
"\n",
"}"
] | // NSSelectOne behaves identically to NSSelectOneCtx, but uses DefaultNSContext as the
// surrounding context. | [
"NSSelectOne",
"behaves",
"identically",
"to",
"NSSelectOneCtx",
"but",
"uses",
"DefaultNSContext",
"as",
"the",
"surrounding",
"context",
"."
] | 7acd5e4a6ef74fe1b082c20f119556adf70c3944 | https://github.com/russellhaering/goxmldsig/blob/7acd5e4a6ef74fe1b082c20f119556adf70c3944/etreeutils/namespace.go#L225-L227 |
10,236 | russellhaering/goxmldsig | etreeutils/namespace.go | NSFindIterate | func NSFindIterate(el *etree.Element, namespace, tag string, handle NSIterHandler) error {
return NSFindIterateCtx(DefaultNSContext, el, namespace, tag, handle)
} | go | func NSFindIterate(el *etree.Element, namespace, tag string, handle NSIterHandler) error {
return NSFindIterateCtx(DefaultNSContext, el, namespace, tag, handle)
} | [
"func",
"NSFindIterate",
"(",
"el",
"*",
"etree",
".",
"Element",
",",
"namespace",
",",
"tag",
"string",
",",
"handle",
"NSIterHandler",
")",
"error",
"{",
"return",
"NSFindIterateCtx",
"(",
"DefaultNSContext",
",",
"el",
",",
"namespace",
",",
"tag",
",",
"handle",
")",
"\n",
"}"
] | // NSFindIterate behaves identically to NSFindIterateCtx, but uses DefaultNSContext
// as the surrounding context. | [
"NSFindIterate",
"behaves",
"identically",
"to",
"NSFindIterateCtx",
"but",
"uses",
"DefaultNSContext",
"as",
"the",
"surrounding",
"context",
"."
] | 7acd5e4a6ef74fe1b082c20f119556adf70c3944 | https://github.com/russellhaering/goxmldsig/blob/7acd5e4a6ef74fe1b082c20f119556adf70c3944/etreeutils/namespace.go#L256-L258 |
10,237 | russellhaering/goxmldsig | etreeutils/namespace.go | NSFindIterateCtx | func NSFindIterateCtx(ctx NSContext, el *etree.Element, namespace, tag string, handle NSIterHandler) error {
err := NSTraverse(ctx, el, func(ctx NSContext, el *etree.Element) error {
_ctx, err := ctx.SubContext(el)
if err != nil {
return err
}
currentNS, err := _ctx.LookupPrefix(el.Space)
if err != nil {
return err
}
// Base case, el is the sought after element.
if currentNS == namespace && el.Tag == tag {
return handle(ctx, el)
}
return nil
})
if err != nil && err != ErrTraversalHalted {
return err
}
return nil
} | go | func NSFindIterateCtx(ctx NSContext, el *etree.Element, namespace, tag string, handle NSIterHandler) error {
err := NSTraverse(ctx, el, func(ctx NSContext, el *etree.Element) error {
_ctx, err := ctx.SubContext(el)
if err != nil {
return err
}
currentNS, err := _ctx.LookupPrefix(el.Space)
if err != nil {
return err
}
// Base case, el is the sought after element.
if currentNS == namespace && el.Tag == tag {
return handle(ctx, el)
}
return nil
})
if err != nil && err != ErrTraversalHalted {
return err
}
return nil
} | [
"func",
"NSFindIterateCtx",
"(",
"ctx",
"NSContext",
",",
"el",
"*",
"etree",
".",
"Element",
",",
"namespace",
",",
"tag",
"string",
",",
"handle",
"NSIterHandler",
")",
"error",
"{",
"err",
":=",
"NSTraverse",
"(",
"ctx",
",",
"el",
",",
"func",
"(",
"ctx",
"NSContext",
",",
"el",
"*",
"etree",
".",
"Element",
")",
"error",
"{",
"_ctx",
",",
"err",
":=",
"ctx",
".",
"SubContext",
"(",
"el",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"currentNS",
",",
"err",
":=",
"_ctx",
".",
"LookupPrefix",
"(",
"el",
".",
"Space",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Base case, el is the sought after element.",
"if",
"currentNS",
"==",
"namespace",
"&&",
"el",
".",
"Tag",
"==",
"tag",
"{",
"return",
"handle",
"(",
"ctx",
",",
"el",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"&&",
"err",
"!=",
"ErrTraversalHalted",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // NSFindIterateCtx conducts a depth-first traversal searching for elements with the
// specified tag in the specified namespace. It uses the passed NSContext for prefix
// lookups. For each such element, the passed handler function is invoked. If the
// handler function returns an error traversal is immediately halted. If the error
// returned by the handler is ErrTraversalHalted then nil will be returned by
// NSFindIterate. If any other error is returned by the handler, that error will be
// returned by NSFindIterate. | [
"NSFindIterateCtx",
"conducts",
"a",
"depth",
"-",
"first",
"traversal",
"searching",
"for",
"elements",
"with",
"the",
"specified",
"tag",
"in",
"the",
"specified",
"namespace",
".",
"It",
"uses",
"the",
"passed",
"NSContext",
"for",
"prefix",
"lookups",
".",
"For",
"each",
"such",
"element",
"the",
"passed",
"handler",
"function",
"is",
"invoked",
".",
"If",
"the",
"handler",
"function",
"returns",
"an",
"error",
"traversal",
"is",
"immediately",
"halted",
".",
"If",
"the",
"error",
"returned",
"by",
"the",
"handler",
"is",
"ErrTraversalHalted",
"then",
"nil",
"will",
"be",
"returned",
"by",
"NSFindIterate",
".",
"If",
"any",
"other",
"error",
"is",
"returned",
"by",
"the",
"handler",
"that",
"error",
"will",
"be",
"returned",
"by",
"NSFindIterate",
"."
] | 7acd5e4a6ef74fe1b082c20f119556adf70c3944 | https://github.com/russellhaering/goxmldsig/blob/7acd5e4a6ef74fe1b082c20f119556adf70c3944/etreeutils/namespace.go#L267-L292 |
10,238 | russellhaering/goxmldsig | etreeutils/namespace.go | NSFindOne | func NSFindOne(el *etree.Element, namespace, tag string) (*etree.Element, error) {
return NSFindOneCtx(DefaultNSContext, el, namespace, tag)
} | go | func NSFindOne(el *etree.Element, namespace, tag string) (*etree.Element, error) {
return NSFindOneCtx(DefaultNSContext, el, namespace, tag)
} | [
"func",
"NSFindOne",
"(",
"el",
"*",
"etree",
".",
"Element",
",",
"namespace",
",",
"tag",
"string",
")",
"(",
"*",
"etree",
".",
"Element",
",",
"error",
")",
"{",
"return",
"NSFindOneCtx",
"(",
"DefaultNSContext",
",",
"el",
",",
"namespace",
",",
"tag",
")",
"\n",
"}"
] | // NSFindOne behaves identically to NSFindOneCtx, but uses DefaultNSContext for
// context. | [
"NSFindOne",
"behaves",
"identically",
"to",
"NSFindOneCtx",
"but",
"uses",
"DefaultNSContext",
"for",
"context",
"."
] | 7acd5e4a6ef74fe1b082c20f119556adf70c3944 | https://github.com/russellhaering/goxmldsig/blob/7acd5e4a6ef74fe1b082c20f119556adf70c3944/etreeutils/namespace.go#L296-L298 |
10,239 | russellhaering/goxmldsig | etreeutils/namespace.go | NSIterateChildren | func NSIterateChildren(ctx NSContext, el *etree.Element, handle NSIterHandler) error {
ctx, err := ctx.SubContext(el)
if err != nil {
return err
}
// Iterate the child elements.
for _, child := range el.ChildElements() {
err = handle(ctx, child)
if err != nil {
return err
}
}
return nil
} | go | func NSIterateChildren(ctx NSContext, el *etree.Element, handle NSIterHandler) error {
ctx, err := ctx.SubContext(el)
if err != nil {
return err
}
// Iterate the child elements.
for _, child := range el.ChildElements() {
err = handle(ctx, child)
if err != nil {
return err
}
}
return nil
} | [
"func",
"NSIterateChildren",
"(",
"ctx",
"NSContext",
",",
"el",
"*",
"etree",
".",
"Element",
",",
"handle",
"NSIterHandler",
")",
"error",
"{",
"ctx",
",",
"err",
":=",
"ctx",
".",
"SubContext",
"(",
"el",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Iterate the child elements.",
"for",
"_",
",",
"child",
":=",
"range",
"el",
".",
"ChildElements",
"(",
")",
"{",
"err",
"=",
"handle",
"(",
"ctx",
",",
"child",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // NSIterateChildren iterates the children of an element, invoking the passed
// handler with each direct child of the element, and the context surrounding
// that child. | [
"NSIterateChildren",
"iterates",
"the",
"children",
"of",
"an",
"element",
"invoking",
"the",
"passed",
"handler",
"with",
"each",
"direct",
"child",
"of",
"the",
"element",
"and",
"the",
"context",
"surrounding",
"that",
"child",
"."
] | 7acd5e4a6ef74fe1b082c20f119556adf70c3944 | https://github.com/russellhaering/goxmldsig/blob/7acd5e4a6ef74fe1b082c20f119556adf70c3944/etreeutils/namespace.go#L320-L335 |
10,240 | russellhaering/goxmldsig | etreeutils/namespace.go | NSFindOneChild | func NSFindOneChild(el *etree.Element, namespace, tag string) (*etree.Element, error) {
return NSFindOneChildCtx(DefaultNSContext, el, namespace, tag)
} | go | func NSFindOneChild(el *etree.Element, namespace, tag string) (*etree.Element, error) {
return NSFindOneChildCtx(DefaultNSContext, el, namespace, tag)
} | [
"func",
"NSFindOneChild",
"(",
"el",
"*",
"etree",
".",
"Element",
",",
"namespace",
",",
"tag",
"string",
")",
"(",
"*",
"etree",
".",
"Element",
",",
"error",
")",
"{",
"return",
"NSFindOneChildCtx",
"(",
"DefaultNSContext",
",",
"el",
",",
"namespace",
",",
"tag",
")",
"\n",
"}"
] | // NSFindOneChild behaves identically to NSFindOneChildCtx, but uses
// DefaultNSContext for context. | [
"NSFindOneChild",
"behaves",
"identically",
"to",
"NSFindOneChildCtx",
"but",
"uses",
"DefaultNSContext",
"for",
"context",
"."
] | 7acd5e4a6ef74fe1b082c20f119556adf70c3944 | https://github.com/russellhaering/goxmldsig/blob/7acd5e4a6ef74fe1b082c20f119556adf70c3944/etreeutils/namespace.go#L370-L372 |
10,241 | russellhaering/goxmldsig | etreeutils/namespace.go | NSFindOneChildCtx | func NSFindOneChildCtx(ctx NSContext, el *etree.Element, namespace, tag string) (*etree.Element, error) {
var found *etree.Element
err := NSFindChildrenIterateCtx(ctx, el, namespace, tag, func(ctx NSContext, el *etree.Element) error {
found = el
return ErrTraversalHalted
})
if err != nil && err != ErrTraversalHalted {
return nil, err
}
return found, nil
} | go | func NSFindOneChildCtx(ctx NSContext, el *etree.Element, namespace, tag string) (*etree.Element, error) {
var found *etree.Element
err := NSFindChildrenIterateCtx(ctx, el, namespace, tag, func(ctx NSContext, el *etree.Element) error {
found = el
return ErrTraversalHalted
})
if err != nil && err != ErrTraversalHalted {
return nil, err
}
return found, nil
} | [
"func",
"NSFindOneChildCtx",
"(",
"ctx",
"NSContext",
",",
"el",
"*",
"etree",
".",
"Element",
",",
"namespace",
",",
"tag",
"string",
")",
"(",
"*",
"etree",
".",
"Element",
",",
"error",
")",
"{",
"var",
"found",
"*",
"etree",
".",
"Element",
"\n\n",
"err",
":=",
"NSFindChildrenIterateCtx",
"(",
"ctx",
",",
"el",
",",
"namespace",
",",
"tag",
",",
"func",
"(",
"ctx",
"NSContext",
",",
"el",
"*",
"etree",
".",
"Element",
")",
"error",
"{",
"found",
"=",
"el",
"\n",
"return",
"ErrTraversalHalted",
"\n",
"}",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"&&",
"err",
"!=",
"ErrTraversalHalted",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"found",
",",
"nil",
"\n",
"}"
] | // NSFindOneCtx conducts a depth-first search for the specified element. If such an
// element is found a reference to it is returned. | [
"NSFindOneCtx",
"conducts",
"a",
"depth",
"-",
"first",
"search",
"for",
"the",
"specified",
"element",
".",
"If",
"such",
"an",
"element",
"is",
"found",
"a",
"reference",
"to",
"it",
"is",
"returned",
"."
] | 7acd5e4a6ef74fe1b082c20f119556adf70c3944 | https://github.com/russellhaering/goxmldsig/blob/7acd5e4a6ef74fe1b082c20f119556adf70c3944/etreeutils/namespace.go#L376-L389 |
10,242 | russellhaering/goxmldsig | etreeutils/namespace.go | NSBuildParentContext | func NSBuildParentContext(el *etree.Element) (NSContext, error) {
parent := el.Parent()
if parent == nil {
return DefaultNSContext, nil
}
ctx, err := NSBuildParentContext(parent)
if err != nil {
return ctx, err
}
return ctx.SubContext(parent)
} | go | func NSBuildParentContext(el *etree.Element) (NSContext, error) {
parent := el.Parent()
if parent == nil {
return DefaultNSContext, nil
}
ctx, err := NSBuildParentContext(parent)
if err != nil {
return ctx, err
}
return ctx.SubContext(parent)
} | [
"func",
"NSBuildParentContext",
"(",
"el",
"*",
"etree",
".",
"Element",
")",
"(",
"NSContext",
",",
"error",
")",
"{",
"parent",
":=",
"el",
".",
"Parent",
"(",
")",
"\n",
"if",
"parent",
"==",
"nil",
"{",
"return",
"DefaultNSContext",
",",
"nil",
"\n",
"}",
"\n\n",
"ctx",
",",
"err",
":=",
"NSBuildParentContext",
"(",
"parent",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ctx",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"ctx",
".",
"SubContext",
"(",
"parent",
")",
"\n",
"}"
] | // NSBuildParentContext recurses upward from an element in order to build an NSContext
// for its immediate parent. If the element has no parent DefaultNSContext
// is returned. | [
"NSBuildParentContext",
"recurses",
"upward",
"from",
"an",
"element",
"in",
"order",
"to",
"build",
"an",
"NSContext",
"for",
"its",
"immediate",
"parent",
".",
"If",
"the",
"element",
"has",
"no",
"parent",
"DefaultNSContext",
"is",
"returned",
"."
] | 7acd5e4a6ef74fe1b082c20f119556adf70c3944 | https://github.com/russellhaering/goxmldsig/blob/7acd5e4a6ef74fe1b082c20f119556adf70c3944/etreeutils/namespace.go#L394-L407 |
10,243 | russellhaering/goxmldsig | etreeutils/canonicalize.go | TransformExcC14n | func TransformExcC14n(el *etree.Element, inclusiveNamespacesPrefixList string) error {
prefixes := strings.Fields(inclusiveNamespacesPrefixList)
prefixSet := make(map[string]struct{}, len(prefixes))
for _, prefix := range prefixes {
prefixSet[prefix] = struct{}{}
}
err := transformExcC14n(DefaultNSContext, DefaultNSContext, el, prefixSet)
if err != nil {
return err
}
return nil
} | go | func TransformExcC14n(el *etree.Element, inclusiveNamespacesPrefixList string) error {
prefixes := strings.Fields(inclusiveNamespacesPrefixList)
prefixSet := make(map[string]struct{}, len(prefixes))
for _, prefix := range prefixes {
prefixSet[prefix] = struct{}{}
}
err := transformExcC14n(DefaultNSContext, DefaultNSContext, el, prefixSet)
if err != nil {
return err
}
return nil
} | [
"func",
"TransformExcC14n",
"(",
"el",
"*",
"etree",
".",
"Element",
",",
"inclusiveNamespacesPrefixList",
"string",
")",
"error",
"{",
"prefixes",
":=",
"strings",
".",
"Fields",
"(",
"inclusiveNamespacesPrefixList",
")",
"\n",
"prefixSet",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
",",
"len",
"(",
"prefixes",
")",
")",
"\n\n",
"for",
"_",
",",
"prefix",
":=",
"range",
"prefixes",
"{",
"prefixSet",
"[",
"prefix",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n",
"}",
"\n\n",
"err",
":=",
"transformExcC14n",
"(",
"DefaultNSContext",
",",
"DefaultNSContext",
",",
"el",
",",
"prefixSet",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // TransformExcC14n transforms the passed element into xml-exc-c14n form. | [
"TransformExcC14n",
"transforms",
"the",
"passed",
"element",
"into",
"xml",
"-",
"exc",
"-",
"c14n",
"form",
"."
] | 7acd5e4a6ef74fe1b082c20f119556adf70c3944 | https://github.com/russellhaering/goxmldsig/blob/7acd5e4a6ef74fe1b082c20f119556adf70c3944/etreeutils/canonicalize.go#L11-L25 |
10,244 | russellhaering/goxmldsig | validate.go | transform | func (ctx *ValidationContext) transform(
el *etree.Element,
sig *types.Signature,
ref *types.Reference) (*etree.Element, Canonicalizer, error) {
transforms := ref.Transforms.Transforms
if len(transforms) != 2 {
return nil, nil, errors.New("Expected Enveloped and C14N transforms")
}
// map the path to the passed signature relative to the passed root, in
// order to enable removal of the signature by an enveloped signature
// transform
signaturePath := mapPathToElement(el, sig.UnderlyingElement())
// make a copy of the passed root
el = el.Copy()
var canonicalizer Canonicalizer
for _, transform := range transforms {
algo := transform.Algorithm
switch AlgorithmID(algo) {
case EnvelopedSignatureAltorithmId:
if !removeElementAtPath(el, signaturePath) {
return nil, nil, errors.New("Error applying canonicalization transform: Signature not found")
}
case CanonicalXML10ExclusiveAlgorithmId:
var prefixList string
if transform.InclusiveNamespaces != nil {
prefixList = transform.InclusiveNamespaces.PrefixList
}
canonicalizer = MakeC14N10ExclusiveCanonicalizerWithPrefixList(prefixList)
case CanonicalXML11AlgorithmId:
canonicalizer = MakeC14N11Canonicalizer()
case CanonicalXML10RecAlgorithmId:
canonicalizer = MakeC14N10RecCanonicalizer()
case CanonicalXML10CommentAlgorithmId:
canonicalizer = MakeC14N10CommentCanonicalizer()
default:
return nil, nil, errors.New("Unknown Transform Algorithm: " + algo)
}
}
if canonicalizer == nil {
return nil, nil, errors.New("Expected canonicalization transform")
}
return el, canonicalizer, nil
} | go | func (ctx *ValidationContext) transform(
el *etree.Element,
sig *types.Signature,
ref *types.Reference) (*etree.Element, Canonicalizer, error) {
transforms := ref.Transforms.Transforms
if len(transforms) != 2 {
return nil, nil, errors.New("Expected Enveloped and C14N transforms")
}
// map the path to the passed signature relative to the passed root, in
// order to enable removal of the signature by an enveloped signature
// transform
signaturePath := mapPathToElement(el, sig.UnderlyingElement())
// make a copy of the passed root
el = el.Copy()
var canonicalizer Canonicalizer
for _, transform := range transforms {
algo := transform.Algorithm
switch AlgorithmID(algo) {
case EnvelopedSignatureAltorithmId:
if !removeElementAtPath(el, signaturePath) {
return nil, nil, errors.New("Error applying canonicalization transform: Signature not found")
}
case CanonicalXML10ExclusiveAlgorithmId:
var prefixList string
if transform.InclusiveNamespaces != nil {
prefixList = transform.InclusiveNamespaces.PrefixList
}
canonicalizer = MakeC14N10ExclusiveCanonicalizerWithPrefixList(prefixList)
case CanonicalXML11AlgorithmId:
canonicalizer = MakeC14N11Canonicalizer()
case CanonicalXML10RecAlgorithmId:
canonicalizer = MakeC14N10RecCanonicalizer()
case CanonicalXML10CommentAlgorithmId:
canonicalizer = MakeC14N10CommentCanonicalizer()
default:
return nil, nil, errors.New("Unknown Transform Algorithm: " + algo)
}
}
if canonicalizer == nil {
return nil, nil, errors.New("Expected canonicalization transform")
}
return el, canonicalizer, nil
} | [
"func",
"(",
"ctx",
"*",
"ValidationContext",
")",
"transform",
"(",
"el",
"*",
"etree",
".",
"Element",
",",
"sig",
"*",
"types",
".",
"Signature",
",",
"ref",
"*",
"types",
".",
"Reference",
")",
"(",
"*",
"etree",
".",
"Element",
",",
"Canonicalizer",
",",
"error",
")",
"{",
"transforms",
":=",
"ref",
".",
"Transforms",
".",
"Transforms",
"\n\n",
"if",
"len",
"(",
"transforms",
")",
"!=",
"2",
"{",
"return",
"nil",
",",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// map the path to the passed signature relative to the passed root, in",
"// order to enable removal of the signature by an enveloped signature",
"// transform",
"signaturePath",
":=",
"mapPathToElement",
"(",
"el",
",",
"sig",
".",
"UnderlyingElement",
"(",
")",
")",
"\n\n",
"// make a copy of the passed root",
"el",
"=",
"el",
".",
"Copy",
"(",
")",
"\n\n",
"var",
"canonicalizer",
"Canonicalizer",
"\n\n",
"for",
"_",
",",
"transform",
":=",
"range",
"transforms",
"{",
"algo",
":=",
"transform",
".",
"Algorithm",
"\n\n",
"switch",
"AlgorithmID",
"(",
"algo",
")",
"{",
"case",
"EnvelopedSignatureAltorithmId",
":",
"if",
"!",
"removeElementAtPath",
"(",
"el",
",",
"signaturePath",
")",
"{",
"return",
"nil",
",",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"case",
"CanonicalXML10ExclusiveAlgorithmId",
":",
"var",
"prefixList",
"string",
"\n",
"if",
"transform",
".",
"InclusiveNamespaces",
"!=",
"nil",
"{",
"prefixList",
"=",
"transform",
".",
"InclusiveNamespaces",
".",
"PrefixList",
"\n",
"}",
"\n\n",
"canonicalizer",
"=",
"MakeC14N10ExclusiveCanonicalizerWithPrefixList",
"(",
"prefixList",
")",
"\n\n",
"case",
"CanonicalXML11AlgorithmId",
":",
"canonicalizer",
"=",
"MakeC14N11Canonicalizer",
"(",
")",
"\n\n",
"case",
"CanonicalXML10RecAlgorithmId",
":",
"canonicalizer",
"=",
"MakeC14N10RecCanonicalizer",
"(",
")",
"\n\n",
"case",
"CanonicalXML10CommentAlgorithmId",
":",
"canonicalizer",
"=",
"MakeC14N10CommentCanonicalizer",
"(",
")",
"\n\n",
"default",
":",
"return",
"nil",
",",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
"+",
"algo",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"canonicalizer",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"el",
",",
"canonicalizer",
",",
"nil",
"\n",
"}"
] | // Transform returns a new element equivalent to the passed root el, but with
// the set of transformations described by the ref applied.
//
// The functionality of transform is currently very limited and purpose-specific. | [
"Transform",
"returns",
"a",
"new",
"element",
"equivalent",
"to",
"the",
"passed",
"root",
"el",
"but",
"with",
"the",
"set",
"of",
"transformations",
"described",
"by",
"the",
"ref",
"applied",
".",
"The",
"functionality",
"of",
"transform",
"is",
"currently",
"very",
"limited",
"and",
"purpose",
"-",
"specific",
"."
] | 7acd5e4a6ef74fe1b082c20f119556adf70c3944 | https://github.com/russellhaering/goxmldsig/blob/7acd5e4a6ef74fe1b082c20f119556adf70c3944/validate.go#L107-L163 |
10,245 | russellhaering/goxmldsig | validate.go | findSignature | func (ctx *ValidationContext) findSignature(el *etree.Element) (*types.Signature, error) {
idAttr := el.SelectAttr(ctx.IdAttribute)
if idAttr == nil || idAttr.Value == "" {
return nil, errors.New("Missing ID attribute")
}
var sig *types.Signature
// Traverse the tree looking for a Signature element
err := etreeutils.NSFindIterate(el, Namespace, SignatureTag, func(ctx etreeutils.NSContext, el *etree.Element) error {
found := false
err := etreeutils.NSFindChildrenIterateCtx(ctx, el, Namespace, SignedInfoTag,
func(ctx etreeutils.NSContext, signedInfo *etree.Element) error {
detachedSignedInfo, err := etreeutils.NSDetatch(ctx, signedInfo)
if err != nil {
return err
}
c14NMethod, err := etreeutils.NSFindOneChildCtx(ctx, detachedSignedInfo, Namespace, CanonicalizationMethodTag)
if err != nil {
return err
}
if c14NMethod == nil {
return errors.New("missing CanonicalizationMethod on Signature")
}
c14NAlgorithm := c14NMethod.SelectAttrValue(AlgorithmAttr, "")
var canonicalSignedInfo *etree.Element
switch AlgorithmID(c14NAlgorithm) {
case CanonicalXML10ExclusiveAlgorithmId:
err := etreeutils.TransformExcC14n(detachedSignedInfo, "")
if err != nil {
return err
}
// NOTE: TransformExcC14n transforms the element in-place,
// while canonicalPrep isn't meant to. Once we standardize
// this behavior we can drop this, as well as the adding and
// removing of elements below.
canonicalSignedInfo = detachedSignedInfo
case CanonicalXML11AlgorithmId:
canonicalSignedInfo = canonicalPrep(detachedSignedInfo, map[string]struct{}{})
case CanonicalXML10RecAlgorithmId:
canonicalSignedInfo = canonicalPrep(detachedSignedInfo, map[string]struct{}{})
case CanonicalXML10CommentAlgorithmId:
canonicalSignedInfo = canonicalPrep(detachedSignedInfo, map[string]struct{}{})
default:
return fmt.Errorf("invalid CanonicalizationMethod on Signature: %s", c14NAlgorithm)
}
el.RemoveChild(signedInfo)
el.AddChild(canonicalSignedInfo)
found = true
return etreeutils.ErrTraversalHalted
})
if err != nil {
return err
}
if !found {
return errors.New("Missing SignedInfo")
}
// Unmarshal the signature into a structured Signature type
_sig := &types.Signature{}
err = etreeutils.NSUnmarshalElement(ctx, el, _sig)
if err != nil {
return err
}
// Traverse references in the signature to determine whether it has at least
// one reference to the top level element. If so, conclude the search.
for _, ref := range _sig.SignedInfo.References {
if ref.URI == "" || ref.URI[1:] == idAttr.Value {
sig = _sig
return etreeutils.ErrTraversalHalted
}
}
return nil
})
if err != nil {
return nil, err
}
if sig == nil {
return nil, ErrMissingSignature
}
return sig, nil
} | go | func (ctx *ValidationContext) findSignature(el *etree.Element) (*types.Signature, error) {
idAttr := el.SelectAttr(ctx.IdAttribute)
if idAttr == nil || idAttr.Value == "" {
return nil, errors.New("Missing ID attribute")
}
var sig *types.Signature
// Traverse the tree looking for a Signature element
err := etreeutils.NSFindIterate(el, Namespace, SignatureTag, func(ctx etreeutils.NSContext, el *etree.Element) error {
found := false
err := etreeutils.NSFindChildrenIterateCtx(ctx, el, Namespace, SignedInfoTag,
func(ctx etreeutils.NSContext, signedInfo *etree.Element) error {
detachedSignedInfo, err := etreeutils.NSDetatch(ctx, signedInfo)
if err != nil {
return err
}
c14NMethod, err := etreeutils.NSFindOneChildCtx(ctx, detachedSignedInfo, Namespace, CanonicalizationMethodTag)
if err != nil {
return err
}
if c14NMethod == nil {
return errors.New("missing CanonicalizationMethod on Signature")
}
c14NAlgorithm := c14NMethod.SelectAttrValue(AlgorithmAttr, "")
var canonicalSignedInfo *etree.Element
switch AlgorithmID(c14NAlgorithm) {
case CanonicalXML10ExclusiveAlgorithmId:
err := etreeutils.TransformExcC14n(detachedSignedInfo, "")
if err != nil {
return err
}
// NOTE: TransformExcC14n transforms the element in-place,
// while canonicalPrep isn't meant to. Once we standardize
// this behavior we can drop this, as well as the adding and
// removing of elements below.
canonicalSignedInfo = detachedSignedInfo
case CanonicalXML11AlgorithmId:
canonicalSignedInfo = canonicalPrep(detachedSignedInfo, map[string]struct{}{})
case CanonicalXML10RecAlgorithmId:
canonicalSignedInfo = canonicalPrep(detachedSignedInfo, map[string]struct{}{})
case CanonicalXML10CommentAlgorithmId:
canonicalSignedInfo = canonicalPrep(detachedSignedInfo, map[string]struct{}{})
default:
return fmt.Errorf("invalid CanonicalizationMethod on Signature: %s", c14NAlgorithm)
}
el.RemoveChild(signedInfo)
el.AddChild(canonicalSignedInfo)
found = true
return etreeutils.ErrTraversalHalted
})
if err != nil {
return err
}
if !found {
return errors.New("Missing SignedInfo")
}
// Unmarshal the signature into a structured Signature type
_sig := &types.Signature{}
err = etreeutils.NSUnmarshalElement(ctx, el, _sig)
if err != nil {
return err
}
// Traverse references in the signature to determine whether it has at least
// one reference to the top level element. If so, conclude the search.
for _, ref := range _sig.SignedInfo.References {
if ref.URI == "" || ref.URI[1:] == idAttr.Value {
sig = _sig
return etreeutils.ErrTraversalHalted
}
}
return nil
})
if err != nil {
return nil, err
}
if sig == nil {
return nil, ErrMissingSignature
}
return sig, nil
} | [
"func",
"(",
"ctx",
"*",
"ValidationContext",
")",
"findSignature",
"(",
"el",
"*",
"etree",
".",
"Element",
")",
"(",
"*",
"types",
".",
"Signature",
",",
"error",
")",
"{",
"idAttr",
":=",
"el",
".",
"SelectAttr",
"(",
"ctx",
".",
"IdAttribute",
")",
"\n",
"if",
"idAttr",
"==",
"nil",
"||",
"idAttr",
".",
"Value",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"var",
"sig",
"*",
"types",
".",
"Signature",
"\n\n",
"// Traverse the tree looking for a Signature element",
"err",
":=",
"etreeutils",
".",
"NSFindIterate",
"(",
"el",
",",
"Namespace",
",",
"SignatureTag",
",",
"func",
"(",
"ctx",
"etreeutils",
".",
"NSContext",
",",
"el",
"*",
"etree",
".",
"Element",
")",
"error",
"{",
"found",
":=",
"false",
"\n",
"err",
":=",
"etreeutils",
".",
"NSFindChildrenIterateCtx",
"(",
"ctx",
",",
"el",
",",
"Namespace",
",",
"SignedInfoTag",
",",
"func",
"(",
"ctx",
"etreeutils",
".",
"NSContext",
",",
"signedInfo",
"*",
"etree",
".",
"Element",
")",
"error",
"{",
"detachedSignedInfo",
",",
"err",
":=",
"etreeutils",
".",
"NSDetatch",
"(",
"ctx",
",",
"signedInfo",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"c14NMethod",
",",
"err",
":=",
"etreeutils",
".",
"NSFindOneChildCtx",
"(",
"ctx",
",",
"detachedSignedInfo",
",",
"Namespace",
",",
"CanonicalizationMethodTag",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"c14NMethod",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"c14NAlgorithm",
":=",
"c14NMethod",
".",
"SelectAttrValue",
"(",
"AlgorithmAttr",
",",
"\"",
"\"",
")",
"\n\n",
"var",
"canonicalSignedInfo",
"*",
"etree",
".",
"Element",
"\n\n",
"switch",
"AlgorithmID",
"(",
"c14NAlgorithm",
")",
"{",
"case",
"CanonicalXML10ExclusiveAlgorithmId",
":",
"err",
":=",
"etreeutils",
".",
"TransformExcC14n",
"(",
"detachedSignedInfo",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// NOTE: TransformExcC14n transforms the element in-place,",
"// while canonicalPrep isn't meant to. Once we standardize",
"// this behavior we can drop this, as well as the adding and",
"// removing of elements below.",
"canonicalSignedInfo",
"=",
"detachedSignedInfo",
"\n\n",
"case",
"CanonicalXML11AlgorithmId",
":",
"canonicalSignedInfo",
"=",
"canonicalPrep",
"(",
"detachedSignedInfo",
",",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
"{",
"}",
")",
"\n\n",
"case",
"CanonicalXML10RecAlgorithmId",
":",
"canonicalSignedInfo",
"=",
"canonicalPrep",
"(",
"detachedSignedInfo",
",",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
"{",
"}",
")",
"\n\n",
"case",
"CanonicalXML10CommentAlgorithmId",
":",
"canonicalSignedInfo",
"=",
"canonicalPrep",
"(",
"detachedSignedInfo",
",",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
"{",
"}",
")",
"\n\n",
"default",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"c14NAlgorithm",
")",
"\n",
"}",
"\n\n",
"el",
".",
"RemoveChild",
"(",
"signedInfo",
")",
"\n",
"el",
".",
"AddChild",
"(",
"canonicalSignedInfo",
")",
"\n\n",
"found",
"=",
"true",
"\n\n",
"return",
"etreeutils",
".",
"ErrTraversalHalted",
"\n",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"!",
"found",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Unmarshal the signature into a structured Signature type",
"_sig",
":=",
"&",
"types",
".",
"Signature",
"{",
"}",
"\n",
"err",
"=",
"etreeutils",
".",
"NSUnmarshalElement",
"(",
"ctx",
",",
"el",
",",
"_sig",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Traverse references in the signature to determine whether it has at least",
"// one reference to the top level element. If so, conclude the search.",
"for",
"_",
",",
"ref",
":=",
"range",
"_sig",
".",
"SignedInfo",
".",
"References",
"{",
"if",
"ref",
".",
"URI",
"==",
"\"",
"\"",
"||",
"ref",
".",
"URI",
"[",
"1",
":",
"]",
"==",
"idAttr",
".",
"Value",
"{",
"sig",
"=",
"_sig",
"\n",
"return",
"etreeutils",
".",
"ErrTraversalHalted",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"sig",
"==",
"nil",
"{",
"return",
"nil",
",",
"ErrMissingSignature",
"\n",
"}",
"\n\n",
"return",
"sig",
",",
"nil",
"\n",
"}"
] | // findSignature searches for a Signature element referencing the passed root element. | [
"findSignature",
"searches",
"for",
"a",
"Signature",
"element",
"referencing",
"the",
"passed",
"root",
"element",
"."
] | 7acd5e4a6ef74fe1b082c20f119556adf70c3944 | https://github.com/russellhaering/goxmldsig/blob/7acd5e4a6ef74fe1b082c20f119556adf70c3944/validate.go#L300-L401 |
10,246 | russellhaering/goxmldsig | validate.go | Validate | func (ctx *ValidationContext) Validate(el *etree.Element) (*etree.Element, error) {
// Make a copy of the element to avoid mutating the one we were passed.
el = el.Copy()
sig, err := ctx.findSignature(el)
if err != nil {
return nil, err
}
cert, err := ctx.verifyCertificate(sig)
if err != nil {
return nil, err
}
return ctx.validateSignature(el, sig, cert)
} | go | func (ctx *ValidationContext) Validate(el *etree.Element) (*etree.Element, error) {
// Make a copy of the element to avoid mutating the one we were passed.
el = el.Copy()
sig, err := ctx.findSignature(el)
if err != nil {
return nil, err
}
cert, err := ctx.verifyCertificate(sig)
if err != nil {
return nil, err
}
return ctx.validateSignature(el, sig, cert)
} | [
"func",
"(",
"ctx",
"*",
"ValidationContext",
")",
"Validate",
"(",
"el",
"*",
"etree",
".",
"Element",
")",
"(",
"*",
"etree",
".",
"Element",
",",
"error",
")",
"{",
"// Make a copy of the element to avoid mutating the one we were passed.",
"el",
"=",
"el",
".",
"Copy",
"(",
")",
"\n\n",
"sig",
",",
"err",
":=",
"ctx",
".",
"findSignature",
"(",
"el",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"cert",
",",
"err",
":=",
"ctx",
".",
"verifyCertificate",
"(",
"sig",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"ctx",
".",
"validateSignature",
"(",
"el",
",",
"sig",
",",
"cert",
")",
"\n",
"}"
] | // Validate verifies that the passed element contains a valid enveloped signature
// matching a currently-valid certificate in the context's CertificateStore. | [
"Validate",
"verifies",
"that",
"the",
"passed",
"element",
"contains",
"a",
"valid",
"enveloped",
"signature",
"matching",
"a",
"currently",
"-",
"valid",
"certificate",
"in",
"the",
"context",
"s",
"CertificateStore",
"."
] | 7acd5e4a6ef74fe1b082c20f119556adf70c3944 | https://github.com/russellhaering/goxmldsig/blob/7acd5e4a6ef74fe1b082c20f119556adf70c3944/validate.go#L452-L467 |
10,247 | sethvargo/go-fastly | fastly/dictionary_item.go | ListDictionaryItems | func (c *Client) ListDictionaryItems(i *ListDictionaryItemsInput) ([]*DictionaryItem, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Dictionary == "" {
return nil, ErrMissingDictionary
}
path := fmt.Sprintf("/service/%s/dictionary/%s/items", i.Service, i.Dictionary)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var bs []*DictionaryItem
if err := decodeJSON(&bs, resp.Body); err != nil {
return nil, err
}
sort.Stable(dictionaryItemsByKey(bs))
return bs, nil
} | go | func (c *Client) ListDictionaryItems(i *ListDictionaryItemsInput) ([]*DictionaryItem, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Dictionary == "" {
return nil, ErrMissingDictionary
}
path := fmt.Sprintf("/service/%s/dictionary/%s/items", i.Service, i.Dictionary)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var bs []*DictionaryItem
if err := decodeJSON(&bs, resp.Body); err != nil {
return nil, err
}
sort.Stable(dictionaryItemsByKey(bs))
return bs, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListDictionaryItems",
"(",
"i",
"*",
"ListDictionaryItemsInput",
")",
"(",
"[",
"]",
"*",
"DictionaryItem",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Dictionary",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingDictionary",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Dictionary",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"bs",
"[",
"]",
"*",
"DictionaryItem",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"bs",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"dictionaryItemsByKey",
"(",
"bs",
")",
")",
"\n",
"return",
"bs",
",",
"nil",
"\n",
"}"
] | // ListDictionaryItems returns the list of dictionary items for the
// configuration version. | [
"ListDictionaryItems",
"returns",
"the",
"list",
"of",
"dictionary",
"items",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/dictionary_item.go#L53-L74 |
10,248 | sethvargo/go-fastly | fastly/dictionary_item.go | CreateDictionaryItem | func (c *Client) CreateDictionaryItem(i *CreateDictionaryItemInput) (*DictionaryItem, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Dictionary == "" {
return nil, ErrMissingDictionary
}
path := fmt.Sprintf("/service/%s/dictionary/%s/item", i.Service, i.Dictionary)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var b *DictionaryItem
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) CreateDictionaryItem(i *CreateDictionaryItemInput) (*DictionaryItem, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Dictionary == "" {
return nil, ErrMissingDictionary
}
path := fmt.Sprintf("/service/%s/dictionary/%s/item", i.Service, i.Dictionary)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var b *DictionaryItem
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateDictionaryItem",
"(",
"i",
"*",
"CreateDictionaryItemInput",
")",
"(",
"*",
"DictionaryItem",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Dictionary",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingDictionary",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Dictionary",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"b",
"*",
"DictionaryItem",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // CreateDictionaryItem creates a new Fastly dictionary item. | [
"CreateDictionaryItem",
"creates",
"a",
"new",
"Fastly",
"dictionary",
"item",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/dictionary_item.go#L88-L108 |
10,249 | sethvargo/go-fastly | fastly/dictionary_item.go | CreateDictionaryItems | func (c *Client) CreateDictionaryItems(i []CreateDictionaryItemInput) ([]DictionaryItem, error) {
var b []DictionaryItem
for _, cdii := range i {
di, err := c.CreateDictionaryItem(&cdii)
if err != nil {
return nil, err
}
b = append(b, *di)
}
return b, nil
} | go | func (c *Client) CreateDictionaryItems(i []CreateDictionaryItemInput) ([]DictionaryItem, error) {
var b []DictionaryItem
for _, cdii := range i {
di, err := c.CreateDictionaryItem(&cdii)
if err != nil {
return nil, err
}
b = append(b, *di)
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateDictionaryItems",
"(",
"i",
"[",
"]",
"CreateDictionaryItemInput",
")",
"(",
"[",
"]",
"DictionaryItem",
",",
"error",
")",
"{",
"var",
"b",
"[",
"]",
"DictionaryItem",
"\n",
"for",
"_",
",",
"cdii",
":=",
"range",
"i",
"{",
"di",
",",
"err",
":=",
"c",
".",
"CreateDictionaryItem",
"(",
"&",
"cdii",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"b",
"=",
"append",
"(",
"b",
",",
"*",
"di",
")",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // CreateDictionaryItems creates new Fastly dictionary items from a slice. | [
"CreateDictionaryItems",
"creates",
"new",
"Fastly",
"dictionary",
"items",
"from",
"a",
"slice",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/dictionary_item.go#L111-L122 |
10,250 | sethvargo/go-fastly | fastly/dictionary_item.go | GetDictionaryItem | func (c *Client) GetDictionaryItem(i *GetDictionaryItemInput) (*DictionaryItem, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Dictionary == "" {
return nil, ErrMissingDictionary
}
if i.ItemKey == "" {
return nil, ErrMissingItemKey
}
path := fmt.Sprintf("/service/%s/dictionary/%s/item/%s", i.Service, i.Dictionary, i.ItemKey)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *DictionaryItem
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) GetDictionaryItem(i *GetDictionaryItemInput) (*DictionaryItem, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Dictionary == "" {
return nil, ErrMissingDictionary
}
if i.ItemKey == "" {
return nil, ErrMissingItemKey
}
path := fmt.Sprintf("/service/%s/dictionary/%s/item/%s", i.Service, i.Dictionary, i.ItemKey)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *DictionaryItem
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetDictionaryItem",
"(",
"i",
"*",
"GetDictionaryItemInput",
")",
"(",
"*",
"DictionaryItem",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Dictionary",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingDictionary",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"ItemKey",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingItemKey",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Dictionary",
",",
"i",
".",
"ItemKey",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"b",
"*",
"DictionaryItem",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // GetDictionaryItem gets the dictionary item with the given parameters. | [
"GetDictionaryItem",
"gets",
"the",
"dictionary",
"item",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/dictionary_item.go#L136-L160 |
10,251 | sethvargo/go-fastly | fastly/dictionary_item.go | UpdateDictionaryItem | func (c *Client) UpdateDictionaryItem(i *UpdateDictionaryItemInput) (*DictionaryItem, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Dictionary == "" {
return nil, ErrMissingDictionary
}
if i.ItemKey == "" {
return nil, ErrMissingItemKey
}
path := fmt.Sprintf("/service/%s/dictionary/%s/item/%s", i.Service, i.Dictionary, i.ItemKey)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var b *DictionaryItem
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) UpdateDictionaryItem(i *UpdateDictionaryItemInput) (*DictionaryItem, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Dictionary == "" {
return nil, ErrMissingDictionary
}
if i.ItemKey == "" {
return nil, ErrMissingItemKey
}
path := fmt.Sprintf("/service/%s/dictionary/%s/item/%s", i.Service, i.Dictionary, i.ItemKey)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var b *DictionaryItem
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateDictionaryItem",
"(",
"i",
"*",
"UpdateDictionaryItemInput",
")",
"(",
"*",
"DictionaryItem",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Dictionary",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingDictionary",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"ItemKey",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingItemKey",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Dictionary",
",",
"i",
".",
"ItemKey",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"b",
"*",
"DictionaryItem",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // UpdateDictionaryItem updates a specific dictionary item. | [
"UpdateDictionaryItem",
"updates",
"a",
"specific",
"dictionary",
"item",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/dictionary_item.go#L176-L200 |
10,252 | sethvargo/go-fastly | fastly/dictionary_item.go | DeleteDictionaryItem | func (c *Client) DeleteDictionaryItem(i *DeleteDictionaryItemInput) error {
if i.Service == "" {
return ErrMissingService
}
if i.Dictionary == "" {
return ErrMissingDictionary
}
if i.ItemKey == "" {
return ErrMissingItemKey
}
path := fmt.Sprintf("/service/%s/dictionary/%s/item/%s", i.Service, i.Dictionary, i.ItemKey)
resp, err := c.Delete(path, nil)
if err != nil {
return err
}
defer resp.Body.Close()
// Unlike other endpoints, the dictionary endpoint does not return a status
// response - it just returns a 200 OK.
return nil
} | go | func (c *Client) DeleteDictionaryItem(i *DeleteDictionaryItemInput) error {
if i.Service == "" {
return ErrMissingService
}
if i.Dictionary == "" {
return ErrMissingDictionary
}
if i.ItemKey == "" {
return ErrMissingItemKey
}
path := fmt.Sprintf("/service/%s/dictionary/%s/item/%s", i.Service, i.Dictionary, i.ItemKey)
resp, err := c.Delete(path, nil)
if err != nil {
return err
}
defer resp.Body.Close()
// Unlike other endpoints, the dictionary endpoint does not return a status
// response - it just returns a 200 OK.
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteDictionaryItem",
"(",
"i",
"*",
"DeleteDictionaryItemInput",
")",
"error",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Dictionary",
"==",
"\"",
"\"",
"{",
"return",
"ErrMissingDictionary",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"ItemKey",
"==",
"\"",
"\"",
"{",
"return",
"ErrMissingItemKey",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Dictionary",
",",
"i",
".",
"ItemKey",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Delete",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"// Unlike other endpoints, the dictionary endpoint does not return a status",
"// response - it just returns a 200 OK.",
"return",
"nil",
"\n",
"}"
] | // DeleteDictionaryItem deletes the given dictionary item. | [
"DeleteDictionaryItem",
"deletes",
"the",
"given",
"dictionary",
"item",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/dictionary_item.go#L214-L237 |
10,253 | sethvargo/go-fastly | fastly/request.go | RawRequest | func (c *Client) RawRequest(verb, p string, ro *RequestOptions) (*http.Request, error) {
// Ensure we have request options.
if ro == nil {
ro = new(RequestOptions)
}
// Append the path to the URL.
u := *c.url
u.Path = strings.TrimRight(c.url.Path, "/") + "/" + strings.TrimLeft(p, "/")
// Add the token and other params.
var params = make(url.Values)
for k, v := range ro.Params {
params.Add(k, v)
}
u.RawQuery = params.Encode()
// Create the request object.
request, err := http.NewRequest(verb, u.String(), ro.Body)
if err != nil {
return nil, err
}
// Set the API key.
if len(c.apiKey) > 0 {
request.Header.Set(APIKeyHeader, c.apiKey)
}
// Set the User-Agent.
request.Header.Set("User-Agent", UserAgent)
// Add any custom headers.
for k, v := range ro.Headers {
request.Header.Add(k, v)
}
// Add Content-Length if we have it.
if ro.BodyLength > 0 {
request.ContentLength = ro.BodyLength
}
return request, nil
} | go | func (c *Client) RawRequest(verb, p string, ro *RequestOptions) (*http.Request, error) {
// Ensure we have request options.
if ro == nil {
ro = new(RequestOptions)
}
// Append the path to the URL.
u := *c.url
u.Path = strings.TrimRight(c.url.Path, "/") + "/" + strings.TrimLeft(p, "/")
// Add the token and other params.
var params = make(url.Values)
for k, v := range ro.Params {
params.Add(k, v)
}
u.RawQuery = params.Encode()
// Create the request object.
request, err := http.NewRequest(verb, u.String(), ro.Body)
if err != nil {
return nil, err
}
// Set the API key.
if len(c.apiKey) > 0 {
request.Header.Set(APIKeyHeader, c.apiKey)
}
// Set the User-Agent.
request.Header.Set("User-Agent", UserAgent)
// Add any custom headers.
for k, v := range ro.Headers {
request.Header.Add(k, v)
}
// Add Content-Length if we have it.
if ro.BodyLength > 0 {
request.ContentLength = ro.BodyLength
}
return request, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"RawRequest",
"(",
"verb",
",",
"p",
"string",
",",
"ro",
"*",
"RequestOptions",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"// Ensure we have request options.",
"if",
"ro",
"==",
"nil",
"{",
"ro",
"=",
"new",
"(",
"RequestOptions",
")",
"\n",
"}",
"\n\n",
"// Append the path to the URL.",
"u",
":=",
"*",
"c",
".",
"url",
"\n",
"u",
".",
"Path",
"=",
"strings",
".",
"TrimRight",
"(",
"c",
".",
"url",
".",
"Path",
",",
"\"",
"\"",
")",
"+",
"\"",
"\"",
"+",
"strings",
".",
"TrimLeft",
"(",
"p",
",",
"\"",
"\"",
")",
"\n\n",
"// Add the token and other params.",
"var",
"params",
"=",
"make",
"(",
"url",
".",
"Values",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"ro",
".",
"Params",
"{",
"params",
".",
"Add",
"(",
"k",
",",
"v",
")",
"\n",
"}",
"\n",
"u",
".",
"RawQuery",
"=",
"params",
".",
"Encode",
"(",
")",
"\n\n",
"// Create the request object.",
"request",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"verb",
",",
"u",
".",
"String",
"(",
")",
",",
"ro",
".",
"Body",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Set the API key.",
"if",
"len",
"(",
"c",
".",
"apiKey",
")",
">",
"0",
"{",
"request",
".",
"Header",
".",
"Set",
"(",
"APIKeyHeader",
",",
"c",
".",
"apiKey",
")",
"\n",
"}",
"\n\n",
"// Set the User-Agent.",
"request",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"UserAgent",
")",
"\n\n",
"// Add any custom headers.",
"for",
"k",
",",
"v",
":=",
"range",
"ro",
".",
"Headers",
"{",
"request",
".",
"Header",
".",
"Add",
"(",
"k",
",",
"v",
")",
"\n",
"}",
"\n\n",
"// Add Content-Length if we have it.",
"if",
"ro",
".",
"BodyLength",
">",
"0",
"{",
"request",
".",
"ContentLength",
"=",
"ro",
".",
"BodyLength",
"\n",
"}",
"\n\n",
"return",
"request",
",",
"nil",
"\n",
"}"
] | // RawRequest accepts a verb, URL, and RequestOptions struct and returns the
// constructed http.Request and any errors that occurred | [
"RawRequest",
"accepts",
"a",
"verb",
"URL",
"and",
"RequestOptions",
"struct",
"and",
"returns",
"the",
"constructed",
"http",
".",
"Request",
"and",
"any",
"errors",
"that",
"occurred"
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/request.go#L26-L68 |
10,254 | sethvargo/go-fastly | fastly/request.go | SimpleGet | func (c *Client) SimpleGet(target string) (*http.Response, error) {
// We parse the URL and then convert it right back to a string
// later; this just acts as a check that Fastly isn't sending
// us nonsense.
url, err := url.Parse(target)
if err != nil {
return nil, err
}
request, err := http.NewRequest("GET", url.String(), nil)
if err != nil {
return nil, err
}
if len(c.apiKey) > 0 {
request.Header.Set(APIKeyHeader, c.apiKey)
}
request.Header.Set("User-Agent", UserAgent)
resp, err := checkResp(c.HTTPClient.Do(request))
if err != nil {
return resp, err
}
return resp, nil
} | go | func (c *Client) SimpleGet(target string) (*http.Response, error) {
// We parse the URL and then convert it right back to a string
// later; this just acts as a check that Fastly isn't sending
// us nonsense.
url, err := url.Parse(target)
if err != nil {
return nil, err
}
request, err := http.NewRequest("GET", url.String(), nil)
if err != nil {
return nil, err
}
if len(c.apiKey) > 0 {
request.Header.Set(APIKeyHeader, c.apiKey)
}
request.Header.Set("User-Agent", UserAgent)
resp, err := checkResp(c.HTTPClient.Do(request))
if err != nil {
return resp, err
}
return resp, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SimpleGet",
"(",
"target",
"string",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"// We parse the URL and then convert it right back to a string",
"// later; this just acts as a check that Fastly isn't sending",
"// us nonsense.",
"url",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"target",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"request",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"url",
".",
"String",
"(",
")",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"c",
".",
"apiKey",
")",
">",
"0",
"{",
"request",
".",
"Header",
".",
"Set",
"(",
"APIKeyHeader",
",",
"c",
".",
"apiKey",
")",
"\n",
"}",
"\n",
"request",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"UserAgent",
")",
"\n\n",
"resp",
",",
"err",
":=",
"checkResp",
"(",
"c",
".",
"HTTPClient",
".",
"Do",
"(",
"request",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"resp",
",",
"err",
"\n",
"}",
"\n",
"return",
"resp",
",",
"nil",
"\n",
"}"
] | // SimpleGet combines the RawRequest and Request methods,
// but doesn't add any parameters or change any encoding in the URL
// passed to it. It's mostly for calling the URLs given to us
// directly from Fastly without mangling them. | [
"SimpleGet",
"combines",
"the",
"RawRequest",
"and",
"Request",
"methods",
"but",
"doesn",
"t",
"add",
"any",
"parameters",
"or",
"change",
"any",
"encoding",
"in",
"the",
"URL",
"passed",
"to",
"it",
".",
"It",
"s",
"mostly",
"for",
"calling",
"the",
"URLs",
"given",
"to",
"us",
"directly",
"from",
"Fastly",
"without",
"mangling",
"them",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/request.go#L74-L98 |
10,255 | sethvargo/go-fastly | fastly/acl_entry.go | ListACLEntries | func (c *Client) ListACLEntries(i *ListACLEntriesInput) ([]*ACLEntry, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.ACL == "" {
return nil, ErrMissingACL
}
path := fmt.Sprintf("/service/%s/acl/%s/entries", i.Service, i.ACL)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var es []*ACLEntry
if err := decodeJSON(&es, resp.Body); err != nil {
return nil, err
}
sort.Stable(entriesById(es))
return es, nil
} | go | func (c *Client) ListACLEntries(i *ListACLEntriesInput) ([]*ACLEntry, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.ACL == "" {
return nil, ErrMissingACL
}
path := fmt.Sprintf("/service/%s/acl/%s/entries", i.Service, i.ACL)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var es []*ACLEntry
if err := decodeJSON(&es, resp.Body); err != nil {
return nil, err
}
sort.Stable(entriesById(es))
return es, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListACLEntries",
"(",
"i",
"*",
"ListACLEntriesInput",
")",
"(",
"[",
"]",
"*",
"ACLEntry",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"ACL",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingACL",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"ACL",
")",
"\n\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"es",
"[",
"]",
"*",
"ACLEntry",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"es",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"sort",
".",
"Stable",
"(",
"entriesById",
"(",
"es",
")",
")",
"\n\n",
"return",
"es",
",",
"nil",
"\n",
"}"
] | // ListACLEntries return a list of entries for an ACL | [
"ListACLEntries",
"return",
"a",
"list",
"of",
"entries",
"for",
"an",
"ACL"
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/acl_entry.go#L40-L64 |
10,256 | sethvargo/go-fastly | fastly/acl_entry.go | GetACLEntry | func (c *Client) GetACLEntry(i *GetACLEntryInput) (*ACLEntry, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.ACL == "" {
return nil, ErrMissingACL
}
if i.ID == "" {
return nil, ErrMissingID
}
path := fmt.Sprintf("/service/%s/acl/%s/entry/%s", i.Service, i.ACL, i.ID)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var e *ACLEntry
if err := decodeJSON(&e, resp.Body); err != nil {
return nil, err
}
return e, nil
} | go | func (c *Client) GetACLEntry(i *GetACLEntryInput) (*ACLEntry, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.ACL == "" {
return nil, ErrMissingACL
}
if i.ID == "" {
return nil, ErrMissingID
}
path := fmt.Sprintf("/service/%s/acl/%s/entry/%s", i.Service, i.ACL, i.ID)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var e *ACLEntry
if err := decodeJSON(&e, resp.Body); err != nil {
return nil, err
}
return e, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetACLEntry",
"(",
"i",
"*",
"GetACLEntryInput",
")",
"(",
"*",
"ACLEntry",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"ACL",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingACL",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"ID",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingID",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"ACL",
",",
"i",
".",
"ID",
")",
"\n\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"e",
"*",
"ACLEntry",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"e",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"e",
",",
"nil",
"\n",
"}"
] | // GetACLEntry returns a single ACL entry based on its ID. | [
"GetACLEntry",
"returns",
"a",
"single",
"ACL",
"entry",
"based",
"on",
"its",
"ID",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/acl_entry.go#L74-L100 |
10,257 | sethvargo/go-fastly | fastly/acl_entry.go | CreateACLEntry | func (c *Client) CreateACLEntry(i *CreateACLEntryInput) (*ACLEntry, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.ACL == "" {
return nil, ErrMissingACL
}
if i.IP == "" {
return nil, ErrMissingIP
}
path := fmt.Sprintf("/service/%s/acl/%s/entry", i.Service, i.ACL)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var e *ACLEntry
if err := decodeJSON(&e, resp.Body); err != nil {
return nil, err
}
return e, nil
} | go | func (c *Client) CreateACLEntry(i *CreateACLEntryInput) (*ACLEntry, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.ACL == "" {
return nil, ErrMissingACL
}
if i.IP == "" {
return nil, ErrMissingIP
}
path := fmt.Sprintf("/service/%s/acl/%s/entry", i.Service, i.ACL)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var e *ACLEntry
if err := decodeJSON(&e, resp.Body); err != nil {
return nil, err
}
return e, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateACLEntry",
"(",
"i",
"*",
"CreateACLEntryInput",
")",
"(",
"*",
"ACLEntry",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"ACL",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingACL",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"IP",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingIP",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"ACL",
")",
"\n\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"e",
"*",
"ACLEntry",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"e",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"e",
",",
"nil",
"\n",
"}"
] | // CreateACLEntry creates and returns a new ACL entry. | [
"CreateACLEntry",
"creates",
"and",
"returns",
"a",
"new",
"ACL",
"entry",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/acl_entry.go#L116-L142 |
10,258 | sethvargo/go-fastly | fastly/acl_entry.go | DeleteACLEntry | func (c *Client) DeleteACLEntry(i *DeleteACLEntryInput) error {
if i.Service == "" {
return ErrMissingService
}
if i.ACL == "" {
return ErrMissingACL
}
if i.ID == "" {
return ErrMissingID
}
path := fmt.Sprintf("/service/%s/acl/%s/entry/%s", i.Service, i.ACL, i.ID)
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) DeleteACLEntry(i *DeleteACLEntryInput) error {
if i.Service == "" {
return ErrMissingService
}
if i.ACL == "" {
return ErrMissingACL
}
if i.ID == "" {
return ErrMissingID
}
path := fmt.Sprintf("/service/%s/acl/%s/entry/%s", i.Service, i.ACL, i.ID)
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",
")",
"DeleteACLEntry",
"(",
"i",
"*",
"DeleteACLEntryInput",
")",
"error",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"ACL",
"==",
"\"",
"\"",
"{",
"return",
"ErrMissingACL",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"ID",
"==",
"\"",
"\"",
"{",
"return",
"ErrMissingID",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"ACL",
",",
"i",
".",
"ID",
")",
"\n\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\n",
"if",
"!",
"r",
".",
"Ok",
"(",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n\n",
"}"
] | // DeleteACLEntry deletes an entry from an ACL based on its ID | [
"DeleteACLEntry",
"deletes",
"an",
"entry",
"from",
"an",
"ACL",
"based",
"on",
"its",
"ID"
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/acl_entry.go#L152-L183 |
10,259 | sethvargo/go-fastly | fastly/acl_entry.go | UpdateACLEntry | func (c *Client) UpdateACLEntry(i *UpdateACLEntryInput) (*ACLEntry, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.ACL == "" {
return nil, ErrMissingACL
}
if i.ID == "" {
return nil, ErrMissingID
}
path := fmt.Sprintf("/service/%s/acl/%s/entry/%s", i.Service, i.ACL, i.ID)
resp, err := c.RequestForm("PATCH", path, i, nil)
if err != nil {
return nil, err
}
var e *ACLEntry
if err := decodeJSON(&e, resp.Body); err != nil {
return nil, err
}
return e, nil
} | go | func (c *Client) UpdateACLEntry(i *UpdateACLEntryInput) (*ACLEntry, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.ACL == "" {
return nil, ErrMissingACL
}
if i.ID == "" {
return nil, ErrMissingID
}
path := fmt.Sprintf("/service/%s/acl/%s/entry/%s", i.Service, i.ACL, i.ID)
resp, err := c.RequestForm("PATCH", path, i, nil)
if err != nil {
return nil, err
}
var e *ACLEntry
if err := decodeJSON(&e, resp.Body); err != nil {
return nil, err
}
return e, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateACLEntry",
"(",
"i",
"*",
"UpdateACLEntryInput",
")",
"(",
"*",
"ACLEntry",
",",
"error",
")",
"{",
"if",
"i",
".",
"Service",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingService",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"ACL",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingACL",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"ID",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingID",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"ACL",
",",
"i",
".",
"ID",
")",
"\n\n",
"resp",
",",
"err",
":=",
"c",
".",
"RequestForm",
"(",
"\"",
"\"",
",",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"e",
"*",
"ACLEntry",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"e",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"e",
",",
"nil",
"\n",
"}"
] | // UpdateACLEntry updates an ACL entry | [
"UpdateACLEntry",
"updates",
"an",
"ACL",
"entry"
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/acl_entry.go#L200-L226 |
10,260 | sethvargo/go-fastly | fastly/director.go | ListDirectors | func (c *Client) ListDirectors(i *ListDirectorsInput) ([]*Director, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/director", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ds []*Director
if err := decodeJSON(&ds, resp.Body); err != nil {
return nil, err
}
sort.Stable(directorsByName(ds))
return ds, nil
} | go | func (c *Client) ListDirectors(i *ListDirectorsInput) ([]*Director, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/director", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ds []*Director
if err := decodeJSON(&ds, resp.Body); err != nil {
return nil, err
}
sort.Stable(directorsByName(ds))
return ds, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListDirectors",
"(",
"i",
"*",
"ListDirectorsInput",
")",
"(",
"[",
"]",
"*",
"Director",
",",
"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",
"[",
"]",
"*",
"Director",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"ds",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"directorsByName",
"(",
"ds",
")",
")",
"\n",
"return",
"ds",
",",
"nil",
"\n",
"}"
] | // ListDirectors returns the list of directors for the configuration version. | [
"ListDirectors",
"returns",
"the",
"list",
"of",
"directors",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/director.go#L63-L84 |
10,261 | sethvargo/go-fastly | fastly/director.go | CreateDirector | func (c *Client) CreateDirector(i *CreateDirectorInput) (*Director, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/director", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var d *Director
if err := decodeJSON(&d, resp.Body); err != nil {
return nil, err
}
return d, nil
} | go | func (c *Client) CreateDirector(i *CreateDirectorInput) (*Director, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/director", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var d *Director
if err := decodeJSON(&d, resp.Body); err != nil {
return nil, err
}
return d, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateDirector",
"(",
"i",
"*",
"CreateDirectorInput",
")",
"(",
"*",
"Director",
",",
"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",
"*",
"Director",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"d",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"d",
",",
"nil",
"\n",
"}"
] | // CreateDirector creates a new Fastly director. | [
"CreateDirector",
"creates",
"a",
"new",
"Fastly",
"director",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/director.go#L103-L123 |
10,262 | sethvargo/go-fastly | fastly/director.go | GetDirector | func (c *Client) GetDirector(i *GetDirectorInput) (*Director, 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/director/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var d *Director
if err := decodeJSON(&d, resp.Body); err != nil {
return nil, err
}
return d, nil
} | go | func (c *Client) GetDirector(i *GetDirectorInput) (*Director, 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/director/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var d *Director
if err := decodeJSON(&d, resp.Body); err != nil {
return nil, err
}
return d, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetDirector",
"(",
"i",
"*",
"GetDirectorInput",
")",
"(",
"*",
"Director",
",",
"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",
"*",
"Director",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"d",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"d",
",",
"nil",
"\n",
"}"
] | // GetDirector gets the director configuration with the given parameters. | [
"GetDirector",
"gets",
"the",
"director",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/director.go#L137-L161 |
10,263 | sethvargo/go-fastly | fastly/director.go | UpdateDirector | func (c *Client) UpdateDirector(i *UpdateDirectorInput) (*Director, 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/director/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var d *Director
if err := decodeJSON(&d, resp.Body); err != nil {
return nil, err
}
return d, nil
} | go | func (c *Client) UpdateDirector(i *UpdateDirectorInput) (*Director, 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/director/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var d *Director
if err := decodeJSON(&d, resp.Body); err != nil {
return nil, err
}
return d, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateDirector",
"(",
"i",
"*",
"UpdateDirectorInput",
")",
"(",
"*",
"Director",
",",
"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",
"*",
"Director",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"d",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"d",
",",
"nil",
"\n",
"}"
] | // UpdateDirector updates a specific director. | [
"UpdateDirector",
"updates",
"a",
"specific",
"director",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/director.go#L183-L207 |
10,264 | sethvargo/go-fastly | fastly/director.go | DeleteDirector | func (c *Client) DeleteDirector(i *DeleteDirectorInput) error {
if i.Service == "" {
return ErrMissingService
}
if i.Version == 0 {
return ErrMissingVersion
}
if i.Name == "" {
return ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/director/%s", i.Service, i.Version, 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) DeleteDirector(i *DeleteDirectorInput) error {
if i.Service == "" {
return ErrMissingService
}
if i.Version == 0 {
return ErrMissingVersion
}
if i.Name == "" {
return ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/director/%s", i.Service, i.Version, 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",
")",
"DeleteDirector",
"(",
"i",
"*",
"DeleteDirectorInput",
")",
"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",
"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",
"}"
] | // DeleteDirector deletes the given director version. | [
"DeleteDirector",
"deletes",
"the",
"given",
"director",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/director.go#L221-L248 |
10,265 | sethvargo/go-fastly | fastly/ip.go | IPs | func (c *Client) IPs() (IPAddrs, error) {
resp, err := c.Get("/public-ip-list", nil)
if err != nil {
return nil, err
}
var m map[string][]string
if err := decodeJSON(&m, resp.Body); err != nil {
return nil, err
}
return IPAddrs(m["addresses"]), nil
} | go | func (c *Client) IPs() (IPAddrs, error) {
resp, err := c.Get("/public-ip-list", nil)
if err != nil {
return nil, err
}
var m map[string][]string
if err := decodeJSON(&m, resp.Body); err != nil {
return nil, err
}
return IPAddrs(m["addresses"]), nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"IPs",
"(",
")",
"(",
"IPAddrs",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"\"",
"\"",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"m",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"m",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"IPAddrs",
"(",
"m",
"[",
"\"",
"\"",
"]",
")",
",",
"nil",
"\n",
"}"
] | // IPs returns the list of public IP addresses for Fastly's network. | [
"IPs",
"returns",
"the",
"list",
"of",
"public",
"IP",
"addresses",
"for",
"Fastly",
"s",
"network",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/ip.go#L7-L18 |
10,266 | sethvargo/go-fastly | fastly/decode_hooks.go | mapToHTTPHeaderHookFunc | func mapToHTTPHeaderHookFunc() mapstructure.DecodeHookFunc {
return func(
f reflect.Type,
t reflect.Type,
data interface{}) (interface{}, error) {
if f.Kind() != reflect.Map {
return data, nil
}
if t != reflect.TypeOf(new(http.Header)) {
return data, nil
}
typed, ok := data.(map[string]interface{})
if !ok {
return nil, fmt.Errorf("cannot convert %T to http.Header", data)
}
n := map[string][]string{}
for k, v := range typed {
switch v.(type) {
case string:
n[k] = []string{v.(string)}
case []string:
n[k] = v.([]string)
case int, int8, int16, int32, int64:
n[k] = []string{fmt.Sprintf("%d", v.(int))}
case float32, float64:
n[k] = []string{fmt.Sprintf("%f", v.(float64))}
default:
return nil, fmt.Errorf("cannot convert %T to http.Header", v)
}
}
return n, nil
}
} | go | func mapToHTTPHeaderHookFunc() mapstructure.DecodeHookFunc {
return func(
f reflect.Type,
t reflect.Type,
data interface{}) (interface{}, error) {
if f.Kind() != reflect.Map {
return data, nil
}
if t != reflect.TypeOf(new(http.Header)) {
return data, nil
}
typed, ok := data.(map[string]interface{})
if !ok {
return nil, fmt.Errorf("cannot convert %T to http.Header", data)
}
n := map[string][]string{}
for k, v := range typed {
switch v.(type) {
case string:
n[k] = []string{v.(string)}
case []string:
n[k] = v.([]string)
case int, int8, int16, int32, int64:
n[k] = []string{fmt.Sprintf("%d", v.(int))}
case float32, float64:
n[k] = []string{fmt.Sprintf("%f", v.(float64))}
default:
return nil, fmt.Errorf("cannot convert %T to http.Header", v)
}
}
return n, nil
}
} | [
"func",
"mapToHTTPHeaderHookFunc",
"(",
")",
"mapstructure",
".",
"DecodeHookFunc",
"{",
"return",
"func",
"(",
"f",
"reflect",
".",
"Type",
",",
"t",
"reflect",
".",
"Type",
",",
"data",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"f",
".",
"Kind",
"(",
")",
"!=",
"reflect",
".",
"Map",
"{",
"return",
"data",
",",
"nil",
"\n",
"}",
"\n",
"if",
"t",
"!=",
"reflect",
".",
"TypeOf",
"(",
"new",
"(",
"http",
".",
"Header",
")",
")",
"{",
"return",
"data",
",",
"nil",
"\n",
"}",
"\n\n",
"typed",
",",
"ok",
":=",
"data",
".",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"data",
")",
"\n",
"}",
"\n\n",
"n",
":=",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"typed",
"{",
"switch",
"v",
".",
"(",
"type",
")",
"{",
"case",
"string",
":",
"n",
"[",
"k",
"]",
"=",
"[",
"]",
"string",
"{",
"v",
".",
"(",
"string",
")",
"}",
"\n",
"case",
"[",
"]",
"string",
":",
"n",
"[",
"k",
"]",
"=",
"v",
".",
"(",
"[",
"]",
"string",
")",
"\n",
"case",
"int",
",",
"int8",
",",
"int16",
",",
"int32",
",",
"int64",
":",
"n",
"[",
"k",
"]",
"=",
"[",
"]",
"string",
"{",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"v",
".",
"(",
"int",
")",
")",
"}",
"\n",
"case",
"float32",
",",
"float64",
":",
"n",
"[",
"k",
"]",
"=",
"[",
"]",
"string",
"{",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"v",
".",
"(",
"float64",
")",
")",
"}",
"\n",
"default",
":",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"v",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"n",
",",
"nil",
"\n",
"}",
"\n",
"}"
] | // mapToHTTPHeaderHookFunc returns a function that converts maps into an
// http.Header value. | [
"mapToHTTPHeaderHookFunc",
"returns",
"a",
"function",
"that",
"converts",
"maps",
"into",
"an",
"http",
".",
"Header",
"value",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/decode_hooks.go#L14-L49 |
10,267 | sethvargo/go-fastly | fastly/decode_hooks.go | stringToTimeHookFunc | func stringToTimeHookFunc() mapstructure.DecodeHookFunc {
return func(
f reflect.Type,
t reflect.Type,
data interface{}) (interface{}, error) {
if f.Kind() != reflect.String {
return data, nil
}
if t != reflect.TypeOf(time.Now()) {
return data, nil
}
// Convert it by parsing
return time.Parse(time.RFC3339, data.(string))
}
} | go | func stringToTimeHookFunc() mapstructure.DecodeHookFunc {
return func(
f reflect.Type,
t reflect.Type,
data interface{}) (interface{}, error) {
if f.Kind() != reflect.String {
return data, nil
}
if t != reflect.TypeOf(time.Now()) {
return data, nil
}
// Convert it by parsing
return time.Parse(time.RFC3339, data.(string))
}
} | [
"func",
"stringToTimeHookFunc",
"(",
")",
"mapstructure",
".",
"DecodeHookFunc",
"{",
"return",
"func",
"(",
"f",
"reflect",
".",
"Type",
",",
"t",
"reflect",
".",
"Type",
",",
"data",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"f",
".",
"Kind",
"(",
")",
"!=",
"reflect",
".",
"String",
"{",
"return",
"data",
",",
"nil",
"\n",
"}",
"\n",
"if",
"t",
"!=",
"reflect",
".",
"TypeOf",
"(",
"time",
".",
"Now",
"(",
")",
")",
"{",
"return",
"data",
",",
"nil",
"\n",
"}",
"\n\n",
"// Convert it by parsing",
"return",
"time",
".",
"Parse",
"(",
"time",
".",
"RFC3339",
",",
"data",
".",
"(",
"string",
")",
")",
"\n",
"}",
"\n",
"}"
] | // stringToTimeHookFunc returns a function that converts strings to a time.Time
// value. | [
"stringToTimeHookFunc",
"returns",
"a",
"function",
"that",
"converts",
"strings",
"to",
"a",
"time",
".",
"Time",
"value",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/decode_hooks.go#L53-L68 |
10,268 | sethvargo/go-fastly | fastly/header.go | ListHeaders | func (c *Client) ListHeaders(i *ListHeadersInput) ([]*Header, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/header", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var bs []*Header
if err := decodeJSON(&bs, resp.Body); err != nil {
return nil, err
}
sort.Stable(headersByName(bs))
return bs, nil
} | go | func (c *Client) ListHeaders(i *ListHeadersInput) ([]*Header, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/header", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var bs []*Header
if err := decodeJSON(&bs, resp.Body); err != nil {
return nil, err
}
sort.Stable(headersByName(bs))
return bs, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListHeaders",
"(",
"i",
"*",
"ListHeadersInput",
")",
"(",
"[",
"]",
"*",
"Header",
",",
"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",
"[",
"]",
"*",
"Header",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"bs",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"headersByName",
"(",
"bs",
")",
")",
"\n",
"return",
"bs",
",",
"nil",
"\n",
"}"
] | // ListHeaders returns the list of headers for the configuration version. | [
"ListHeaders",
"returns",
"the",
"list",
"of",
"headers",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/header.go#L90-L111 |
10,269 | sethvargo/go-fastly | fastly/header.go | CreateHeader | func (c *Client) CreateHeader(i *CreateHeaderInput) (*Header, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/header", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var b *Header
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) CreateHeader(i *CreateHeaderInput) (*Header, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/header", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var b *Header
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateHeader",
"(",
"i",
"*",
"CreateHeaderInput",
")",
"(",
"*",
"Header",
",",
"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",
"*",
"Header",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // CreateHeader creates a new Fastly header. | [
"CreateHeader",
"creates",
"a",
"new",
"Fastly",
"header",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/header.go#L135-L155 |
10,270 | sethvargo/go-fastly | fastly/header.go | GetHeader | func (c *Client) GetHeader(i *GetHeaderInput) (*Header, 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/header/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *Header
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) GetHeader(i *GetHeaderInput) (*Header, 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/header/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *Header
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetHeader",
"(",
"i",
"*",
"GetHeaderInput",
")",
"(",
"*",
"Header",
",",
"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",
"*",
"Header",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // GetHeader gets the header configuration with the given parameters. | [
"GetHeader",
"gets",
"the",
"header",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/header.go#L169-L193 |
10,271 | sethvargo/go-fastly | fastly/header.go | UpdateHeader | func (c *Client) UpdateHeader(i *UpdateHeaderInput) (*Header, 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/header/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var b *Header
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) UpdateHeader(i *UpdateHeaderInput) (*Header, 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/header/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var b *Header
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateHeader",
"(",
"i",
"*",
"UpdateHeaderInput",
")",
"(",
"*",
"Header",
",",
"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",
"*",
"Header",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // UpdateHeader updates a specific header. | [
"UpdateHeader",
"updates",
"a",
"specific",
"header",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/header.go#L220-L244 |
10,272 | sethvargo/go-fastly | fastly/bigquery.go | GetBigQuery | func (c *Client) GetBigQuery(i *GetBigQueryInput) ([]*BigQuery, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var bs []*BigQuery
if err := decodeJSON(&bs, resp.Body); err != nil {
return nil, err
}
return bs, nil
} | go | func (c *Client) GetBigQuery(i *GetBigQueryInput) ([]*BigQuery, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var bs []*BigQuery
if err := decodeJSON(&bs, resp.Body); err != nil {
return nil, err
}
return bs, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetBigQuery",
"(",
"i",
"*",
"GetBigQueryInput",
")",
"(",
"[",
"]",
"*",
"BigQuery",
",",
"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",
"[",
"]",
"*",
"BigQuery",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"bs",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"bs",
",",
"nil",
"\n",
"}"
] | // GetBigQuery lists all BigQuerys associated with a service version. | [
"GetBigQuery",
"lists",
"all",
"BigQuerys",
"associated",
"with",
"a",
"service",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/bigquery.go#L34-L54 |
10,273 | sethvargo/go-fastly | fastly/bigquery.go | CreateBigQuery | func (c *Client) CreateBigQuery(i *CreateBigQueryInput) (*BigQuery, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
if i.ProjectID == "" {
return nil, ErrMissingProjectID
}
if i.Dataset == "" {
return nil, ErrMissingDataset
}
if i.Table == "" {
return nil, ErrMissingTable
}
if i.User == "" {
return nil, ErrMissingUser
}
if i.SecretKey == "" {
return nil, ErrMissingSecretKey
}
params := make(map[string]string)
params["name"] = i.Name
params["project_id"] = i.ProjectID
params["dataset"] = i.Dataset
params["table"] = i.Table
params["user"] = i.User
params["secret_key"] = i.SecretKey
if i.Format != "" {
params["format"] = i.Format
}
if i.ResponseCondition != "" {
params["response_condition"] = i.ResponseCondition
}
if i.Template != "" {
params["template_suffix"] = i.Template
}
if i.Placement != "" {
params["placement"] = i.Placement
}
path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery", i.Service, i.Version)
resp, err := c.PostForm(path, i, &RequestOptions{
Params: params,
})
if err != nil {
return nil, err
}
var b *BigQuery
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) CreateBigQuery(i *CreateBigQueryInput) (*BigQuery, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
if i.Name == "" {
return nil, ErrMissingName
}
if i.ProjectID == "" {
return nil, ErrMissingProjectID
}
if i.Dataset == "" {
return nil, ErrMissingDataset
}
if i.Table == "" {
return nil, ErrMissingTable
}
if i.User == "" {
return nil, ErrMissingUser
}
if i.SecretKey == "" {
return nil, ErrMissingSecretKey
}
params := make(map[string]string)
params["name"] = i.Name
params["project_id"] = i.ProjectID
params["dataset"] = i.Dataset
params["table"] = i.Table
params["user"] = i.User
params["secret_key"] = i.SecretKey
if i.Format != "" {
params["format"] = i.Format
}
if i.ResponseCondition != "" {
params["response_condition"] = i.ResponseCondition
}
if i.Template != "" {
params["template_suffix"] = i.Template
}
if i.Placement != "" {
params["placement"] = i.Placement
}
path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery", i.Service, i.Version)
resp, err := c.PostForm(path, i, &RequestOptions{
Params: params,
})
if err != nil {
return nil, err
}
var b *BigQuery
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateBigQuery",
"(",
"i",
"*",
"CreateBigQueryInput",
")",
"(",
"*",
"BigQuery",
",",
"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",
".",
"ProjectID",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingProjectID",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Dataset",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingDataset",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Table",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingTable",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"User",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingUser",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"SecretKey",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingSecretKey",
"\n",
"}",
"\n\n",
"params",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"Name",
"\n",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"ProjectID",
"\n",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"Dataset",
"\n",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"Table",
"\n",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"User",
"\n",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"SecretKey",
"\n",
"if",
"i",
".",
"Format",
"!=",
"\"",
"\"",
"{",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"Format",
"\n",
"}",
"\n",
"if",
"i",
".",
"ResponseCondition",
"!=",
"\"",
"\"",
"{",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"ResponseCondition",
"\n",
"}",
"\n",
"if",
"i",
".",
"Template",
"!=",
"\"",
"\"",
"{",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"Template",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Placement",
"!=",
"\"",
"\"",
"{",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"Placement",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"path",
",",
"i",
",",
"&",
"RequestOptions",
"{",
"Params",
":",
"params",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"b",
"*",
"BigQuery",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // CreateBigQuery creates a new Fastly BigQuery logging endpoint. | [
"CreateBigQuery",
"creates",
"a",
"new",
"Fastly",
"BigQuery",
"logging",
"endpoint",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/bigquery.go#L100-L167 |
10,274 | sethvargo/go-fastly | fastly/bigquery.go | UpdateBigQuery | func (c *Client) UpdateBigQuery(i *UpdateBigQueryInput) (*BigQuery, 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
}
params := make(map[string]string)
params["name"] = i.NewName
if i.ProjectID != "" {
params["project_id"] = i.ProjectID
}
if i.Dataset != "" {
params["dataset"] = i.Dataset
}
if i.Table != "" {
params["table"] = i.Table
}
if i.Template != "" {
params["template_suffix"] = i.Template
}
if i.User != "" {
params["user"] = i.User
}
if i.SecretKey != "" {
params["secret_key"] = i.SecretKey
}
if i.Format != "" {
params["format"] = i.Format
}
if i.ResponseCondition != "" {
params["response_condition"] = i.ResponseCondition
}
if i.Placement != "" {
params["placement"] = i.Placement
}
path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, &RequestOptions{
Params: params,
})
if err != nil {
return nil, err
}
var b *BigQuery
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) UpdateBigQuery(i *UpdateBigQueryInput) (*BigQuery, 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
}
params := make(map[string]string)
params["name"] = i.NewName
if i.ProjectID != "" {
params["project_id"] = i.ProjectID
}
if i.Dataset != "" {
params["dataset"] = i.Dataset
}
if i.Table != "" {
params["table"] = i.Table
}
if i.Template != "" {
params["template_suffix"] = i.Template
}
if i.User != "" {
params["user"] = i.User
}
if i.SecretKey != "" {
params["secret_key"] = i.SecretKey
}
if i.Format != "" {
params["format"] = i.Format
}
if i.ResponseCondition != "" {
params["response_condition"] = i.ResponseCondition
}
if i.Placement != "" {
params["placement"] = i.Placement
}
path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, &RequestOptions{
Params: params,
})
if err != nil {
return nil, err
}
var b *BigQuery
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateBigQuery",
"(",
"i",
"*",
"UpdateBigQueryInput",
")",
"(",
"*",
"BigQuery",
",",
"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",
"params",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"NewName",
"\n",
"if",
"i",
".",
"ProjectID",
"!=",
"\"",
"\"",
"{",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"ProjectID",
"\n",
"}",
"\n",
"if",
"i",
".",
"Dataset",
"!=",
"\"",
"\"",
"{",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"Dataset",
"\n",
"}",
"\n",
"if",
"i",
".",
"Table",
"!=",
"\"",
"\"",
"{",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"Table",
"\n",
"}",
"\n",
"if",
"i",
".",
"Template",
"!=",
"\"",
"\"",
"{",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"Template",
"\n",
"}",
"\n",
"if",
"i",
".",
"User",
"!=",
"\"",
"\"",
"{",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"User",
"\n",
"}",
"\n",
"if",
"i",
".",
"SecretKey",
"!=",
"\"",
"\"",
"{",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"SecretKey",
"\n",
"}",
"\n",
"if",
"i",
".",
"Format",
"!=",
"\"",
"\"",
"{",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"Format",
"\n",
"}",
"\n",
"if",
"i",
".",
"ResponseCondition",
"!=",
"\"",
"\"",
"{",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"ResponseCondition",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Placement",
"!=",
"\"",
"\"",
"{",
"params",
"[",
"\"",
"\"",
"]",
"=",
"i",
".",
"Placement",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Service",
",",
"i",
".",
"Version",
",",
"i",
".",
"Name",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"&",
"RequestOptions",
"{",
"Params",
":",
"params",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"b",
"*",
"BigQuery",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // UpdateBigQuery updates a BigQuery logging endpoint. | [
"UpdateBigQuery",
"updates",
"a",
"BigQuery",
"logging",
"endpoint",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/bigquery.go#L221-L282 |
10,275 | sethvargo/go-fastly | fastly/request_setting.go | ListRequestSettings | func (c *Client) ListRequestSettings(i *ListRequestSettingsInput) ([]*RequestSetting, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/request_settings", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var bs []*RequestSetting
if err := decodeJSON(&bs, resp.Body); err != nil {
return nil, err
}
sort.Stable(requestSettingsByName(bs))
return bs, nil
} | go | func (c *Client) ListRequestSettings(i *ListRequestSettingsInput) ([]*RequestSetting, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/request_settings", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var bs []*RequestSetting
if err := decodeJSON(&bs, resp.Body); err != nil {
return nil, err
}
sort.Stable(requestSettingsByName(bs))
return bs, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListRequestSettings",
"(",
"i",
"*",
"ListRequestSettingsInput",
")",
"(",
"[",
"]",
"*",
"RequestSetting",
",",
"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",
"[",
"]",
"*",
"RequestSetting",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"bs",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"requestSettingsByName",
"(",
"bs",
")",
")",
"\n",
"return",
"bs",
",",
"nil",
"\n",
"}"
] | // ListRequestSettings returns the list of request settings for the
// configuration version. | [
"ListRequestSettings",
"returns",
"the",
"list",
"of",
"request",
"settings",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/request_setting.go#L81-L102 |
10,276 | sethvargo/go-fastly | fastly/request_setting.go | CreateRequestSetting | func (c *Client) CreateRequestSetting(i *CreateRequestSettingInput) (*RequestSetting, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/request_settings", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var b *RequestSetting
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) CreateRequestSetting(i *CreateRequestSettingInput) (*RequestSetting, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/request_settings", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var b *RequestSetting
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateRequestSetting",
"(",
"i",
"*",
"CreateRequestSettingInput",
")",
"(",
"*",
"RequestSetting",
",",
"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",
"*",
"RequestSetting",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // CreateRequestSetting creates a new Fastly request settings. | [
"CreateRequestSetting",
"creates",
"a",
"new",
"Fastly",
"request",
"settings",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/request_setting.go#L127-L147 |
10,277 | sethvargo/go-fastly | fastly/request_setting.go | GetRequestSetting | func (c *Client) GetRequestSetting(i *GetRequestSettingInput) (*RequestSetting, 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/request_settings/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *RequestSetting
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) GetRequestSetting(i *GetRequestSettingInput) (*RequestSetting, 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/request_settings/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *RequestSetting
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetRequestSetting",
"(",
"i",
"*",
"GetRequestSettingInput",
")",
"(",
"*",
"RequestSetting",
",",
"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",
"*",
"RequestSetting",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // GetRequestSetting gets the request settings configuration with the given
// parameters. | [
"GetRequestSetting",
"gets",
"the",
"request",
"settings",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/request_setting.go#L162-L186 |
10,278 | sethvargo/go-fastly | fastly/request_setting.go | UpdateRequestSetting | func (c *Client) UpdateRequestSetting(i *UpdateRequestSettingInput) (*RequestSetting, 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/request_settings/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var b *RequestSetting
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) UpdateRequestSetting(i *UpdateRequestSettingInput) (*RequestSetting, 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/request_settings/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var b *RequestSetting
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateRequestSetting",
"(",
"i",
"*",
"UpdateRequestSettingInput",
")",
"(",
"*",
"RequestSetting",
",",
"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",
"*",
"RequestSetting",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // UpdateRequestSetting updates a specific request settings. | [
"UpdateRequestSetting",
"updates",
"a",
"specific",
"request",
"settings",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/request_setting.go#L214-L238 |
10,279 | sethvargo/go-fastly | fastly/dictionary.go | ListDictionaries | func (c *Client) ListDictionaries(i *ListDictionariesInput) ([]*Dictionary, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/dictionary", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var bs []*Dictionary
if err := decodeJSON(&bs, resp.Body); err != nil {
return nil, err
}
sort.Stable(dictionariesByName(bs))
return bs, nil
} | go | func (c *Client) ListDictionaries(i *ListDictionariesInput) ([]*Dictionary, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/dictionary", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var bs []*Dictionary
if err := decodeJSON(&bs, resp.Body); err != nil {
return nil, err
}
sort.Stable(dictionariesByName(bs))
return bs, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListDictionaries",
"(",
"i",
"*",
"ListDictionariesInput",
")",
"(",
"[",
"]",
"*",
"Dictionary",
",",
"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",
"[",
"]",
"*",
"Dictionary",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"bs",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"dictionariesByName",
"(",
"bs",
")",
")",
"\n",
"return",
"bs",
",",
"nil",
"\n",
"}"
] | // ListDictionaries returns the list of dictionaries for the configuration version. | [
"ListDictionaries",
"returns",
"the",
"list",
"of",
"dictionaries",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/dictionary.go#L55-L76 |
10,280 | sethvargo/go-fastly | fastly/dictionary.go | CreateDictionary | func (c *Client) CreateDictionary(i *CreateDictionaryInput) (*Dictionary, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/dictionary", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var b *Dictionary
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) CreateDictionary(i *CreateDictionaryInput) (*Dictionary, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/dictionary", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var b *Dictionary
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateDictionary",
"(",
"i",
"*",
"CreateDictionaryInput",
")",
"(",
"*",
"Dictionary",
",",
"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",
"*",
"Dictionary",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // CreateDictionary creates a new Fastly dictionary. | [
"CreateDictionary",
"creates",
"a",
"new",
"Fastly",
"dictionary",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/dictionary.go#L90-L110 |
10,281 | sethvargo/go-fastly | fastly/dictionary.go | GetDictionary | func (c *Client) GetDictionary(i *GetDictionaryInput) (*Dictionary, 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/dictionary/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *Dictionary
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) GetDictionary(i *GetDictionaryInput) (*Dictionary, 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/dictionary/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var b *Dictionary
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetDictionary",
"(",
"i",
"*",
"GetDictionaryInput",
")",
"(",
"*",
"Dictionary",
",",
"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",
"*",
"Dictionary",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // GetDictionary gets the dictionary configuration with the given parameters. | [
"GetDictionary",
"gets",
"the",
"dictionary",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/dictionary.go#L124-L148 |
10,282 | sethvargo/go-fastly | fastly/dictionary.go | UpdateDictionary | func (c *Client) UpdateDictionary(i *UpdateDictionaryInput) (*Dictionary, 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/dictionary/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var b *Dictionary
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | go | func (c *Client) UpdateDictionary(i *UpdateDictionaryInput) (*Dictionary, 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/dictionary/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var b *Dictionary
if err := decodeJSON(&b, resp.Body); err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateDictionary",
"(",
"i",
"*",
"UpdateDictionaryInput",
")",
"(",
"*",
"Dictionary",
",",
"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",
"*",
"Dictionary",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"b",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | // UpdateDictionary updates a specific dictionary. | [
"UpdateDictionary",
"updates",
"a",
"specific",
"dictionary",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/dictionary.go#L165-L189 |
10,283 | sethvargo/go-fastly | fastly/dictionary.go | DeleteDictionary | func (c *Client) DeleteDictionary(i *DeleteDictionaryInput) error {
if i.Service == "" {
return ErrMissingService
}
if i.Version == 0 {
return ErrMissingVersion
}
if i.Name == "" {
return ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/dictionary/%s", i.Service, i.Version, i.Name)
resp, err := c.Delete(path, nil)
if err != nil {
return err
}
defer resp.Body.Close()
// Unlike other endpoints, the dictionary endpoint does not return a status
// response - it just returns a 200 OK.
return nil
} | go | func (c *Client) DeleteDictionary(i *DeleteDictionaryInput) error {
if i.Service == "" {
return ErrMissingService
}
if i.Version == 0 {
return ErrMissingVersion
}
if i.Name == "" {
return ErrMissingName
}
path := fmt.Sprintf("/service/%s/version/%d/dictionary/%s", i.Service, i.Version, i.Name)
resp, err := c.Delete(path, nil)
if err != nil {
return err
}
defer resp.Body.Close()
// Unlike other endpoints, the dictionary endpoint does not return a status
// response - it just returns a 200 OK.
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteDictionary",
"(",
"i",
"*",
"DeleteDictionaryInput",
")",
"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",
"resp",
",",
"err",
":=",
"c",
".",
"Delete",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"// Unlike other endpoints, the dictionary endpoint does not return a status",
"// response - it just returns a 200 OK.",
"return",
"nil",
"\n",
"}"
] | // DeleteDictionary deletes the given dictionary version. | [
"DeleteDictionary",
"deletes",
"the",
"given",
"dictionary",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/dictionary.go#L203-L226 |
10,284 | sethvargo/go-fastly | fastly/service.go | ListServices | func (c *Client) ListServices(i *ListServicesInput) ([]*Service, error) {
resp, err := c.Get("/service", nil)
if err != nil {
return nil, err
}
var s []*Service
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
sort.Stable(servicesByName(s))
return s, nil
} | go | func (c *Client) ListServices(i *ListServicesInput) ([]*Service, error) {
resp, err := c.Get("/service", nil)
if err != nil {
return nil, err
}
var s []*Service
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
sort.Stable(servicesByName(s))
return s, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListServices",
"(",
"i",
"*",
"ListServicesInput",
")",
"(",
"[",
"]",
"*",
"Service",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"\"",
"\"",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"s",
"[",
"]",
"*",
"Service",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"s",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"servicesByName",
"(",
"s",
")",
")",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] | // ListServices returns the full list of services for the current account. | [
"ListServices",
"returns",
"the",
"full",
"list",
"of",
"services",
"for",
"the",
"current",
"account",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/service.go#L58-L70 |
10,285 | sethvargo/go-fastly | fastly/service.go | CreateService | func (c *Client) CreateService(i *CreateServiceInput) (*Service, error) {
resp, err := c.PostForm("/service", i, nil)
if err != nil {
return nil, err
}
var s *Service
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | go | func (c *Client) CreateService(i *CreateServiceInput) (*Service, error) {
resp, err := c.PostForm("/service", i, nil)
if err != nil {
return nil, err
}
var s *Service
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateService",
"(",
"i",
"*",
"CreateServiceInput",
")",
"(",
"*",
"Service",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"PostForm",
"(",
"\"",
"\"",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"s",
"*",
"Service",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"s",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] | // CreateService creates a new service with the given information. | [
"CreateService",
"creates",
"a",
"new",
"service",
"with",
"the",
"given",
"information",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/service.go#L79-L90 |
10,286 | sethvargo/go-fastly | fastly/service.go | UpdateService | func (c *Client) UpdateService(i *UpdateServiceInput) (*Service, error) {
if i.ID == "" {
return nil, ErrMissingID
}
path := fmt.Sprintf("/service/%s", i.ID)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var s *Service
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | go | func (c *Client) UpdateService(i *UpdateServiceInput) (*Service, error) {
if i.ID == "" {
return nil, ErrMissingID
}
path := fmt.Sprintf("/service/%s", i.ID)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var s *Service
if err := decodeJSON(&s, resp.Body); err != nil {
return nil, err
}
return s, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateService",
"(",
"i",
"*",
"UpdateServiceInput",
")",
"(",
"*",
"Service",
",",
"error",
")",
"{",
"if",
"i",
".",
"ID",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingID",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"ID",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"PutForm",
"(",
"path",
",",
"i",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"s",
"*",
"Service",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"s",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] | // UpdateService updates the service with the given input. | [
"UpdateService",
"updates",
"the",
"service",
"with",
"the",
"given",
"input",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/service.go#L149-L165 |
10,287 | sethvargo/go-fastly | fastly/service.go | DeleteService | func (c *Client) DeleteService(i *DeleteServiceInput) error {
if i.ID == "" {
return ErrMissingID
}
path := fmt.Sprintf("/service/%s", i.ID)
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) DeleteService(i *DeleteServiceInput) error {
if i.ID == "" {
return ErrMissingID
}
path := fmt.Sprintf("/service/%s", i.ID)
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",
")",
"DeleteService",
"(",
"i",
"*",
"DeleteServiceInput",
")",
"error",
"{",
"if",
"i",
".",
"ID",
"==",
"\"",
"\"",
"{",
"return",
"ErrMissingID",
"\n",
"}",
"\n\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"ID",
")",
"\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",
"}"
] | // DeleteService updates the service with the given input. | [
"DeleteService",
"updates",
"the",
"service",
"with",
"the",
"given",
"input",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/service.go#L173-L192 |
10,288 | sethvargo/go-fastly | fastly/service.go | ListServiceDomains | func (c *Client) ListServiceDomains(i *ListServiceDomainInput) (ServiceDomainsList, error) {
if i.ID == "" {
return nil, ErrMissingID
}
path := fmt.Sprintf("/service/%s/domain", i.ID)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ds ServiceDomainsList
if err := decodeJSON(&ds, resp.Body); err != nil {
return nil, err
}
return ds, nil
} | go | func (c *Client) ListServiceDomains(i *ListServiceDomainInput) (ServiceDomainsList, error) {
if i.ID == "" {
return nil, ErrMissingID
}
path := fmt.Sprintf("/service/%s/domain", i.ID)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ds ServiceDomainsList
if err := decodeJSON(&ds, resp.Body); err != nil {
return nil, err
}
return ds, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListServiceDomains",
"(",
"i",
"*",
"ListServiceDomainInput",
")",
"(",
"ServiceDomainsList",
",",
"error",
")",
"{",
"if",
"i",
".",
"ID",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"ErrMissingID",
"\n",
"}",
"\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"ID",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"ds",
"ServiceDomainsList",
"\n\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"ds",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"ds",
",",
"nil",
"\n",
"}"
] | // ListServiceDomains lists all domains associated with a given service | [
"ListServiceDomains",
"lists",
"all",
"domains",
"associated",
"with",
"a",
"given",
"service"
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/service.go#L228-L245 |
10,289 | sethvargo/go-fastly | fastly/vcl.go | ListVCLs | func (c *Client) ListVCLs(i *ListVCLsInput) ([]*VCL, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/vcl", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var vcls []*VCL
if err := decodeJSON(&vcls, resp.Body); err != nil {
return nil, err
}
sort.Stable(vclsByName(vcls))
return vcls, nil
} | go | func (c *Client) ListVCLs(i *ListVCLsInput) ([]*VCL, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/vcl", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var vcls []*VCL
if err := decodeJSON(&vcls, resp.Body); err != nil {
return nil, err
}
sort.Stable(vclsByName(vcls))
return vcls, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListVCLs",
"(",
"i",
"*",
"ListVCLsInput",
")",
"(",
"[",
"]",
"*",
"VCL",
",",
"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",
"vcls",
"[",
"]",
"*",
"VCL",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"vcls",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"vclsByName",
"(",
"vcls",
")",
")",
"\n",
"return",
"vcls",
",",
"nil",
"\n",
"}"
] | // ListVCLs returns the list of VCLs for the configuration version. | [
"ListVCLs",
"returns",
"the",
"list",
"of",
"VCLs",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/vcl.go#L38-L59 |
10,290 | sethvargo/go-fastly | fastly/vcl.go | GetVCL | func (c *Client) GetVCL(i *GetVCLInput) (*VCL, 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/vcl/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var vcl *VCL
if err := decodeJSON(&vcl, resp.Body); err != nil {
return nil, err
}
return vcl, nil
} | go | func (c *Client) GetVCL(i *GetVCLInput) (*VCL, 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/vcl/%s", i.Service, i.Version, i.Name)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var vcl *VCL
if err := decodeJSON(&vcl, resp.Body); err != nil {
return nil, err
}
return vcl, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetVCL",
"(",
"i",
"*",
"GetVCLInput",
")",
"(",
"*",
"VCL",
",",
"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",
"vcl",
"*",
"VCL",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"vcl",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"vcl",
",",
"nil",
"\n",
"}"
] | // GetVCL gets the VCL configuration with the given parameters. | [
"GetVCL",
"gets",
"the",
"VCL",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/vcl.go#L73-L97 |
10,291 | sethvargo/go-fastly | fastly/vcl.go | GetGeneratedVCL | func (c *Client) GetGeneratedVCL(i *GetGeneratedVCLInput) (*VCL, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/generated_vcl", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var vcl *VCL
if err := decodeJSON(&vcl, resp.Body); err != nil {
return nil, err
}
return vcl, nil
} | go | func (c *Client) GetGeneratedVCL(i *GetGeneratedVCLInput) (*VCL, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/generated_vcl", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var vcl *VCL
if err := decodeJSON(&vcl, resp.Body); err != nil {
return nil, err
}
return vcl, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetGeneratedVCL",
"(",
"i",
"*",
"GetGeneratedVCLInput",
")",
"(",
"*",
"VCL",
",",
"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",
"vcl",
"*",
"VCL",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"vcl",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"vcl",
",",
"nil",
"\n",
"}"
] | // GetGeneratedVCL gets the VCL configuration with the given parameters. | [
"GetGeneratedVCL",
"gets",
"the",
"VCL",
"configuration",
"with",
"the",
"given",
"parameters",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/vcl.go#L108-L128 |
10,292 | sethvargo/go-fastly | fastly/vcl.go | CreateVCL | func (c *Client) CreateVCL(i *CreateVCLInput) (*VCL, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/vcl", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var vcl *VCL
if err := decodeJSON(&vcl, resp.Body); err != nil {
return nil, err
}
return vcl, nil
} | go | func (c *Client) CreateVCL(i *CreateVCLInput) (*VCL, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/vcl", i.Service, i.Version)
resp, err := c.PostForm(path, i, nil)
if err != nil {
return nil, err
}
var vcl *VCL
if err := decodeJSON(&vcl, resp.Body); err != nil {
return nil, err
}
return vcl, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateVCL",
"(",
"i",
"*",
"CreateVCLInput",
")",
"(",
"*",
"VCL",
",",
"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",
"vcl",
"*",
"VCL",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"vcl",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"vcl",
",",
"nil",
"\n",
"}"
] | // CreateVCL creates a new Fastly VCL. | [
"CreateVCL",
"creates",
"a",
"new",
"Fastly",
"VCL",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/vcl.go#L143-L163 |
10,293 | sethvargo/go-fastly | fastly/vcl.go | UpdateVCL | func (c *Client) UpdateVCL(i *UpdateVCLInput) (*VCL, 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/vcl/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var vcl *VCL
if err := decodeJSON(&vcl, resp.Body); err != nil {
return nil, err
}
return vcl, nil
} | go | func (c *Client) UpdateVCL(i *UpdateVCLInput) (*VCL, 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/vcl/%s", i.Service, i.Version, i.Name)
resp, err := c.PutForm(path, i, nil)
if err != nil {
return nil, err
}
var vcl *VCL
if err := decodeJSON(&vcl, resp.Body); err != nil {
return nil, err
}
return vcl, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateVCL",
"(",
"i",
"*",
"UpdateVCLInput",
")",
"(",
"*",
"VCL",
",",
"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",
"vcl",
"*",
"VCL",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"vcl",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"vcl",
",",
"nil",
"\n",
"}"
] | // UpdateVCL creates a new Fastly VCL. | [
"UpdateVCL",
"creates",
"a",
"new",
"Fastly",
"VCL",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/vcl.go#L180-L204 |
10,294 | sethvargo/go-fastly | fastly/vcl.go | ActivateVCL | func (c *Client) ActivateVCL(i *ActivateVCLInput) (*VCL, 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/vcl/%s/main", i.Service, i.Version, i.Name)
resp, err := c.Put(path, nil)
if err != nil {
return nil, err
}
var vcl *VCL
if err := decodeJSON(&vcl, resp.Body); err != nil {
return nil, err
}
return vcl, nil
} | go | func (c *Client) ActivateVCL(i *ActivateVCLInput) (*VCL, 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/vcl/%s/main", i.Service, i.Version, i.Name)
resp, err := c.Put(path, nil)
if err != nil {
return nil, err
}
var vcl *VCL
if err := decodeJSON(&vcl, resp.Body); err != nil {
return nil, err
}
return vcl, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ActivateVCL",
"(",
"i",
"*",
"ActivateVCLInput",
")",
"(",
"*",
"VCL",
",",
"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",
".",
"Put",
"(",
"path",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"vcl",
"*",
"VCL",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"vcl",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"vcl",
",",
"nil",
"\n",
"}"
] | // ActivateVCL creates a new Fastly VCL. | [
"ActivateVCL",
"creates",
"a",
"new",
"Fastly",
"VCL",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/vcl.go#L218-L242 |
10,295 | sethvargo/go-fastly | fastly/stats.go | GetStats | func (c *Client) GetStats(i *GetStatsInput) (*StatsResponse, error) {
p := "/stats"
if i.Service != "" {
p = fmt.Sprintf("%s/service/%s", p, i.Service)
}
if i.Field != "" {
p = fmt.Sprintf("%s/field/%s", p, i.Field)
}
r, err := c.Get(p, &RequestOptions{
Params: map[string]string{
"from": i.From,
"to": i.To,
"by": i.By,
"region": i.Region,
},
})
if err != nil {
return nil, err
}
var sr *StatsResponse
if err := decodeJSON(&sr, r.Body); err != nil {
return nil, err
}
return sr, nil
} | go | func (c *Client) GetStats(i *GetStatsInput) (*StatsResponse, error) {
p := "/stats"
if i.Service != "" {
p = fmt.Sprintf("%s/service/%s", p, i.Service)
}
if i.Field != "" {
p = fmt.Sprintf("%s/field/%s", p, i.Field)
}
r, err := c.Get(p, &RequestOptions{
Params: map[string]string{
"from": i.From,
"to": i.To,
"by": i.By,
"region": i.Region,
},
})
if err != nil {
return nil, err
}
var sr *StatsResponse
if err := decodeJSON(&sr, r.Body); err != nil {
return nil, err
}
return sr, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetStats",
"(",
"i",
"*",
"GetStatsInput",
")",
"(",
"*",
"StatsResponse",
",",
"error",
")",
"{",
"p",
":=",
"\"",
"\"",
"\n\n",
"if",
"i",
".",
"Service",
"!=",
"\"",
"\"",
"{",
"p",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"p",
",",
"i",
".",
"Service",
")",
"\n",
"}",
"\n\n",
"if",
"i",
".",
"Field",
"!=",
"\"",
"\"",
"{",
"p",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"p",
",",
"i",
".",
"Field",
")",
"\n",
"}",
"\n\n",
"r",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"p",
",",
"&",
"RequestOptions",
"{",
"Params",
":",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"i",
".",
"From",
",",
"\"",
"\"",
":",
"i",
".",
"To",
",",
"\"",
"\"",
":",
"i",
".",
"By",
",",
"\"",
"\"",
":",
"i",
".",
"Region",
",",
"}",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"sr",
"*",
"StatsResponse",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"sr",
",",
"r",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"sr",
",",
"nil",
"\n",
"}"
] | // GetStats returns stats data based on GetStatsInput | [
"GetStats",
"returns",
"stats",
"data",
"based",
"on",
"GetStatsInput"
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/stats.go#L103-L133 |
10,296 | sethvargo/go-fastly | fastly/stats.go | GetUsage | func (c *Client) GetUsage(i *GetUsageInput) (*UsageResponse, error) {
r, err := c.Get("/stats/usage", &RequestOptions{
Params: map[string]string{
"from": i.From,
"to": i.To,
"by": i.By,
"region": i.Region,
},
})
if err != nil {
return nil, err
}
var sr *UsageResponse
if err := decodeJSON(&sr, r.Body); err != nil {
return nil, err
}
return sr, nil
} | go | func (c *Client) GetUsage(i *GetUsageInput) (*UsageResponse, error) {
r, err := c.Get("/stats/usage", &RequestOptions{
Params: map[string]string{
"from": i.From,
"to": i.To,
"by": i.By,
"region": i.Region,
},
})
if err != nil {
return nil, err
}
var sr *UsageResponse
if err := decodeJSON(&sr, r.Body); err != nil {
return nil, err
}
return sr, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetUsage",
"(",
"i",
"*",
"GetUsageInput",
")",
"(",
"*",
"UsageResponse",
",",
"error",
")",
"{",
"r",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"\"",
"\"",
",",
"&",
"RequestOptions",
"{",
"Params",
":",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"i",
".",
"From",
",",
"\"",
"\"",
":",
"i",
".",
"To",
",",
"\"",
"\"",
":",
"i",
".",
"By",
",",
"\"",
"\"",
":",
"i",
".",
"Region",
",",
"}",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"var",
"sr",
"*",
"UsageResponse",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"sr",
",",
"r",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"sr",
",",
"nil",
"\n",
"}"
] | // GetUsage returns usage information aggregated across all Fastly services and grouped by region. | [
"GetUsage",
"returns",
"usage",
"information",
"aggregated",
"across",
"all",
"Fastly",
"services",
"and",
"grouped",
"by",
"region",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/stats.go#L170-L188 |
10,297 | sethvargo/go-fastly | fastly/stats.go | GetRegions | func (c *Client) GetRegions() (*RegionsResponse, error) {
r, err := c.Get("stats/regions", nil)
if err != nil {
return nil, err
}
var rr *RegionsResponse
if err := decodeJSON(&rr, r.Body); err != nil {
return nil, err
}
return rr, nil
} | go | func (c *Client) GetRegions() (*RegionsResponse, error) {
r, err := c.Get("stats/regions", nil)
if err != nil {
return nil, err
}
var rr *RegionsResponse
if err := decodeJSON(&rr, r.Body); err != nil {
return nil, err
}
return rr, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetRegions",
"(",
")",
"(",
"*",
"RegionsResponse",
",",
"error",
")",
"{",
"r",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"\"",
"\"",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"rr",
"*",
"RegionsResponse",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"rr",
",",
"r",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"rr",
",",
"nil",
"\n",
"}"
] | // GetRegions returns a list of Fastly regions | [
"GetRegions",
"returns",
"a",
"list",
"of",
"Fastly",
"regions"
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/stats.go#L235-L247 |
10,298 | sethvargo/go-fastly | fastly/splunk.go | ListSplunks | func (c *Client) ListSplunks(i *ListSplunksInput) ([]*Splunk, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/splunk", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ss []*Splunk
if err := decodeJSON(&ss, resp.Body); err != nil {
return nil, err
}
sort.Stable(splunkByName(ss))
return ss, nil
} | go | func (c *Client) ListSplunks(i *ListSplunksInput) ([]*Splunk, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/splunk", i.Service, i.Version)
resp, err := c.Get(path, nil)
if err != nil {
return nil, err
}
var ss []*Splunk
if err := decodeJSON(&ss, resp.Body); err != nil {
return nil, err
}
sort.Stable(splunkByName(ss))
return ss, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListSplunks",
"(",
"i",
"*",
"ListSplunksInput",
")",
"(",
"[",
"]",
"*",
"Splunk",
",",
"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",
"[",
"]",
"*",
"Splunk",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"ss",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"splunkByName",
"(",
"ss",
")",
")",
"\n",
"return",
"ss",
",",
"nil",
"\n",
"}"
] | // ListSplunks returns the list of splunks for the configuration version. | [
"ListSplunks",
"returns",
"the",
"list",
"of",
"splunks",
"for",
"the",
"configuration",
"version",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/splunk.go#L46-L67 |
10,299 | sethvargo/go-fastly | fastly/splunk.go | CreateSplunk | func (c *Client) CreateSplunk(i *CreateSplunkInput) (*Splunk, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/splunk", i.Service, i.Version)
resp, err := c.PostForm(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) CreateSplunk(i *CreateSplunkInput) (*Splunk, error) {
if i.Service == "" {
return nil, ErrMissingService
}
if i.Version == 0 {
return nil, ErrMissingVersion
}
path := fmt.Sprintf("/service/%s/version/%d/logging/splunk", i.Service, i.Version)
resp, err := c.PostForm(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",
")",
"CreateSplunk",
"(",
"i",
"*",
"CreateSplunkInput",
")",
"(",
"*",
"Splunk",
",",
"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",
"*",
"Splunk",
"\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"&",
"s",
",",
"resp",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] | // CreateSplunk creates a new Fastly splunk. | [
"CreateSplunk",
"creates",
"a",
"new",
"Fastly",
"splunk",
"."
] | f249287bd4fda366a7f324f45a2308e934198464 | https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/splunk.go#L86-L106 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.