repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
TheThingsNetwork/go-utils
grpc/streambuffer/streambuffer.go
CloseRecv
func (s *Stream) CloseRecv() { s.mu.Lock() if s.recvBuffer != nil { close(s.recvBuffer) s.recvBuffer = nil } s.mu.Unlock() }
go
func (s *Stream) CloseRecv() { s.mu.Lock() if s.recvBuffer != nil { close(s.recvBuffer) s.recvBuffer = nil } s.mu.Unlock() }
[ "func", "(", "s", "*", "Stream", ")", "CloseRecv", "(", ")", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "if", "s", ".", "recvBuffer", "!=", "nil", "{", "close", "(", "s", ".", "recvBuffer", ")", "\n", "s", ".", "recvBuffer", "=", "nil", "\n", "}", "\n", "s", ".", "mu", ".", "Unlock", "(", ")", "\n", "}" ]
// CloseRecv closes the receive channel
[ "CloseRecv", "closes", "the", "receive", "channel" ]
aa2a11bd59104d2a8609328c2b2b55da61826470
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/grpc/streambuffer/streambuffer.go#L73-L80
test
TheThingsNetwork/go-utils
grpc/streambuffer/streambuffer.go
Stats
func (s *Stream) Stats() (sent, dropped uint64) { return atomic.LoadUint64(&s.sent), atomic.LoadUint64(&s.dropped) }
go
func (s *Stream) Stats() (sent, dropped uint64) { return atomic.LoadUint64(&s.sent), atomic.LoadUint64(&s.dropped) }
[ "func", "(", "s", "*", "Stream", ")", "Stats", "(", ")", "(", "sent", ",", "dropped", "uint64", ")", "{", "return", "atomic", ".", "LoadUint64", "(", "&", "s", ".", "sent", ")", ",", "atomic", ".", "LoadUint64", "(", "&", "s", ".", "dropped", ")", "\n", "}" ]
// Stats of the stream
[ "Stats", "of", "the", "stream" ]
aa2a11bd59104d2a8609328c2b2b55da61826470
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/grpc/streambuffer/streambuffer.go#L83-L85
test
TheThingsNetwork/go-utils
grpc/streambuffer/streambuffer.go
Run
func (s *Stream) Run() (err error) { s.mu.RLock() defer s.mu.RUnlock() defer func() { if err != nil { if grpc.Code(err) == codes.Canceled { s.log.Debug("streambuffer: context canceled") err = context.Canceled return } if grpc.Code(err) == codes.DeadlineExceeded { s.log.Debug("streambuffer: context deadline exceeded") err = context.DeadlineExceeded return } } }() stream, err := s.setupFunc() if err != nil { s.log.WithError(err).Debug("streambuffer: setup returned error") return err } recvErr := make(chan error) defer func() { go func() { // empty the recvErr channel on return <-recvErr }() }() go func() { for { var r interface{} if s.recvFunc != nil { r = s.recvFunc() } else { r = new(empty.Empty) // Generic proto message if not interested in received values } err := stream.RecvMsg(r) if err != nil { s.log.WithError(err).Debug("streambuffer: error from stream.RecvMsg") recvErr <- err close(recvErr) return } if s.recvFunc != nil { s.recvMsg(r) } } }() defer stream.CloseSend() for { select { case err := <-recvErr: return err case <-stream.Context().Done(): s.log.WithError(stream.Context().Err()).Debug("streambuffer: context done") return stream.Context().Err() case msg := <-s.sendBuffer: if err = stream.SendMsg(msg); err != nil { s.log.WithError(err).Debug("streambuffer: error from stream.SendMsg") return err } atomic.AddUint64(&s.sent, 1) } } }
go
func (s *Stream) Run() (err error) { s.mu.RLock() defer s.mu.RUnlock() defer func() { if err != nil { if grpc.Code(err) == codes.Canceled { s.log.Debug("streambuffer: context canceled") err = context.Canceled return } if grpc.Code(err) == codes.DeadlineExceeded { s.log.Debug("streambuffer: context deadline exceeded") err = context.DeadlineExceeded return } } }() stream, err := s.setupFunc() if err != nil { s.log.WithError(err).Debug("streambuffer: setup returned error") return err } recvErr := make(chan error) defer func() { go func() { // empty the recvErr channel on return <-recvErr }() }() go func() { for { var r interface{} if s.recvFunc != nil { r = s.recvFunc() } else { r = new(empty.Empty) // Generic proto message if not interested in received values } err := stream.RecvMsg(r) if err != nil { s.log.WithError(err).Debug("streambuffer: error from stream.RecvMsg") recvErr <- err close(recvErr) return } if s.recvFunc != nil { s.recvMsg(r) } } }() defer stream.CloseSend() for { select { case err := <-recvErr: return err case <-stream.Context().Done(): s.log.WithError(stream.Context().Err()).Debug("streambuffer: context done") return stream.Context().Err() case msg := <-s.sendBuffer: if err = stream.SendMsg(msg); err != nil { s.log.WithError(err).Debug("streambuffer: error from stream.SendMsg") return err } atomic.AddUint64(&s.sent, 1) } } }
[ "func", "(", "s", "*", "Stream", ")", "Run", "(", ")", "(", "err", "error", ")", "{", "s", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "RUnlock", "(", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "if", "grpc", ".", "Code", "(", "err", ")", "==", "codes", ".", "Canceled", "{", "s", ".", "log", ".", "Debug", "(", "\"streambuffer: context canceled\"", ")", "\n", "err", "=", "context", ".", "Canceled", "\n", "return", "\n", "}", "\n", "if", "grpc", ".", "Code", "(", "err", ")", "==", "codes", ".", "DeadlineExceeded", "{", "s", ".", "log", ".", "Debug", "(", "\"streambuffer: context deadline exceeded\"", ")", "\n", "err", "=", "context", ".", "DeadlineExceeded", "\n", "return", "\n", "}", "\n", "}", "\n", "}", "(", ")", "\n", "stream", ",", "err", ":=", "s", ".", "setupFunc", "(", ")", "\n", "if", "err", "!=", "nil", "{", "s", ".", "log", ".", "WithError", "(", "err", ")", ".", "Debug", "(", "\"streambuffer: setup returned error\"", ")", "\n", "return", "err", "\n", "}", "\n", "recvErr", ":=", "make", "(", "chan", "error", ")", "\n", "defer", "func", "(", ")", "{", "go", "func", "(", ")", "{", "<-", "recvErr", "\n", "}", "(", ")", "\n", "}", "(", ")", "\n", "go", "func", "(", ")", "{", "for", "{", "var", "r", "interface", "{", "}", "\n", "if", "s", ".", "recvFunc", "!=", "nil", "{", "r", "=", "s", ".", "recvFunc", "(", ")", "\n", "}", "else", "{", "r", "=", "new", "(", "empty", ".", "Empty", ")", "\n", "}", "\n", "err", ":=", "stream", ".", "RecvMsg", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "s", ".", "log", ".", "WithError", "(", "err", ")", ".", "Debug", "(", "\"streambuffer: error from stream.RecvMsg\"", ")", "\n", "recvErr", "<-", "err", "\n", "close", "(", "recvErr", ")", "\n", "return", "\n", "}", "\n", "if", "s", ".", "recvFunc", "!=", "nil", "{", "s", ".", "recvMsg", "(", "r", ")", "\n", "}", "\n", "}", "\n", "}", "(", ")", "\n", "defer", "stream", ".", "CloseSend", "(", ")", "\n", "for", "{", "select", "{", "case", "err", ":=", "<-", "recvErr", ":", "return", "err", "\n", "case", "<-", "stream", ".", "Context", "(", ")", ".", "Done", "(", ")", ":", "s", ".", "log", ".", "WithError", "(", "stream", ".", "Context", "(", ")", ".", "Err", "(", ")", ")", ".", "Debug", "(", "\"streambuffer: context done\"", ")", "\n", "return", "stream", ".", "Context", "(", ")", ".", "Err", "(", ")", "\n", "case", "msg", ":=", "<-", "s", ".", "sendBuffer", ":", "if", "err", "=", "stream", ".", "SendMsg", "(", "msg", ")", ";", "err", "!=", "nil", "{", "s", ".", "log", ".", "WithError", "(", "err", ")", ".", "Debug", "(", "\"streambuffer: error from stream.SendMsg\"", ")", "\n", "return", "err", "\n", "}", "\n", "atomic", ".", "AddUint64", "(", "&", "s", ".", "sent", ",", "1", ")", "\n", "}", "\n", "}", "\n", "}" ]
// Run the stream. // // This calls the underlying grpc.ClientStreams methods to send and receive messages over the stream. // Run returns the error returned by any of those functions, or context.Canceled if the context is canceled.
[ "Run", "the", "stream", ".", "This", "calls", "the", "underlying", "grpc", ".", "ClientStreams", "methods", "to", "send", "and", "receive", "messages", "over", "the", "stream", ".", "Run", "returns", "the", "error", "returned", "by", "any", "of", "those", "functions", "or", "context", ".", "Canceled", "if", "the", "context", "is", "canceled", "." ]
aa2a11bd59104d2a8609328c2b2b55da61826470
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/grpc/streambuffer/streambuffer.go#L131-L201
test
TheThingsNetwork/go-utils
grpc/rpclog/grpc.go
ServerOptions
func ServerOptions(log ttnlog.Interface) []grpc.ServerOption { return []grpc.ServerOption{ grpc.UnaryInterceptor(UnaryServerInterceptor(log)), grpc.StreamInterceptor(StreamServerInterceptor(log)), } }
go
func ServerOptions(log ttnlog.Interface) []grpc.ServerOption { return []grpc.ServerOption{ grpc.UnaryInterceptor(UnaryServerInterceptor(log)), grpc.StreamInterceptor(StreamServerInterceptor(log)), } }
[ "func", "ServerOptions", "(", "log", "ttnlog", ".", "Interface", ")", "[", "]", "grpc", ".", "ServerOption", "{", "return", "[", "]", "grpc", ".", "ServerOption", "{", "grpc", ".", "UnaryInterceptor", "(", "UnaryServerInterceptor", "(", "log", ")", ")", ",", "grpc", ".", "StreamInterceptor", "(", "StreamServerInterceptor", "(", "log", ")", ")", ",", "}", "\n", "}" ]
// ServerOptions for logging RPCs
[ "ServerOptions", "for", "logging", "RPCs" ]
aa2a11bd59104d2a8609328c2b2b55da61826470
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/grpc/rpclog/grpc.go#L23-L28
test
TheThingsNetwork/go-utils
grpc/rpclog/grpc.go
ClientOptions
func ClientOptions(log ttnlog.Interface) []grpc.DialOption { return []grpc.DialOption{ grpc.WithUnaryInterceptor(UnaryClientInterceptor(log)), grpc.WithStreamInterceptor(StreamClientInterceptor(log)), } }
go
func ClientOptions(log ttnlog.Interface) []grpc.DialOption { return []grpc.DialOption{ grpc.WithUnaryInterceptor(UnaryClientInterceptor(log)), grpc.WithStreamInterceptor(StreamClientInterceptor(log)), } }
[ "func", "ClientOptions", "(", "log", "ttnlog", ".", "Interface", ")", "[", "]", "grpc", ".", "DialOption", "{", "return", "[", "]", "grpc", ".", "DialOption", "{", "grpc", ".", "WithUnaryInterceptor", "(", "UnaryClientInterceptor", "(", "log", ")", ")", ",", "grpc", ".", "WithStreamInterceptor", "(", "StreamClientInterceptor", "(", "log", ")", ")", ",", "}", "\n", "}" ]
// ClientOptions for logging RPCs
[ "ClientOptions", "for", "logging", "RPCs" ]
aa2a11bd59104d2a8609328c2b2b55da61826470
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/grpc/rpclog/grpc.go#L31-L36
test
TheThingsNetwork/go-utils
grpc/rpclog/grpc.go
UnaryServerInterceptor
func UnaryServerInterceptor(log ttnlog.Interface) grpc.UnaryServerInterceptor { return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) { log := getLog(log).WithField("method", info.FullMethod) log = log.WithFields(FieldsFromIncomingContext(ctx)) start := time.Now() resp, err = handler(ctx, req) log = log.WithField("duration", time.Since(start)) if err != nil { log.WithError(err).Debug("rpc-server: call failed") return } log.Debug("rpc-server: call done") return } }
go
func UnaryServerInterceptor(log ttnlog.Interface) grpc.UnaryServerInterceptor { return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) { log := getLog(log).WithField("method", info.FullMethod) log = log.WithFields(FieldsFromIncomingContext(ctx)) start := time.Now() resp, err = handler(ctx, req) log = log.WithField("duration", time.Since(start)) if err != nil { log.WithError(err).Debug("rpc-server: call failed") return } log.Debug("rpc-server: call done") return } }
[ "func", "UnaryServerInterceptor", "(", "log", "ttnlog", ".", "Interface", ")", "grpc", ".", "UnaryServerInterceptor", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "req", "interface", "{", "}", ",", "info", "*", "grpc", ".", "UnaryServerInfo", ",", "handler", "grpc", ".", "UnaryHandler", ")", "(", "resp", "interface", "{", "}", ",", "err", "error", ")", "{", "log", ":=", "getLog", "(", "log", ")", ".", "WithField", "(", "\"method\"", ",", "info", ".", "FullMethod", ")", "\n", "log", "=", "log", ".", "WithFields", "(", "FieldsFromIncomingContext", "(", "ctx", ")", ")", "\n", "start", ":=", "time", ".", "Now", "(", ")", "\n", "resp", ",", "err", "=", "handler", "(", "ctx", ",", "req", ")", "\n", "log", "=", "log", ".", "WithField", "(", "\"duration\"", ",", "time", ".", "Since", "(", "start", ")", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "WithError", "(", "err", ")", ".", "Debug", "(", "\"rpc-server: call failed\"", ")", "\n", "return", "\n", "}", "\n", "log", ".", "Debug", "(", "\"rpc-server: call done\"", ")", "\n", "return", "\n", "}", "\n", "}" ]
// UnaryServerInterceptor logs unary RPCs on the server side
[ "UnaryServerInterceptor", "logs", "unary", "RPCs", "on", "the", "server", "side" ]
aa2a11bd59104d2a8609328c2b2b55da61826470
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/grpc/rpclog/grpc.go#L39-L53
test
TheThingsNetwork/go-utils
grpc/rpclog/grpc.go
StreamServerInterceptor
func StreamServerInterceptor(log ttnlog.Interface) grpc.StreamServerInterceptor { return func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) (err error) { log := getLog(log).WithField("method", info.FullMethod) log = log.WithFields(FieldsFromIncomingContext(ss.Context())) start := time.Now() log.Debug("rpc-server: stream starting") err = handler(srv, ss) log = log.WithField("duration", time.Since(start)) if err != nil { if err == context.Canceled || grpc.Code(err) == codes.Canceled { log.Debug("rpc-server: stream canceled") return } log.WithError(err).Debug("rpc-server: stream failed") return } log.Debug("rpc-server: stream done") return } }
go
func StreamServerInterceptor(log ttnlog.Interface) grpc.StreamServerInterceptor { return func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) (err error) { log := getLog(log).WithField("method", info.FullMethod) log = log.WithFields(FieldsFromIncomingContext(ss.Context())) start := time.Now() log.Debug("rpc-server: stream starting") err = handler(srv, ss) log = log.WithField("duration", time.Since(start)) if err != nil { if err == context.Canceled || grpc.Code(err) == codes.Canceled { log.Debug("rpc-server: stream canceled") return } log.WithError(err).Debug("rpc-server: stream failed") return } log.Debug("rpc-server: stream done") return } }
[ "func", "StreamServerInterceptor", "(", "log", "ttnlog", ".", "Interface", ")", "grpc", ".", "StreamServerInterceptor", "{", "return", "func", "(", "srv", "interface", "{", "}", ",", "ss", "grpc", ".", "ServerStream", ",", "info", "*", "grpc", ".", "StreamServerInfo", ",", "handler", "grpc", ".", "StreamHandler", ")", "(", "err", "error", ")", "{", "log", ":=", "getLog", "(", "log", ")", ".", "WithField", "(", "\"method\"", ",", "info", ".", "FullMethod", ")", "\n", "log", "=", "log", ".", "WithFields", "(", "FieldsFromIncomingContext", "(", "ss", ".", "Context", "(", ")", ")", ")", "\n", "start", ":=", "time", ".", "Now", "(", ")", "\n", "log", ".", "Debug", "(", "\"rpc-server: stream starting\"", ")", "\n", "err", "=", "handler", "(", "srv", ",", "ss", ")", "\n", "log", "=", "log", ".", "WithField", "(", "\"duration\"", ",", "time", ".", "Since", "(", "start", ")", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "context", ".", "Canceled", "||", "grpc", ".", "Code", "(", "err", ")", "==", "codes", ".", "Canceled", "{", "log", ".", "Debug", "(", "\"rpc-server: stream canceled\"", ")", "\n", "return", "\n", "}", "\n", "log", ".", "WithError", "(", "err", ")", ".", "Debug", "(", "\"rpc-server: stream failed\"", ")", "\n", "return", "\n", "}", "\n", "log", ".", "Debug", "(", "\"rpc-server: stream done\"", ")", "\n", "return", "\n", "}", "\n", "}" ]
// StreamServerInterceptor logs streaming RPCs on the server side
[ "StreamServerInterceptor", "logs", "streaming", "RPCs", "on", "the", "server", "side" ]
aa2a11bd59104d2a8609328c2b2b55da61826470
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/grpc/rpclog/grpc.go#L56-L75
test
TheThingsNetwork/go-utils
grpc/rpclog/grpc.go
UnaryClientInterceptor
func UnaryClientInterceptor(log ttnlog.Interface) grpc.UnaryClientInterceptor { return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) (err error) { log := getLog(log).WithField("method", method) log = log.WithFields(FieldsFromOutgoingContext(ctx)) start := time.Now() err = invoker(ctx, method, req, reply, cc, opts...) log = log.WithField("duration", time.Since(start)) if err != nil { log.WithError(err).Debug("rpc-client: call failed") return } log.Debug("rpc-client: call done") return } }
go
func UnaryClientInterceptor(log ttnlog.Interface) grpc.UnaryClientInterceptor { return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) (err error) { log := getLog(log).WithField("method", method) log = log.WithFields(FieldsFromOutgoingContext(ctx)) start := time.Now() err = invoker(ctx, method, req, reply, cc, opts...) log = log.WithField("duration", time.Since(start)) if err != nil { log.WithError(err).Debug("rpc-client: call failed") return } log.Debug("rpc-client: call done") return } }
[ "func", "UnaryClientInterceptor", "(", "log", "ttnlog", ".", "Interface", ")", "grpc", ".", "UnaryClientInterceptor", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "method", "string", ",", "req", ",", "reply", "interface", "{", "}", ",", "cc", "*", "grpc", ".", "ClientConn", ",", "invoker", "grpc", ".", "UnaryInvoker", ",", "opts", "...", "grpc", ".", "CallOption", ")", "(", "err", "error", ")", "{", "log", ":=", "getLog", "(", "log", ")", ".", "WithField", "(", "\"method\"", ",", "method", ")", "\n", "log", "=", "log", ".", "WithFields", "(", "FieldsFromOutgoingContext", "(", "ctx", ")", ")", "\n", "start", ":=", "time", ".", "Now", "(", ")", "\n", "err", "=", "invoker", "(", "ctx", ",", "method", ",", "req", ",", "reply", ",", "cc", ",", "opts", "...", ")", "\n", "log", "=", "log", ".", "WithField", "(", "\"duration\"", ",", "time", ".", "Since", "(", "start", ")", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "WithError", "(", "err", ")", ".", "Debug", "(", "\"rpc-client: call failed\"", ")", "\n", "return", "\n", "}", "\n", "log", ".", "Debug", "(", "\"rpc-client: call done\"", ")", "\n", "return", "\n", "}", "\n", "}" ]
// UnaryClientInterceptor logs unary RPCs on the client side
[ "UnaryClientInterceptor", "logs", "unary", "RPCs", "on", "the", "client", "side" ]
aa2a11bd59104d2a8609328c2b2b55da61826470
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/grpc/rpclog/grpc.go#L78-L92
test
TheThingsNetwork/go-utils
grpc/rpclog/grpc.go
StreamClientInterceptor
func StreamClientInterceptor(log ttnlog.Interface) grpc.StreamClientInterceptor { return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (stream grpc.ClientStream, err error) { log := getLog(log).WithField("method", method) log = log.WithFields(FieldsFromOutgoingContext(ctx)) log.Debug("rpc-client: stream starting") stream, err = streamer(ctx, desc, cc, method, opts...) if err != nil { if err == context.Canceled || grpc.Code(err) == codes.Canceled { log.Debug("rpc-client: stream canceled") return } log.WithError(err).Debug("rpc-client: stream failed") return } go func() { <-stream.Context().Done() if err := stream.Context().Err(); err != nil { log = log.WithError(err) } log.Debug("rpc-client: stream done") }() return } }
go
func StreamClientInterceptor(log ttnlog.Interface) grpc.StreamClientInterceptor { return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (stream grpc.ClientStream, err error) { log := getLog(log).WithField("method", method) log = log.WithFields(FieldsFromOutgoingContext(ctx)) log.Debug("rpc-client: stream starting") stream, err = streamer(ctx, desc, cc, method, opts...) if err != nil { if err == context.Canceled || grpc.Code(err) == codes.Canceled { log.Debug("rpc-client: stream canceled") return } log.WithError(err).Debug("rpc-client: stream failed") return } go func() { <-stream.Context().Done() if err := stream.Context().Err(); err != nil { log = log.WithError(err) } log.Debug("rpc-client: stream done") }() return } }
[ "func", "StreamClientInterceptor", "(", "log", "ttnlog", ".", "Interface", ")", "grpc", ".", "StreamClientInterceptor", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "desc", "*", "grpc", ".", "StreamDesc", ",", "cc", "*", "grpc", ".", "ClientConn", ",", "method", "string", ",", "streamer", "grpc", ".", "Streamer", ",", "opts", "...", "grpc", ".", "CallOption", ")", "(", "stream", "grpc", ".", "ClientStream", ",", "err", "error", ")", "{", "log", ":=", "getLog", "(", "log", ")", ".", "WithField", "(", "\"method\"", ",", "method", ")", "\n", "log", "=", "log", ".", "WithFields", "(", "FieldsFromOutgoingContext", "(", "ctx", ")", ")", "\n", "log", ".", "Debug", "(", "\"rpc-client: stream starting\"", ")", "\n", "stream", ",", "err", "=", "streamer", "(", "ctx", ",", "desc", ",", "cc", ",", "method", ",", "opts", "...", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "context", ".", "Canceled", "||", "grpc", ".", "Code", "(", "err", ")", "==", "codes", ".", "Canceled", "{", "log", ".", "Debug", "(", "\"rpc-client: stream canceled\"", ")", "\n", "return", "\n", "}", "\n", "log", ".", "WithError", "(", "err", ")", ".", "Debug", "(", "\"rpc-client: stream failed\"", ")", "\n", "return", "\n", "}", "\n", "go", "func", "(", ")", "{", "<-", "stream", ".", "Context", "(", ")", ".", "Done", "(", ")", "\n", "if", "err", ":=", "stream", ".", "Context", "(", ")", ".", "Err", "(", ")", ";", "err", "!=", "nil", "{", "log", "=", "log", ".", "WithError", "(", "err", ")", "\n", "}", "\n", "log", ".", "Debug", "(", "\"rpc-client: stream done\"", ")", "\n", "}", "(", ")", "\n", "return", "\n", "}", "\n", "}" ]
// StreamClientInterceptor logs streaming RPCs on the client side
[ "StreamClientInterceptor", "logs", "streaming", "RPCs", "on", "the", "client", "side" ]
aa2a11bd59104d2a8609328c2b2b55da61826470
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/grpc/rpclog/grpc.go#L95-L118
test
TheThingsNetwork/go-utils
handlers/elasticsearch/elasticsearch.go
defaults
func (c *Config) defaults() { if c.BufferSize == 0 { c.BufferSize = 100 } if c.Prefix == "" { c.Prefix = "logs" } }
go
func (c *Config) defaults() { if c.BufferSize == 0 { c.BufferSize = 100 } if c.Prefix == "" { c.Prefix = "logs" } }
[ "func", "(", "c", "*", "Config", ")", "defaults", "(", ")", "{", "if", "c", ".", "BufferSize", "==", "0", "{", "c", ".", "BufferSize", "=", "100", "\n", "}", "\n", "if", "c", ".", "Prefix", "==", "\"\"", "{", "c", ".", "Prefix", "=", "\"logs\"", "\n", "}", "\n", "}" ]
// defaults applies defaults to the config.
[ "defaults", "applies", "defaults", "to", "the", "config", "." ]
aa2a11bd59104d2a8609328c2b2b55da61826470
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/handlers/elasticsearch/elasticsearch.go#L30-L38
test
TheThingsNetwork/go-utils
handlers/elasticsearch/elasticsearch.go
Flush
func (h *Handler) Flush() { h.mu.Lock() defer h.mu.Unlock() if h.batch != nil { go h.flush(h.batch) h.batch = nil } }
go
func (h *Handler) Flush() { h.mu.Lock() defer h.mu.Unlock() if h.batch != nil { go h.flush(h.batch) h.batch = nil } }
[ "func", "(", "h", "*", "Handler", ")", "Flush", "(", ")", "{", "h", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "h", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "h", ".", "batch", "!=", "nil", "{", "go", "h", ".", "flush", "(", "h", ".", "batch", ")", "\n", "h", ".", "batch", "=", "nil", "\n", "}", "\n", "}" ]
// Flush the current `batch`.
[ "Flush", "the", "current", "batch", "." ]
aa2a11bd59104d2a8609328c2b2b55da61826470
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/handlers/elasticsearch/elasticsearch.go#L96-L103
test
TheThingsNetwork/go-utils
handlers/cli/cli.go
New
func New(w io.Writer) *Handler { var useColor bool if os.Getenv("COLORTERM") != "" { useColor = true } if term := os.Getenv("TERM"); term != "" { for _, substring := range colorTermSubstrings { if strings.Contains(term, substring) { useColor = true break } } } return &Handler{ Writer: w, UseColor: useColor, } }
go
func New(w io.Writer) *Handler { var useColor bool if os.Getenv("COLORTERM") != "" { useColor = true } if term := os.Getenv("TERM"); term != "" { for _, substring := range colorTermSubstrings { if strings.Contains(term, substring) { useColor = true break } } } return &Handler{ Writer: w, UseColor: useColor, } }
[ "func", "New", "(", "w", "io", ".", "Writer", ")", "*", "Handler", "{", "var", "useColor", "bool", "\n", "if", "os", ".", "Getenv", "(", "\"COLORTERM\"", ")", "!=", "\"\"", "{", "useColor", "=", "true", "\n", "}", "\n", "if", "term", ":=", "os", ".", "Getenv", "(", "\"TERM\"", ")", ";", "term", "!=", "\"\"", "{", "for", "_", ",", "substring", ":=", "range", "colorTermSubstrings", "{", "if", "strings", ".", "Contains", "(", "term", ",", "substring", ")", "{", "useColor", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "&", "Handler", "{", "Writer", ":", "w", ",", "UseColor", ":", "useColor", ",", "}", "\n", "}" ]
// New handler.
[ "New", "handler", "." ]
aa2a11bd59104d2a8609328c2b2b55da61826470
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/handlers/cli/cli.go#L72-L89
test
TheThingsNetwork/go-utils
handlers/cli/cli.go
HandleLog
func (h *Handler) HandleLog(e *log.Entry) error { color := Colors[e.Level] level := Strings[e.Level] var fields []field for k, v := range e.Fields { fields = append(fields, field{k, v}) } sort.Sort(byName(fields)) h.mu.Lock() defer h.mu.Unlock() if h.UseColor { fmt.Fprintf(h.Writer, "\033[%dm%6s\033[0m %-40s", color, level, e.Message) } else { fmt.Fprintf(h.Writer, "%6s %-40s", level, e.Message) } for _, f := range fields { var value interface{} switch t := f.Value.(type) { case []byte: // addresses and EUIs are []byte value = fmt.Sprintf("%X", t) case [21]byte: // bundle IDs [21]byte value = fmt.Sprintf("%X-%X-%X-%X", t[0], t[1:9], t[9:17], t[17:]) default: value = f.Value } if h.UseColor { fmt.Fprintf(h.Writer, " \033[%dm%s\033[0m=%v", color, f.Name, value) } else { fmt.Fprintf(h.Writer, " %s=%v", f.Name, value) } } fmt.Fprintln(h.Writer) return nil }
go
func (h *Handler) HandleLog(e *log.Entry) error { color := Colors[e.Level] level := Strings[e.Level] var fields []field for k, v := range e.Fields { fields = append(fields, field{k, v}) } sort.Sort(byName(fields)) h.mu.Lock() defer h.mu.Unlock() if h.UseColor { fmt.Fprintf(h.Writer, "\033[%dm%6s\033[0m %-40s", color, level, e.Message) } else { fmt.Fprintf(h.Writer, "%6s %-40s", level, e.Message) } for _, f := range fields { var value interface{} switch t := f.Value.(type) { case []byte: // addresses and EUIs are []byte value = fmt.Sprintf("%X", t) case [21]byte: // bundle IDs [21]byte value = fmt.Sprintf("%X-%X-%X-%X", t[0], t[1:9], t[9:17], t[17:]) default: value = f.Value } if h.UseColor { fmt.Fprintf(h.Writer, " \033[%dm%s\033[0m=%v", color, f.Name, value) } else { fmt.Fprintf(h.Writer, " %s=%v", f.Name, value) } } fmt.Fprintln(h.Writer) return nil }
[ "func", "(", "h", "*", "Handler", ")", "HandleLog", "(", "e", "*", "log", ".", "Entry", ")", "error", "{", "color", ":=", "Colors", "[", "e", ".", "Level", "]", "\n", "level", ":=", "Strings", "[", "e", ".", "Level", "]", "\n", "var", "fields", "[", "]", "field", "\n", "for", "k", ",", "v", ":=", "range", "e", ".", "Fields", "{", "fields", "=", "append", "(", "fields", ",", "field", "{", "k", ",", "v", "}", ")", "\n", "}", "\n", "sort", ".", "Sort", "(", "byName", "(", "fields", ")", ")", "\n", "h", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "h", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "h", ".", "UseColor", "{", "fmt", ".", "Fprintf", "(", "h", ".", "Writer", ",", "\"\\033[%dm%6s\\033[0m %-40s\"", ",", "\\033", ",", "\\033", ",", "color", ")", "\n", "}", "else", "level", "\n", "e", ".", "Message", "\n", "{", "fmt", ".", "Fprintf", "(", "h", ".", "Writer", ",", "\"%6s %-40s\"", ",", "level", ",", "e", ".", "Message", ")", "\n", "}", "\n", "for", "_", ",", "f", ":=", "range", "fields", "{", "var", "value", "interface", "{", "}", "\n", "switch", "t", ":=", "f", ".", "Value", ".", "(", "type", ")", "{", "case", "[", "]", "byte", ":", "value", "=", "fmt", ".", "Sprintf", "(", "\"%X\"", ",", "t", ")", "\n", "case", "[", "21", "]", "byte", ":", "value", "=", "fmt", ".", "Sprintf", "(", "\"%X-%X-%X-%X\"", ",", "t", "[", "0", "]", ",", "t", "[", "1", ":", "9", "]", ",", "t", "[", "9", ":", "17", "]", ",", "t", "[", "17", ":", "]", ")", "\n", "default", ":", "value", "=", "f", ".", "Value", "\n", "}", "\n", "if", "h", ".", "UseColor", "{", "fmt", ".", "Fprintf", "(", "h", ".", "Writer", ",", "\" \\033[%dm%s\\033[0m=%v\"", ",", "\\033", ",", "\\033", ",", "color", ")", "\n", "}", "else", "f", ".", "Name", "\n", "}", "\n", "}" ]
// HandleLog implements log.Handler.
[ "HandleLog", "implements", "log", ".", "Handler", "." ]
aa2a11bd59104d2a8609328c2b2b55da61826470
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/handlers/cli/cli.go#L92-L135
test
TheThingsNetwork/go-utils
pseudorandom/random.go
New
func New(seed int64) random.Interface { return &TTNRandom{ Interface: &random.TTNRandom{ Source: rand.New(rand.NewSource(seed)), }, } }
go
func New(seed int64) random.Interface { return &TTNRandom{ Interface: &random.TTNRandom{ Source: rand.New(rand.NewSource(seed)), }, } }
[ "func", "New", "(", "seed", "int64", ")", "random", ".", "Interface", "{", "return", "&", "TTNRandom", "{", "Interface", ":", "&", "random", ".", "TTNRandom", "{", "Source", ":", "rand", ".", "New", "(", "rand", ".", "NewSource", "(", "seed", ")", ")", ",", "}", ",", "}", "\n", "}" ]
// New returns a new Random, in most cases you can also just use the global funcs
[ "New", "returns", "a", "new", "Random", "in", "most", "cases", "you", "can", "also", "just", "use", "the", "global", "funcs" ]
aa2a11bd59104d2a8609328c2b2b55da61826470
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/pseudorandom/random.go#L21-L27
test
jtacoma/uritemplates
uritemplates.go
Names
func (self *UriTemplate) Names() []string { names := make([]string, 0, len(self.parts)) for _, p := range self.parts { if len(p.raw) > 0 || len(p.terms) == 0 { continue } for _, term := range p.terms { names = append(names, term.name) } } return names }
go
func (self *UriTemplate) Names() []string { names := make([]string, 0, len(self.parts)) for _, p := range self.parts { if len(p.raw) > 0 || len(p.terms) == 0 { continue } for _, term := range p.terms { names = append(names, term.name) } } return names }
[ "func", "(", "self", "*", "UriTemplate", ")", "Names", "(", ")", "[", "]", "string", "{", "names", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "self", ".", "parts", ")", ")", "\n", "for", "_", ",", "p", ":=", "range", "self", ".", "parts", "{", "if", "len", "(", "p", ".", "raw", ")", ">", "0", "||", "len", "(", "p", ".", "terms", ")", "==", "0", "{", "continue", "\n", "}", "\n", "for", "_", ",", "term", ":=", "range", "p", ".", "terms", "{", "names", "=", "append", "(", "names", ",", "term", ".", "name", ")", "\n", "}", "\n", "}", "\n", "return", "names", "\n", "}" ]
// Names returns the names of all variables within the template.
[ "Names", "returns", "the", "names", "of", "all", "variables", "within", "the", "template", "." ]
307ae868f90f4ee1b73ebe4596e0394237dacce8
https://github.com/jtacoma/uritemplates/blob/307ae868f90f4ee1b73ebe4596e0394237dacce8/uritemplates.go#L192-L206
test
olorin/nagiosplugin
perfdata.go
String
func (p PerfDatum) String() string { val := fmtPerfFloat(p.value) value := fmt.Sprintf("%s=%s%s", p.label, val, p.unit) value += fmt.Sprintf(";%s;%s", fmtThreshold(p.warn), fmtThreshold(p.crit)) value += fmt.Sprintf(";%s;%s", fmtThreshold(p.min), fmtThreshold(p.max)) return value }
go
func (p PerfDatum) String() string { val := fmtPerfFloat(p.value) value := fmt.Sprintf("%s=%s%s", p.label, val, p.unit) value += fmt.Sprintf(";%s;%s", fmtThreshold(p.warn), fmtThreshold(p.crit)) value += fmt.Sprintf(";%s;%s", fmtThreshold(p.min), fmtThreshold(p.max)) return value }
[ "func", "(", "p", "PerfDatum", ")", "String", "(", ")", "string", "{", "val", ":=", "fmtPerfFloat", "(", "p", ".", "value", ")", "\n", "value", ":=", "fmt", ".", "Sprintf", "(", "\"%s=%s%s\"", ",", "p", ".", "label", ",", "val", ",", "p", ".", "unit", ")", "\n", "value", "+=", "fmt", ".", "Sprintf", "(", "\";%s;%s\"", ",", "fmtThreshold", "(", "p", ".", "warn", ")", ",", "fmtThreshold", "(", "p", ".", "crit", ")", ")", "\n", "value", "+=", "fmt", ".", "Sprintf", "(", "\";%s;%s\"", ",", "fmtThreshold", "(", "p", ".", "min", ")", ",", "fmtThreshold", "(", "p", ".", "max", ")", ")", "\n", "return", "value", "\n", "}" ]
// String returns the string representation of a PerfDatum, suitable for // check output.
[ "String", "returns", "the", "string", "representation", "of", "a", "PerfDatum", "suitable", "for", "check", "output", "." ]
893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064
https://github.com/olorin/nagiosplugin/blob/893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064/perfdata.go#L99-L105
test
olorin/nagiosplugin
perfdata.go
RenderPerfdata
func RenderPerfdata(perfdata []PerfDatum) string { value := "" if len(perfdata) == 0 { return value } // Demarcate start of perfdata in check output. value += " |" for _, datum := range perfdata { value += fmt.Sprintf(" %v", datum) } return value }
go
func RenderPerfdata(perfdata []PerfDatum) string { value := "" if len(perfdata) == 0 { return value } // Demarcate start of perfdata in check output. value += " |" for _, datum := range perfdata { value += fmt.Sprintf(" %v", datum) } return value }
[ "func", "RenderPerfdata", "(", "perfdata", "[", "]", "PerfDatum", ")", "string", "{", "value", ":=", "\"\"", "\n", "if", "len", "(", "perfdata", ")", "==", "0", "{", "return", "value", "\n", "}", "\n", "value", "+=", "\" |\"", "\n", "for", "_", ",", "datum", ":=", "range", "perfdata", "{", "value", "+=", "fmt", ".", "Sprintf", "(", "\" %v\"", ",", "datum", ")", "\n", "}", "\n", "return", "value", "\n", "}" ]
// RenderPerfdata accepts a slice of PerfDatum objects and returns their // concatenated string representations in a form suitable to append to // the first line of check output.
[ "RenderPerfdata", "accepts", "a", "slice", "of", "PerfDatum", "objects", "and", "returns", "their", "concatenated", "string", "representations", "in", "a", "form", "suitable", "to", "append", "to", "the", "first", "line", "of", "check", "output", "." ]
893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064
https://github.com/olorin/nagiosplugin/blob/893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064/perfdata.go#L110-L121
test
olorin/nagiosplugin
check.go
Exit
func Exit(status Status, message string) { fmt.Printf("%v: %s\n", status, message) os.Exit(int(status)) }
go
func Exit(status Status, message string) { fmt.Printf("%v: %s\n", status, message) os.Exit(int(status)) }
[ "func", "Exit", "(", "status", "Status", ",", "message", "string", ")", "{", "fmt", ".", "Printf", "(", "\"%v: %s\\n\"", ",", "\\n", ",", "status", ")", "\n", "message", "\n", "}" ]
// Exit is a standalone exit function for simple checks without multiple results // or perfdata.
[ "Exit", "is", "a", "standalone", "exit", "function", "for", "simple", "checks", "without", "multiple", "results", "or", "perfdata", "." ]
893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064
https://github.com/olorin/nagiosplugin/blob/893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064/check.go#L15-L18
test
olorin/nagiosplugin
check.go
NewCheckWithOptions
func NewCheckWithOptions(options CheckOptions) *Check { c := NewCheck() if options.StatusPolicy != nil { c.statusPolicy = options.StatusPolicy } return c }
go
func NewCheckWithOptions(options CheckOptions) *Check { c := NewCheck() if options.StatusPolicy != nil { c.statusPolicy = options.StatusPolicy } return c }
[ "func", "NewCheckWithOptions", "(", "options", "CheckOptions", ")", "*", "Check", "{", "c", ":=", "NewCheck", "(", ")", "\n", "if", "options", ".", "StatusPolicy", "!=", "nil", "{", "c", ".", "statusPolicy", "=", "options", ".", "StatusPolicy", "\n", "}", "\n", "return", "c", "\n", "}" ]
// NewCheckWithOptions returns an empty Check object with // caller-specified behavioural modifications. See CheckOptions.
[ "NewCheckWithOptions", "returns", "an", "empty", "Check", "object", "with", "caller", "-", "specified", "behavioural", "modifications", ".", "See", "CheckOptions", "." ]
893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064
https://github.com/olorin/nagiosplugin/blob/893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064/check.go#L57-L63
test
olorin/nagiosplugin
check.go
AddResult
func (c *Check) AddResult(status Status, message string) { var result Result result.status = status result.message = message c.results = append(c.results, result) if (*c.statusPolicy)[result.status] > (*c.statusPolicy)[c.status] { c.status = result.status } }
go
func (c *Check) AddResult(status Status, message string) { var result Result result.status = status result.message = message c.results = append(c.results, result) if (*c.statusPolicy)[result.status] > (*c.statusPolicy)[c.status] { c.status = result.status } }
[ "func", "(", "c", "*", "Check", ")", "AddResult", "(", "status", "Status", ",", "message", "string", ")", "{", "var", "result", "Result", "\n", "result", ".", "status", "=", "status", "\n", "result", ".", "message", "=", "message", "\n", "c", ".", "results", "=", "append", "(", "c", ".", "results", ",", "result", ")", "\n", "if", "(", "*", "c", ".", "statusPolicy", ")", "[", "result", ".", "status", "]", ">", "(", "*", "c", ".", "statusPolicy", ")", "[", "c", ".", "status", "]", "{", "c", ".", "status", "=", "result", ".", "status", "\n", "}", "\n", "}" ]
// AddResult adds a check result. This will not terminate the check. If // status is the highest yet reported, this will update the check's // final return status.
[ "AddResult", "adds", "a", "check", "result", ".", "This", "will", "not", "terminate", "the", "check", ".", "If", "status", "is", "the", "highest", "yet", "reported", "this", "will", "update", "the", "check", "s", "final", "return", "status", "." ]
893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064
https://github.com/olorin/nagiosplugin/blob/893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064/check.go#L68-L77
test
olorin/nagiosplugin
check.go
AddResultf
func (c *Check) AddResultf(status Status, format string, v ...interface{}) { msg := fmt.Sprintf(format, v...) c.AddResult(status, msg) }
go
func (c *Check) AddResultf(status Status, format string, v ...interface{}) { msg := fmt.Sprintf(format, v...) c.AddResult(status, msg) }
[ "func", "(", "c", "*", "Check", ")", "AddResultf", "(", "status", "Status", ",", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "msg", ":=", "fmt", ".", "Sprintf", "(", "format", ",", "v", "...", ")", "\n", "c", ".", "AddResult", "(", "status", ",", "msg", ")", "\n", "}" ]
// AddResultf functions as AddResult, but takes a printf-style format // string and arguments.
[ "AddResultf", "functions", "as", "AddResult", "but", "takes", "a", "printf", "-", "style", "format", "string", "and", "arguments", "." ]
893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064
https://github.com/olorin/nagiosplugin/blob/893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064/check.go#L81-L84
test
olorin/nagiosplugin
check.go
String
func (c Check) String() string { value := fmt.Sprintf("%v: %s", c.status, c.exitInfoText()) value += RenderPerfdata(c.perfdata) return value }
go
func (c Check) String() string { value := fmt.Sprintf("%v: %s", c.status, c.exitInfoText()) value += RenderPerfdata(c.perfdata) return value }
[ "func", "(", "c", "Check", ")", "String", "(", ")", "string", "{", "value", ":=", "fmt", ".", "Sprintf", "(", "\"%v: %s\"", ",", "c", ".", "status", ",", "c", ".", "exitInfoText", "(", ")", ")", "\n", "value", "+=", "RenderPerfdata", "(", "c", ".", "perfdata", ")", "\n", "return", "value", "\n", "}" ]
// String representation of the check results, suitable for output and // parsing by Nagios.
[ "String", "representation", "of", "the", "check", "results", "suitable", "for", "output", "and", "parsing", "by", "Nagios", "." ]
893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064
https://github.com/olorin/nagiosplugin/blob/893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064/check.go#L125-L129
test
olorin/nagiosplugin
check.go
Exitf
func (c *Check) Exitf(status Status, format string, v ...interface{}) { info := fmt.Sprintf(format, v...) c.AddResult(status, info) c.Finish() }
go
func (c *Check) Exitf(status Status, format string, v ...interface{}) { info := fmt.Sprintf(format, v...) c.AddResult(status, info) c.Finish() }
[ "func", "(", "c", "*", "Check", ")", "Exitf", "(", "status", "Status", ",", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "info", ":=", "fmt", ".", "Sprintf", "(", "format", ",", "v", "...", ")", "\n", "c", ".", "AddResult", "(", "status", ",", "info", ")", "\n", "c", ".", "Finish", "(", ")", "\n", "}" ]
// Exitf takes a status plus a format string, and a list of // parameters to pass to Sprintf. It then immediately outputs and exits.
[ "Exitf", "takes", "a", "status", "plus", "a", "format", "string", "and", "a", "list", "of", "parameters", "to", "pass", "to", "Sprintf", ".", "It", "then", "immediately", "outputs", "and", "exits", "." ]
893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064
https://github.com/olorin/nagiosplugin/blob/893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064/check.go#L146-L150
test
olorin/nagiosplugin
check.go
Criticalf
func (c *Check) Criticalf(format string, v ...interface{}) { c.Exitf(CRITICAL, format, v...) }
go
func (c *Check) Criticalf(format string, v ...interface{}) { c.Exitf(CRITICAL, format, v...) }
[ "func", "(", "c", "*", "Check", ")", "Criticalf", "(", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "c", ".", "Exitf", "(", "CRITICAL", ",", "format", ",", "v", "...", ")", "\n", "}" ]
// Criticalf is a shorthand function which exits the check with status // CRITICAL and the message provided.
[ "Criticalf", "is", "a", "shorthand", "function", "which", "exits", "the", "check", "with", "status", "CRITICAL", "and", "the", "message", "provided", "." ]
893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064
https://github.com/olorin/nagiosplugin/blob/893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064/check.go#L154-L156
test
olorin/nagiosplugin
check.go
Unknownf
func (c *Check) Unknownf(format string, v ...interface{}) { c.Exitf(UNKNOWN, format, v...) }
go
func (c *Check) Unknownf(format string, v ...interface{}) { c.Exitf(UNKNOWN, format, v...) }
[ "func", "(", "c", "*", "Check", ")", "Unknownf", "(", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "c", ".", "Exitf", "(", "UNKNOWN", ",", "format", ",", "v", "...", ")", "\n", "}" ]
// Unknownf is a shorthand function which exits the check with status // UNKNOWN and the message provided.
[ "Unknownf", "is", "a", "shorthand", "function", "which", "exits", "the", "check", "with", "status", "UNKNOWN", "and", "the", "message", "provided", "." ]
893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064
https://github.com/olorin/nagiosplugin/blob/893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064/check.go#L160-L162
test
olorin/nagiosplugin
result.go
NewDefaultStatusPolicy
func NewDefaultStatusPolicy() *statusPolicy { return &statusPolicy{ OK: statusSeverity(OK), WARNING: statusSeverity(WARNING), CRITICAL: statusSeverity(CRITICAL), UNKNOWN: statusSeverity(UNKNOWN), } }
go
func NewDefaultStatusPolicy() *statusPolicy { return &statusPolicy{ OK: statusSeverity(OK), WARNING: statusSeverity(WARNING), CRITICAL: statusSeverity(CRITICAL), UNKNOWN: statusSeverity(UNKNOWN), } }
[ "func", "NewDefaultStatusPolicy", "(", ")", "*", "statusPolicy", "{", "return", "&", "statusPolicy", "{", "OK", ":", "statusSeverity", "(", "OK", ")", ",", "WARNING", ":", "statusSeverity", "(", "WARNING", ")", ",", "CRITICAL", ":", "statusSeverity", "(", "CRITICAL", ")", ",", "UNKNOWN", ":", "statusSeverity", "(", "UNKNOWN", ")", ",", "}", "\n", "}" ]
// NewDefaultStatusPolicy returns a status policy that assigns relative // severity in accordance with conventional Nagios plugin return codes. // Statuses associated with higher return codes are more severe.
[ "NewDefaultStatusPolicy", "returns", "a", "status", "policy", "that", "assigns", "relative", "severity", "in", "accordance", "with", "conventional", "Nagios", "plugin", "return", "codes", ".", "Statuses", "associated", "with", "higher", "return", "codes", "are", "more", "severe", "." ]
893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064
https://github.com/olorin/nagiosplugin/blob/893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064/result.go#L29-L36
test
olorin/nagiosplugin
result.go
NewStatusPolicy
func NewStatusPolicy(statuses []Status) (*statusPolicy, error) { newPol := make(statusPolicy) for i, status := range statuses { newPol[status] = statusSeverity(i) } // Ensure all statuses are covered by the new policy. defaultPol := NewDefaultStatusPolicy() for status := range *defaultPol { _, ok := newPol[status] if !ok { return nil, fmt.Errorf("missing status: %v", status) } } return &newPol, nil }
go
func NewStatusPolicy(statuses []Status) (*statusPolicy, error) { newPol := make(statusPolicy) for i, status := range statuses { newPol[status] = statusSeverity(i) } // Ensure all statuses are covered by the new policy. defaultPol := NewDefaultStatusPolicy() for status := range *defaultPol { _, ok := newPol[status] if !ok { return nil, fmt.Errorf("missing status: %v", status) } } return &newPol, nil }
[ "func", "NewStatusPolicy", "(", "statuses", "[", "]", "Status", ")", "(", "*", "statusPolicy", ",", "error", ")", "{", "newPol", ":=", "make", "(", "statusPolicy", ")", "\n", "for", "i", ",", "status", ":=", "range", "statuses", "{", "newPol", "[", "status", "]", "=", "statusSeverity", "(", "i", ")", "\n", "}", "\n", "defaultPol", ":=", "NewDefaultStatusPolicy", "(", ")", "\n", "for", "status", ":=", "range", "*", "defaultPol", "{", "_", ",", "ok", ":=", "newPol", "[", "status", "]", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"missing status: %v\"", ",", "status", ")", "\n", "}", "\n", "}", "\n", "return", "&", "newPol", ",", "nil", "\n", "}" ]
// NewStatusPolicy returns a status policy that assigns relative // severity in accordance with a user-configurable prioritised slice. // Check statuses must be listed in ascending severity order.
[ "NewStatusPolicy", "returns", "a", "status", "policy", "that", "assigns", "relative", "severity", "in", "accordance", "with", "a", "user", "-", "configurable", "prioritised", "slice", ".", "Check", "statuses", "must", "be", "listed", "in", "ascending", "severity", "order", "." ]
893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064
https://github.com/olorin/nagiosplugin/blob/893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064/result.go#L50-L66
test
olorin/nagiosplugin
range.go
ParseRange
func ParseRange(rangeStr string) (*Range, error) { // Set defaults t := &Range{ Start: 0, End: math.Inf(1), AlertOnInside: false, } // Remove leading and trailing whitespace rangeStr = strings.Trim(rangeStr, " \n\r") // Check for inverted semantics if rangeStr[0] == '@' { t.AlertOnInside = true rangeStr = rangeStr[1:] } // Parse lower limit endPos := strings.Index(rangeStr, ":") if endPos > -1 { if rangeStr[0] == '~' { t.Start = math.Inf(-1) } else { min, err := strconv.ParseFloat(rangeStr[0:endPos], 64) if err != nil { return nil, fmt.Errorf("failed to parse lower limit: %v", err) } t.Start = min } rangeStr = rangeStr[endPos+1:] } // Parse upper limit if len(rangeStr) > 0 { max, err := strconv.ParseFloat(rangeStr, 64) if err != nil { return nil, fmt.Errorf("failed to parse upper limit: %v", err) } t.End = max } if t.End < t.Start { return nil, errors.New("Invalid range definition. min <= max violated!") } // OK return t, nil }
go
func ParseRange(rangeStr string) (*Range, error) { // Set defaults t := &Range{ Start: 0, End: math.Inf(1), AlertOnInside: false, } // Remove leading and trailing whitespace rangeStr = strings.Trim(rangeStr, " \n\r") // Check for inverted semantics if rangeStr[0] == '@' { t.AlertOnInside = true rangeStr = rangeStr[1:] } // Parse lower limit endPos := strings.Index(rangeStr, ":") if endPos > -1 { if rangeStr[0] == '~' { t.Start = math.Inf(-1) } else { min, err := strconv.ParseFloat(rangeStr[0:endPos], 64) if err != nil { return nil, fmt.Errorf("failed to parse lower limit: %v", err) } t.Start = min } rangeStr = rangeStr[endPos+1:] } // Parse upper limit if len(rangeStr) > 0 { max, err := strconv.ParseFloat(rangeStr, 64) if err != nil { return nil, fmt.Errorf("failed to parse upper limit: %v", err) } t.End = max } if t.End < t.Start { return nil, errors.New("Invalid range definition. min <= max violated!") } // OK return t, nil }
[ "func", "ParseRange", "(", "rangeStr", "string", ")", "(", "*", "Range", ",", "error", ")", "{", "t", ":=", "&", "Range", "{", "Start", ":", "0", ",", "End", ":", "math", ".", "Inf", "(", "1", ")", ",", "AlertOnInside", ":", "false", ",", "}", "\n", "rangeStr", "=", "strings", ".", "Trim", "(", "rangeStr", ",", "\" \\n\\r\"", ")", "\n", "\\n", "\n", "\\r", "\n", "if", "rangeStr", "[", "0", "]", "==", "'@'", "{", "t", ".", "AlertOnInside", "=", "true", "\n", "rangeStr", "=", "rangeStr", "[", "1", ":", "]", "\n", "}", "\n", "endPos", ":=", "strings", ".", "Index", "(", "rangeStr", ",", "\":\"", ")", "\n", "if", "endPos", ">", "-", "1", "{", "if", "rangeStr", "[", "0", "]", "==", "'~'", "{", "t", ".", "Start", "=", "math", ".", "Inf", "(", "-", "1", ")", "\n", "}", "else", "{", "min", ",", "err", ":=", "strconv", ".", "ParseFloat", "(", "rangeStr", "[", "0", ":", "endPos", "]", ",", "64", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"failed to parse lower limit: %v\"", ",", "err", ")", "\n", "}", "\n", "t", ".", "Start", "=", "min", "\n", "}", "\n", "rangeStr", "=", "rangeStr", "[", "endPos", "+", "1", ":", "]", "\n", "}", "\n", "if", "len", "(", "rangeStr", ")", ">", "0", "{", "max", ",", "err", ":=", "strconv", ".", "ParseFloat", "(", "rangeStr", ",", "64", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"failed to parse upper limit: %v\"", ",", "err", ")", "\n", "}", "\n", "t", ".", "End", "=", "max", "\n", "}", "\n", "}" ]
// ParseRange returns a new range object and nil if the given range definition was // valid, or nil and an error if it was invalid.
[ "ParseRange", "returns", "a", "new", "range", "object", "and", "nil", "if", "the", "given", "range", "definition", "was", "valid", "or", "nil", "and", "an", "error", "if", "it", "was", "invalid", "." ]
893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064
https://github.com/olorin/nagiosplugin/blob/893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064/range.go#L24-L70
test
olorin/nagiosplugin
range.go
Check
func (r *Range) Check(value float64) bool { // Ranges are treated as a closed interval. if r.Start <= value && value <= r.End { return r.AlertOnInside } return !r.AlertOnInside }
go
func (r *Range) Check(value float64) bool { // Ranges are treated as a closed interval. if r.Start <= value && value <= r.End { return r.AlertOnInside } return !r.AlertOnInside }
[ "func", "(", "r", "*", "Range", ")", "Check", "(", "value", "float64", ")", "bool", "{", "if", "r", ".", "Start", "<=", "value", "&&", "value", "<=", "r", ".", "End", "{", "return", "r", ".", "AlertOnInside", "\n", "}", "\n", "return", "!", "r", ".", "AlertOnInside", "\n", "}" ]
// Check returns true if an alert should be raised based on the range (if the // value is outside the range for normal semantics, or if the value is // inside the range for inverted semantics ('@-semantics')).
[ "Check", "returns", "true", "if", "an", "alert", "should", "be", "raised", "based", "on", "the", "range", "(", "if", "the", "value", "is", "outside", "the", "range", "for", "normal", "semantics", "or", "if", "the", "value", "is", "inside", "the", "range", "for", "inverted", "semantics", "(" ]
893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064
https://github.com/olorin/nagiosplugin/blob/893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064/range.go#L75-L81
test
olorin/nagiosplugin
range.go
CheckInt
func (r *Range) CheckInt(val int) bool { return r.Check(float64(val)) }
go
func (r *Range) CheckInt(val int) bool { return r.Check(float64(val)) }
[ "func", "(", "r", "*", "Range", ")", "CheckInt", "(", "val", "int", ")", "bool", "{", "return", "r", ".", "Check", "(", "float64", "(", "val", ")", ")", "\n", "}" ]
// CheckInt is a convenience method which does an unchecked type // conversion from an int to a float64.
[ "CheckInt", "is", "a", "convenience", "method", "which", "does", "an", "unchecked", "type", "conversion", "from", "an", "int", "to", "a", "float64", "." ]
893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064
https://github.com/olorin/nagiosplugin/blob/893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064/range.go#L85-L87
test
olorin/nagiosplugin
range.go
CheckUint64
func (r *Range) CheckUint64(val uint64) bool { return r.Check(float64(val)) }
go
func (r *Range) CheckUint64(val uint64) bool { return r.Check(float64(val)) }
[ "func", "(", "r", "*", "Range", ")", "CheckUint64", "(", "val", "uint64", ")", "bool", "{", "return", "r", ".", "Check", "(", "float64", "(", "val", ")", ")", "\n", "}" ]
// CheckUint64 is a convenience method which does an unchecked type // conversion from an uint64 to a float64.
[ "CheckUint64", "is", "a", "convenience", "method", "which", "does", "an", "unchecked", "type", "conversion", "from", "an", "uint64", "to", "a", "float64", "." ]
893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064
https://github.com/olorin/nagiosplugin/blob/893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064/range.go#L91-L93
test
apparentlymart/go-rundeck-api
rundeck/client.go
NewClient
func NewClient(config *ClientConfig) (*Client, error) { t := &http.Transport{ TLSClientConfig: &tls.Config{ InsecureSkipVerify: config.AllowUnverifiedSSL, }, } httpClient := &http.Client{ Transport: t, } apiPath, _ := url.Parse("api/13/") baseURL, err := url.Parse(config.BaseURL) if err != nil { return nil, fmt.Errorf("invalid base URL: %s", err.Error()) } apiURL := baseURL.ResolveReference(apiPath) return &Client{ httpClient: httpClient, apiURL: apiURL, authToken: config.AuthToken, }, nil }
go
func NewClient(config *ClientConfig) (*Client, error) { t := &http.Transport{ TLSClientConfig: &tls.Config{ InsecureSkipVerify: config.AllowUnverifiedSSL, }, } httpClient := &http.Client{ Transport: t, } apiPath, _ := url.Parse("api/13/") baseURL, err := url.Parse(config.BaseURL) if err != nil { return nil, fmt.Errorf("invalid base URL: %s", err.Error()) } apiURL := baseURL.ResolveReference(apiPath) return &Client{ httpClient: httpClient, apiURL: apiURL, authToken: config.AuthToken, }, nil }
[ "func", "NewClient", "(", "config", "*", "ClientConfig", ")", "(", "*", "Client", ",", "error", ")", "{", "t", ":=", "&", "http", ".", "Transport", "{", "TLSClientConfig", ":", "&", "tls", ".", "Config", "{", "InsecureSkipVerify", ":", "config", ".", "AllowUnverifiedSSL", ",", "}", ",", "}", "\n", "httpClient", ":=", "&", "http", ".", "Client", "{", "Transport", ":", "t", ",", "}", "\n", "apiPath", ",", "_", ":=", "url", ".", "Parse", "(", "\"api/13/\"", ")", "\n", "baseURL", ",", "err", ":=", "url", ".", "Parse", "(", "config", ".", "BaseURL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"invalid base URL: %s\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "apiURL", ":=", "baseURL", ".", "ResolveReference", "(", "apiPath", ")", "\n", "return", "&", "Client", "{", "httpClient", ":", "httpClient", ",", "apiURL", ":", "apiURL", ",", "authToken", ":", "config", ".", "AuthToken", ",", "}", ",", "nil", "\n", "}" ]
// NewClient returns a configured Rundeck client.
[ "NewClient", "returns", "a", "configured", "Rundeck", "client", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/client.go#L50-L72
test
apparentlymart/go-rundeck-api
rundeck/key.go
GetKeyMeta
func (c *Client) GetKeyMeta(path string) (*KeyMeta, error) { k := &KeyMeta{} err := c.get([]string{"storage", "keys", path}, nil, k) return k, err }
go
func (c *Client) GetKeyMeta(path string) (*KeyMeta, error) { k := &KeyMeta{} err := c.get([]string{"storage", "keys", path}, nil, k) return k, err }
[ "func", "(", "c", "*", "Client", ")", "GetKeyMeta", "(", "path", "string", ")", "(", "*", "KeyMeta", ",", "error", ")", "{", "k", ":=", "&", "KeyMeta", "{", "}", "\n", "err", ":=", "c", ".", "get", "(", "[", "]", "string", "{", "\"storage\"", ",", "\"keys\"", ",", "path", "}", ",", "nil", ",", "k", ")", "\n", "return", "k", ",", "err", "\n", "}" ]
// GetKeyMeta returns the metadata for the key at the given keystore path.
[ "GetKeyMeta", "returns", "the", "metadata", "for", "the", "key", "at", "the", "given", "keystore", "path", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/key.go#L25-L29
test
apparentlymart/go-rundeck-api
rundeck/key.go
GetKeysInDirMeta
func (c *Client) GetKeysInDirMeta(path string) ([]KeyMeta, error) { r := &keyMetaListContents{} err := c.get([]string{"storage", "keys", path}, nil, r) if err != nil { return nil, err } return r.Keys, nil }
go
func (c *Client) GetKeysInDirMeta(path string) ([]KeyMeta, error) { r := &keyMetaListContents{} err := c.get([]string{"storage", "keys", path}, nil, r) if err != nil { return nil, err } return r.Keys, nil }
[ "func", "(", "c", "*", "Client", ")", "GetKeysInDirMeta", "(", "path", "string", ")", "(", "[", "]", "KeyMeta", ",", "error", ")", "{", "r", ":=", "&", "keyMetaListContents", "{", "}", "\n", "err", ":=", "c", ".", "get", "(", "[", "]", "string", "{", "\"storage\"", ",", "\"keys\"", ",", "path", "}", ",", "nil", ",", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "r", ".", "Keys", ",", "nil", "\n", "}" ]
// GetKeysInDirMeta returns the metadata for the keys and subdirectories within // the directory at the given keystore path.
[ "GetKeysInDirMeta", "returns", "the", "metadata", "for", "the", "keys", "and", "subdirectories", "within", "the", "directory", "at", "the", "given", "keystore", "path", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/key.go#L33-L40
test
apparentlymart/go-rundeck-api
rundeck/key.go
GetKeyContent
func (c *Client) GetKeyContent(path string) (string, error) { return c.rawGet([]string{"storage", "keys", path}, nil, "application/pgp-keys") }
go
func (c *Client) GetKeyContent(path string) (string, error) { return c.rawGet([]string{"storage", "keys", path}, nil, "application/pgp-keys") }
[ "func", "(", "c", "*", "Client", ")", "GetKeyContent", "(", "path", "string", ")", "(", "string", ",", "error", ")", "{", "return", "c", ".", "rawGet", "(", "[", "]", "string", "{", "\"storage\"", ",", "\"keys\"", ",", "path", "}", ",", "nil", ",", "\"application/pgp-keys\"", ")", "\n", "}" ]
// GetKeyContent retrieves and returns the content of the key at the given keystore path. // Private keys are write-only, so they cannot be retrieved via this interface.
[ "GetKeyContent", "retrieves", "and", "returns", "the", "content", "of", "the", "key", "at", "the", "given", "keystore", "path", ".", "Private", "keys", "are", "write", "-", "only", "so", "they", "cannot", "be", "retrieved", "via", "this", "interface", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/key.go#L44-L46
test
apparentlymart/go-rundeck-api
rundeck/job.go
GetJobSummariesForProject
func (c *Client) GetJobSummariesForProject(projectName string) ([]JobSummary, error) { jobList := &jobSummaryList{} err := c.get([]string{"project", projectName, "jobs"}, nil, jobList) return jobList.Jobs, err }
go
func (c *Client) GetJobSummariesForProject(projectName string) ([]JobSummary, error) { jobList := &jobSummaryList{} err := c.get([]string{"project", projectName, "jobs"}, nil, jobList) return jobList.Jobs, err }
[ "func", "(", "c", "*", "Client", ")", "GetJobSummariesForProject", "(", "projectName", "string", ")", "(", "[", "]", "JobSummary", ",", "error", ")", "{", "jobList", ":=", "&", "jobSummaryList", "{", "}", "\n", "err", ":=", "c", ".", "get", "(", "[", "]", "string", "{", "\"project\"", ",", "projectName", ",", "\"jobs\"", "}", ",", "nil", ",", "jobList", ")", "\n", "return", "jobList", ".", "Jobs", ",", "err", "\n", "}" ]
// GetJobSummariesForProject returns summaries of the jobs belonging to the named project.
[ "GetJobSummariesForProject", "returns", "summaries", "of", "the", "jobs", "belonging", "to", "the", "named", "project", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/job.go#L310-L314
test
apparentlymart/go-rundeck-api
rundeck/job.go
GetJobsForProject
func (c *Client) GetJobsForProject(projectName string) ([]JobDetail, error) { jobList := &jobDetailList{} err := c.get([]string{"jobs", "export"}, map[string]string{"project": projectName}, jobList) if err != nil { return nil, err } return jobList.Jobs, nil }
go
func (c *Client) GetJobsForProject(projectName string) ([]JobDetail, error) { jobList := &jobDetailList{} err := c.get([]string{"jobs", "export"}, map[string]string{"project": projectName}, jobList) if err != nil { return nil, err } return jobList.Jobs, nil }
[ "func", "(", "c", "*", "Client", ")", "GetJobsForProject", "(", "projectName", "string", ")", "(", "[", "]", "JobDetail", ",", "error", ")", "{", "jobList", ":=", "&", "jobDetailList", "{", "}", "\n", "err", ":=", "c", ".", "get", "(", "[", "]", "string", "{", "\"jobs\"", ",", "\"export\"", "}", ",", "map", "[", "string", "]", "string", "{", "\"project\"", ":", "projectName", "}", ",", "jobList", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "jobList", ".", "Jobs", ",", "nil", "\n", "}" ]
// GetJobsForProject returns the full job details of the jobs belonging to the named project.
[ "GetJobsForProject", "returns", "the", "full", "job", "details", "of", "the", "jobs", "belonging", "to", "the", "named", "project", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/job.go#L317-L324
test
apparentlymart/go-rundeck-api
rundeck/job.go
GetJob
func (c *Client) GetJob(id string) (*JobDetail, error) { jobList := &jobDetailList{} err := c.get([]string{"job", id}, nil, jobList) if err != nil { return nil, err } return &jobList.Jobs[0], nil }
go
func (c *Client) GetJob(id string) (*JobDetail, error) { jobList := &jobDetailList{} err := c.get([]string{"job", id}, nil, jobList) if err != nil { return nil, err } return &jobList.Jobs[0], nil }
[ "func", "(", "c", "*", "Client", ")", "GetJob", "(", "id", "string", ")", "(", "*", "JobDetail", ",", "error", ")", "{", "jobList", ":=", "&", "jobDetailList", "{", "}", "\n", "err", ":=", "c", ".", "get", "(", "[", "]", "string", "{", "\"job\"", ",", "id", "}", ",", "nil", ",", "jobList", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "jobList", ".", "Jobs", "[", "0", "]", ",", "nil", "\n", "}" ]
// GetJob returns the full job details of the job with the given id.
[ "GetJob", "returns", "the", "full", "job", "details", "of", "the", "job", "with", "the", "given", "id", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/job.go#L327-L334
test
apparentlymart/go-rundeck-api
rundeck/job.go
CreateJob
func (c *Client) CreateJob(job *JobDetail) (*JobSummary, error) { return c.importJob(job, "create") }
go
func (c *Client) CreateJob(job *JobDetail) (*JobSummary, error) { return c.importJob(job, "create") }
[ "func", "(", "c", "*", "Client", ")", "CreateJob", "(", "job", "*", "JobDetail", ")", "(", "*", "JobSummary", ",", "error", ")", "{", "return", "c", ".", "importJob", "(", "job", ",", "\"create\"", ")", "\n", "}" ]
// CreateJob creates a new job based on the provided structure.
[ "CreateJob", "creates", "a", "new", "job", "based", "on", "the", "provided", "structure", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/job.go#L337-L339
test
apparentlymart/go-rundeck-api
rundeck/job.go
CreateOrUpdateJob
func (c *Client) CreateOrUpdateJob(job *JobDetail) (*JobSummary, error) { return c.importJob(job, "update") }
go
func (c *Client) CreateOrUpdateJob(job *JobDetail) (*JobSummary, error) { return c.importJob(job, "update") }
[ "func", "(", "c", "*", "Client", ")", "CreateOrUpdateJob", "(", "job", "*", "JobDetail", ")", "(", "*", "JobSummary", ",", "error", ")", "{", "return", "c", ".", "importJob", "(", "job", ",", "\"update\"", ")", "\n", "}" ]
// CreateOrUpdateJob takes a job detail structure which has its ID set and either updates // an existing job with the same id or creates a new job with that id.
[ "CreateOrUpdateJob", "takes", "a", "job", "detail", "structure", "which", "has", "its", "ID", "set", "and", "either", "updates", "an", "existing", "job", "with", "the", "same", "id", "or", "creates", "a", "new", "job", "with", "that", "id", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/job.go#L343-L345
test
apparentlymart/go-rundeck-api
rundeck/job.go
DeleteJob
func (c *Client) DeleteJob(id string) error { return c.delete([]string{"job", id}) }
go
func (c *Client) DeleteJob(id string) error { return c.delete([]string{"job", id}) }
[ "func", "(", "c", "*", "Client", ")", "DeleteJob", "(", "id", "string", ")", "error", "{", "return", "c", ".", "delete", "(", "[", "]", "string", "{", "\"job\"", ",", "id", "}", ")", "\n", "}" ]
// DeleteJob deletes the job with the given id.
[ "DeleteJob", "deletes", "the", "job", "with", "the", "given", "id", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/job.go#L377-L379
test
apparentlymart/go-rundeck-api
rundeck/job.go
JobSummary
func (r *jobImportResult) JobSummary() *JobSummary { return &JobSummary{ ID: r.ID, Name: r.Name, GroupName: r.GroupName, ProjectName: r.ProjectName, } }
go
func (r *jobImportResult) JobSummary() *JobSummary { return &JobSummary{ ID: r.ID, Name: r.Name, GroupName: r.GroupName, ProjectName: r.ProjectName, } }
[ "func", "(", "r", "*", "jobImportResult", ")", "JobSummary", "(", ")", "*", "JobSummary", "{", "return", "&", "JobSummary", "{", "ID", ":", "r", ".", "ID", ",", "Name", ":", "r", ".", "Name", ",", "GroupName", ":", "r", ".", "GroupName", ",", "ProjectName", ":", "r", ".", "ProjectName", ",", "}", "\n", "}" ]
// JobSummary produces a JobSummary instance with values populated from the import result. // The summary object won't have its Description populated, since import results do not // include descriptions.
[ "JobSummary", "produces", "a", "JobSummary", "instance", "with", "values", "populated", "from", "the", "import", "result", ".", "The", "summary", "object", "won", "t", "have", "its", "Description", "populated", "since", "import", "results", "do", "not", "include", "descriptions", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/job.go#L457-L464
test
apparentlymart/go-rundeck-api
rundeck/system_info.go
GetSystemInfo
func (c *Client) GetSystemInfo() (*SystemInfo, error) { sysInfo := &SystemInfo{} err := c.get([]string{"system", "info"}, nil, sysInfo) return sysInfo, err }
go
func (c *Client) GetSystemInfo() (*SystemInfo, error) { sysInfo := &SystemInfo{} err := c.get([]string{"system", "info"}, nil, sysInfo) return sysInfo, err }
[ "func", "(", "c", "*", "Client", ")", "GetSystemInfo", "(", ")", "(", "*", "SystemInfo", ",", "error", ")", "{", "sysInfo", ":=", "&", "SystemInfo", "{", "}", "\n", "err", ":=", "c", ".", "get", "(", "[", "]", "string", "{", "\"system\"", ",", "\"info\"", "}", ",", "nil", ",", "sysInfo", ")", "\n", "return", "sysInfo", ",", "err", "\n", "}" ]
// GetSystemInfo retrieves and returns miscellaneous system information about the Rundeck server // and the machine it's running on.
[ "GetSystemInfo", "retrieves", "and", "returns", "miscellaneous", "system", "information", "about", "the", "Rundeck", "server", "and", "the", "machine", "it", "s", "running", "on", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/system_info.go#L103-L107
test
apparentlymart/go-rundeck-api
rundeck/system_info.go
DateTime
func (ts *SystemTimestamp) DateTime() time.Time { // Assume the server will always give us a valid timestamp, // so we don't need to handle the error case. // (Famous last words?) t, _ := time.Parse(time.RFC3339, ts.DateTimeStr) return t }
go
func (ts *SystemTimestamp) DateTime() time.Time { // Assume the server will always give us a valid timestamp, // so we don't need to handle the error case. // (Famous last words?) t, _ := time.Parse(time.RFC3339, ts.DateTimeStr) return t }
[ "func", "(", "ts", "*", "SystemTimestamp", ")", "DateTime", "(", ")", "time", ".", "Time", "{", "t", ",", "_", ":=", "time", ".", "Parse", "(", "time", ".", "RFC3339", ",", "ts", ".", "DateTimeStr", ")", "\n", "return", "t", "\n", "}" ]
// DateTime produces a time.Time object from a SystemTimestamp object.
[ "DateTime", "produces", "a", "time", ".", "Time", "object", "from", "a", "SystemTimestamp", "object", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/system_info.go#L110-L116
test
apparentlymart/go-rundeck-api
rundeck/project.go
GetAllProjects
func (c *Client) GetAllProjects() ([]ProjectSummary, error) { p := &projects{} err := c.get([]string{"projects"}, nil, p) return p.Projects, err }
go
func (c *Client) GetAllProjects() ([]ProjectSummary, error) { p := &projects{} err := c.get([]string{"projects"}, nil, p) return p.Projects, err }
[ "func", "(", "c", "*", "Client", ")", "GetAllProjects", "(", ")", "(", "[", "]", "ProjectSummary", ",", "error", ")", "{", "p", ":=", "&", "projects", "{", "}", "\n", "err", ":=", "c", ".", "get", "(", "[", "]", "string", "{", "\"projects\"", "}", ",", "nil", ",", "p", ")", "\n", "return", "p", ".", "Projects", ",", "err", "\n", "}" ]
// GetAllProjects retrieves and returns all of the projects defined in the Rundeck server.
[ "GetAllProjects", "retrieves", "and", "returns", "all", "of", "the", "projects", "defined", "in", "the", "Rundeck", "server", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/project.go#L45-L49
test
apparentlymart/go-rundeck-api
rundeck/project.go
GetProject
func (c *Client) GetProject(name string) (*Project, error) { p := &Project{} err := c.get([]string{"project", name}, nil, p) return p, err }
go
func (c *Client) GetProject(name string) (*Project, error) { p := &Project{} err := c.get([]string{"project", name}, nil, p) return p, err }
[ "func", "(", "c", "*", "Client", ")", "GetProject", "(", "name", "string", ")", "(", "*", "Project", ",", "error", ")", "{", "p", ":=", "&", "Project", "{", "}", "\n", "err", ":=", "c", ".", "get", "(", "[", "]", "string", "{", "\"project\"", ",", "name", "}", ",", "nil", ",", "p", ")", "\n", "return", "p", ",", "err", "\n", "}" ]
// GetProject retrieves and returns the named project.
[ "GetProject", "retrieves", "and", "returns", "the", "named", "project", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/project.go#L52-L56
test
apparentlymart/go-rundeck-api
rundeck/project.go
CreateProject
func (c *Client) CreateProject(project *Project) (*Project, error) { p := &Project{} err := c.post([]string{"projects"}, nil, project, p) return p, err }
go
func (c *Client) CreateProject(project *Project) (*Project, error) { p := &Project{} err := c.post([]string{"projects"}, nil, project, p) return p, err }
[ "func", "(", "c", "*", "Client", ")", "CreateProject", "(", "project", "*", "Project", ")", "(", "*", "Project", ",", "error", ")", "{", "p", ":=", "&", "Project", "{", "}", "\n", "err", ":=", "c", ".", "post", "(", "[", "]", "string", "{", "\"projects\"", "}", ",", "nil", ",", "project", ",", "p", ")", "\n", "return", "p", ",", "err", "\n", "}" ]
// CreateProject creates a new, empty project.
[ "CreateProject", "creates", "a", "new", "empty", "project", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/project.go#L59-L63
test
apparentlymart/go-rundeck-api
rundeck/project.go
DeleteProject
func (c *Client) DeleteProject(name string) error { return c.delete([]string{"project", name}) }
go
func (c *Client) DeleteProject(name string) error { return c.delete([]string{"project", name}) }
[ "func", "(", "c", "*", "Client", ")", "DeleteProject", "(", "name", "string", ")", "error", "{", "return", "c", ".", "delete", "(", "[", "]", "string", "{", "\"project\"", ",", "name", "}", ")", "\n", "}" ]
// DeleteProject deletes a project and all of its jobs.
[ "DeleteProject", "deletes", "a", "project", "and", "all", "of", "its", "jobs", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/project.go#L66-L68
test
apparentlymart/go-rundeck-api
rundeck/project.go
SetProjectConfig
func (c *Client) SetProjectConfig(projectName string, config ProjectConfig) error { return c.put( []string{"project", projectName, "config"}, config, nil, ) }
go
func (c *Client) SetProjectConfig(projectName string, config ProjectConfig) error { return c.put( []string{"project", projectName, "config"}, config, nil, ) }
[ "func", "(", "c", "*", "Client", ")", "SetProjectConfig", "(", "projectName", "string", ",", "config", "ProjectConfig", ")", "error", "{", "return", "c", ".", "put", "(", "[", "]", "string", "{", "\"project\"", ",", "projectName", ",", "\"config\"", "}", ",", "config", ",", "nil", ",", ")", "\n", "}" ]
// SetProjectConfig replaces the configuration of the named project.
[ "SetProjectConfig", "replaces", "the", "configuration", "of", "the", "named", "project", "." ]
2c962acae81080a937c350a5bea054c239f27a81
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/project.go#L71-L77
test
profitbricks/profitbricks-sdk-go
profitbricks.go
NewClient
func NewClient(username, password string) *Client { c := newPBRestClient(username, password, "", "", true) return &Client{ userName: c.username, password: c.password, client: c, } }
go
func NewClient(username, password string) *Client { c := newPBRestClient(username, password, "", "", true) return &Client{ userName: c.username, password: c.password, client: c, } }
[ "func", "NewClient", "(", "username", ",", "password", "string", ")", "*", "Client", "{", "c", ":=", "newPBRestClient", "(", "username", ",", "password", ",", "\"\"", ",", "\"\"", ",", "true", ")", "\n", "return", "&", "Client", "{", "userName", ":", "c", ".", "username", ",", "password", ":", "c", ".", "password", ",", "client", ":", "c", ",", "}", "\n", "}" ]
//NewClient is a constructor for Client object
[ "NewClient", "is", "a", "constructor", "for", "Client", "object" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/profitbricks.go#L15-L23
test
profitbricks/profitbricks-sdk-go
profitbricks.go
NewClientbyToken
func NewClientbyToken(token string) *Client { c := newPBRestClientbyToken(token, "", "", true) return &Client{ token: c.token, client: c, } }
go
func NewClientbyToken(token string) *Client { c := newPBRestClientbyToken(token, "", "", true) return &Client{ token: c.token, client: c, } }
[ "func", "NewClientbyToken", "(", "token", "string", ")", "*", "Client", "{", "c", ":=", "newPBRestClientbyToken", "(", "token", ",", "\"\"", ",", "\"\"", ",", "true", ")", "\n", "return", "&", "Client", "{", "token", ":", "c", ".", "token", ",", "client", ":", "c", ",", "}", "\n", "}" ]
// NewClientbyToken is a constructor for Client object using bearer tokens for // authentication instead of username, password
[ "NewClientbyToken", "is", "a", "constructor", "for", "Client", "object", "using", "bearer", "tokens", "for", "authentication", "instead", "of", "username", "password" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/profitbricks.go#L27-L34
test
profitbricks/profitbricks-sdk-go
profitbricks.go
SetDepth
func (c *Client) SetDepth(depth int) { c.client.depth = strconv.Itoa(depth) }
go
func (c *Client) SetDepth(depth int) { c.client.depth = strconv.Itoa(depth) }
[ "func", "(", "c", "*", "Client", ")", "SetDepth", "(", "depth", "int", ")", "{", "c", ".", "client", ".", "depth", "=", "strconv", ".", "Itoa", "(", "depth", ")", "\n", "}" ]
// SetDepth sets depth parameter for api calls
[ "SetDepth", "sets", "depth", "parameter", "for", "api", "calls" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/profitbricks.go#L37-L39
test
profitbricks/profitbricks-sdk-go
datacenter.go
ListDatacenters
func (c *Client) ListDatacenters() (*Datacenters, error) { url := dcColPath() + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Datacenters{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) ListDatacenters() (*Datacenters, error) { url := dcColPath() + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Datacenters{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "ListDatacenters", "(", ")", "(", "*", "Datacenters", ",", "error", ")", "{", "url", ":=", "dcColPath", "(", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Datacenters", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//ListDatacenters lists all data centers
[ "ListDatacenters", "lists", "all", "data", "centers" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/datacenter.go#L59-L64
test
profitbricks/profitbricks-sdk-go
datacenter.go
CreateDatacenter
func (c *Client) CreateDatacenter(dc Datacenter) (*Datacenter, error) { url := dcColPath() + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Datacenter{} err := c.client.Post(url, dc, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) CreateDatacenter(dc Datacenter) (*Datacenter, error) { url := dcColPath() + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Datacenter{} err := c.client.Post(url, dc, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "CreateDatacenter", "(", "dc", "Datacenter", ")", "(", "*", "Datacenter", ",", "error", ")", "{", "url", ":=", "dcColPath", "(", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Datacenter", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Post", "(", "url", ",", "dc", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//CreateDatacenter creates a data center
[ "CreateDatacenter", "creates", "a", "data", "center" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/datacenter.go#L67-L72
test
profitbricks/profitbricks-sdk-go
datacenter.go
GetDatacenter
func (c *Client) GetDatacenter(dcid string) (*Datacenter, error) { url := dcPath(dcid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Datacenter{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) GetDatacenter(dcid string) (*Datacenter, error) { url := dcPath(dcid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Datacenter{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "GetDatacenter", "(", "dcid", "string", ")", "(", "*", "Datacenter", ",", "error", ")", "{", "url", ":=", "dcPath", "(", "dcid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Datacenter", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//GetDatacenter gets a datacenter
[ "GetDatacenter", "gets", "a", "datacenter" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/datacenter.go#L75-L80
test
profitbricks/profitbricks-sdk-go
datacenter.go
UpdateDataCenter
func (c *Client) UpdateDataCenter(dcid string, obj DatacenterProperties) (*Datacenter, error) { url := dcPath(dcid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Datacenter{} err := c.client.Patch(url, obj, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) UpdateDataCenter(dcid string, obj DatacenterProperties) (*Datacenter, error) { url := dcPath(dcid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Datacenter{} err := c.client.Patch(url, obj, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "UpdateDataCenter", "(", "dcid", "string", ",", "obj", "DatacenterProperties", ")", "(", "*", "Datacenter", ",", "error", ")", "{", "url", ":=", "dcPath", "(", "dcid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Datacenter", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Patch", "(", "url", ",", "obj", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//UpdateDataCenter updates a data center
[ "UpdateDataCenter", "updates", "a", "data", "center" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/datacenter.go#L83-L88
test
profitbricks/profitbricks-sdk-go
datacenter.go
DeleteDatacenter
func (c *Client) DeleteDatacenter(dcid string) (*http.Header, error) { url := dcPath(dcid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &http.Header{} return ret, c.client.Delete(url, ret, http.StatusAccepted) }
go
func (c *Client) DeleteDatacenter(dcid string) (*http.Header, error) { url := dcPath(dcid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &http.Header{} return ret, c.client.Delete(url, ret, http.StatusAccepted) }
[ "func", "(", "c", "*", "Client", ")", "DeleteDatacenter", "(", "dcid", "string", ")", "(", "*", "http", ".", "Header", ",", "error", ")", "{", "url", ":=", "dcPath", "(", "dcid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "http", ".", "Header", "{", "}", "\n", "return", "ret", ",", "c", ".", "client", ".", "Delete", "(", "url", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "}" ]
//DeleteDatacenter deletes a data center
[ "DeleteDatacenter", "deletes", "a", "data", "center" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/datacenter.go#L91-L95
test
profitbricks/profitbricks-sdk-go
datacenter.go
WaitTillProvisioned
func (c *Client) WaitTillProvisioned(path string) error { waitCount := 300 for i := 0; i < waitCount; i++ { request, err := c.GetRequestStatus(path) if err != nil { return err } if request.Metadata.Status == "DONE" { return nil } time.Sleep(1 * time.Second) i++ } return fmt.Errorf("timeout expired while waiting for request to complete") }
go
func (c *Client) WaitTillProvisioned(path string) error { waitCount := 300 for i := 0; i < waitCount; i++ { request, err := c.GetRequestStatus(path) if err != nil { return err } if request.Metadata.Status == "DONE" { return nil } time.Sleep(1 * time.Second) i++ } return fmt.Errorf("timeout expired while waiting for request to complete") }
[ "func", "(", "c", "*", "Client", ")", "WaitTillProvisioned", "(", "path", "string", ")", "error", "{", "waitCount", ":=", "300", "\n", "for", "i", ":=", "0", ";", "i", "<", "waitCount", ";", "i", "++", "{", "request", ",", "err", ":=", "c", ".", "GetRequestStatus", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "request", ".", "Metadata", ".", "Status", "==", "\"DONE\"", "{", "return", "nil", "\n", "}", "\n", "time", ".", "Sleep", "(", "1", "*", "time", ".", "Second", ")", "\n", "i", "++", "\n", "}", "\n", "return", "fmt", ".", "Errorf", "(", "\"timeout expired while waiting for request to complete\"", ")", "\n", "}" ]
//WaitTillProvisioned helper function
[ "WaitTillProvisioned", "helper", "function" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/datacenter.go#L98-L112
test
profitbricks/profitbricks-sdk-go
firewallrule.go
ListFirewallRules
func (c *Client) ListFirewallRules(dcID string, serverID string, nicID string) (*FirewallRules, error) { url := fwruleColPath(dcID, serverID, nicID) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &FirewallRules{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) ListFirewallRules(dcID string, serverID string, nicID string) (*FirewallRules, error) { url := fwruleColPath(dcID, serverID, nicID) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &FirewallRules{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "ListFirewallRules", "(", "dcID", "string", ",", "serverID", "string", ",", "nicID", "string", ")", "(", "*", "FirewallRules", ",", "error", ")", "{", "url", ":=", "fwruleColPath", "(", "dcID", ",", "serverID", ",", "nicID", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "FirewallRules", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//ListFirewallRules lists all firewall rules
[ "ListFirewallRules", "lists", "all", "firewall", "rules" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/firewallrule.go#L45-L50
test
profitbricks/profitbricks-sdk-go
firewallrule.go
GetFirewallRule
func (c *Client) GetFirewallRule(dcID string, serverID string, nicID string, fwID string) (*FirewallRule, error) { url := fwrulePath(dcID, serverID, nicID, fwID) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &FirewallRule{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) GetFirewallRule(dcID string, serverID string, nicID string, fwID string) (*FirewallRule, error) { url := fwrulePath(dcID, serverID, nicID, fwID) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &FirewallRule{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "GetFirewallRule", "(", "dcID", "string", ",", "serverID", "string", ",", "nicID", "string", ",", "fwID", "string", ")", "(", "*", "FirewallRule", ",", "error", ")", "{", "url", ":=", "fwrulePath", "(", "dcID", ",", "serverID", ",", "nicID", ",", "fwID", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "FirewallRule", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//GetFirewallRule gets a firewall rule
[ "GetFirewallRule", "gets", "a", "firewall", "rule" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/firewallrule.go#L53-L58
test
profitbricks/profitbricks-sdk-go
firewallrule.go
CreateFirewallRule
func (c *Client) CreateFirewallRule(dcID string, serverID string, nicID string, fw FirewallRule) (*FirewallRule, error) { url := fwruleColPath(dcID, serverID, nicID) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &FirewallRule{} err := c.client.Post(url, fw, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) CreateFirewallRule(dcID string, serverID string, nicID string, fw FirewallRule) (*FirewallRule, error) { url := fwruleColPath(dcID, serverID, nicID) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &FirewallRule{} err := c.client.Post(url, fw, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "CreateFirewallRule", "(", "dcID", "string", ",", "serverID", "string", ",", "nicID", "string", ",", "fw", "FirewallRule", ")", "(", "*", "FirewallRule", ",", "error", ")", "{", "url", ":=", "fwruleColPath", "(", "dcID", ",", "serverID", ",", "nicID", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "FirewallRule", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Post", "(", "url", ",", "fw", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//CreateFirewallRule creates a firewall rule
[ "CreateFirewallRule", "creates", "a", "firewall", "rule" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/firewallrule.go#L61-L66
test
profitbricks/profitbricks-sdk-go
firewallrule.go
UpdateFirewallRule
func (c *Client) UpdateFirewallRule(dcID string, serverID string, nicID string, fwID string, obj FirewallruleProperties) (*FirewallRule, error) { url := fwrulePath(dcID, serverID, nicID, fwID) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &FirewallRule{} err := c.client.Patch(url, obj, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) UpdateFirewallRule(dcID string, serverID string, nicID string, fwID string, obj FirewallruleProperties) (*FirewallRule, error) { url := fwrulePath(dcID, serverID, nicID, fwID) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &FirewallRule{} err := c.client.Patch(url, obj, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "UpdateFirewallRule", "(", "dcID", "string", ",", "serverID", "string", ",", "nicID", "string", ",", "fwID", "string", ",", "obj", "FirewallruleProperties", ")", "(", "*", "FirewallRule", ",", "error", ")", "{", "url", ":=", "fwrulePath", "(", "dcID", ",", "serverID", ",", "nicID", ",", "fwID", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "FirewallRule", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Patch", "(", "url", ",", "obj", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//UpdateFirewallRule updates a firewall rule
[ "UpdateFirewallRule", "updates", "a", "firewall", "rule" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/firewallrule.go#L69-L74
test
profitbricks/profitbricks-sdk-go
firewallrule.go
DeleteFirewallRule
func (c *Client) DeleteFirewallRule(dcID string, serverID string, nicID string, fwID string) (*http.Header, error) { url := fwrulePath(dcID, serverID, nicID, fwID) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &http.Header{} err := c.client.Delete(url, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) DeleteFirewallRule(dcID string, serverID string, nicID string, fwID string) (*http.Header, error) { url := fwrulePath(dcID, serverID, nicID, fwID) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &http.Header{} err := c.client.Delete(url, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "DeleteFirewallRule", "(", "dcID", "string", ",", "serverID", "string", ",", "nicID", "string", ",", "fwID", "string", ")", "(", "*", "http", ".", "Header", ",", "error", ")", "{", "url", ":=", "fwrulePath", "(", "dcID", ",", "serverID", ",", "nicID", ",", "fwID", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "http", ".", "Header", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Delete", "(", "url", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//DeleteFirewallRule deletes a firewall rule
[ "DeleteFirewallRule", "deletes", "a", "firewall", "rule" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/firewallrule.go#L77-L82
test
profitbricks/profitbricks-sdk-go
loadbalancer.go
ListLoadbalancers
func (c *Client) ListLoadbalancers(dcid string) (*Loadbalancers, error) { url := lbalColPath(dcid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Loadbalancers{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) ListLoadbalancers(dcid string) (*Loadbalancers, error) { url := lbalColPath(dcid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Loadbalancers{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "ListLoadbalancers", "(", "dcid", "string", ")", "(", "*", "Loadbalancers", ",", "error", ")", "{", "url", ":=", "lbalColPath", "(", "dcid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Loadbalancers", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//ListLoadbalancers returns a Collection struct for loadbalancers in the Datacenter
[ "ListLoadbalancers", "returns", "a", "Collection", "struct", "for", "loadbalancers", "in", "the", "Datacenter" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/loadbalancer.go#L54-L60
test
profitbricks/profitbricks-sdk-go
loadbalancer.go
GetLoadbalancer
func (c *Client) GetLoadbalancer(dcid, lbalid string) (*Loadbalancer, error) { url := lbalPath(dcid, lbalid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Loadbalancer{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) GetLoadbalancer(dcid, lbalid string) (*Loadbalancer, error) { url := lbalPath(dcid, lbalid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Loadbalancer{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "GetLoadbalancer", "(", "dcid", ",", "lbalid", "string", ")", "(", "*", "Loadbalancer", ",", "error", ")", "{", "url", ":=", "lbalPath", "(", "dcid", ",", "lbalid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Loadbalancer", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//GetLoadbalancer pulls data for the Loadbalancer where id = lbalid returns a Instance struct
[ "GetLoadbalancer", "pulls", "data", "for", "the", "Loadbalancer", "where", "id", "=", "lbalid", "returns", "a", "Instance", "struct" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/loadbalancer.go#L72-L77
test
profitbricks/profitbricks-sdk-go
loadbalancer.go
UpdateLoadbalancer
func (c *Client) UpdateLoadbalancer(dcid string, lbalid string, obj LoadbalancerProperties) (*Loadbalancer, error) { url := lbalPath(dcid, lbalid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Loadbalancer{} err := c.client.Patch(url, obj, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) UpdateLoadbalancer(dcid string, lbalid string, obj LoadbalancerProperties) (*Loadbalancer, error) { url := lbalPath(dcid, lbalid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Loadbalancer{} err := c.client.Patch(url, obj, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "UpdateLoadbalancer", "(", "dcid", "string", ",", "lbalid", "string", ",", "obj", "LoadbalancerProperties", ")", "(", "*", "Loadbalancer", ",", "error", ")", "{", "url", ":=", "lbalPath", "(", "dcid", ",", "lbalid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Loadbalancer", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Patch", "(", "url", ",", "obj", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//UpdateLoadbalancer updates a load balancer
[ "UpdateLoadbalancer", "updates", "a", "load", "balancer" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/loadbalancer.go#L80-L85
test
profitbricks/profitbricks-sdk-go
loadbalancer.go
DeleteLoadbalancer
func (c *Client) DeleteLoadbalancer(dcid, lbalid string) (*http.Header, error) { url := lbalPath(dcid, lbalid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &http.Header{} err := c.client.Delete(url, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) DeleteLoadbalancer(dcid, lbalid string) (*http.Header, error) { url := lbalPath(dcid, lbalid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &http.Header{} err := c.client.Delete(url, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "DeleteLoadbalancer", "(", "dcid", ",", "lbalid", "string", ")", "(", "*", "http", ".", "Header", ",", "error", ")", "{", "url", ":=", "lbalPath", "(", "dcid", ",", "lbalid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "http", ".", "Header", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Delete", "(", "url", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//DeleteLoadbalancer deletes a load balancer
[ "DeleteLoadbalancer", "deletes", "a", "load", "balancer" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/loadbalancer.go#L88-L93
test
profitbricks/profitbricks-sdk-go
loadbalancer.go
ListBalancedNics
func (c *Client) ListBalancedNics(dcid, lbalid string) (*Nics, error) { url := balnicColPath(dcid, lbalid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Nics{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) ListBalancedNics(dcid, lbalid string) (*Nics, error) { url := balnicColPath(dcid, lbalid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Nics{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "ListBalancedNics", "(", "dcid", ",", "lbalid", "string", ")", "(", "*", "Nics", ",", "error", ")", "{", "url", ":=", "balnicColPath", "(", "dcid", ",", "lbalid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Nics", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//ListBalancedNics lists balanced nics
[ "ListBalancedNics", "lists", "balanced", "nics" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/loadbalancer.go#L96-L101
test
profitbricks/profitbricks-sdk-go
loadbalancer.go
AssociateNic
func (c *Client) AssociateNic(dcid string, lbalid string, nicid string) (*Nic, error) { sm := map[string]string{"id": nicid} url := balnicColPath(dcid, lbalid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Nic{} err := c.client.Post(url, sm, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) AssociateNic(dcid string, lbalid string, nicid string) (*Nic, error) { sm := map[string]string{"id": nicid} url := balnicColPath(dcid, lbalid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Nic{} err := c.client.Post(url, sm, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "AssociateNic", "(", "dcid", "string", ",", "lbalid", "string", ",", "nicid", "string", ")", "(", "*", "Nic", ",", "error", ")", "{", "sm", ":=", "map", "[", "string", "]", "string", "{", "\"id\"", ":", "nicid", "}", "\n", "url", ":=", "balnicColPath", "(", "dcid", ",", "lbalid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Nic", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Post", "(", "url", ",", "sm", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//AssociateNic attach a nic to load balancer
[ "AssociateNic", "attach", "a", "nic", "to", "load", "balancer" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/loadbalancer.go#L104-L110
test
profitbricks/profitbricks-sdk-go
loadbalancer.go
GetBalancedNic
func (c *Client) GetBalancedNic(dcid, lbalid, balnicid string) (*Nic, error) { url := balnicPath(dcid, lbalid, balnicid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Nic{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) GetBalancedNic(dcid, lbalid, balnicid string) (*Nic, error) { url := balnicPath(dcid, lbalid, balnicid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Nic{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "GetBalancedNic", "(", "dcid", ",", "lbalid", ",", "balnicid", "string", ")", "(", "*", "Nic", ",", "error", ")", "{", "url", ":=", "balnicPath", "(", "dcid", ",", "lbalid", ",", "balnicid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Nic", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//GetBalancedNic gets a balanced nic
[ "GetBalancedNic", "gets", "a", "balanced", "nic" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/loadbalancer.go#L113-L118
test
profitbricks/profitbricks-sdk-go
loadbalancer.go
DeleteBalancedNic
func (c *Client) DeleteBalancedNic(dcid, lbalid, balnicid string) (*http.Header, error) { url := balnicPath(dcid, lbalid, balnicid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &http.Header{} err := c.client.Delete(url, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) DeleteBalancedNic(dcid, lbalid, balnicid string) (*http.Header, error) { url := balnicPath(dcid, lbalid, balnicid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &http.Header{} err := c.client.Delete(url, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "DeleteBalancedNic", "(", "dcid", ",", "lbalid", ",", "balnicid", "string", ")", "(", "*", "http", ".", "Header", ",", "error", ")", "{", "url", ":=", "balnicPath", "(", "dcid", ",", "lbalid", ",", "balnicid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "http", ".", "Header", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Delete", "(", "url", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//DeleteBalancedNic removes a balanced nic
[ "DeleteBalancedNic", "removes", "a", "balanced", "nic" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/loadbalancer.go#L121-L126
test
profitbricks/profitbricks-sdk-go
lan.go
ListLans
func (c *Client) ListLans(dcid string) (*Lans, error) { url := lanColPath(dcid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Lans{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) ListLans(dcid string) (*Lans, error) { url := lanColPath(dcid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Lans{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "ListLans", "(", "dcid", "string", ")", "(", "*", "Lans", ",", "error", ")", "{", "url", ":=", "lanColPath", "(", "dcid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Lans", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
// ListLans returns a Collection for lans in the Datacenter
[ "ListLans", "returns", "a", "Collection", "for", "lans", "in", "the", "Datacenter" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/lan.go#L59-L64
test
profitbricks/profitbricks-sdk-go
lan.go
GetLan
func (c *Client) GetLan(dcid, lanid string) (*Lan, error) { url := lanPath(dcid, lanid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Lan{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) GetLan(dcid, lanid string) (*Lan, error) { url := lanPath(dcid, lanid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Lan{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "GetLan", "(", "dcid", ",", "lanid", "string", ")", "(", "*", "Lan", ",", "error", ")", "{", "url", ":=", "lanPath", "(", "dcid", ",", "lanid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Lan", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
// GetLan pulls data for the lan where id = lanid returns an Instance struct
[ "GetLan", "pulls", "data", "for", "the", "lan", "where", "id", "=", "lanid", "returns", "an", "Instance", "struct" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/lan.go#L76-L81
test
profitbricks/profitbricks-sdk-go
lan.go
DeleteLan
func (c *Client) DeleteLan(dcid, lanid string) (*http.Header, error) { url := lanPath(dcid, lanid) ret := &http.Header{} err := c.client.Delete(url, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) DeleteLan(dcid, lanid string) (*http.Header, error) { url := lanPath(dcid, lanid) ret := &http.Header{} err := c.client.Delete(url, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "DeleteLan", "(", "dcid", ",", "lanid", "string", ")", "(", "*", "http", ".", "Header", ",", "error", ")", "{", "url", ":=", "lanPath", "(", "dcid", ",", "lanid", ")", "\n", "ret", ":=", "&", "http", ".", "Header", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Delete", "(", "url", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
// DeleteLan deletes a lan where id == lanid
[ "DeleteLan", "deletes", "a", "lan", "where", "id", "==", "lanid" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/lan.go#L92-L97
test
profitbricks/profitbricks-sdk-go
nic.go
ListNics
func (c *Client) ListNics(dcid, srvid string) (*Nics, error) { url := nicColPath(dcid, srvid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Nics{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) ListNics(dcid, srvid string) (*Nics, error) { url := nicColPath(dcid, srvid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Nics{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "ListNics", "(", "dcid", ",", "srvid", "string", ")", "(", "*", "Nics", ",", "error", ")", "{", "url", ":=", "nicColPath", "(", "dcid", ",", "srvid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Nics", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
// ListNics returns a Nics struct collection
[ "ListNics", "returns", "a", "Nics", "struct", "collection" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/nic.go#L49-L54
test
profitbricks/profitbricks-sdk-go
nic.go
CreateNic
func (c *Client) CreateNic(dcid string, srvid string, nic Nic) (*Nic, error) { url := nicColPath(dcid, srvid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Nic{} err := c.client.Post(url, nic, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) CreateNic(dcid string, srvid string, nic Nic) (*Nic, error) { url := nicColPath(dcid, srvid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Nic{} err := c.client.Post(url, nic, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "CreateNic", "(", "dcid", "string", ",", "srvid", "string", ",", "nic", "Nic", ")", "(", "*", "Nic", ",", "error", ")", "{", "url", ":=", "nicColPath", "(", "dcid", ",", "srvid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Nic", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Post", "(", "url", ",", "nic", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
// CreateNic creates a nic on a server
[ "CreateNic", "creates", "a", "nic", "on", "a", "server" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/nic.go#L57-L64
test
profitbricks/profitbricks-sdk-go
nic.go
GetNic
func (c *Client) GetNic(dcid, srvid, nicid string) (*Nic, error) { url := nicPath(dcid, srvid, nicid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Nic{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) GetNic(dcid, srvid, nicid string) (*Nic, error) { url := nicPath(dcid, srvid, nicid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Nic{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "GetNic", "(", "dcid", ",", "srvid", ",", "nicid", "string", ")", "(", "*", "Nic", ",", "error", ")", "{", "url", ":=", "nicPath", "(", "dcid", ",", "srvid", ",", "nicid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Nic", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
// GetNic pulls data for the nic where id = srvid returns a Instance struct
[ "GetNic", "pulls", "data", "for", "the", "nic", "where", "id", "=", "srvid", "returns", "a", "Instance", "struct" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/nic.go#L67-L73
test
profitbricks/profitbricks-sdk-go
nic.go
UpdateNic
func (c *Client) UpdateNic(dcid string, srvid string, nicid string, obj NicProperties) (*Nic, error) { url := nicPath(dcid, srvid, nicid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Nic{} err := c.client.Patch(url, obj, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) UpdateNic(dcid string, srvid string, nicid string, obj NicProperties) (*Nic, error) { url := nicPath(dcid, srvid, nicid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Nic{} err := c.client.Patch(url, obj, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "UpdateNic", "(", "dcid", "string", ",", "srvid", "string", ",", "nicid", "string", ",", "obj", "NicProperties", ")", "(", "*", "Nic", ",", "error", ")", "{", "url", ":=", "nicPath", "(", "dcid", ",", "srvid", ",", "nicid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Nic", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Patch", "(", "url", ",", "obj", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
// UpdateNic partial update of nic properties
[ "UpdateNic", "partial", "update", "of", "nic", "properties" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/nic.go#L76-L83
test
profitbricks/profitbricks-sdk-go
nic.go
DeleteNic
func (c *Client) DeleteNic(dcid, srvid, nicid string) (*http.Header, error) { url := nicPath(dcid, srvid, nicid) ret := &http.Header{} err := c.client.Delete(url, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) DeleteNic(dcid, srvid, nicid string) (*http.Header, error) { url := nicPath(dcid, srvid, nicid) ret := &http.Header{} err := c.client.Delete(url, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "DeleteNic", "(", "dcid", ",", "srvid", ",", "nicid", "string", ")", "(", "*", "http", ".", "Header", ",", "error", ")", "{", "url", ":=", "nicPath", "(", "dcid", ",", "srvid", ",", "nicid", ")", "\n", "ret", ":=", "&", "http", ".", "Header", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Delete", "(", "url", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
// DeleteNic deletes the nic where id=nicid and returns a Resp struct
[ "DeleteNic", "deletes", "the", "nic", "where", "id", "=", "nicid", "and", "returns", "a", "Resp", "struct" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/nic.go#L86-L91
test
profitbricks/profitbricks-sdk-go
snapshot.go
ListSnapshots
func (c *Client) ListSnapshots() (*Snapshots, error) { url := snapshotColPath() + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Snapshots{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) ListSnapshots() (*Snapshots, error) { url := snapshotColPath() + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Snapshots{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "ListSnapshots", "(", ")", "(", "*", "Snapshots", ",", "error", ")", "{", "url", ":=", "snapshotColPath", "(", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Snapshots", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//ListSnapshots lists all snapshots
[ "ListSnapshots", "lists", "all", "snapshots" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/snapshot.go#L51-L56
test
profitbricks/profitbricks-sdk-go
snapshot.go
GetSnapshot
func (c *Client) GetSnapshot(snapshotID string) (*Snapshot, error) { url := snapshotColPath() + slash(snapshotID) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Snapshot{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) GetSnapshot(snapshotID string) (*Snapshot, error) { url := snapshotColPath() + slash(snapshotID) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Snapshot{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "GetSnapshot", "(", "snapshotID", "string", ")", "(", "*", "Snapshot", ",", "error", ")", "{", "url", ":=", "snapshotColPath", "(", ")", "+", "slash", "(", "snapshotID", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Snapshot", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//GetSnapshot gets a specific snapshot
[ "GetSnapshot", "gets", "a", "specific", "snapshot" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/snapshot.go#L59-L64
test
profitbricks/profitbricks-sdk-go
snapshot.go
DeleteSnapshot
func (c *Client) DeleteSnapshot(snapshotID string) (*http.Header, error) { url := snapshotColPath() + slash(snapshotID) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &http.Header{} err := c.client.Delete(url, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) DeleteSnapshot(snapshotID string) (*http.Header, error) { url := snapshotColPath() + slash(snapshotID) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &http.Header{} err := c.client.Delete(url, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "DeleteSnapshot", "(", "snapshotID", "string", ")", "(", "*", "http", ".", "Header", ",", "error", ")", "{", "url", ":=", "snapshotColPath", "(", ")", "+", "slash", "(", "snapshotID", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "http", ".", "Header", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Delete", "(", "url", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
// DeleteSnapshot deletes a specified snapshot
[ "DeleteSnapshot", "deletes", "a", "specified", "snapshot" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/snapshot.go#L67-L72
test
profitbricks/profitbricks-sdk-go
snapshot.go
UpdateSnapshot
func (c *Client) UpdateSnapshot(snapshotID string, request SnapshotProperties) (*Snapshot, error) { url := snapshotColPath() + slash(snapshotID) ret := &Snapshot{} err := c.client.Patch(url, request, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) UpdateSnapshot(snapshotID string, request SnapshotProperties) (*Snapshot, error) { url := snapshotColPath() + slash(snapshotID) ret := &Snapshot{} err := c.client.Patch(url, request, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "UpdateSnapshot", "(", "snapshotID", "string", ",", "request", "SnapshotProperties", ")", "(", "*", "Snapshot", ",", "error", ")", "{", "url", ":=", "snapshotColPath", "(", ")", "+", "slash", "(", "snapshotID", ")", "\n", "ret", ":=", "&", "Snapshot", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Patch", "(", "url", ",", "request", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
// UpdateSnapshot updates a snapshot
[ "UpdateSnapshot", "updates", "a", "snapshot" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/snapshot.go#L75-L80
test
profitbricks/profitbricks-sdk-go
ipblock.go
ListIPBlocks
func (c *Client) ListIPBlocks() (*IPBlocks, error) { url := ipblockColPath() + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &IPBlocks{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) ListIPBlocks() (*IPBlocks, error) { url := ipblockColPath() + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &IPBlocks{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "ListIPBlocks", "(", ")", "(", "*", "IPBlocks", ",", "error", ")", "{", "url", ":=", "ipblockColPath", "(", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "IPBlocks", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//ListIPBlocks lists all IP blocks
[ "ListIPBlocks", "lists", "all", "IP", "blocks" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/ipblock.go#L40-L45
test
profitbricks/profitbricks-sdk-go
ipblock.go
ReserveIPBlock
func (c *Client) ReserveIPBlock(request IPBlock) (*IPBlock, error) { url := ipblockColPath() + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &IPBlock{} err := c.client.Post(url, request, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) ReserveIPBlock(request IPBlock) (*IPBlock, error) { url := ipblockColPath() + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &IPBlock{} err := c.client.Post(url, request, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "ReserveIPBlock", "(", "request", "IPBlock", ")", "(", "*", "IPBlock", ",", "error", ")", "{", "url", ":=", "ipblockColPath", "(", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "IPBlock", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Post", "(", "url", ",", "request", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//ReserveIPBlock creates an IP block
[ "ReserveIPBlock", "creates", "an", "IP", "block" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/ipblock.go#L48-L53
test
profitbricks/profitbricks-sdk-go
ipblock.go
GetIPBlock
func (c *Client) GetIPBlock(ipblockid string) (*IPBlock, error) { url := ipblockPath(ipblockid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &IPBlock{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) GetIPBlock(ipblockid string) (*IPBlock, error) { url := ipblockPath(ipblockid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &IPBlock{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "GetIPBlock", "(", "ipblockid", "string", ")", "(", "*", "IPBlock", ",", "error", ")", "{", "url", ":=", "ipblockPath", "(", "ipblockid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "IPBlock", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//GetIPBlock gets an IP blocks
[ "GetIPBlock", "gets", "an", "IP", "blocks" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/ipblock.go#L56-L61
test
profitbricks/profitbricks-sdk-go
ipblock.go
UpdateIPBlock
func (c *Client) UpdateIPBlock(ipblockid string, props IPBlockProperties) (*IPBlock, error) { url := ipblockPath(ipblockid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &IPBlock{} err := c.client.Patch(url, props, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) UpdateIPBlock(ipblockid string, props IPBlockProperties) (*IPBlock, error) { url := ipblockPath(ipblockid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &IPBlock{} err := c.client.Patch(url, props, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "UpdateIPBlock", "(", "ipblockid", "string", ",", "props", "IPBlockProperties", ")", "(", "*", "IPBlock", ",", "error", ")", "{", "url", ":=", "ipblockPath", "(", "ipblockid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "IPBlock", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Patch", "(", "url", ",", "props", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
// UpdateIPBlock partial update of ipblock properties
[ "UpdateIPBlock", "partial", "update", "of", "ipblock", "properties" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/ipblock.go#L64-L69
test
profitbricks/profitbricks-sdk-go
ipblock.go
ReleaseIPBlock
func (c *Client) ReleaseIPBlock(ipblockid string) (*http.Header, error) { url := ipblockPath(ipblockid) ret := &http.Header{} err := c.client.Delete(url, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) ReleaseIPBlock(ipblockid string) (*http.Header, error) { url := ipblockPath(ipblockid) ret := &http.Header{} err := c.client.Delete(url, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "ReleaseIPBlock", "(", "ipblockid", "string", ")", "(", "*", "http", ".", "Header", ",", "error", ")", "{", "url", ":=", "ipblockPath", "(", "ipblockid", ")", "\n", "ret", ":=", "&", "http", ".", "Header", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Delete", "(", "url", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//ReleaseIPBlock deletes an IP block
[ "ReleaseIPBlock", "deletes", "an", "IP", "block" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/ipblock.go#L72-L77
test
profitbricks/profitbricks-sdk-go
volume.go
ListVolumes
func (c *Client) ListVolumes(dcid string) (*Volumes, error) { url := volumeColPath(dcid) + `?depth=` + c.client.depth ret := &Volumes{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) ListVolumes(dcid string) (*Volumes, error) { url := volumeColPath(dcid) + `?depth=` + c.client.depth ret := &Volumes{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "ListVolumes", "(", "dcid", "string", ")", "(", "*", "Volumes", ",", "error", ")", "{", "url", ":=", "volumeColPath", "(", "dcid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "\n", "ret", ":=", "&", "Volumes", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
// ListVolumes returns a Collection struct for volumes in the Datacenter
[ "ListVolumes", "returns", "a", "Collection", "struct", "for", "volumes", "in", "the", "Datacenter" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/volume.go#L58-L63
test
profitbricks/profitbricks-sdk-go
volume.go
GetVolume
func (c *Client) GetVolume(dcid string, volumeID string) (*Volume, error) { url := volumePath(dcid, volumeID) + `?depth=` + c.client.depth ret := &Volume{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) GetVolume(dcid string, volumeID string) (*Volume, error) { url := volumePath(dcid, volumeID) + `?depth=` + c.client.depth ret := &Volume{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "GetVolume", "(", "dcid", "string", ",", "volumeID", "string", ")", "(", "*", "Volume", ",", "error", ")", "{", "url", ":=", "volumePath", "(", "dcid", ",", "volumeID", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "\n", "ret", ":=", "&", "Volume", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//GetVolume gets a volume
[ "GetVolume", "gets", "a", "volume" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/volume.go#L66-L71
test
profitbricks/profitbricks-sdk-go
volume.go
UpdateVolume
func (c *Client) UpdateVolume(dcid string, volid string, request VolumeProperties) (*Volume, error) { url := volumePath(dcid, volid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Volume{} err := c.client.Patch(url, request, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) UpdateVolume(dcid string, volid string, request VolumeProperties) (*Volume, error) { url := volumePath(dcid, volid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Volume{} err := c.client.Patch(url, request, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "UpdateVolume", "(", "dcid", "string", ",", "volid", "string", ",", "request", "VolumeProperties", ")", "(", "*", "Volume", ",", "error", ")", "{", "url", ":=", "volumePath", "(", "dcid", ",", "volid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Volume", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Patch", "(", "url", ",", "request", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//UpdateVolume updates a volume
[ "UpdateVolume", "updates", "a", "volume" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/volume.go#L74-L79
test
profitbricks/profitbricks-sdk-go
volume.go
CreateVolume
func (c *Client) CreateVolume(dcid string, request Volume) (*Volume, error) { url := volumeColPath(dcid) + `?depth=` + c.client.depth ret := &Volume{} err := c.client.Post(url, request, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) CreateVolume(dcid string, request Volume) (*Volume, error) { url := volumeColPath(dcid) + `?depth=` + c.client.depth ret := &Volume{} err := c.client.Post(url, request, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "CreateVolume", "(", "dcid", "string", ",", "request", "Volume", ")", "(", "*", "Volume", ",", "error", ")", "{", "url", ":=", "volumeColPath", "(", "dcid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "\n", "ret", ":=", "&", "Volume", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Post", "(", "url", ",", "request", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//CreateVolume creates a volume
[ "CreateVolume", "creates", "a", "volume" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/volume.go#L82-L87
test
profitbricks/profitbricks-sdk-go
volume.go
DeleteVolume
func (c *Client) DeleteVolume(dcid, volid string) (*http.Header, error) { url := volumePath(dcid, volid) ret := &http.Header{} err := c.client.Delete(url, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) DeleteVolume(dcid, volid string) (*http.Header, error) { url := volumePath(dcid, volid) ret := &http.Header{} err := c.client.Delete(url, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "DeleteVolume", "(", "dcid", ",", "volid", "string", ")", "(", "*", "http", ".", "Header", ",", "error", ")", "{", "url", ":=", "volumePath", "(", "dcid", ",", "volid", ")", "\n", "ret", ":=", "&", "http", ".", "Header", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Delete", "(", "url", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
// DeleteVolume deletes a volume
[ "DeleteVolume", "deletes", "a", "volume" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/volume.go#L90-L95
test
profitbricks/profitbricks-sdk-go
volume.go
CreateSnapshot
func (c *Client) CreateSnapshot(dcid string, volid string, name string, description string) (*Snapshot, error) { path := volumePath(dcid, volid) + "/create-snapshot" data := url.Values{} data.Set("name", name) data.Add("description", description) ret := &Snapshot{} err := c.client.Post(path, data, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) CreateSnapshot(dcid string, volid string, name string, description string) (*Snapshot, error) { path := volumePath(dcid, volid) + "/create-snapshot" data := url.Values{} data.Set("name", name) data.Add("description", description) ret := &Snapshot{} err := c.client.Post(path, data, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "CreateSnapshot", "(", "dcid", "string", ",", "volid", "string", ",", "name", "string", ",", "description", "string", ")", "(", "*", "Snapshot", ",", "error", ")", "{", "path", ":=", "volumePath", "(", "dcid", ",", "volid", ")", "+", "\"/create-snapshot\"", "\n", "data", ":=", "url", ".", "Values", "{", "}", "\n", "data", ".", "Set", "(", "\"name\"", ",", "name", ")", "\n", "data", ".", "Add", "(", "\"description\"", ",", "description", ")", "\n", "ret", ":=", "&", "Snapshot", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Post", "(", "path", ",", "data", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//CreateSnapshot creates a volume snapshot
[ "CreateSnapshot", "creates", "a", "volume", "snapshot" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/volume.go#L98-L107
test
profitbricks/profitbricks-sdk-go
volume.go
RestoreSnapshot
func (c *Client) RestoreSnapshot(dcid string, volid string, snapshotID string) (*http.Header, error) { path := volumePath(dcid, volid) + "/restore-snapshot" data := url.Values{} data.Set("snapshotId", snapshotID) ret := &http.Header{} err := c.client.Post(path, data, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) RestoreSnapshot(dcid string, volid string, snapshotID string) (*http.Header, error) { path := volumePath(dcid, volid) + "/restore-snapshot" data := url.Values{} data.Set("snapshotId", snapshotID) ret := &http.Header{} err := c.client.Post(path, data, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "RestoreSnapshot", "(", "dcid", "string", ",", "volid", "string", ",", "snapshotID", "string", ")", "(", "*", "http", ".", "Header", ",", "error", ")", "{", "path", ":=", "volumePath", "(", "dcid", ",", "volid", ")", "+", "\"/restore-snapshot\"", "\n", "data", ":=", "url", ".", "Values", "{", "}", "\n", "data", ".", "Set", "(", "\"snapshotId\"", ",", "snapshotID", ")", "\n", "ret", ":=", "&", "http", ".", "Header", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Post", "(", "path", ",", "data", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
// RestoreSnapshot restores a volume with provided snapshot
[ "RestoreSnapshot", "restores", "a", "volume", "with", "provided", "snapshot" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/volume.go#L110-L117
test
profitbricks/profitbricks-sdk-go
server.go
ListServers
func (c *Client) ListServers(dcid string) (*Servers, error) { url := serverColPath(dcid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Servers{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) ListServers(dcid string) (*Servers, error) { url := serverColPath(dcid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Servers{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "ListServers", "(", "dcid", "string", ")", "(", "*", "Servers", ",", "error", ")", "{", "url", ":=", "serverColPath", "(", "dcid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Servers", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
// ListServers returns a server struct collection
[ "ListServers", "returns", "a", "server", "struct", "collection" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/server.go#L59-L64
test
profitbricks/profitbricks-sdk-go
server.go
GetServer
func (c *Client) GetServer(dcid, srvid string) (*Server, error) { url := serverPath(dcid, srvid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Server{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) GetServer(dcid, srvid string) (*Server, error) { url := serverPath(dcid, srvid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Server{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "GetServer", "(", "dcid", ",", "srvid", "string", ")", "(", "*", "Server", ",", "error", ")", "{", "url", ":=", "serverPath", "(", "dcid", ",", "srvid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Server", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
// GetServer pulls data for the server where id = srvid returns a Instance struct
[ "GetServer", "pulls", "data", "for", "the", "server", "where", "id", "=", "srvid", "returns", "a", "Instance", "struct" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/server.go#L75-L80
test
profitbricks/profitbricks-sdk-go
server.go
DeleteServer
func (c *Client) DeleteServer(dcid, srvid string) (*http.Header, error) { ret := &http.Header{} err := c.client.Delete(serverPath(dcid, srvid), ret, http.StatusAccepted) return ret, err }
go
func (c *Client) DeleteServer(dcid, srvid string) (*http.Header, error) { ret := &http.Header{} err := c.client.Delete(serverPath(dcid, srvid), ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "DeleteServer", "(", "dcid", ",", "srvid", "string", ")", "(", "*", "http", ".", "Header", ",", "error", ")", "{", "ret", ":=", "&", "http", ".", "Header", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Delete", "(", "serverPath", "(", "dcid", ",", "srvid", ")", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
// DeleteServer deletes the server where id=srvid and returns Resp struct
[ "DeleteServer", "deletes", "the", "server", "where", "id", "=", "srvid", "and", "returns", "Resp", "struct" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/server.go#L92-L96
test
profitbricks/profitbricks-sdk-go
server.go
ListAttachedCdroms
func (c *Client) ListAttachedCdroms(dcid, srvid string) (*Images, error) { url := serverCdromColPath(dcid, srvid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Images{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
go
func (c *Client) ListAttachedCdroms(dcid, srvid string) (*Images, error) { url := serverCdromColPath(dcid, srvid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Images{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "ListAttachedCdroms", "(", "dcid", ",", "srvid", "string", ")", "(", "*", "Images", ",", "error", ")", "{", "url", ":=", "serverCdromColPath", "(", "dcid", ",", "srvid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Images", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//ListAttachedCdroms returns list of attached cd roms
[ "ListAttachedCdroms", "returns", "list", "of", "attached", "cd", "roms" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/server.go#L99-L104
test
profitbricks/profitbricks-sdk-go
server.go
AttachCdrom
func (c *Client) AttachCdrom(dcid string, srvid string, cdid string) (*Image, error) { data := struct { ID string `json:"id,omitempty"` }{ cdid, } url := serverCdromColPath(dcid, srvid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Image{} err := c.client.Post(url, data, ret, http.StatusAccepted) return ret, err }
go
func (c *Client) AttachCdrom(dcid string, srvid string, cdid string) (*Image, error) { data := struct { ID string `json:"id,omitempty"` }{ cdid, } url := serverCdromColPath(dcid, srvid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Image{} err := c.client.Post(url, data, ret, http.StatusAccepted) return ret, err }
[ "func", "(", "c", "*", "Client", ")", "AttachCdrom", "(", "dcid", "string", ",", "srvid", "string", ",", "cdid", "string", ")", "(", "*", "Image", ",", "error", ")", "{", "data", ":=", "struct", "{", "ID", "string", "`json:\"id,omitempty\"`", "\n", "}", "{", "cdid", ",", "}", "\n", "url", ":=", "serverCdromColPath", "(", "dcid", ",", "srvid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Image", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Post", "(", "url", ",", "data", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
//AttachCdrom attaches a CD rom
[ "AttachCdrom", "attaches", "a", "CD", "rom" ]
1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/server.go#L107-L117
test