repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
TheThingsNetwork/ttn
ttnctl/util/account.go
GetTokenSource
func GetTokenSource(ctx ttnlog.Interface) oauth2.TokenSource { if tokenSource != nil { return tokenSource } token := getStoredToken(ctx) source := oauth2.ReuseTokenSource(token, getAccountServerTokenSource(token)) tokenSource = &ttnctlTokenSource{ctx, source} return tokenSource }
go
func GetTokenSource(ctx ttnlog.Interface) oauth2.TokenSource { if tokenSource != nil { return tokenSource } token := getStoredToken(ctx) source := oauth2.ReuseTokenSource(token, getAccountServerTokenSource(token)) tokenSource = &ttnctlTokenSource{ctx, source} return tokenSource }
[ "func", "GetTokenSource", "(", "ctx", "ttnlog", ".", "Interface", ")", "oauth2", ".", "TokenSource", "{", "if", "tokenSource", "!=", "nil", "{", "return", "tokenSource", "\n", "}", "\n", "token", ":=", "getStoredToken", "(", "ctx", ")", "\n", "source", ":=", "oauth2", ".", "ReuseTokenSource", "(", "token", ",", "getAccountServerTokenSource", "(", "token", ")", ")", "\n", "tokenSource", "=", "&", "ttnctlTokenSource", "{", "ctx", ",", "source", "}", "\n", "return", "tokenSource", "\n", "}" ]
// GetTokenSource builds a new oauth2.TokenSource that uses the ttnctl config to store the token
[ "GetTokenSource", "builds", "a", "new", "oauth2", ".", "TokenSource", "that", "uses", "the", "ttnctl", "config", "to", "store", "the", "token" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/account.go#L133-L141
train
TheThingsNetwork/ttn
ttnctl/util/account.go
GetAccount
func GetAccount(ctx ttnlog.Interface) *account.Account { token, err := GetTokenSource(ctx).Token() if err != nil { ctx.WithError(err).Fatal("Could not get access token") } server := viper.GetString("auth-server") manager := GetTokenManager(token.AccessToken) return account.NewWithManager(server, token.AccessToken, manager).WithHeader("User-Agent", GetUserAgent()) }
go
func GetAccount(ctx ttnlog.Interface) *account.Account { token, err := GetTokenSource(ctx).Token() if err != nil { ctx.WithError(err).Fatal("Could not get access token") } server := viper.GetString("auth-server") manager := GetTokenManager(token.AccessToken) return account.NewWithManager(server, token.AccessToken, manager).WithHeader("User-Agent", GetUserAgent()) }
[ "func", "GetAccount", "(", "ctx", "ttnlog", ".", "Interface", ")", "*", "account", ".", "Account", "{", "token", ",", "err", ":=", "GetTokenSource", "(", "ctx", ")", ".", "Token", "(", ")", "\n", "if", "err", "!=", "nil", "{", "ctx", ".", "WithError", "(", "err", ")", ".", "Fatal", "(", "\"", "\"", ")", "\n", "}", "\n\n", "server", ":=", "viper", ".", "GetString", "(", "\"", "\"", ")", "\n", "manager", ":=", "GetTokenManager", "(", "token", ".", "AccessToken", ")", "\n\n", "return", "account", ".", "NewWithManager", "(", "server", ",", "token", ".", "AccessToken", ",", "manager", ")", ".", "WithHeader", "(", "\"", "\"", ",", "GetUserAgent", "(", ")", ")", "\n", "}" ]
// GetAccount gets a new Account server client for ttnctl
[ "GetAccount", "gets", "a", "new", "Account", "server", "client", "for", "ttnctl" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/account.go#L149-L159
train
TheThingsNetwork/ttn
ttnctl/util/account.go
Login
func Login(ctx ttnlog.Interface, code string) (*oauth2.Token, error) { config := getOAuth() token, err := config.Exchange(code) if err != nil { return nil, err } saveToken(ctx, token) return token, nil }
go
func Login(ctx ttnlog.Interface, code string) (*oauth2.Token, error) { config := getOAuth() token, err := config.Exchange(code) if err != nil { return nil, err } saveToken(ctx, token) return token, nil }
[ "func", "Login", "(", "ctx", "ttnlog", ".", "Interface", ",", "code", "string", ")", "(", "*", "oauth2", ".", "Token", ",", "error", ")", "{", "config", ":=", "getOAuth", "(", ")", "\n", "token", ",", "err", ":=", "config", ".", "Exchange", "(", "code", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "saveToken", "(", "ctx", ",", "token", ")", "\n", "return", "token", ",", "nil", "\n", "}" ]
// Login does a login to the Account server with the given username and password
[ "Login", "does", "a", "login", "to", "the", "Account", "server", "with", "the", "given", "username", "and", "password" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/account.go#L162-L170
train
TheThingsNetwork/ttn
ttnctl/util/router.go
GetRouter
func GetRouter(ctx ttnlog.Interface) (*grpc.ClientConn, *routerclient.Client) { ctx.Info("Discovering Router...") dscConn, client := GetDiscovery(ctx) defer dscConn.Close() routerAnnouncement, err := client.Get(GetContext(ctx), &discovery.GetRequest{ ServiceName: "router", ID: viper.GetString("router-id"), }) if err != nil { ctx.WithError(errors.FromGRPCError(err)).Fatal("Could not get Router from Discovery") } ctx.Info("Connecting with Router...") rtrConn, err := routerAnnouncement.Dial(nil) ctx.Info("Connected to Router") rtrClient := routerclient.NewClient(routerclient.DefaultClientConfig) rtrClient.AddServer(viper.GetString("router-id"), rtrConn) return rtrConn, rtrClient }
go
func GetRouter(ctx ttnlog.Interface) (*grpc.ClientConn, *routerclient.Client) { ctx.Info("Discovering Router...") dscConn, client := GetDiscovery(ctx) defer dscConn.Close() routerAnnouncement, err := client.Get(GetContext(ctx), &discovery.GetRequest{ ServiceName: "router", ID: viper.GetString("router-id"), }) if err != nil { ctx.WithError(errors.FromGRPCError(err)).Fatal("Could not get Router from Discovery") } ctx.Info("Connecting with Router...") rtrConn, err := routerAnnouncement.Dial(nil) ctx.Info("Connected to Router") rtrClient := routerclient.NewClient(routerclient.DefaultClientConfig) rtrClient.AddServer(viper.GetString("router-id"), rtrConn) return rtrConn, rtrClient }
[ "func", "GetRouter", "(", "ctx", "ttnlog", ".", "Interface", ")", "(", "*", "grpc", ".", "ClientConn", ",", "*", "routerclient", ".", "Client", ")", "{", "ctx", ".", "Info", "(", "\"", "\"", ")", "\n", "dscConn", ",", "client", ":=", "GetDiscovery", "(", "ctx", ")", "\n", "defer", "dscConn", ".", "Close", "(", ")", "\n", "routerAnnouncement", ",", "err", ":=", "client", ".", "Get", "(", "GetContext", "(", "ctx", ")", ",", "&", "discovery", ".", "GetRequest", "{", "ServiceName", ":", "\"", "\"", ",", "ID", ":", "viper", ".", "GetString", "(", "\"", "\"", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "ctx", ".", "WithError", "(", "errors", ".", "FromGRPCError", "(", "err", ")", ")", ".", "Fatal", "(", "\"", "\"", ")", "\n", "}", "\n", "ctx", ".", "Info", "(", "\"", "\"", ")", "\n", "rtrConn", ",", "err", ":=", "routerAnnouncement", ".", "Dial", "(", "nil", ")", "\n", "ctx", ".", "Info", "(", "\"", "\"", ")", "\n", "rtrClient", ":=", "routerclient", ".", "NewClient", "(", "routerclient", ".", "DefaultClientConfig", ")", "\n", "rtrClient", ".", "AddServer", "(", "viper", ".", "GetString", "(", "\"", "\"", ")", ",", "rtrConn", ")", "\n", "return", "rtrConn", ",", "rtrClient", "\n", "}" ]
// GetRouter starts a connection with the router
[ "GetRouter", "starts", "a", "connection", "with", "the", "router" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/router.go#L17-L34
train
TheThingsNetwork/ttn
ttnctl/util/router.go
GetRouterManager
func GetRouterManager(ctx ttnlog.Interface) (*grpc.ClientConn, router.RouterManagerClient) { ctx.Info("Discovering Router...") dscConn, client := GetDiscovery(ctx) defer dscConn.Close() routerAnnouncement, err := client.Get(GetContext(ctx), &discovery.GetRequest{ ServiceName: "router", ID: viper.GetString("router-id"), }) if err != nil { ctx.WithError(errors.FromGRPCError(err)).Fatal("Could not get Router from Discovery") } ctx.Info("Connecting with Router...") rtrConn, err := routerAnnouncement.Dial(nil) if err != nil { ctx.WithError(err).Fatal("Could not connect to Router") } ctx.Info("Connected to Router") return rtrConn, router.NewRouterManagerClient(rtrConn) }
go
func GetRouterManager(ctx ttnlog.Interface) (*grpc.ClientConn, router.RouterManagerClient) { ctx.Info("Discovering Router...") dscConn, client := GetDiscovery(ctx) defer dscConn.Close() routerAnnouncement, err := client.Get(GetContext(ctx), &discovery.GetRequest{ ServiceName: "router", ID: viper.GetString("router-id"), }) if err != nil { ctx.WithError(errors.FromGRPCError(err)).Fatal("Could not get Router from Discovery") } ctx.Info("Connecting with Router...") rtrConn, err := routerAnnouncement.Dial(nil) if err != nil { ctx.WithError(err).Fatal("Could not connect to Router") } ctx.Info("Connected to Router") return rtrConn, router.NewRouterManagerClient(rtrConn) }
[ "func", "GetRouterManager", "(", "ctx", "ttnlog", ".", "Interface", ")", "(", "*", "grpc", ".", "ClientConn", ",", "router", ".", "RouterManagerClient", ")", "{", "ctx", ".", "Info", "(", "\"", "\"", ")", "\n", "dscConn", ",", "client", ":=", "GetDiscovery", "(", "ctx", ")", "\n", "defer", "dscConn", ".", "Close", "(", ")", "\n", "routerAnnouncement", ",", "err", ":=", "client", ".", "Get", "(", "GetContext", "(", "ctx", ")", ",", "&", "discovery", ".", "GetRequest", "{", "ServiceName", ":", "\"", "\"", ",", "ID", ":", "viper", ".", "GetString", "(", "\"", "\"", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "ctx", ".", "WithError", "(", "errors", ".", "FromGRPCError", "(", "err", ")", ")", ".", "Fatal", "(", "\"", "\"", ")", "\n", "}", "\n", "ctx", ".", "Info", "(", "\"", "\"", ")", "\n", "rtrConn", ",", "err", ":=", "routerAnnouncement", ".", "Dial", "(", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "ctx", ".", "WithError", "(", "err", ")", ".", "Fatal", "(", "\"", "\"", ")", "\n", "}", "\n", "ctx", ".", "Info", "(", "\"", "\"", ")", "\n", "return", "rtrConn", ",", "router", ".", "NewRouterManagerClient", "(", "rtrConn", ")", "\n", "}" ]
// GetRouterManager starts a management connection with the router
[ "GetRouterManager", "starts", "a", "management", "connection", "with", "the", "router" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/router.go#L37-L55
train
TheThingsNetwork/ttn
utils/version/version.go
Selfupdate
func Selfupdate(ctx ttnlog.Interface, component string) { if viper.GetString("gitBranch") == "unknown" { ctx.Infof("You are not using an official %s build. Not proceeding with the update", component) return } info, err := GetLatestInfo() if err != nil { ctx.WithError(err).Fatal("Could not get version information from the server") } if viper.GetString("gitCommit") == info.Commit { ctx.Info("The git commit of the build on the server is the same as yours") ctx.Info("Not proceeding with the update") return } if date, err := time.Parse(time.RFC3339, viper.GetString("buildDate")); err == nil { if date.Equal(info.Date) { ctx.Infof("You have the latest version of %s", component) ctx.Info("Nothing to update") return } if date.After(info.Date) { ctx.Infof("Your build is %s newer than the build on the server", date.Sub(info.Date)) ctx.Info("Not proceeding with the update") return } ctx.Infof("The build on the server is %s newer than yours", info.Date.Sub(date)) } ctx.Infof("Downloading the latest %s...", component) binary, err := GetLatest(component) if err != nil { ctx.WithError(err).Fatal("Could not download latest binary") } filename, err := osext.Executable() if err != nil { ctx.WithError(err).Fatal("Could not get path to local binary") } stat, err := os.Stat(filename) if err != nil { ctx.WithError(err).Fatal("Could not stat local binary") } ctx.Info("Replacing local binary...") if err := ioutil.WriteFile(filename+".new", binary, stat.Mode()); err != nil { ctx.WithError(err).Fatal("Could not write new binary to filesystem") } if err := os.Rename(filename, filename+".old"); err != nil { ctx.WithError(err).Fatal("Could not rename binary") } if err := os.Rename(filename+".new", filename); err != nil { ctx.WithError(err).Fatal("Could not rename binary") } ctx.Infof("Updated %s to the latest version", component) }
go
func Selfupdate(ctx ttnlog.Interface, component string) { if viper.GetString("gitBranch") == "unknown" { ctx.Infof("You are not using an official %s build. Not proceeding with the update", component) return } info, err := GetLatestInfo() if err != nil { ctx.WithError(err).Fatal("Could not get version information from the server") } if viper.GetString("gitCommit") == info.Commit { ctx.Info("The git commit of the build on the server is the same as yours") ctx.Info("Not proceeding with the update") return } if date, err := time.Parse(time.RFC3339, viper.GetString("buildDate")); err == nil { if date.Equal(info.Date) { ctx.Infof("You have the latest version of %s", component) ctx.Info("Nothing to update") return } if date.After(info.Date) { ctx.Infof("Your build is %s newer than the build on the server", date.Sub(info.Date)) ctx.Info("Not proceeding with the update") return } ctx.Infof("The build on the server is %s newer than yours", info.Date.Sub(date)) } ctx.Infof("Downloading the latest %s...", component) binary, err := GetLatest(component) if err != nil { ctx.WithError(err).Fatal("Could not download latest binary") } filename, err := osext.Executable() if err != nil { ctx.WithError(err).Fatal("Could not get path to local binary") } stat, err := os.Stat(filename) if err != nil { ctx.WithError(err).Fatal("Could not stat local binary") } ctx.Info("Replacing local binary...") if err := ioutil.WriteFile(filename+".new", binary, stat.Mode()); err != nil { ctx.WithError(err).Fatal("Could not write new binary to filesystem") } if err := os.Rename(filename, filename+".old"); err != nil { ctx.WithError(err).Fatal("Could not rename binary") } if err := os.Rename(filename+".new", filename); err != nil { ctx.WithError(err).Fatal("Could not rename binary") } ctx.Infof("Updated %s to the latest version", component) }
[ "func", "Selfupdate", "(", "ctx", "ttnlog", ".", "Interface", ",", "component", "string", ")", "{", "if", "viper", ".", "GetString", "(", "\"", "\"", ")", "==", "\"", "\"", "{", "ctx", ".", "Infof", "(", "\"", "\"", ",", "component", ")", "\n", "return", "\n", "}", "\n\n", "info", ",", "err", ":=", "GetLatestInfo", "(", ")", "\n", "if", "err", "!=", "nil", "{", "ctx", ".", "WithError", "(", "err", ")", ".", "Fatal", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "viper", ".", "GetString", "(", "\"", "\"", ")", "==", "info", ".", "Commit", "{", "ctx", ".", "Info", "(", "\"", "\"", ")", "\n", "ctx", ".", "Info", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n\n", "if", "date", ",", "err", ":=", "time", ".", "Parse", "(", "time", ".", "RFC3339", ",", "viper", ".", "GetString", "(", "\"", "\"", ")", ")", ";", "err", "==", "nil", "{", "if", "date", ".", "Equal", "(", "info", ".", "Date", ")", "{", "ctx", ".", "Infof", "(", "\"", "\"", ",", "component", ")", "\n", "ctx", ".", "Info", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "if", "date", ".", "After", "(", "info", ".", "Date", ")", "{", "ctx", ".", "Infof", "(", "\"", "\"", ",", "date", ".", "Sub", "(", "info", ".", "Date", ")", ")", "\n", "ctx", ".", "Info", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "ctx", ".", "Infof", "(", "\"", "\"", ",", "info", ".", "Date", ".", "Sub", "(", "date", ")", ")", "\n", "}", "\n\n", "ctx", ".", "Infof", "(", "\"", "\"", ",", "component", ")", "\n", "binary", ",", "err", ":=", "GetLatest", "(", "component", ")", "\n", "if", "err", "!=", "nil", "{", "ctx", ".", "WithError", "(", "err", ")", ".", "Fatal", "(", "\"", "\"", ")", "\n", "}", "\n", "filename", ",", "err", ":=", "osext", ".", "Executable", "(", ")", "\n", "if", "err", "!=", "nil", "{", "ctx", ".", "WithError", "(", "err", ")", ".", "Fatal", "(", "\"", "\"", ")", "\n", "}", "\n", "stat", ",", "err", ":=", "os", ".", "Stat", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "ctx", ".", "WithError", "(", "err", ")", ".", "Fatal", "(", "\"", "\"", ")", "\n", "}", "\n", "ctx", ".", "Info", "(", "\"", "\"", ")", "\n", "if", "err", ":=", "ioutil", ".", "WriteFile", "(", "filename", "+", "\"", "\"", ",", "binary", ",", "stat", ".", "Mode", "(", ")", ")", ";", "err", "!=", "nil", "{", "ctx", ".", "WithError", "(", "err", ")", ".", "Fatal", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "err", ":=", "os", ".", "Rename", "(", "filename", ",", "filename", "+", "\"", "\"", ")", ";", "err", "!=", "nil", "{", "ctx", ".", "WithError", "(", "err", ")", ".", "Fatal", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "err", ":=", "os", ".", "Rename", "(", "filename", "+", "\"", "\"", ",", "filename", ")", ";", "err", "!=", "nil", "{", "ctx", ".", "WithError", "(", "err", ")", ".", "Fatal", "(", "\"", "\"", ")", "\n", "}", "\n", "ctx", ".", "Infof", "(", "\"", "\"", ",", "component", ")", "\n", "}" ]
// Selfupdate runs a self-update for the current binary
[ "Selfupdate", "runs", "a", "self", "-", "update", "for", "the", "current", "binary" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/version/version.go#L120-L175
train
TheThingsNetwork/ttn
api/ratelimit/ratelimit.go
NewRegistry
func NewRegistry(rate int, per time.Duration) *Registry { return &Registry{ rate: rate, per: per, entities: make(map[string]*ratelimit.Bucket), } }
go
func NewRegistry(rate int, per time.Duration) *Registry { return &Registry{ rate: rate, per: per, entities: make(map[string]*ratelimit.Bucket), } }
[ "func", "NewRegistry", "(", "rate", "int", ",", "per", "time", ".", "Duration", ")", "*", "Registry", "{", "return", "&", "Registry", "{", "rate", ":", "rate", ",", "per", ":", "per", ",", "entities", ":", "make", "(", "map", "[", "string", "]", "*", "ratelimit", ".", "Bucket", ")", ",", "}", "\n", "}" ]
// NewRegistry returns a new Registry for rate limiting
[ "NewRegistry", "returns", "a", "new", "Registry", "for", "rate", "limiting" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/api/ratelimit/ratelimit.go#L22-L28
train
TheThingsNetwork/ttn
api/ratelimit/ratelimit.go
Wait
func (r *Registry) Wait(id string) time.Duration { return r.getOrCreate(id, r.newFunc).Take(1) }
go
func (r *Registry) Wait(id string) time.Duration { return r.getOrCreate(id, r.newFunc).Take(1) }
[ "func", "(", "r", "*", "Registry", ")", "Wait", "(", "id", "string", ")", "time", ".", "Duration", "{", "return", "r", ".", "getOrCreate", "(", "id", ",", "r", ".", "newFunc", ")", ".", "Take", "(", "1", ")", "\n", "}" ]
// Wait returns the time to wait until available
[ "Wait", "returns", "the", "time", "to", "wait", "until", "available" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/api/ratelimit/ratelimit.go#L54-L56
train
TheThingsNetwork/ttn
mqtt/events.go
UnsubscribeAppEvents
func (c *DefaultClient) UnsubscribeAppEvents(appID string, eventType types.EventType) Token { topic := ApplicationTopic{appID, AppEvents, string(eventType)} return c.unsubscribe(topic.String()) }
go
func (c *DefaultClient) UnsubscribeAppEvents(appID string, eventType types.EventType) Token { topic := ApplicationTopic{appID, AppEvents, string(eventType)} return c.unsubscribe(topic.String()) }
[ "func", "(", "c", "*", "DefaultClient", ")", "UnsubscribeAppEvents", "(", "appID", "string", ",", "eventType", "types", ".", "EventType", ")", "Token", "{", "topic", ":=", "ApplicationTopic", "{", "appID", ",", "AppEvents", ",", "string", "(", "eventType", ")", "}", "\n", "return", "c", ".", "unsubscribe", "(", "topic", ".", "String", "(", ")", ")", "\n", "}" ]
// UnsubscribeAppEvents unsubscribes from the events that were subscribed to by SubscribeAppEvents
[ "UnsubscribeAppEvents", "unsubscribes", "from", "the", "events", "that", "were", "subscribed", "to", "by", "SubscribeAppEvents" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/events.go#L72-L75
train
TheThingsNetwork/ttn
mqtt/events.go
UnsubscribeDeviceEvents
func (c *DefaultClient) UnsubscribeDeviceEvents(appID string, devID string, eventType types.EventType) Token { topic := DeviceTopic{appID, devID, DeviceEvents, string(eventType)} return c.unsubscribe(topic.String()) }
go
func (c *DefaultClient) UnsubscribeDeviceEvents(appID string, devID string, eventType types.EventType) Token { topic := DeviceTopic{appID, devID, DeviceEvents, string(eventType)} return c.unsubscribe(topic.String()) }
[ "func", "(", "c", "*", "DefaultClient", ")", "UnsubscribeDeviceEvents", "(", "appID", "string", ",", "devID", "string", ",", "eventType", "types", ".", "EventType", ")", "Token", "{", "topic", ":=", "DeviceTopic", "{", "appID", ",", "devID", ",", "DeviceEvents", ",", "string", "(", "eventType", ")", "}", "\n", "return", "c", ".", "unsubscribe", "(", "topic", ".", "String", "(", ")", ")", "\n", "}" ]
// UnsubscribeDeviceEvents unsubscribes from the events that were subscribed to by SubscribeDeviceEvents
[ "UnsubscribeDeviceEvents", "unsubscribes", "from", "the", "events", "that", "were", "subscribed", "to", "by", "SubscribeDeviceEvents" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/events.go#L78-L81
train
TheThingsNetwork/ttn
core/handler/device/device.go
Clone
func (d *Device) Clone() *Device { n := new(Device) *n = *d n.old = nil if d.CurrentDownlink != nil { n.CurrentDownlink = new(types.DownlinkMessage) *n.CurrentDownlink = *d.CurrentDownlink } return n }
go
func (d *Device) Clone() *Device { n := new(Device) *n = *d n.old = nil if d.CurrentDownlink != nil { n.CurrentDownlink = new(types.DownlinkMessage) *n.CurrentDownlink = *d.CurrentDownlink } return n }
[ "func", "(", "d", "*", "Device", ")", "Clone", "(", ")", "*", "Device", "{", "n", ":=", "new", "(", "Device", ")", "\n", "*", "n", "=", "*", "d", "\n", "n", ".", "old", "=", "nil", "\n", "if", "d", ".", "CurrentDownlink", "!=", "nil", "{", "n", ".", "CurrentDownlink", "=", "new", "(", "types", ".", "DownlinkMessage", ")", "\n", "*", "n", ".", "CurrentDownlink", "=", "*", "d", ".", "CurrentDownlink", "\n", "}", "\n", "return", "n", "\n", "}" ]
// Clone the device
[ "Clone", "the", "device" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/device.go#L67-L76
train
TheThingsNetwork/ttn
core/discovery/announcement/cache.go
NewCachedAnnouncementStore
func NewCachedAnnouncementStore(store Store, options CacheOptions) Store { serviceCache := gcache.New(options.ServiceCacheSize).Expiration(options.ServiceCacheExpiration).LRU(). LoaderFunc(func(k interface{}) (interface{}, error) { key := strings.Split(k.(string), ":") return store.Get(key[0], key[1]) }).Build() listCache := gcache.New(options.ListCacheSize).Expiration(options.ListCacheExpiration).LRU(). LoaderFunc(func(k interface{}) (interface{}, error) { key := k.(string) announcements, err := store.ListService(key, nil) if err != nil { return nil, err } go func(announcements []*Announcement) { for _, announcement := range announcements { serviceCache.Set(serviceCacheKey(announcement.ServiceName, announcement.ID), announcement) } }(announcements) return announcements, nil }).Build() return &cachedAnnouncementStore{ backingStore: store, serviceCache: serviceCache, listCache: listCache, } }
go
func NewCachedAnnouncementStore(store Store, options CacheOptions) Store { serviceCache := gcache.New(options.ServiceCacheSize).Expiration(options.ServiceCacheExpiration).LRU(). LoaderFunc(func(k interface{}) (interface{}, error) { key := strings.Split(k.(string), ":") return store.Get(key[0], key[1]) }).Build() listCache := gcache.New(options.ListCacheSize).Expiration(options.ListCacheExpiration).LRU(). LoaderFunc(func(k interface{}) (interface{}, error) { key := k.(string) announcements, err := store.ListService(key, nil) if err != nil { return nil, err } go func(announcements []*Announcement) { for _, announcement := range announcements { serviceCache.Set(serviceCacheKey(announcement.ServiceName, announcement.ID), announcement) } }(announcements) return announcements, nil }).Build() return &cachedAnnouncementStore{ backingStore: store, serviceCache: serviceCache, listCache: listCache, } }
[ "func", "NewCachedAnnouncementStore", "(", "store", "Store", ",", "options", "CacheOptions", ")", "Store", "{", "serviceCache", ":=", "gcache", ".", "New", "(", "options", ".", "ServiceCacheSize", ")", ".", "Expiration", "(", "options", ".", "ServiceCacheExpiration", ")", ".", "LRU", "(", ")", ".", "LoaderFunc", "(", "func", "(", "k", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "key", ":=", "strings", ".", "Split", "(", "k", ".", "(", "string", ")", ",", "\"", "\"", ")", "\n", "return", "store", ".", "Get", "(", "key", "[", "0", "]", ",", "key", "[", "1", "]", ")", "\n", "}", ")", ".", "Build", "(", ")", "\n\n", "listCache", ":=", "gcache", ".", "New", "(", "options", ".", "ListCacheSize", ")", ".", "Expiration", "(", "options", ".", "ListCacheExpiration", ")", ".", "LRU", "(", ")", ".", "LoaderFunc", "(", "func", "(", "k", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "key", ":=", "k", ".", "(", "string", ")", "\n", "announcements", ",", "err", ":=", "store", ".", "ListService", "(", "key", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "go", "func", "(", "announcements", "[", "]", "*", "Announcement", ")", "{", "for", "_", ",", "announcement", ":=", "range", "announcements", "{", "serviceCache", ".", "Set", "(", "serviceCacheKey", "(", "announcement", ".", "ServiceName", ",", "announcement", ".", "ID", ")", ",", "announcement", ")", "\n", "}", "\n", "}", "(", "announcements", ")", "\n", "return", "announcements", ",", "nil", "\n", "}", ")", ".", "Build", "(", ")", "\n\n", "return", "&", "cachedAnnouncementStore", "{", "backingStore", ":", "store", ",", "serviceCache", ":", "serviceCache", ",", "listCache", ":", "listCache", ",", "}", "\n", "}" ]
// NewCachedAnnouncementStore returns a cache wrapper around the existing store
[ "NewCachedAnnouncementStore", "returns", "a", "cache", "wrapper", "around", "the", "existing", "store" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/discovery/announcement/cache.go#L43-L70
train
TheThingsNetwork/ttn
core/storage/redis_kv_store.go
NewRedisKVStore
func NewRedisKVStore(client *redis.Client, prefix string) *RedisKVStore { if !strings.HasSuffix(prefix, ":") { prefix += ":" } return &RedisKVStore{ RedisStore: NewRedisStore(client, prefix), } }
go
func NewRedisKVStore(client *redis.Client, prefix string) *RedisKVStore { if !strings.HasSuffix(prefix, ":") { prefix += ":" } return &RedisKVStore{ RedisStore: NewRedisStore(client, prefix), } }
[ "func", "NewRedisKVStore", "(", "client", "*", "redis", ".", "Client", ",", "prefix", "string", ")", "*", "RedisKVStore", "{", "if", "!", "strings", ".", "HasSuffix", "(", "prefix", ",", "\"", "\"", ")", "{", "prefix", "+=", "\"", "\"", "\n", "}", "\n", "return", "&", "RedisKVStore", "{", "RedisStore", ":", "NewRedisStore", "(", "client", ",", "prefix", ")", ",", "}", "\n", "}" ]
// NewRedisKVStore creates a new RedisKVStore
[ "NewRedisKVStore", "creates", "a", "new", "RedisKVStore" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/storage/redis_kv_store.go#L20-L27
train
TheThingsNetwork/ttn
core/storage/redis_kv_store.go
List
func (s *RedisKVStore) List(selector string, options *ListOptions) (map[string]string, error) { allKeys, err := s.Keys(selector, options) if err != nil { return nil, err } return s.GetAll(allKeys, options) }
go
func (s *RedisKVStore) List(selector string, options *ListOptions) (map[string]string, error) { allKeys, err := s.Keys(selector, options) if err != nil { return nil, err } return s.GetAll(allKeys, options) }
[ "func", "(", "s", "*", "RedisKVStore", ")", "List", "(", "selector", "string", ",", "options", "*", "ListOptions", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "allKeys", ",", "err", ":=", "s", ".", "Keys", "(", "selector", ",", "options", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "s", ".", "GetAll", "(", "allKeys", ",", "options", ")", "\n", "}" ]
// List all results matching the selector, prepending the prefix to the selector if necessary
[ "List", "all", "results", "matching", "the", "selector", "prepending", "the", "prefix", "to", "the", "selector", "if", "necessary" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/storage/redis_kv_store.go#L76-L82
train
TheThingsNetwork/ttn
core/storage/redis_kv_store.go
Set
func (s *RedisKVStore) Set(key string, value string) error { if !strings.HasPrefix(key, s.prefix) { key = s.prefix + key } return s.client.Set(key, value, 0).Err() }
go
func (s *RedisKVStore) Set(key string, value string) error { if !strings.HasPrefix(key, s.prefix) { key = s.prefix + key } return s.client.Set(key, value, 0).Err() }
[ "func", "(", "s", "*", "RedisKVStore", ")", "Set", "(", "key", "string", ",", "value", "string", ")", "error", "{", "if", "!", "strings", ".", "HasPrefix", "(", "key", ",", "s", ".", "prefix", ")", "{", "key", "=", "s", ".", "prefix", "+", "key", "\n", "}", "\n", "return", "s", ".", "client", ".", "Set", "(", "key", ",", "value", ",", "0", ")", ".", "Err", "(", ")", "\n", "}" ]
// Set a record, prepending the prefix to the key if necessary
[ "Set", "a", "record", "prepending", "the", "prefix", "to", "the", "key", "if", "necessary" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/storage/redis_kv_store.go#L100-L105
train
TheThingsNetwork/ttn
core/storage/redis_kv_store.go
Create
func (s *RedisKVStore) Create(key string, value string) error { if !strings.HasPrefix(key, s.prefix) { key = s.prefix + key } err := s.client.Watch(func(tx *redis.Tx) error { exists, err := tx.Exists(key).Result() if err != nil { return err } if exists { return errors.NewErrAlreadyExists(key) } _, err = tx.Pipelined(func(pipe *redis.Pipeline) error { pipe.Set(key, value, 0) return nil }) if err != nil { return err } return nil }, key) if err != nil { return err } return nil }
go
func (s *RedisKVStore) Create(key string, value string) error { if !strings.HasPrefix(key, s.prefix) { key = s.prefix + key } err := s.client.Watch(func(tx *redis.Tx) error { exists, err := tx.Exists(key).Result() if err != nil { return err } if exists { return errors.NewErrAlreadyExists(key) } _, err = tx.Pipelined(func(pipe *redis.Pipeline) error { pipe.Set(key, value, 0) return nil }) if err != nil { return err } return nil }, key) if err != nil { return err } return nil }
[ "func", "(", "s", "*", "RedisKVStore", ")", "Create", "(", "key", "string", ",", "value", "string", ")", "error", "{", "if", "!", "strings", ".", "HasPrefix", "(", "key", ",", "s", ".", "prefix", ")", "{", "key", "=", "s", ".", "prefix", "+", "key", "\n", "}", "\n", "err", ":=", "s", ".", "client", ".", "Watch", "(", "func", "(", "tx", "*", "redis", ".", "Tx", ")", "error", "{", "exists", ",", "err", ":=", "tx", ".", "Exists", "(", "key", ")", ".", "Result", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "exists", "{", "return", "errors", ".", "NewErrAlreadyExists", "(", "key", ")", "\n", "}", "\n", "_", ",", "err", "=", "tx", ".", "Pipelined", "(", "func", "(", "pipe", "*", "redis", ".", "Pipeline", ")", "error", "{", "pipe", ".", "Set", "(", "key", ",", "value", ",", "0", ")", "\n", "return", "nil", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}", ",", "key", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Create a new record, prepending the prefix to the key if necessary // This function returns an error if the record already exists
[ "Create", "a", "new", "record", "prepending", "the", "prefix", "to", "the", "key", "if", "necessary", "This", "function", "returns", "an", "error", "if", "the", "record", "already", "exists" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/storage/redis_kv_store.go#L109-L134
train
TheThingsNetwork/ttn
utils/security/convert_keys.go
PublicPEM
func PublicPEM(key *ecdsa.PrivateKey) ([]byte, error) { pubBytes, err := x509.MarshalPKIXPublicKey(key.Public()) if err != nil { return nil, err } pubPEM := pem.EncodeToMemory(&pem.Block{ Type: "PUBLIC KEY", Bytes: pubBytes, }) return pubPEM, nil }
go
func PublicPEM(key *ecdsa.PrivateKey) ([]byte, error) { pubBytes, err := x509.MarshalPKIXPublicKey(key.Public()) if err != nil { return nil, err } pubPEM := pem.EncodeToMemory(&pem.Block{ Type: "PUBLIC KEY", Bytes: pubBytes, }) return pubPEM, nil }
[ "func", "PublicPEM", "(", "key", "*", "ecdsa", ".", "PrivateKey", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "pubBytes", ",", "err", ":=", "x509", ".", "MarshalPKIXPublicKey", "(", "key", ".", "Public", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "pubPEM", ":=", "pem", ".", "EncodeToMemory", "(", "&", "pem", ".", "Block", "{", "Type", ":", "\"", "\"", ",", "Bytes", ":", "pubBytes", ",", "}", ")", "\n", "return", "pubPEM", ",", "nil", "\n", "}" ]
// PublicPEM returns the PEM-encoded public key
[ "PublicPEM", "returns", "the", "PEM", "-", "encoded", "public", "key" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/security/convert_keys.go#L13-L23
train
TheThingsNetwork/ttn
utils/security/convert_keys.go
PrivatePEM
func PrivatePEM(key *ecdsa.PrivateKey) ([]byte, error) { privBytes, err := x509.MarshalECPrivateKey(key) if err != nil { return nil, err } privPEM := pem.EncodeToMemory(&pem.Block{ Type: "EC PRIVATE KEY", Bytes: privBytes, }) return privPEM, nil }
go
func PrivatePEM(key *ecdsa.PrivateKey) ([]byte, error) { privBytes, err := x509.MarshalECPrivateKey(key) if err != nil { return nil, err } privPEM := pem.EncodeToMemory(&pem.Block{ Type: "EC PRIVATE KEY", Bytes: privBytes, }) return privPEM, nil }
[ "func", "PrivatePEM", "(", "key", "*", "ecdsa", ".", "PrivateKey", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "privBytes", ",", "err", ":=", "x509", ".", "MarshalECPrivateKey", "(", "key", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "privPEM", ":=", "pem", ".", "EncodeToMemory", "(", "&", "pem", ".", "Block", "{", "Type", ":", "\"", "\"", ",", "Bytes", ":", "privBytes", ",", "}", ")", "\n", "return", "privPEM", ",", "nil", "\n", "}" ]
// PrivatePEM returns the PEM-encoded private key
[ "PrivatePEM", "returns", "the", "PEM", "-", "encoded", "private", "key" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/security/convert_keys.go#L26-L36
train
TheThingsNetwork/ttn
amqp/subscriber.go
NewSubscriber
func (c *DefaultClient) NewSubscriber(exchange, name string, durable, autoDelete bool) Subscriber { return &DefaultSubscriber{ DefaultChannelClient: DefaultChannelClient{ ctx: c.ctx, client: c, exchange: exchange, name: "Subscriber", }, name: name, durable: durable, autoDelete: autoDelete, } }
go
func (c *DefaultClient) NewSubscriber(exchange, name string, durable, autoDelete bool) Subscriber { return &DefaultSubscriber{ DefaultChannelClient: DefaultChannelClient{ ctx: c.ctx, client: c, exchange: exchange, name: "Subscriber", }, name: name, durable: durable, autoDelete: autoDelete, } }
[ "func", "(", "c", "*", "DefaultClient", ")", "NewSubscriber", "(", "exchange", ",", "name", "string", ",", "durable", ",", "autoDelete", "bool", ")", "Subscriber", "{", "return", "&", "DefaultSubscriber", "{", "DefaultChannelClient", ":", "DefaultChannelClient", "{", "ctx", ":", "c", ".", "ctx", ",", "client", ":", "c", ",", "exchange", ":", "exchange", ",", "name", ":", "\"", "\"", ",", "}", ",", "name", ":", "name", ",", "durable", ":", "durable", ",", "autoDelete", ":", "autoDelete", ",", "}", "\n", "}" ]
// NewSubscriber returns a new topic subscriber on the specified exchange
[ "NewSubscriber", "returns", "a", "new", "topic", "subscriber", "on", "the", "specified", "exchange" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/amqp/subscriber.go#L51-L63
train
TheThingsNetwork/ttn
amqp/subscriber.go
QueueDeclare
func (s *DefaultSubscriber) QueueDeclare() (string, error) { queue, err := s.channel.QueueDeclare(s.name, s.durable, s.autoDelete, false, false, nil) if err != nil { return "", fmt.Errorf("Failed to declare queue '%s' (%s)", s.name, err) } return queue.Name, nil }
go
func (s *DefaultSubscriber) QueueDeclare() (string, error) { queue, err := s.channel.QueueDeclare(s.name, s.durable, s.autoDelete, false, false, nil) if err != nil { return "", fmt.Errorf("Failed to declare queue '%s' (%s)", s.name, err) } return queue.Name, nil }
[ "func", "(", "s", "*", "DefaultSubscriber", ")", "QueueDeclare", "(", ")", "(", "string", ",", "error", ")", "{", "queue", ",", "err", ":=", "s", ".", "channel", ".", "QueueDeclare", "(", "s", ".", "name", ",", "s", ".", "durable", ",", "s", ".", "autoDelete", ",", "false", ",", "false", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ".", "name", ",", "err", ")", "\n", "}", "\n", "return", "queue", ".", "Name", ",", "nil", "\n", "}" ]
// QueueDeclare declares the queue on the AMQP broker
[ "QueueDeclare", "declares", "the", "queue", "on", "the", "AMQP", "broker" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/amqp/subscriber.go#L66-L72
train
TheThingsNetwork/ttn
amqp/subscriber.go
QueueBind
func (s *DefaultSubscriber) QueueBind(name, key string) error { err := s.channel.QueueBind(name, key, s.exchange, false, nil) if err != nil { return fmt.Errorf("Failed to bind queue %s with key %s on exchange '%s' (%s)", name, key, s.exchange, err) } return nil }
go
func (s *DefaultSubscriber) QueueBind(name, key string) error { err := s.channel.QueueBind(name, key, s.exchange, false, nil) if err != nil { return fmt.Errorf("Failed to bind queue %s with key %s on exchange '%s' (%s)", name, key, s.exchange, err) } return nil }
[ "func", "(", "s", "*", "DefaultSubscriber", ")", "QueueBind", "(", "name", ",", "key", "string", ")", "error", "{", "err", ":=", "s", ".", "channel", ".", "QueueBind", "(", "name", ",", "key", ",", "s", ".", "exchange", ",", "false", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ",", "key", ",", "s", ".", "exchange", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// QueueBind binds the routing key to the specified queue
[ "QueueBind", "binds", "the", "routing", "key", "to", "the", "specified", "queue" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/amqp/subscriber.go#L75-L81
train
TheThingsNetwork/ttn
utils/toa/toa.go
ComputeFSK
func ComputeFSK(payloadSize uint, bitrate int) (time.Duration, error) { tPkt := int64(time.Second) * (int64(payloadSize) + 5 + 3 + 1 + 2) * 8 / int64(bitrate) return time.Duration(tPkt), nil }
go
func ComputeFSK(payloadSize uint, bitrate int) (time.Duration, error) { tPkt := int64(time.Second) * (int64(payloadSize) + 5 + 3 + 1 + 2) * 8 / int64(bitrate) return time.Duration(tPkt), nil }
[ "func", "ComputeFSK", "(", "payloadSize", "uint", ",", "bitrate", "int", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "tPkt", ":=", "int64", "(", "time", ".", "Second", ")", "*", "(", "int64", "(", "payloadSize", ")", "+", "5", "+", "3", "+", "1", "+", "2", ")", "*", "8", "/", "int64", "(", "bitrate", ")", "\n", "return", "time", ".", "Duration", "(", "tPkt", ")", ",", "nil", "\n", "}" ]
// ComputeFSK computes the time-on-air given a PHY payload size in bytes and a // bitrate, Note that this function operates on the PHY payload size and does // not add the LoRaWAN header.
[ "ComputeFSK", "computes", "the", "time", "-", "on", "-", "air", "given", "a", "PHY", "payload", "size", "in", "bytes", "and", "a", "bitrate", "Note", "that", "this", "function", "operates", "on", "the", "PHY", "payload", "size", "and", "does", "not", "add", "the", "LoRaWAN", "header", "." ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/toa/toa.go#L60-L63
train
TheThingsNetwork/ttn
utils/backoff/backoff.go
Backoff
func (bc Config) Backoff(retries int) time.Duration { if retries == 0 { return bc.BaseDelay } backoff, max := float64(bc.BaseDelay), float64(bc.MaxDelay) for backoff < max && retries > 0 { backoff *= bc.Factor retries-- } if backoff > max { backoff = max } // Randomize backoff delays so that if a cluster of requests start at // the same time, they won't operate in lockstep. backoff *= 1 + bc.Jitter*(rand.Float64()*2-1) if backoff < 0 { return 0 } return time.Duration(backoff) }
go
func (bc Config) Backoff(retries int) time.Duration { if retries == 0 { return bc.BaseDelay } backoff, max := float64(bc.BaseDelay), float64(bc.MaxDelay) for backoff < max && retries > 0 { backoff *= bc.Factor retries-- } if backoff > max { backoff = max } // Randomize backoff delays so that if a cluster of requests start at // the same time, they won't operate in lockstep. backoff *= 1 + bc.Jitter*(rand.Float64()*2-1) if backoff < 0 { return 0 } return time.Duration(backoff) }
[ "func", "(", "bc", "Config", ")", "Backoff", "(", "retries", "int", ")", "time", ".", "Duration", "{", "if", "retries", "==", "0", "{", "return", "bc", ".", "BaseDelay", "\n", "}", "\n", "backoff", ",", "max", ":=", "float64", "(", "bc", ".", "BaseDelay", ")", ",", "float64", "(", "bc", ".", "MaxDelay", ")", "\n", "for", "backoff", "<", "max", "&&", "retries", ">", "0", "{", "backoff", "*=", "bc", ".", "Factor", "\n", "retries", "--", "\n", "}", "\n", "if", "backoff", ">", "max", "{", "backoff", "=", "max", "\n", "}", "\n", "// Randomize backoff delays so that if a cluster of requests start at", "// the same time, they won't operate in lockstep.", "backoff", "*=", "1", "+", "bc", ".", "Jitter", "*", "(", "rand", ".", "Float64", "(", ")", "*", "2", "-", "1", ")", "\n", "if", "backoff", "<", "0", "{", "return", "0", "\n", "}", "\n", "return", "time", ".", "Duration", "(", "backoff", ")", "\n", "}" ]
// Backoff returns the delay for the current amount of retries
[ "Backoff", "returns", "the", "delay", "for", "the", "current", "amount", "of", "retries" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/backoff/backoff.go#L36-L55
train
TheThingsNetwork/ttn
mqtt/uplink.go
PublishUplink
func (c *DefaultClient) PublishUplink(dataUp types.UplinkMessage) Token { topic := DeviceTopic{dataUp.AppID, dataUp.DevID, DeviceUplink, ""} msg, err := json.Marshal(dataUp) if err != nil { return &simpleToken{fmt.Errorf("Unable to marshal the message payload: %s", err)} } return c.publish(topic.String(), msg) }
go
func (c *DefaultClient) PublishUplink(dataUp types.UplinkMessage) Token { topic := DeviceTopic{dataUp.AppID, dataUp.DevID, DeviceUplink, ""} msg, err := json.Marshal(dataUp) if err != nil { return &simpleToken{fmt.Errorf("Unable to marshal the message payload: %s", err)} } return c.publish(topic.String(), msg) }
[ "func", "(", "c", "*", "DefaultClient", ")", "PublishUplink", "(", "dataUp", "types", ".", "UplinkMessage", ")", "Token", "{", "topic", ":=", "DeviceTopic", "{", "dataUp", ".", "AppID", ",", "dataUp", ".", "DevID", ",", "DeviceUplink", ",", "\"", "\"", "}", "\n", "msg", ",", "err", ":=", "json", ".", "Marshal", "(", "dataUp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "&", "simpleToken", "{", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "}", "\n", "}", "\n", "return", "c", ".", "publish", "(", "topic", ".", "String", "(", ")", ",", "msg", ")", "\n", "}" ]
// PublishUplink publishes an uplink message to the MQTT broker
[ "PublishUplink", "publishes", "an", "uplink", "message", "to", "the", "MQTT", "broker" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/uplink.go#L18-L25
train
TheThingsNetwork/ttn
mqtt/uplink.go
PublishUplinkFields
func (c *DefaultClient) PublishUplinkFields(appID string, devID string, fields map[string]interface{}) Token { flattenedFields := make(map[string]interface{}) flatten("", "/", fields, flattenedFields) tokens := make([]Token, 0, len(flattenedFields)) for field, value := range flattenedFields { topic := DeviceTopic{appID, devID, DeviceUplink, field} pld, _ := json.Marshal(value) token := c.publish(topic.String(), pld) tokens = append(tokens, token) } t := newToken() go func() { for _, token := range tokens { token.Wait() if token.Error() != nil { c.ctx.Warnf("mqtt: error publishing uplink fields: %s", token.Error()) t.err = token.Error() } } t.flowComplete() }() return t }
go
func (c *DefaultClient) PublishUplinkFields(appID string, devID string, fields map[string]interface{}) Token { flattenedFields := make(map[string]interface{}) flatten("", "/", fields, flattenedFields) tokens := make([]Token, 0, len(flattenedFields)) for field, value := range flattenedFields { topic := DeviceTopic{appID, devID, DeviceUplink, field} pld, _ := json.Marshal(value) token := c.publish(topic.String(), pld) tokens = append(tokens, token) } t := newToken() go func() { for _, token := range tokens { token.Wait() if token.Error() != nil { c.ctx.Warnf("mqtt: error publishing uplink fields: %s", token.Error()) t.err = token.Error() } } t.flowComplete() }() return t }
[ "func", "(", "c", "*", "DefaultClient", ")", "PublishUplinkFields", "(", "appID", "string", ",", "devID", "string", ",", "fields", "map", "[", "string", "]", "interface", "{", "}", ")", "Token", "{", "flattenedFields", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "flatten", "(", "\"", "\"", ",", "\"", "\"", ",", "fields", ",", "flattenedFields", ")", "\n", "tokens", ":=", "make", "(", "[", "]", "Token", ",", "0", ",", "len", "(", "flattenedFields", ")", ")", "\n", "for", "field", ",", "value", ":=", "range", "flattenedFields", "{", "topic", ":=", "DeviceTopic", "{", "appID", ",", "devID", ",", "DeviceUplink", ",", "field", "}", "\n", "pld", ",", "_", ":=", "json", ".", "Marshal", "(", "value", ")", "\n", "token", ":=", "c", ".", "publish", "(", "topic", ".", "String", "(", ")", ",", "pld", ")", "\n", "tokens", "=", "append", "(", "tokens", ",", "token", ")", "\n", "}", "\n", "t", ":=", "newToken", "(", ")", "\n", "go", "func", "(", ")", "{", "for", "_", ",", "token", ":=", "range", "tokens", "{", "token", ".", "Wait", "(", ")", "\n", "if", "token", ".", "Error", "(", ")", "!=", "nil", "{", "c", ".", "ctx", ".", "Warnf", "(", "\"", "\"", ",", "token", ".", "Error", "(", ")", ")", "\n", "t", ".", "err", "=", "token", ".", "Error", "(", ")", "\n", "}", "\n", "}", "\n", "t", ".", "flowComplete", "(", ")", "\n", "}", "(", ")", "\n", "return", "t", "\n", "}" ]
// PublishUplinkFields publishes uplink fields to MQTT
[ "PublishUplinkFields", "publishes", "uplink", "fields", "to", "MQTT" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/uplink.go#L28-L50
train
TheThingsNetwork/ttn
mqtt/uplink.go
UnsubscribeDeviceUplink
func (c *DefaultClient) UnsubscribeDeviceUplink(appID string, devID string) Token { topic := DeviceTopic{appID, devID, DeviceUplink, ""} return c.unsubscribe(topic.String()) }
go
func (c *DefaultClient) UnsubscribeDeviceUplink(appID string, devID string) Token { topic := DeviceTopic{appID, devID, DeviceUplink, ""} return c.unsubscribe(topic.String()) }
[ "func", "(", "c", "*", "DefaultClient", ")", "UnsubscribeDeviceUplink", "(", "appID", "string", ",", "devID", "string", ")", "Token", "{", "topic", ":=", "DeviceTopic", "{", "appID", ",", "devID", ",", "DeviceUplink", ",", "\"", "\"", "}", "\n", "return", "c", ".", "unsubscribe", "(", "topic", ".", "String", "(", ")", ")", "\n", "}" ]
// UnsubscribeDeviceUplink unsubscribes from the uplink messages for the given application and device
[ "UnsubscribeDeviceUplink", "unsubscribes", "from", "the", "uplink", "messages", "for", "the", "given", "application", "and", "device" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/uplink.go#L103-L106
train
TheThingsNetwork/ttn
core/networkserver/device/store.go
NewRedisDeviceStore
func NewRedisDeviceStore(client *redis.Client, prefix string) Store { if prefix == "" { prefix = defaultRedisPrefix } store := storage.NewRedisMapStore(client, prefix+":"+redisDevicePrefix) store.SetBase(Device{}, "") for v, f := range migrate.DeviceMigrations(prefix) { store.AddMigration(v, f) } frameStore := storage.NewRedisQueueStore(client, prefix+":"+redisFramesPrefix) s := &RedisDeviceStore{ client: client, prefix: prefix, store: store, frameStore: frameStore, devAddrIndex: storage.NewRedisSetStore(client, prefix+":"+redisDevAddrPrefix), } countStore(s) return s }
go
func NewRedisDeviceStore(client *redis.Client, prefix string) Store { if prefix == "" { prefix = defaultRedisPrefix } store := storage.NewRedisMapStore(client, prefix+":"+redisDevicePrefix) store.SetBase(Device{}, "") for v, f := range migrate.DeviceMigrations(prefix) { store.AddMigration(v, f) } frameStore := storage.NewRedisQueueStore(client, prefix+":"+redisFramesPrefix) s := &RedisDeviceStore{ client: client, prefix: prefix, store: store, frameStore: frameStore, devAddrIndex: storage.NewRedisSetStore(client, prefix+":"+redisDevAddrPrefix), } countStore(s) return s }
[ "func", "NewRedisDeviceStore", "(", "client", "*", "redis", ".", "Client", ",", "prefix", "string", ")", "Store", "{", "if", "prefix", "==", "\"", "\"", "{", "prefix", "=", "defaultRedisPrefix", "\n", "}", "\n", "store", ":=", "storage", ".", "NewRedisMapStore", "(", "client", ",", "prefix", "+", "\"", "\"", "+", "redisDevicePrefix", ")", "\n", "store", ".", "SetBase", "(", "Device", "{", "}", ",", "\"", "\"", ")", "\n", "for", "v", ",", "f", ":=", "range", "migrate", ".", "DeviceMigrations", "(", "prefix", ")", "{", "store", ".", "AddMigration", "(", "v", ",", "f", ")", "\n", "}", "\n", "frameStore", ":=", "storage", ".", "NewRedisQueueStore", "(", "client", ",", "prefix", "+", "\"", "\"", "+", "redisFramesPrefix", ")", "\n", "s", ":=", "&", "RedisDeviceStore", "{", "client", ":", "client", ",", "prefix", ":", "prefix", ",", "store", ":", "store", ",", "frameStore", ":", "frameStore", ",", "devAddrIndex", ":", "storage", ".", "NewRedisSetStore", "(", "client", ",", "prefix", "+", "\"", "\"", "+", "redisDevAddrPrefix", ")", ",", "}", "\n", "countStore", "(", "s", ")", "\n", "return", "s", "\n", "}" ]
// NewRedisDeviceStore creates a new Redis-based status store
[ "NewRedisDeviceStore", "creates", "a", "new", "Redis", "-", "based", "status", "store" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/networkserver/device/store.go#L36-L55
train
TheThingsNetwork/ttn
core/networkserver/device/store.go
CountForAddress
func (s *RedisDeviceStore) CountForAddress(devAddr types.DevAddr) (int, error) { return s.devAddrIndex.Count(devAddr.String()) }
go
func (s *RedisDeviceStore) CountForAddress(devAddr types.DevAddr) (int, error) { return s.devAddrIndex.Count(devAddr.String()) }
[ "func", "(", "s", "*", "RedisDeviceStore", ")", "CountForAddress", "(", "devAddr", "types", ".", "DevAddr", ")", "(", "int", ",", "error", ")", "{", "return", "s", ".", "devAddrIndex", ".", "Count", "(", "devAddr", ".", "String", "(", ")", ")", "\n", "}" ]
// CountForAddress counts all devices for a specific DevAddr
[ "CountForAddress", "counts", "all", "devices", "for", "a", "specific", "DevAddr" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/networkserver/device/store.go#L96-L98
train
TheThingsNetwork/ttn
core/networkserver/device/store.go
ListForAddress
func (s *RedisDeviceStore) ListForAddress(devAddr types.DevAddr) ([]*Device, error) { deviceKeys, err := s.devAddrIndex.Get(devAddr.String()) if errors.GetErrType(err) == errors.NotFound { return nil, nil } if err != nil { return nil, err } devicesI, err := s.store.GetAll(deviceKeys, nil) if err != nil { return nil, err } devices := make([]*Device, len(devicesI)) for i, deviceI := range devicesI { if device, ok := deviceI.(Device); ok { devices[i] = &device } } return devices, nil }
go
func (s *RedisDeviceStore) ListForAddress(devAddr types.DevAddr) ([]*Device, error) { deviceKeys, err := s.devAddrIndex.Get(devAddr.String()) if errors.GetErrType(err) == errors.NotFound { return nil, nil } if err != nil { return nil, err } devicesI, err := s.store.GetAll(deviceKeys, nil) if err != nil { return nil, err } devices := make([]*Device, len(devicesI)) for i, deviceI := range devicesI { if device, ok := deviceI.(Device); ok { devices[i] = &device } } return devices, nil }
[ "func", "(", "s", "*", "RedisDeviceStore", ")", "ListForAddress", "(", "devAddr", "types", ".", "DevAddr", ")", "(", "[", "]", "*", "Device", ",", "error", ")", "{", "deviceKeys", ",", "err", ":=", "s", ".", "devAddrIndex", ".", "Get", "(", "devAddr", ".", "String", "(", ")", ")", "\n", "if", "errors", ".", "GetErrType", "(", "err", ")", "==", "errors", ".", "NotFound", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "devicesI", ",", "err", ":=", "s", ".", "store", ".", "GetAll", "(", "deviceKeys", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "devices", ":=", "make", "(", "[", "]", "*", "Device", ",", "len", "(", "devicesI", ")", ")", "\n", "for", "i", ",", "deviceI", ":=", "range", "devicesI", "{", "if", "device", ",", "ok", ":=", "deviceI", ".", "(", "Device", ")", ";", "ok", "{", "devices", "[", "i", "]", "=", "&", "device", "\n", "}", "\n", "}", "\n", "return", "devices", ",", "nil", "\n", "}" ]
// ListForAddress lists all devices for a specific DevAddr
[ "ListForAddress", "lists", "all", "devices", "for", "a", "specific", "DevAddr" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/networkserver/device/store.go#L101-L120
train
TheThingsNetwork/ttn
core/networkserver/device/store.go
Frames
func (s *RedisDeviceStore) Frames(appEUI types.AppEUI, devEUI types.DevEUI) (FrameHistory, error) { return &RedisFrameHistory{ appEUI: appEUI, devEUI: devEUI, store: s.frameStore, }, nil }
go
func (s *RedisDeviceStore) Frames(appEUI types.AppEUI, devEUI types.DevEUI) (FrameHistory, error) { return &RedisFrameHistory{ appEUI: appEUI, devEUI: devEUI, store: s.frameStore, }, nil }
[ "func", "(", "s", "*", "RedisDeviceStore", ")", "Frames", "(", "appEUI", "types", ".", "AppEUI", ",", "devEUI", "types", ".", "DevEUI", ")", "(", "FrameHistory", ",", "error", ")", "{", "return", "&", "RedisFrameHistory", "{", "appEUI", ":", "appEUI", ",", "devEUI", ":", "devEUI", ",", "store", ":", "s", ".", "frameStore", ",", "}", ",", "nil", "\n", "}" ]
// Frames history for a specific Device
[ "Frames", "history", "for", "a", "specific", "Device" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/networkserver/device/store.go#L192-L198
train
TheThingsNetwork/ttn
ttnctl/util/mqtt.go
GetMQTT
func GetMQTT(ctx ttnlog.Interface, accessKey string) mqtt.Client { username, password, err := getMQTTCredentials(ctx, accessKey) if err != nil { ctx.WithError(err).Fatal("Failed to get MQTT credentials") } mqttProto := "tcp" if strings.HasSuffix(viper.GetString("mqtt-address"), ":8883") { mqttProto = "ssl" ctx.Fatal("TLS connections are not yet supported by ttnctl") } broker := fmt.Sprintf("%s://%s", mqttProto, viper.GetString("mqtt-address")) client := mqtt.NewClient(ctx, "ttnctl", username, password, broker) ctx.WithFields(ttnlog.Fields{ "MQTT Broker": broker, "Username": username, }).Info("Connecting to MQTT...") if err := client.Connect(); err != nil { ctx.WithError(err).Fatal("Could not connect") } return client }
go
func GetMQTT(ctx ttnlog.Interface, accessKey string) mqtt.Client { username, password, err := getMQTTCredentials(ctx, accessKey) if err != nil { ctx.WithError(err).Fatal("Failed to get MQTT credentials") } mqttProto := "tcp" if strings.HasSuffix(viper.GetString("mqtt-address"), ":8883") { mqttProto = "ssl" ctx.Fatal("TLS connections are not yet supported by ttnctl") } broker := fmt.Sprintf("%s://%s", mqttProto, viper.GetString("mqtt-address")) client := mqtt.NewClient(ctx, "ttnctl", username, password, broker) ctx.WithFields(ttnlog.Fields{ "MQTT Broker": broker, "Username": username, }).Info("Connecting to MQTT...") if err := client.Connect(); err != nil { ctx.WithError(err).Fatal("Could not connect") } return client }
[ "func", "GetMQTT", "(", "ctx", "ttnlog", ".", "Interface", ",", "accessKey", "string", ")", "mqtt", ".", "Client", "{", "username", ",", "password", ",", "err", ":=", "getMQTTCredentials", "(", "ctx", ",", "accessKey", ")", "\n", "if", "err", "!=", "nil", "{", "ctx", ".", "WithError", "(", "err", ")", ".", "Fatal", "(", "\"", "\"", ")", "\n", "}", "\n\n", "mqttProto", ":=", "\"", "\"", "\n", "if", "strings", ".", "HasSuffix", "(", "viper", ".", "GetString", "(", "\"", "\"", ")", ",", "\"", "\"", ")", "{", "mqttProto", "=", "\"", "\"", "\n", "ctx", ".", "Fatal", "(", "\"", "\"", ")", "\n", "}", "\n", "broker", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "mqttProto", ",", "viper", ".", "GetString", "(", "\"", "\"", ")", ")", "\n", "client", ":=", "mqtt", ".", "NewClient", "(", "ctx", ",", "\"", "\"", ",", "username", ",", "password", ",", "broker", ")", "\n\n", "ctx", ".", "WithFields", "(", "ttnlog", ".", "Fields", "{", "\"", "\"", ":", "broker", ",", "\"", "\"", ":", "username", ",", "}", ")", ".", "Info", "(", "\"", "\"", ")", "\n\n", "if", "err", ":=", "client", ".", "Connect", "(", ")", ";", "err", "!=", "nil", "{", "ctx", ".", "WithError", "(", "err", ")", ".", "Fatal", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "client", "\n", "}" ]
// GetMQTT connects a new MQTT clients with the specified credentials
[ "GetMQTT", "connects", "a", "new", "MQTT", "clients", "with", "the", "specified", "credentials" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/mqtt.go#L18-L42
train
TheThingsNetwork/ttn
core/router/gateway/gateway.go
NewGateway
func NewGateway(ctx ttnlog.Interface, id string) *Gateway { ctx = ctx.WithField("GatewayID", id) gtw := &Gateway{ ID: id, Status: NewStatusStore(), Utilization: NewUtilization(), Schedule: NewSchedule(ctx), Ctx: ctx, } gtw.Schedule.(*schedule).gateway = gtw // FIXME: Issue #420 return gtw }
go
func NewGateway(ctx ttnlog.Interface, id string) *Gateway { ctx = ctx.WithField("GatewayID", id) gtw := &Gateway{ ID: id, Status: NewStatusStore(), Utilization: NewUtilization(), Schedule: NewSchedule(ctx), Ctx: ctx, } gtw.Schedule.(*schedule).gateway = gtw // FIXME: Issue #420 return gtw }
[ "func", "NewGateway", "(", "ctx", "ttnlog", ".", "Interface", ",", "id", "string", ")", "*", "Gateway", "{", "ctx", "=", "ctx", ".", "WithField", "(", "\"", "\"", ",", "id", ")", "\n", "gtw", ":=", "&", "Gateway", "{", "ID", ":", "id", ",", "Status", ":", "NewStatusStore", "(", ")", ",", "Utilization", ":", "NewUtilization", "(", ")", ",", "Schedule", ":", "NewSchedule", "(", "ctx", ")", ",", "Ctx", ":", "ctx", ",", "}", "\n", "gtw", ".", "Schedule", ".", "(", "*", "schedule", ")", ".", "gateway", "=", "gtw", "// FIXME: Issue #420", "\n", "return", "gtw", "\n", "}" ]
// NewGateway creates a new in-memory Gateway structure
[ "NewGateway", "creates", "a", "new", "in", "-", "memory", "Gateway", "structure" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/router/gateway/gateway.go#L19-L30
train
TheThingsNetwork/ttn
utils/security/jwt.go
BuildJWT
func BuildJWT(subject string, ttl time.Duration, privateKey []byte) (token string, err error) { claims := jwt.StandardClaims{ Issuer: subject, Subject: subject, IssuedAt: time.Now().Add(-20 * time.Second).Unix(), NotBefore: time.Now().Add(-20 * time.Second).Unix(), } if ttl > 0 { claims.ExpiresAt = time.Now().Add(ttl).Unix() } tokenBuilder := jwt.NewWithClaims(jwt.SigningMethodES256, claims) var key *ecdsa.PrivateKey key, err = jwt.ParseECPrivateKeyFromPEM(privateKey) if err != nil { return } token, err = tokenBuilder.SignedString(key) if err != nil { return } return }
go
func BuildJWT(subject string, ttl time.Duration, privateKey []byte) (token string, err error) { claims := jwt.StandardClaims{ Issuer: subject, Subject: subject, IssuedAt: time.Now().Add(-20 * time.Second).Unix(), NotBefore: time.Now().Add(-20 * time.Second).Unix(), } if ttl > 0 { claims.ExpiresAt = time.Now().Add(ttl).Unix() } tokenBuilder := jwt.NewWithClaims(jwt.SigningMethodES256, claims) var key *ecdsa.PrivateKey key, err = jwt.ParseECPrivateKeyFromPEM(privateKey) if err != nil { return } token, err = tokenBuilder.SignedString(key) if err != nil { return } return }
[ "func", "BuildJWT", "(", "subject", "string", ",", "ttl", "time", ".", "Duration", ",", "privateKey", "[", "]", "byte", ")", "(", "token", "string", ",", "err", "error", ")", "{", "claims", ":=", "jwt", ".", "StandardClaims", "{", "Issuer", ":", "subject", ",", "Subject", ":", "subject", ",", "IssuedAt", ":", "time", ".", "Now", "(", ")", ".", "Add", "(", "-", "20", "*", "time", ".", "Second", ")", ".", "Unix", "(", ")", ",", "NotBefore", ":", "time", ".", "Now", "(", ")", ".", "Add", "(", "-", "20", "*", "time", ".", "Second", ")", ".", "Unix", "(", ")", ",", "}", "\n", "if", "ttl", ">", "0", "{", "claims", ".", "ExpiresAt", "=", "time", ".", "Now", "(", ")", ".", "Add", "(", "ttl", ")", ".", "Unix", "(", ")", "\n", "}", "\n", "tokenBuilder", ":=", "jwt", ".", "NewWithClaims", "(", "jwt", ".", "SigningMethodES256", ",", "claims", ")", "\n", "var", "key", "*", "ecdsa", ".", "PrivateKey", "\n", "key", ",", "err", "=", "jwt", ".", "ParseECPrivateKeyFromPEM", "(", "privateKey", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "token", ",", "err", "=", "tokenBuilder", ".", "SignedString", "(", "key", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "return", "\n", "}" ]
// BuildJWT builds a JSON Web Token for the given subject and ttl, and signs it with the given private key
[ "BuildJWT", "builds", "a", "JSON", "Web", "Token", "for", "the", "given", "subject", "and", "ttl", "and", "signs", "it", "with", "the", "given", "private", "key" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/security/jwt.go#L15-L36
train
TheThingsNetwork/ttn
utils/security/jwt.go
ValidateJWT
func ValidateJWT(token string, publicKey []byte) (*jwt.StandardClaims, error) { claims := &jwt.StandardClaims{} _, err := jwt.ParseWithClaims(token, claims, func(token *jwt.Token) (interface{}, error) { if _, ok := token.Method.(*jwt.SigningMethodECDSA); !ok { return nil, fmt.Errorf("Unexpected JWT signing method: %v", token.Header["alg"]) } key, err := jwt.ParseECPublicKeyFromPEM(publicKey) if err != nil { return nil, err } return key, nil }) if err != nil { return nil, fmt.Errorf("Unable to verify JWT: %s", err.Error()) } return claims, nil }
go
func ValidateJWT(token string, publicKey []byte) (*jwt.StandardClaims, error) { claims := &jwt.StandardClaims{} _, err := jwt.ParseWithClaims(token, claims, func(token *jwt.Token) (interface{}, error) { if _, ok := token.Method.(*jwt.SigningMethodECDSA); !ok { return nil, fmt.Errorf("Unexpected JWT signing method: %v", token.Header["alg"]) } key, err := jwt.ParseECPublicKeyFromPEM(publicKey) if err != nil { return nil, err } return key, nil }) if err != nil { return nil, fmt.Errorf("Unable to verify JWT: %s", err.Error()) } return claims, nil }
[ "func", "ValidateJWT", "(", "token", "string", ",", "publicKey", "[", "]", "byte", ")", "(", "*", "jwt", ".", "StandardClaims", ",", "error", ")", "{", "claims", ":=", "&", "jwt", ".", "StandardClaims", "{", "}", "\n", "_", ",", "err", ":=", "jwt", ".", "ParseWithClaims", "(", "token", ",", "claims", ",", "func", "(", "token", "*", "jwt", ".", "Token", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "_", ",", "ok", ":=", "token", ".", "Method", ".", "(", "*", "jwt", ".", "SigningMethodECDSA", ")", ";", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "token", ".", "Header", "[", "\"", "\"", "]", ")", "\n", "}", "\n", "key", ",", "err", ":=", "jwt", ".", "ParseECPublicKeyFromPEM", "(", "publicKey", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "key", ",", "nil", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "return", "claims", ",", "nil", "\n", "}" ]
// ValidateJWT validates a JSON Web Token with the given public key
[ "ValidateJWT", "validates", "a", "JSON", "Web", "Token", "with", "the", "given", "public", "key" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/security/jwt.go#L39-L55
train
TheThingsNetwork/ttn
utils/fcnt/fcnt.go
GetFull
func GetFull(full uint32, lsb uint16) uint32 { if int(lsb)-int(full) > 0 { return uint32(lsb) } if uint16(full%maxUint16) <= lsb { return uint32(lsb) + (full/maxUint16)*maxUint16 } return uint32(lsb) + ((full/maxUint16)+1)*maxUint16 }
go
func GetFull(full uint32, lsb uint16) uint32 { if int(lsb)-int(full) > 0 { return uint32(lsb) } if uint16(full%maxUint16) <= lsb { return uint32(lsb) + (full/maxUint16)*maxUint16 } return uint32(lsb) + ((full/maxUint16)+1)*maxUint16 }
[ "func", "GetFull", "(", "full", "uint32", ",", "lsb", "uint16", ")", "uint32", "{", "if", "int", "(", "lsb", ")", "-", "int", "(", "full", ")", ">", "0", "{", "return", "uint32", "(", "lsb", ")", "\n", "}", "\n", "if", "uint16", "(", "full", "%", "maxUint16", ")", "<=", "lsb", "{", "return", "uint32", "(", "lsb", ")", "+", "(", "full", "/", "maxUint16", ")", "*", "maxUint16", "\n", "}", "\n", "return", "uint32", "(", "lsb", ")", "+", "(", "(", "full", "/", "maxUint16", ")", "+", "1", ")", "*", "maxUint16", "\n", "}" ]
// GetFull calculates the full 32-bit frame counter
[ "GetFull", "calculates", "the", "full", "32", "-", "bit", "frame", "counter" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/fcnt/fcnt.go#L9-L17
train
TheThingsNetwork/ttn
core/types/dev_addr.go
ParseDevAddr
func ParseDevAddr(input string) (addr DevAddr, err error) { bytes, err := ParseHEX(input, 4) if err != nil { return } copy(addr[:], bytes) return }
go
func ParseDevAddr(input string) (addr DevAddr, err error) { bytes, err := ParseHEX(input, 4) if err != nil { return } copy(addr[:], bytes) return }
[ "func", "ParseDevAddr", "(", "input", "string", ")", "(", "addr", "DevAddr", ",", "err", "error", ")", "{", "bytes", ",", "err", ":=", "ParseHEX", "(", "input", ",", "4", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "copy", "(", "addr", "[", ":", "]", ",", "bytes", ")", "\n", "return", "\n", "}" ]
// ParseDevAddr parses a 32-bit hex-encoded string to a DevAddr
[ "ParseDevAddr", "parses", "a", "32", "-", "bit", "hex", "-", "encoded", "string", "to", "a", "DevAddr" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/dev_addr.go#L20-L27
train
TheThingsNetwork/ttn
core/types/dev_addr.go
Bytes
func (prefix DevAddrPrefix) Bytes() (bytes []byte) { bytes = append(bytes, byte(prefix.Length)) bytes = append(bytes, prefix.DevAddr.Bytes()...) return bytes }
go
func (prefix DevAddrPrefix) Bytes() (bytes []byte) { bytes = append(bytes, byte(prefix.Length)) bytes = append(bytes, prefix.DevAddr.Bytes()...) return bytes }
[ "func", "(", "prefix", "DevAddrPrefix", ")", "Bytes", "(", ")", "(", "bytes", "[", "]", "byte", ")", "{", "bytes", "=", "append", "(", "bytes", ",", "byte", "(", "prefix", ".", "Length", ")", ")", "\n", "bytes", "=", "append", "(", "bytes", ",", "prefix", ".", "DevAddr", ".", "Bytes", "(", ")", "...", ")", "\n", "return", "bytes", "\n", "}" ]
// Bytes returns the DevAddrPrefix as a byte slice
[ "Bytes", "returns", "the", "DevAddrPrefix", "as", "a", "byte", "slice" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/dev_addr.go#L130-L134
train
TheThingsNetwork/ttn
core/types/dev_addr.go
String
func (prefix DevAddrPrefix) String() string { var addr string if prefix.DevAddr.IsEmpty() { addr = "00000000" } else { addr = prefix.DevAddr.String() } return fmt.Sprintf("%s/%d", addr, prefix.Length) }
go
func (prefix DevAddrPrefix) String() string { var addr string if prefix.DevAddr.IsEmpty() { addr = "00000000" } else { addr = prefix.DevAddr.String() } return fmt.Sprintf("%s/%d", addr, prefix.Length) }
[ "func", "(", "prefix", "DevAddrPrefix", ")", "String", "(", ")", "string", "{", "var", "addr", "string", "\n", "if", "prefix", ".", "DevAddr", ".", "IsEmpty", "(", ")", "{", "addr", "=", "\"", "\"", "\n", "}", "else", "{", "addr", "=", "prefix", ".", "DevAddr", ".", "String", "(", ")", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "addr", ",", "prefix", ".", "Length", ")", "\n", "}" ]
// String implements the fmt.Stringer interface
[ "String", "implements", "the", "fmt", ".", "Stringer", "interface" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/dev_addr.go#L137-L145
train
TheThingsNetwork/ttn
core/types/dev_addr.go
Mask
func (addr DevAddr) Mask(bits int) (masked DevAddr) { return empty.WithPrefix(DevAddrPrefix{addr, bits}) }
go
func (addr DevAddr) Mask(bits int) (masked DevAddr) { return empty.WithPrefix(DevAddrPrefix{addr, bits}) }
[ "func", "(", "addr", "DevAddr", ")", "Mask", "(", "bits", "int", ")", "(", "masked", "DevAddr", ")", "{", "return", "empty", ".", "WithPrefix", "(", "DevAddrPrefix", "{", "addr", ",", "bits", "}", ")", "\n", "}" ]
// Mask returns a copy of the DevAddr with only the first "bits" bits
[ "Mask", "returns", "a", "copy", "of", "the", "DevAddr", "with", "only", "the", "first", "bits", "bits" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/dev_addr.go#L202-L204
train
TheThingsNetwork/ttn
core/types/dev_addr.go
WithPrefix
func (addr DevAddr) WithPrefix(prefix DevAddrPrefix) (prefixed DevAddr) { k := uint(prefix.Length) for i := 0; i < 4; i++ { if k >= 8 { prefixed[i] = prefix.DevAddr[i] & 0xff k -= 8 continue } prefixed[i] = (prefix.DevAddr[i] & ^byte(0xff>>k)) | (addr[i] & byte(0xff>>k)) k = 0 } return }
go
func (addr DevAddr) WithPrefix(prefix DevAddrPrefix) (prefixed DevAddr) { k := uint(prefix.Length) for i := 0; i < 4; i++ { if k >= 8 { prefixed[i] = prefix.DevAddr[i] & 0xff k -= 8 continue } prefixed[i] = (prefix.DevAddr[i] & ^byte(0xff>>k)) | (addr[i] & byte(0xff>>k)) k = 0 } return }
[ "func", "(", "addr", "DevAddr", ")", "WithPrefix", "(", "prefix", "DevAddrPrefix", ")", "(", "prefixed", "DevAddr", ")", "{", "k", ":=", "uint", "(", "prefix", ".", "Length", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "4", ";", "i", "++", "{", "if", "k", ">=", "8", "{", "prefixed", "[", "i", "]", "=", "prefix", ".", "DevAddr", "[", "i", "]", "&", "0xff", "\n", "k", "-=", "8", "\n", "continue", "\n", "}", "\n", "prefixed", "[", "i", "]", "=", "(", "prefix", ".", "DevAddr", "[", "i", "]", "&", "^", "byte", "(", "0xff", ">>", "k", ")", ")", "|", "(", "addr", "[", "i", "]", "&", "byte", "(", "0xff", ">>", "k", ")", ")", "\n", "k", "=", "0", "\n", "}", "\n", "return", "\n", "}" ]
// WithPrefix returns the DevAddr, but with the first length bits replaced by the Prefix
[ "WithPrefix", "returns", "the", "DevAddr", "but", "with", "the", "first", "length", "bits", "replaced", "by", "the", "Prefix" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/dev_addr.go#L207-L219
train
TheThingsNetwork/ttn
core/types/dev_addr.go
HasPrefix
func (addr DevAddr) HasPrefix(prefix DevAddrPrefix) bool { return addr.Mask(prefix.Length) == prefix.DevAddr.Mask(prefix.Length) }
go
func (addr DevAddr) HasPrefix(prefix DevAddrPrefix) bool { return addr.Mask(prefix.Length) == prefix.DevAddr.Mask(prefix.Length) }
[ "func", "(", "addr", "DevAddr", ")", "HasPrefix", "(", "prefix", "DevAddrPrefix", ")", "bool", "{", "return", "addr", ".", "Mask", "(", "prefix", ".", "Length", ")", "==", "prefix", ".", "DevAddr", ".", "Mask", "(", "prefix", ".", "Length", ")", "\n", "}" ]
// HasPrefix returns true if the DevAddr has a prefix of given length
[ "HasPrefix", "returns", "true", "if", "the", "DevAddr", "has", "a", "prefix", "of", "given", "length" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/dev_addr.go#L222-L224
train
minio/sio
reader-v1.go
encryptReaderV10
func encryptReaderV10(src io.Reader, config *Config) (*encReaderV10, error) { ae, err := newAuthEncV10(config) if err != nil { return nil, err } return &encReaderV10{ authEncV10: ae, src: src, buffer: make(packageV10, maxPackageSize), payloadSize: config.PayloadSize, }, nil }
go
func encryptReaderV10(src io.Reader, config *Config) (*encReaderV10, error) { ae, err := newAuthEncV10(config) if err != nil { return nil, err } return &encReaderV10{ authEncV10: ae, src: src, buffer: make(packageV10, maxPackageSize), payloadSize: config.PayloadSize, }, nil }
[ "func", "encryptReaderV10", "(", "src", "io", ".", "Reader", ",", "config", "*", "Config", ")", "(", "*", "encReaderV10", ",", "error", ")", "{", "ae", ",", "err", ":=", "newAuthEncV10", "(", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "encReaderV10", "{", "authEncV10", ":", "ae", ",", "src", ":", "src", ",", "buffer", ":", "make", "(", "packageV10", ",", "maxPackageSize", ")", ",", "payloadSize", ":", "config", ".", "PayloadSize", ",", "}", ",", "nil", "\n", "}" ]
// encryptReaderV10 returns an io.Reader wrapping the given io.Reader. // The returned io.Reader encrypts everything it reads using DARE 1.0.
[ "encryptReaderV10", "returns", "an", "io", ".", "Reader", "wrapping", "the", "given", "io", ".", "Reader", ".", "The", "returned", "io", ".", "Reader", "encrypts", "everything", "it", "reads", "using", "DARE", "1", ".", "0", "." ]
035b4ef8c449ba2ba21ec143c91964e76a1fb68c
https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/reader-v1.go#L30-L41
train
minio/sio
reader-v1.go
decryptReaderV10
func decryptReaderV10(src io.Reader, config *Config) (*decReaderV10, error) { ad, err := newAuthDecV10(config) if err != nil { return nil, err } return &decReaderV10{ authDecV10: ad, src: src, buffer: make(packageV10, maxPackageSize), }, nil }
go
func decryptReaderV10(src io.Reader, config *Config) (*decReaderV10, error) { ad, err := newAuthDecV10(config) if err != nil { return nil, err } return &decReaderV10{ authDecV10: ad, src: src, buffer: make(packageV10, maxPackageSize), }, nil }
[ "func", "decryptReaderV10", "(", "src", "io", ".", "Reader", ",", "config", "*", "Config", ")", "(", "*", "decReaderV10", ",", "error", ")", "{", "ad", ",", "err", ":=", "newAuthDecV10", "(", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "decReaderV10", "{", "authDecV10", ":", "ad", ",", "src", ":", "src", ",", "buffer", ":", "make", "(", "packageV10", ",", "maxPackageSize", ")", ",", "}", ",", "nil", "\n", "}" ]
// decryptReaderV10 returns an io.Reader wrapping the given io.Reader. // The returned io.Reader decrypts everything it reads using DARE 1.0.
[ "decryptReaderV10", "returns", "an", "io", ".", "Reader", "wrapping", "the", "given", "io", ".", "Reader", ".", "The", "returned", "io", ".", "Reader", "decrypts", "everything", "it", "reads", "using", "DARE", "1", ".", "0", "." ]
035b4ef8c449ba2ba21ec143c91964e76a1fb68c
https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/reader-v1.go#L91-L101
train
minio/sio
sio.go
Encrypt
func Encrypt(dst io.Writer, src io.Reader, config Config) (n int64, err error) { encReader, err := EncryptReader(src, config) if err != nil { return 0, err } return io.CopyBuffer(dst, encReader, make([]byte, headerSize+maxPayloadSize+tagSize)) }
go
func Encrypt(dst io.Writer, src io.Reader, config Config) (n int64, err error) { encReader, err := EncryptReader(src, config) if err != nil { return 0, err } return io.CopyBuffer(dst, encReader, make([]byte, headerSize+maxPayloadSize+tagSize)) }
[ "func", "Encrypt", "(", "dst", "io", ".", "Writer", ",", "src", "io", ".", "Reader", ",", "config", "Config", ")", "(", "n", "int64", ",", "err", "error", ")", "{", "encReader", ",", "err", ":=", "EncryptReader", "(", "src", ",", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "return", "io", ".", "CopyBuffer", "(", "dst", ",", "encReader", ",", "make", "(", "[", "]", "byte", ",", "headerSize", "+", "maxPayloadSize", "+", "tagSize", ")", ")", "\n", "}" ]
// Encrypt reads from src until it encounters an io.EOF and encrypts all received // data. The encrypted data is written to dst. It returns the number of bytes // encrypted and the first error encountered while encrypting, if any. // // Encrypt returns the number of bytes written to dst.
[ "Encrypt", "reads", "from", "src", "until", "it", "encounters", "an", "io", ".", "EOF", "and", "encrypts", "all", "received", "data", ".", "The", "encrypted", "data", "is", "written", "to", "dst", ".", "It", "returns", "the", "number", "of", "bytes", "encrypted", "and", "the", "first", "error", "encountered", "while", "encrypting", "if", "any", ".", "Encrypt", "returns", "the", "number", "of", "bytes", "written", "to", "dst", "." ]
035b4ef8c449ba2ba21ec143c91964e76a1fb68c
https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/sio.go#L174-L180
train
minio/sio
sio.go
Decrypt
func Decrypt(dst io.Writer, src io.Reader, config Config) (n int64, err error) { decReader, err := DecryptReader(src, config) if err != nil { return 0, err } return io.CopyBuffer(dst, decReader, make([]byte, maxPayloadSize)) }
go
func Decrypt(dst io.Writer, src io.Reader, config Config) (n int64, err error) { decReader, err := DecryptReader(src, config) if err != nil { return 0, err } return io.CopyBuffer(dst, decReader, make([]byte, maxPayloadSize)) }
[ "func", "Decrypt", "(", "dst", "io", ".", "Writer", ",", "src", "io", ".", "Reader", ",", "config", "Config", ")", "(", "n", "int64", ",", "err", "error", ")", "{", "decReader", ",", "err", ":=", "DecryptReader", "(", "src", ",", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "return", "io", ".", "CopyBuffer", "(", "dst", ",", "decReader", ",", "make", "(", "[", "]", "byte", ",", "maxPayloadSize", ")", ")", "\n", "}" ]
// Decrypt reads from src until it encounters an io.EOF and decrypts all received // data. The decrypted data is written to dst. It returns the number of bytes // decrypted and the first error encountered while decrypting, if any. // // Decrypt returns the number of bytes written to dst. Decrypt only writes data to // dst if the data was decrypted successfully. It returns an error of type sio.Error // if decryption fails.
[ "Decrypt", "reads", "from", "src", "until", "it", "encounters", "an", "io", ".", "EOF", "and", "decrypts", "all", "received", "data", ".", "The", "decrypted", "data", "is", "written", "to", "dst", ".", "It", "returns", "the", "number", "of", "bytes", "decrypted", "and", "the", "first", "error", "encountered", "while", "decrypting", "if", "any", ".", "Decrypt", "returns", "the", "number", "of", "bytes", "written", "to", "dst", ".", "Decrypt", "only", "writes", "data", "to", "dst", "if", "the", "data", "was", "decrypted", "successfully", ".", "It", "returns", "an", "error", "of", "type", "sio", ".", "Error", "if", "decryption", "fails", "." ]
035b4ef8c449ba2ba21ec143c91964e76a1fb68c
https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/sio.go#L189-L195
train
minio/sio
sio.go
EncryptReader
func EncryptReader(src io.Reader, config Config) (io.Reader, error) { if err := setConfigDefaults(&config); err != nil { return nil, err } if config.MaxVersion == Version20 { return encryptReaderV20(src, &config) } return encryptReaderV10(src, &config) }
go
func EncryptReader(src io.Reader, config Config) (io.Reader, error) { if err := setConfigDefaults(&config); err != nil { return nil, err } if config.MaxVersion == Version20 { return encryptReaderV20(src, &config) } return encryptReaderV10(src, &config) }
[ "func", "EncryptReader", "(", "src", "io", ".", "Reader", ",", "config", "Config", ")", "(", "io", ".", "Reader", ",", "error", ")", "{", "if", "err", ":=", "setConfigDefaults", "(", "&", "config", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "config", ".", "MaxVersion", "==", "Version20", "{", "return", "encryptReaderV20", "(", "src", ",", "&", "config", ")", "\n", "}", "\n", "return", "encryptReaderV10", "(", "src", ",", "&", "config", ")", "\n", "}" ]
// EncryptReader wraps the given src and returns an io.Reader which encrypts // all received data. EncryptReader returns an error if the provided encryption // configuration is invalid.
[ "EncryptReader", "wraps", "the", "given", "src", "and", "returns", "an", "io", ".", "Reader", "which", "encrypts", "all", "received", "data", ".", "EncryptReader", "returns", "an", "error", "if", "the", "provided", "encryption", "configuration", "is", "invalid", "." ]
035b4ef8c449ba2ba21ec143c91964e76a1fb68c
https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/sio.go#L200-L208
train
minio/sio
sio.go
DecryptReader
func DecryptReader(src io.Reader, config Config) (io.Reader, error) { if err := setConfigDefaults(&config); err != nil { return nil, err } if config.MinVersion == Version10 && config.MaxVersion == Version10 { return decryptReaderV10(src, &config) } if config.MinVersion == Version20 && config.MaxVersion == Version20 { return decryptReaderV20(src, &config) } return decryptReader(src, &config), nil }
go
func DecryptReader(src io.Reader, config Config) (io.Reader, error) { if err := setConfigDefaults(&config); err != nil { return nil, err } if config.MinVersion == Version10 && config.MaxVersion == Version10 { return decryptReaderV10(src, &config) } if config.MinVersion == Version20 && config.MaxVersion == Version20 { return decryptReaderV20(src, &config) } return decryptReader(src, &config), nil }
[ "func", "DecryptReader", "(", "src", "io", ".", "Reader", ",", "config", "Config", ")", "(", "io", ".", "Reader", ",", "error", ")", "{", "if", "err", ":=", "setConfigDefaults", "(", "&", "config", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "config", ".", "MinVersion", "==", "Version10", "&&", "config", ".", "MaxVersion", "==", "Version10", "{", "return", "decryptReaderV10", "(", "src", ",", "&", "config", ")", "\n", "}", "\n", "if", "config", ".", "MinVersion", "==", "Version20", "&&", "config", ".", "MaxVersion", "==", "Version20", "{", "return", "decryptReaderV20", "(", "src", ",", "&", "config", ")", "\n", "}", "\n", "return", "decryptReader", "(", "src", ",", "&", "config", ")", ",", "nil", "\n", "}" ]
// DecryptReader wraps the given src and returns an io.Reader which decrypts // all received data. DecryptReader returns an error if the provided decryption // configuration is invalid. The returned io.Reader returns an error of // type sio.Error if the decryption fails.
[ "DecryptReader", "wraps", "the", "given", "src", "and", "returns", "an", "io", ".", "Reader", "which", "decrypts", "all", "received", "data", ".", "DecryptReader", "returns", "an", "error", "if", "the", "provided", "decryption", "configuration", "is", "invalid", ".", "The", "returned", "io", ".", "Reader", "returns", "an", "error", "of", "type", "sio", ".", "Error", "if", "the", "decryption", "fails", "." ]
035b4ef8c449ba2ba21ec143c91964e76a1fb68c
https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/sio.go#L214-L225
train
minio/sio
sio.go
EncryptWriter
func EncryptWriter(dst io.Writer, config Config) (io.WriteCloser, error) { if err := setConfigDefaults(&config); err != nil { return nil, err } if config.MaxVersion == Version20 { return encryptWriterV20(dst, &config) } return encryptWriterV10(dst, &config) }
go
func EncryptWriter(dst io.Writer, config Config) (io.WriteCloser, error) { if err := setConfigDefaults(&config); err != nil { return nil, err } if config.MaxVersion == Version20 { return encryptWriterV20(dst, &config) } return encryptWriterV10(dst, &config) }
[ "func", "EncryptWriter", "(", "dst", "io", ".", "Writer", ",", "config", "Config", ")", "(", "io", ".", "WriteCloser", ",", "error", ")", "{", "if", "err", ":=", "setConfigDefaults", "(", "&", "config", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "config", ".", "MaxVersion", "==", "Version20", "{", "return", "encryptWriterV20", "(", "dst", ",", "&", "config", ")", "\n", "}", "\n", "return", "encryptWriterV10", "(", "dst", ",", "&", "config", ")", "\n", "}" ]
// EncryptWriter wraps the given dst and returns an io.WriteCloser which // encrypts all data written to it. EncryptWriter returns an error if the // provided decryption configuration is invalid. // // The returned io.WriteCloser must be closed successfully to finalize the // encryption process.
[ "EncryptWriter", "wraps", "the", "given", "dst", "and", "returns", "an", "io", ".", "WriteCloser", "which", "encrypts", "all", "data", "written", "to", "it", ".", "EncryptWriter", "returns", "an", "error", "if", "the", "provided", "decryption", "configuration", "is", "invalid", ".", "The", "returned", "io", ".", "WriteCloser", "must", "be", "closed", "successfully", "to", "finalize", "the", "encryption", "process", "." ]
035b4ef8c449ba2ba21ec143c91964e76a1fb68c
https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/sio.go#L233-L241
train
minio/sio
sio.go
DecryptWriter
func DecryptWriter(dst io.Writer, config Config) (io.WriteCloser, error) { if err := setConfigDefaults(&config); err != nil { return nil, err } if config.MinVersion == Version10 && config.MaxVersion == Version10 { return decryptWriterV10(dst, &config) } if config.MinVersion == Version20 && config.MaxVersion == Version20 { return decryptWriterV20(dst, &config) } return decryptWriter(dst, &config), nil }
go
func DecryptWriter(dst io.Writer, config Config) (io.WriteCloser, error) { if err := setConfigDefaults(&config); err != nil { return nil, err } if config.MinVersion == Version10 && config.MaxVersion == Version10 { return decryptWriterV10(dst, &config) } if config.MinVersion == Version20 && config.MaxVersion == Version20 { return decryptWriterV20(dst, &config) } return decryptWriter(dst, &config), nil }
[ "func", "DecryptWriter", "(", "dst", "io", ".", "Writer", ",", "config", "Config", ")", "(", "io", ".", "WriteCloser", ",", "error", ")", "{", "if", "err", ":=", "setConfigDefaults", "(", "&", "config", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "config", ".", "MinVersion", "==", "Version10", "&&", "config", ".", "MaxVersion", "==", "Version10", "{", "return", "decryptWriterV10", "(", "dst", ",", "&", "config", ")", "\n", "}", "\n", "if", "config", ".", "MinVersion", "==", "Version20", "&&", "config", ".", "MaxVersion", "==", "Version20", "{", "return", "decryptWriterV20", "(", "dst", ",", "&", "config", ")", "\n", "}", "\n", "return", "decryptWriter", "(", "dst", ",", "&", "config", ")", ",", "nil", "\n", "}" ]
// DecryptWriter wraps the given dst and returns an io.WriteCloser which // decrypts all data written to it. DecryptWriter returns an error if the // provided decryption configuration is invalid. // // The returned io.WriteCloser must be closed successfully to finalize the // decryption process. The returned io.WriteCloser returns an error of // type sio.Error if the decryption fails.
[ "DecryptWriter", "wraps", "the", "given", "dst", "and", "returns", "an", "io", ".", "WriteCloser", "which", "decrypts", "all", "data", "written", "to", "it", ".", "DecryptWriter", "returns", "an", "error", "if", "the", "provided", "decryption", "configuration", "is", "invalid", ".", "The", "returned", "io", ".", "WriteCloser", "must", "be", "closed", "successfully", "to", "finalize", "the", "decryption", "process", ".", "The", "returned", "io", ".", "WriteCloser", "returns", "an", "error", "of", "type", "sio", ".", "Error", "if", "the", "decryption", "fails", "." ]
035b4ef8c449ba2ba21ec143c91964e76a1fb68c
https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/sio.go#L250-L261
train
minio/sio
generic.go
decryptWriter
func decryptWriter(w io.Writer, config *Config) *decWriter { return &decWriter{ config: *config, dst: w, firstWrite: true, } }
go
func decryptWriter(w io.Writer, config *Config) *decWriter { return &decWriter{ config: *config, dst: w, firstWrite: true, } }
[ "func", "decryptWriter", "(", "w", "io", ".", "Writer", ",", "config", "*", "Config", ")", "*", "decWriter", "{", "return", "&", "decWriter", "{", "config", ":", "*", "config", ",", "dst", ":", "w", ",", "firstWrite", ":", "true", ",", "}", "\n", "}" ]
// decryptWriter returns an io.WriteCloser wrapping the given io.Writer. // The returned io.WriteCloser detects whether the data written to it is // encrypted using DARE 1.0 or 2.0 and decrypts it using the correct DARE // version.
[ "decryptWriter", "returns", "an", "io", ".", "WriteCloser", "wrapping", "the", "given", "io", ".", "Writer", ".", "The", "returned", "io", ".", "WriteCloser", "detects", "whether", "the", "data", "written", "to", "it", "is", "encrypted", "using", "DARE", "1", ".", "0", "or", "2", ".", "0", "and", "decrypts", "it", "using", "the", "correct", "DARE", "version", "." ]
035b4ef8c449ba2ba21ec143c91964e76a1fb68c
https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/generic.go#L33-L39
train
minio/sio
generic.go
decryptReader
func decryptReader(r io.Reader, config *Config) *decReader { return &decReader{ config: *config, src: r, firstRead: true, } }
go
func decryptReader(r io.Reader, config *Config) *decReader { return &decReader{ config: *config, src: r, firstRead: true, } }
[ "func", "decryptReader", "(", "r", "io", ".", "Reader", ",", "config", "*", "Config", ")", "*", "decReader", "{", "return", "&", "decReader", "{", "config", ":", "*", "config", ",", "src", ":", "r", ",", "firstRead", ":", "true", ",", "}", "\n", "}" ]
// decryptReader returns an io.Reader wrapping the given io.Reader. // The returned io.Reader detects whether the underlying io.Reader returns // DARE 1.0 or 2.0 encrypted data and decrypts it using the correct DARE version.
[ "decryptReader", "returns", "an", "io", ".", "Reader", "wrapping", "the", "given", "io", ".", "Reader", ".", "The", "returned", "io", ".", "Reader", "detects", "whether", "the", "underlying", "io", ".", "Reader", "returns", "DARE", "1", ".", "0", "or", "2", ".", "0", "encrypted", "data", "and", "decrypts", "it", "using", "the", "correct", "DARE", "version", "." ]
035b4ef8c449ba2ba21ec143c91964e76a1fb68c
https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/generic.go#L82-L88
train
minio/sio
writer-v2.go
encryptWriterV20
func encryptWriterV20(dst io.Writer, config *Config) (*encWriterV20, error) { ae, err := newAuthEncV20(config) if err != nil { return nil, err } return &encWriterV20{ authEncV20: ae, dst: dst, buffer: make(packageV20, maxPackageSize), }, nil }
go
func encryptWriterV20(dst io.Writer, config *Config) (*encWriterV20, error) { ae, err := newAuthEncV20(config) if err != nil { return nil, err } return &encWriterV20{ authEncV20: ae, dst: dst, buffer: make(packageV20, maxPackageSize), }, nil }
[ "func", "encryptWriterV20", "(", "dst", "io", ".", "Writer", ",", "config", "*", "Config", ")", "(", "*", "encWriterV20", ",", "error", ")", "{", "ae", ",", "err", ":=", "newAuthEncV20", "(", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "encWriterV20", "{", "authEncV20", ":", "ae", ",", "dst", ":", "dst", ",", "buffer", ":", "make", "(", "packageV20", ",", "maxPackageSize", ")", ",", "}", ",", "nil", "\n", "}" ]
// encryptWriterV20 returns an io.WriteCloser wrapping the given io.Writer. // The returned io.WriteCloser encrypts everything written to it using DARE 2.0 // and writes all encrypted ciphertext as well as the package header and tag // to the wrapped io.Writer. // // The io.WriteCloser must be closed to finalize the encryption successfully.
[ "encryptWriterV20", "returns", "an", "io", ".", "WriteCloser", "wrapping", "the", "given", "io", ".", "Writer", ".", "The", "returned", "io", ".", "WriteCloser", "encrypts", "everything", "written", "to", "it", "using", "DARE", "2", ".", "0", "and", "writes", "all", "encrypted", "ciphertext", "as", "well", "as", "the", "package", "header", "and", "tag", "to", "the", "wrapped", "io", ".", "Writer", ".", "The", "io", ".", "WriteCloser", "must", "be", "closed", "to", "finalize", "the", "encryption", "successfully", "." ]
035b4ef8c449ba2ba21ec143c91964e76a1fb68c
https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/writer-v2.go#L35-L45
train
minio/sio
writer-v2.go
decryptWriterV20
func decryptWriterV20(dst io.Writer, config *Config) (*decWriterV20, error) { ad, err := newAuthDecV20(config) if err != nil { return nil, err } return &decWriterV20{ authDecV20: ad, dst: dst, buffer: make(packageV20, maxPackageSize), }, nil }
go
func decryptWriterV20(dst io.Writer, config *Config) (*decWriterV20, error) { ad, err := newAuthDecV20(config) if err != nil { return nil, err } return &decWriterV20{ authDecV20: ad, dst: dst, buffer: make(packageV20, maxPackageSize), }, nil }
[ "func", "decryptWriterV20", "(", "dst", "io", ".", "Writer", ",", "config", "*", "Config", ")", "(", "*", "decWriterV20", ",", "error", ")", "{", "ad", ",", "err", ":=", "newAuthDecV20", "(", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "decWriterV20", "{", "authDecV20", ":", "ad", ",", "dst", ":", "dst", ",", "buffer", ":", "make", "(", "packageV20", ",", "maxPackageSize", ")", ",", "}", ",", "nil", "\n", "}" ]
// decryptWriterV20 returns an io.WriteCloser wrapping the given io.Writer. // The returned io.WriteCloser decrypts everything written to it using DARE 2.0 // and writes all decrypted plaintext to the wrapped io.Writer. // // The io.WriteCloser must be closed to finalize the decryption successfully.
[ "decryptWriterV20", "returns", "an", "io", ".", "WriteCloser", "wrapping", "the", "given", "io", ".", "Writer", ".", "The", "returned", "io", ".", "WriteCloser", "decrypts", "everything", "written", "to", "it", "using", "DARE", "2", ".", "0", "and", "writes", "all", "decrypted", "plaintext", "to", "the", "wrapped", "io", ".", "Writer", ".", "The", "io", ".", "WriteCloser", "must", "be", "closed", "to", "finalize", "the", "decryption", "successfully", "." ]
035b4ef8c449ba2ba21ec143c91964e76a1fb68c
https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/writer-v2.go#L109-L119
train
minio/sio
reader-v2.go
encryptReaderV20
func encryptReaderV20(src io.Reader, config *Config) (*encReaderV20, error) { ae, err := newAuthEncV20(config) if err != nil { return nil, err } return &encReaderV20{ authEncV20: ae, src: src, buffer: make(packageV20, maxPackageSize), firstRead: true, }, nil }
go
func encryptReaderV20(src io.Reader, config *Config) (*encReaderV20, error) { ae, err := newAuthEncV20(config) if err != nil { return nil, err } return &encReaderV20{ authEncV20: ae, src: src, buffer: make(packageV20, maxPackageSize), firstRead: true, }, nil }
[ "func", "encryptReaderV20", "(", "src", "io", ".", "Reader", ",", "config", "*", "Config", ")", "(", "*", "encReaderV20", ",", "error", ")", "{", "ae", ",", "err", ":=", "newAuthEncV20", "(", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "encReaderV20", "{", "authEncV20", ":", "ae", ",", "src", ":", "src", ",", "buffer", ":", "make", "(", "packageV20", ",", "maxPackageSize", ")", ",", "firstRead", ":", "true", ",", "}", ",", "nil", "\n", "}" ]
// encryptReaderV20 returns an io.Reader wrapping the given io.Reader. // The returned io.Reader encrypts everything it reads using DARE 2.0.
[ "encryptReaderV20", "returns", "an", "io", ".", "Reader", "wrapping", "the", "given", "io", ".", "Reader", ".", "The", "returned", "io", ".", "Reader", "encrypts", "everything", "it", "reads", "using", "DARE", "2", ".", "0", "." ]
035b4ef8c449ba2ba21ec143c91964e76a1fb68c
https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/reader-v2.go#L34-L45
train
minio/sio
reader-v2.go
decryptReaderV20
func decryptReaderV20(src io.Reader, config *Config) (*decReaderV20, error) { ad, err := newAuthDecV20(config) if err != nil { return nil, err } return &decReaderV20{ authDecV20: ad, src: src, buffer: make(packageV20, maxPackageSize), }, nil }
go
func decryptReaderV20(src io.Reader, config *Config) (*decReaderV20, error) { ad, err := newAuthDecV20(config) if err != nil { return nil, err } return &decReaderV20{ authDecV20: ad, src: src, buffer: make(packageV20, maxPackageSize), }, nil }
[ "func", "decryptReaderV20", "(", "src", "io", ".", "Reader", ",", "config", "*", "Config", ")", "(", "*", "decReaderV20", ",", "error", ")", "{", "ad", ",", "err", ":=", "newAuthDecV20", "(", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "decReaderV20", "{", "authDecV20", ":", "ad", ",", "src", ":", "src", ",", "buffer", ":", "make", "(", "packageV20", ",", "maxPackageSize", ")", ",", "}", ",", "nil", "\n", "}" ]
// decryptReaderV20 returns an io.Reader wrapping the given io.Reader. // The returned io.Reader decrypts everything it reads using DARE 2.0.
[ "decryptReaderV20", "returns", "an", "io", ".", "Reader", "wrapping", "the", "given", "io", ".", "Reader", ".", "The", "returned", "io", ".", "Reader", "decrypts", "everything", "it", "reads", "using", "DARE", "2", ".", "0", "." ]
035b4ef8c449ba2ba21ec143c91964e76a1fb68c
https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/reader-v2.go#L121-L131
train
minio/sio
writer-v1.go
decryptWriterV10
func decryptWriterV10(dst io.Writer, config *Config) (*decWriterV10, error) { ad, err := newAuthDecV10(config) if err != nil { return nil, err } return &decWriterV10{ authDecV10: ad, dst: dst, buffer: make(packageV10, maxPackageSize), }, nil }
go
func decryptWriterV10(dst io.Writer, config *Config) (*decWriterV10, error) { ad, err := newAuthDecV10(config) if err != nil { return nil, err } return &decWriterV10{ authDecV10: ad, dst: dst, buffer: make(packageV10, maxPackageSize), }, nil }
[ "func", "decryptWriterV10", "(", "dst", "io", ".", "Writer", ",", "config", "*", "Config", ")", "(", "*", "decWriterV10", ",", "error", ")", "{", "ad", ",", "err", ":=", "newAuthDecV10", "(", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "decWriterV10", "{", "authDecV10", ":", "ad", ",", "dst", ":", "dst", ",", "buffer", ":", "make", "(", "packageV10", ",", "maxPackageSize", ")", ",", "}", ",", "nil", "\n", "}" ]
// decryptWriterV10 returns an io.WriteCloser wrapping the given io.Writer. // The returned io.WriteCloser decrypts everything written to it using DARE 1.0 // and writes all decrypted plaintext to the wrapped io.Writer. // // The io.WriteCloser must be closed to finalize the decryption successfully.
[ "decryptWriterV10", "returns", "an", "io", ".", "WriteCloser", "wrapping", "the", "given", "io", ".", "Writer", ".", "The", "returned", "io", ".", "WriteCloser", "decrypts", "everything", "written", "to", "it", "using", "DARE", "1", ".", "0", "and", "writes", "all", "decrypted", "plaintext", "to", "the", "wrapped", "io", ".", "Writer", ".", "The", "io", ".", "WriteCloser", "must", "be", "closed", "to", "finalize", "the", "decryption", "successfully", "." ]
035b4ef8c449ba2ba21ec143c91964e76a1fb68c
https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/writer-v1.go#L32-L42
train
minio/sio
writer-v1.go
encryptWriterV10
func encryptWriterV10(dst io.Writer, config *Config) (*encWriterV10, error) { ae, err := newAuthEncV10(config) if err != nil { return nil, err } return &encWriterV10{ authEncV10: ae, dst: dst, buffer: make(packageV10, maxPackageSize), payloadSize: config.PayloadSize, }, nil }
go
func encryptWriterV10(dst io.Writer, config *Config) (*encWriterV10, error) { ae, err := newAuthEncV10(config) if err != nil { return nil, err } return &encWriterV10{ authEncV10: ae, dst: dst, buffer: make(packageV10, maxPackageSize), payloadSize: config.PayloadSize, }, nil }
[ "func", "encryptWriterV10", "(", "dst", "io", ".", "Writer", ",", "config", "*", "Config", ")", "(", "*", "encWriterV10", ",", "error", ")", "{", "ae", ",", "err", ":=", "newAuthEncV10", "(", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "encWriterV10", "{", "authEncV10", ":", "ae", ",", "dst", ":", "dst", ",", "buffer", ":", "make", "(", "packageV10", ",", "maxPackageSize", ")", ",", "payloadSize", ":", "config", ".", "PayloadSize", ",", "}", ",", "nil", "\n", "}" ]
// encryptWriterV10 returns an io.WriteCloser wrapping the given io.Writer. // The returned io.WriteCloser encrypts everything written to it using DARE 1.0 // and writes all encrypted ciphertext as well as the package header and tag // to the wrapped io.Writer. // // The io.WriteCloser must be closed to finalize the encryption successfully.
[ "encryptWriterV10", "returns", "an", "io", ".", "WriteCloser", "wrapping", "the", "given", "io", ".", "Writer", ".", "The", "returned", "io", ".", "WriteCloser", "encrypts", "everything", "written", "to", "it", "using", "DARE", "1", ".", "0", "and", "writes", "all", "encrypted", "ciphertext", "as", "well", "as", "the", "package", "header", "and", "tag", "to", "the", "wrapped", "io", ".", "Writer", ".", "The", "io", ".", "WriteCloser", "must", "be", "closed", "to", "finalize", "the", "encryption", "successfully", "." ]
035b4ef8c449ba2ba21ec143c91964e76a1fb68c
https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/writer-v1.go#L133-L144
train
xanzy/go-cloudstack
cloudstack/ProjectService.go
NewActivateProjectParams
func (s *ProjectService) NewActivateProjectParams(id string) *ActivateProjectParams { p := &ActivateProjectParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
go
func (s *ProjectService) NewActivateProjectParams(id string) *ActivateProjectParams { p := &ActivateProjectParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
[ "func", "(", "s", "*", "ProjectService", ")", "NewActivateProjectParams", "(", "id", "string", ")", "*", "ActivateProjectParams", "{", "p", ":=", "&", "ActivateProjectParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ActivateProjectParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ActivateProjectParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/ProjectService.go#L52-L57
train
xanzy/go-cloudstack
cloudstack/ProjectService.go
NewCreateProjectParams
func (s *ProjectService) NewCreateProjectParams(displaytext string, name string) *CreateProjectParams { p := &CreateProjectParams{} p.p = make(map[string]interface{}) p.p["displaytext"] = displaytext p.p["name"] = name return p }
go
func (s *ProjectService) NewCreateProjectParams(displaytext string, name string) *CreateProjectParams { p := &CreateProjectParams{} p.p = make(map[string]interface{}) p.p["displaytext"] = displaytext p.p["name"] = name return p }
[ "func", "(", "s", "*", "ProjectService", ")", "NewCreateProjectParams", "(", "displaytext", "string", ",", "name", "string", ")", "*", "CreateProjectParams", "{", "p", ":=", "&", "CreateProjectParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "displaytext", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "name", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new CreateProjectParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "CreateProjectParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/ProjectService.go#L200-L206
train
xanzy/go-cloudstack
cloudstack/ProjectService.go
NewDeleteProjectParams
func (s *ProjectService) NewDeleteProjectParams(id string) *DeleteProjectParams { p := &DeleteProjectParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
go
func (s *ProjectService) NewDeleteProjectParams(id string) *DeleteProjectParams { p := &DeleteProjectParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
[ "func", "(", "s", "*", "ProjectService", ")", "NewDeleteProjectParams", "(", "id", "string", ")", "*", "DeleteProjectParams", "{", "p", ":=", "&", "DeleteProjectParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new DeleteProjectParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "DeleteProjectParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/ProjectService.go#L316-L321
train
xanzy/go-cloudstack
cloudstack/ProjectService.go
NewDeleteProjectInvitationParams
func (s *ProjectService) NewDeleteProjectInvitationParams(id string) *DeleteProjectInvitationParams { p := &DeleteProjectInvitationParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
go
func (s *ProjectService) NewDeleteProjectInvitationParams(id string) *DeleteProjectInvitationParams { p := &DeleteProjectInvitationParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
[ "func", "(", "s", "*", "ProjectService", ")", "NewDeleteProjectInvitationParams", "(", "id", "string", ")", "*", "DeleteProjectInvitationParams", "{", "p", ":=", "&", "DeleteProjectInvitationParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new DeleteProjectInvitationParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "DeleteProjectInvitationParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/ProjectService.go#L384-L389
train
xanzy/go-cloudstack
cloudstack/ProjectService.go
NewListProjectInvitationsParams
func (s *ProjectService) NewListProjectInvitationsParams() *ListProjectInvitationsParams { p := &ListProjectInvitationsParams{} p.p = make(map[string]interface{}) return p }
go
func (s *ProjectService) NewListProjectInvitationsParams() *ListProjectInvitationsParams { p := &ListProjectInvitationsParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "ProjectService", ")", "NewListProjectInvitationsParams", "(", ")", "*", "ListProjectInvitationsParams", "{", "p", ":=", "&", "ListProjectInvitationsParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListProjectInvitationsParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListProjectInvitationsParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/ProjectService.go#L567-L571
train
xanzy/go-cloudstack
cloudstack/ProjectService.go
NewListProjectsParams
func (s *ProjectService) NewListProjectsParams() *ListProjectsParams { p := &ListProjectsParams{} p.p = make(map[string]interface{}) return p }
go
func (s *ProjectService) NewListProjectsParams() *ListProjectsParams { p := &ListProjectsParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "ProjectService", ")", "NewListProjectsParams", "(", ")", "*", "ListProjectsParams", "{", "p", ":=", "&", "ListProjectsParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListProjectsParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListProjectsParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/ProjectService.go#L792-L796
train
xanzy/go-cloudstack
cloudstack/ProjectService.go
NewSuspendProjectParams
func (s *ProjectService) NewSuspendProjectParams(id string) *SuspendProjectParams { p := &SuspendProjectParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
go
func (s *ProjectService) NewSuspendProjectParams(id string) *SuspendProjectParams { p := &SuspendProjectParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
[ "func", "(", "s", "*", "ProjectService", ")", "NewSuspendProjectParams", "(", "id", "string", ")", "*", "SuspendProjectParams", "{", "p", ":=", "&", "SuspendProjectParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new SuspendProjectParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "SuspendProjectParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/ProjectService.go#L973-L978
train
xanzy/go-cloudstack
cloudstack/ProjectService.go
NewUpdateProjectParams
func (s *ProjectService) NewUpdateProjectParams(id string) *UpdateProjectParams { p := &UpdateProjectParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
go
func (s *ProjectService) NewUpdateProjectParams(id string) *UpdateProjectParams { p := &UpdateProjectParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
[ "func", "(", "s", "*", "ProjectService", ")", "NewUpdateProjectParams", "(", "id", "string", ")", "*", "UpdateProjectParams", "{", "p", ":=", "&", "UpdateProjectParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new UpdateProjectParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "UpdateProjectParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/ProjectService.go#L1110-L1115
train
xanzy/go-cloudstack
cloudstack/ProjectService.go
NewUpdateProjectInvitationParams
func (s *ProjectService) NewUpdateProjectInvitationParams(projectid string) *UpdateProjectInvitationParams { p := &UpdateProjectInvitationParams{} p.p = make(map[string]interface{}) p.p["projectid"] = projectid return p }
go
func (s *ProjectService) NewUpdateProjectInvitationParams(projectid string) *UpdateProjectInvitationParams { p := &UpdateProjectInvitationParams{} p.p = make(map[string]interface{}) p.p["projectid"] = projectid return p }
[ "func", "(", "s", "*", "ProjectService", ")", "NewUpdateProjectInvitationParams", "(", "projectid", "string", ")", "*", "UpdateProjectInvitationParams", "{", "p", ":=", "&", "UpdateProjectInvitationParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "projectid", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new UpdateProjectInvitationParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "UpdateProjectInvitationParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/ProjectService.go#L1259-L1264
train
xanzy/go-cloudstack
cloudstack/RoleService.go
NewCreateRoleParams
func (s *RoleService) NewCreateRoleParams(name string, roleType string) *CreateRoleParams { p := &CreateRoleParams{} p.p = make(map[string]interface{}) p.p["name"] = name p.p["type"] = roleType return p }
go
func (s *RoleService) NewCreateRoleParams(name string, roleType string) *CreateRoleParams { p := &CreateRoleParams{} p.p = make(map[string]interface{}) p.p["name"] = name p.p["type"] = roleType return p }
[ "func", "(", "s", "*", "RoleService", ")", "NewCreateRoleParams", "(", "name", "string", ",", "roleType", "string", ")", "*", "CreateRoleParams", "{", "p", ":=", "&", "CreateRoleParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "name", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "roleType", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new CreateRoleParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "CreateRoleParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RoleService.go#L73-L79
train
xanzy/go-cloudstack
cloudstack/RoleService.go
CreateRole
func (s *RoleService) CreateRole(p *CreateRoleParams) (*CreateRoleResponse, error) { resp, err := s.cs.newRequest("createRole", p.toURLValues()) if err != nil { return nil, err } var r CreateRoleResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *RoleService) CreateRole(p *CreateRoleParams) (*CreateRoleResponse, error) { resp, err := s.cs.newRequest("createRole", p.toURLValues()) if err != nil { return nil, err } var r CreateRoleResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "RoleService", ")", "CreateRole", "(", "p", "*", "CreateRoleParams", ")", "(", "*", "CreateRoleResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "CreateRoleResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Creates a role
[ "Creates", "a", "role" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RoleService.go#L82-L94
train
xanzy/go-cloudstack
cloudstack/RoleService.go
NewCreateRolePermissionParams
func (s *RoleService) NewCreateRolePermissionParams(permission string, roleid string, rule string) *CreateRolePermissionParams { p := &CreateRolePermissionParams{} p.p = make(map[string]interface{}) p.p["permission"] = permission p.p["roleid"] = roleid p.p["rule"] = rule return p }
go
func (s *RoleService) NewCreateRolePermissionParams(permission string, roleid string, rule string) *CreateRolePermissionParams { p := &CreateRolePermissionParams{} p.p = make(map[string]interface{}) p.p["permission"] = permission p.p["roleid"] = roleid p.p["rule"] = rule return p }
[ "func", "(", "s", "*", "RoleService", ")", "NewCreateRolePermissionParams", "(", "permission", "string", ",", "roleid", "string", ",", "rule", "string", ")", "*", "CreateRolePermissionParams", "{", "p", ":=", "&", "CreateRolePermissionParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "permission", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "roleid", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "rule", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new CreateRolePermissionParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "CreateRolePermissionParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RoleService.go#L161-L168
train
xanzy/go-cloudstack
cloudstack/RoleService.go
CreateRolePermission
func (s *RoleService) CreateRolePermission(p *CreateRolePermissionParams) (*CreateRolePermissionResponse, error) { resp, err := s.cs.newRequest("createRolePermission", p.toURLValues()) if err != nil { return nil, err } var r CreateRolePermissionResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *RoleService) CreateRolePermission(p *CreateRolePermissionParams) (*CreateRolePermissionResponse, error) { resp, err := s.cs.newRequest("createRolePermission", p.toURLValues()) if err != nil { return nil, err } var r CreateRolePermissionResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "RoleService", ")", "CreateRolePermission", "(", "p", "*", "CreateRolePermissionParams", ")", "(", "*", "CreateRolePermissionResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "CreateRolePermissionResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Adds a API permission to a role
[ "Adds", "a", "API", "permission", "to", "a", "role" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RoleService.go#L171-L183
train
xanzy/go-cloudstack
cloudstack/RoleService.go
NewDeleteRoleParams
func (s *RoleService) NewDeleteRoleParams(id string) *DeleteRoleParams { p := &DeleteRoleParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
go
func (s *RoleService) NewDeleteRoleParams(id string) *DeleteRoleParams { p := &DeleteRoleParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
[ "func", "(", "s", "*", "RoleService", ")", "NewDeleteRoleParams", "(", "id", "string", ")", "*", "DeleteRoleParams", "{", "p", ":=", "&", "DeleteRoleParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new DeleteRoleParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "DeleteRoleParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RoleService.go#L219-L224
train
xanzy/go-cloudstack
cloudstack/RoleService.go
DeleteRole
func (s *RoleService) DeleteRole(p *DeleteRoleParams) (*DeleteRoleResponse, error) { resp, err := s.cs.newRequest("deleteRole", p.toURLValues()) if err != nil { return nil, err } var r DeleteRoleResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *RoleService) DeleteRole(p *DeleteRoleParams) (*DeleteRoleResponse, error) { resp, err := s.cs.newRequest("deleteRole", p.toURLValues()) if err != nil { return nil, err } var r DeleteRoleResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "RoleService", ")", "DeleteRole", "(", "p", "*", "DeleteRoleParams", ")", "(", "*", "DeleteRoleResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "DeleteRoleResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Deletes a role
[ "Deletes", "a", "role" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RoleService.go#L227-L239
train
xanzy/go-cloudstack
cloudstack/RoleService.go
NewDeleteRolePermissionParams
func (s *RoleService) NewDeleteRolePermissionParams(id string) *DeleteRolePermissionParams { p := &DeleteRolePermissionParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
go
func (s *RoleService) NewDeleteRolePermissionParams(id string) *DeleteRolePermissionParams { p := &DeleteRolePermissionParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
[ "func", "(", "s", "*", "RoleService", ")", "NewDeleteRolePermissionParams", "(", "id", "string", ")", "*", "DeleteRolePermissionParams", "{", "p", ":=", "&", "DeleteRolePermissionParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new DeleteRolePermissionParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "DeleteRolePermissionParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RoleService.go#L290-L295
train
xanzy/go-cloudstack
cloudstack/RoleService.go
DeleteRolePermission
func (s *RoleService) DeleteRolePermission(p *DeleteRolePermissionParams) (*DeleteRolePermissionResponse, error) { resp, err := s.cs.newRequest("deleteRolePermission", p.toURLValues()) if err != nil { return nil, err } var r DeleteRolePermissionResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *RoleService) DeleteRolePermission(p *DeleteRolePermissionParams) (*DeleteRolePermissionResponse, error) { resp, err := s.cs.newRequest("deleteRolePermission", p.toURLValues()) if err != nil { return nil, err } var r DeleteRolePermissionResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "RoleService", ")", "DeleteRolePermission", "(", "p", "*", "DeleteRolePermissionParams", ")", "(", "*", "DeleteRolePermissionResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "DeleteRolePermissionResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Deletes a role permission
[ "Deletes", "a", "role", "permission" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RoleService.go#L298-L310
train
xanzy/go-cloudstack
cloudstack/RoleService.go
NewListRolePermissionsParams
func (s *RoleService) NewListRolePermissionsParams() *ListRolePermissionsParams { p := &ListRolePermissionsParams{} p.p = make(map[string]interface{}) return p }
go
func (s *RoleService) NewListRolePermissionsParams() *ListRolePermissionsParams { p := &ListRolePermissionsParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "RoleService", ")", "NewListRolePermissionsParams", "(", ")", "*", "ListRolePermissionsParams", "{", "p", ":=", "&", "ListRolePermissionsParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListRolePermissionsParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListRolePermissionsParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RoleService.go#L361-L365
train
xanzy/go-cloudstack
cloudstack/RoleService.go
ListRolePermissions
func (s *RoleService) ListRolePermissions(p *ListRolePermissionsParams) (*ListRolePermissionsResponse, error) { resp, err := s.cs.newRequest("listRolePermissions", p.toURLValues()) if err != nil { return nil, err } var r ListRolePermissionsResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *RoleService) ListRolePermissions(p *ListRolePermissionsParams) (*ListRolePermissionsResponse, error) { resp, err := s.cs.newRequest("listRolePermissions", p.toURLValues()) if err != nil { return nil, err } var r ListRolePermissionsResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "RoleService", ")", "ListRolePermissions", "(", "p", "*", "ListRolePermissionsParams", ")", "(", "*", "ListRolePermissionsResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "ListRolePermissionsResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Lists role permissions
[ "Lists", "role", "permissions" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RoleService.go#L368-L380
train
xanzy/go-cloudstack
cloudstack/RoleService.go
NewListRolesParams
func (s *RoleService) NewListRolesParams() *ListRolesParams { p := &ListRolesParams{} p.p = make(map[string]interface{}) return p }
go
func (s *RoleService) NewListRolesParams() *ListRolesParams { p := &ListRolesParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "RoleService", ")", "NewListRolesParams", "(", ")", "*", "ListRolesParams", "{", "p", ":=", "&", "ListRolesParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListRolesParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListRolesParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RoleService.go#L443-L447
train
xanzy/go-cloudstack
cloudstack/RoleService.go
ListRoles
func (s *RoleService) ListRoles(p *ListRolesParams) (*ListRolesResponse, error) { resp, err := s.cs.newRequest("listRoles", p.toURLValues()) if err != nil { return nil, err } var r ListRolesResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *RoleService) ListRoles(p *ListRolesParams) (*ListRolesResponse, error) { resp, err := s.cs.newRequest("listRoles", p.toURLValues()) if err != nil { return nil, err } var r ListRolesResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "RoleService", ")", "ListRoles", "(", "p", "*", "ListRolesParams", ")", "(", "*", "ListRolesResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "ListRolesResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Lists dynamic roles in CloudStack
[ "Lists", "dynamic", "roles", "in", "CloudStack" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RoleService.go#L533-L545
train
xanzy/go-cloudstack
cloudstack/RoleService.go
NewUpdateRoleParams
func (s *RoleService) NewUpdateRoleParams(id string) *UpdateRoleParams { p := &UpdateRoleParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
go
func (s *RoleService) NewUpdateRoleParams(id string) *UpdateRoleParams { p := &UpdateRoleParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
[ "func", "(", "s", "*", "RoleService", ")", "NewUpdateRoleParams", "(", "id", "string", ")", "*", "UpdateRoleParams", "{", "p", ":=", "&", "UpdateRoleParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new UpdateRoleParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "UpdateRoleParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RoleService.go#L617-L622
train
xanzy/go-cloudstack
cloudstack/RoleService.go
UpdateRole
func (s *RoleService) UpdateRole(p *UpdateRoleParams) (*UpdateRoleResponse, error) { resp, err := s.cs.newRequest("updateRole", p.toURLValues()) if err != nil { return nil, err } var r UpdateRoleResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *RoleService) UpdateRole(p *UpdateRoleParams) (*UpdateRoleResponse, error) { resp, err := s.cs.newRequest("updateRole", p.toURLValues()) if err != nil { return nil, err } var r UpdateRoleResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "RoleService", ")", "UpdateRole", "(", "p", "*", "UpdateRoleParams", ")", "(", "*", "UpdateRoleResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "UpdateRoleResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Updates a role
[ "Updates", "a", "role" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RoleService.go#L625-L637
train
xanzy/go-cloudstack
cloudstack/RoleService.go
NewUpdateRolePermissionParams
func (s *RoleService) NewUpdateRolePermissionParams(roleid string) *UpdateRolePermissionParams { p := &UpdateRolePermissionParams{} p.p = make(map[string]interface{}) p.p["roleid"] = roleid return p }
go
func (s *RoleService) NewUpdateRolePermissionParams(roleid string) *UpdateRolePermissionParams { p := &UpdateRolePermissionParams{} p.p = make(map[string]interface{}) p.p["roleid"] = roleid return p }
[ "func", "(", "s", "*", "RoleService", ")", "NewUpdateRolePermissionParams", "(", "roleid", "string", ")", "*", "UpdateRolePermissionParams", "{", "p", ":=", "&", "UpdateRolePermissionParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "roleid", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new UpdateRolePermissionParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "UpdateRolePermissionParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RoleService.go#L705-L710
train
xanzy/go-cloudstack
cloudstack/RoleService.go
UpdateRolePermission
func (s *RoleService) UpdateRolePermission(p *UpdateRolePermissionParams) (*UpdateRolePermissionResponse, error) { resp, err := s.cs.newRequest("updateRolePermission", p.toURLValues()) if err != nil { return nil, err } var r UpdateRolePermissionResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *RoleService) UpdateRolePermission(p *UpdateRolePermissionParams) (*UpdateRolePermissionResponse, error) { resp, err := s.cs.newRequest("updateRolePermission", p.toURLValues()) if err != nil { return nil, err } var r UpdateRolePermissionResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "RoleService", ")", "UpdateRolePermission", "(", "p", "*", "UpdateRolePermissionParams", ")", "(", "*", "UpdateRolePermissionResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "UpdateRolePermissionResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Updates a role permission order
[ "Updates", "a", "role", "permission", "order" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RoleService.go#L713-L725
train
xanzy/go-cloudstack
cloudstack/BrocadeVCSService.go
NewAddBrocadeVcsDeviceParams
func (s *BrocadeVCSService) NewAddBrocadeVcsDeviceParams(hostname string, password string, physicalnetworkid string, username string) *AddBrocadeVcsDeviceParams { p := &AddBrocadeVcsDeviceParams{} p.p = make(map[string]interface{}) p.p["hostname"] = hostname p.p["password"] = password p.p["physicalnetworkid"] = physicalnetworkid p.p["username"] = username return p }
go
func (s *BrocadeVCSService) NewAddBrocadeVcsDeviceParams(hostname string, password string, physicalnetworkid string, username string) *AddBrocadeVcsDeviceParams { p := &AddBrocadeVcsDeviceParams{} p.p = make(map[string]interface{}) p.p["hostname"] = hostname p.p["password"] = password p.p["physicalnetworkid"] = physicalnetworkid p.p["username"] = username return p }
[ "func", "(", "s", "*", "BrocadeVCSService", ")", "NewAddBrocadeVcsDeviceParams", "(", "hostname", "string", ",", "password", "string", ",", "physicalnetworkid", "string", ",", "username", "string", ")", "*", "AddBrocadeVcsDeviceParams", "{", "p", ":=", "&", "AddBrocadeVcsDeviceParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "hostname", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "password", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "physicalnetworkid", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "username", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new AddBrocadeVcsDeviceParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "AddBrocadeVcsDeviceParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/BrocadeVCSService.go#L84-L92
train
xanzy/go-cloudstack
cloudstack/BrocadeVCSService.go
AddBrocadeVcsDevice
func (s *BrocadeVCSService) AddBrocadeVcsDevice(p *AddBrocadeVcsDeviceParams) (*AddBrocadeVcsDeviceResponse, error) { resp, err := s.cs.newRequest("addBrocadeVcsDevice", p.toURLValues()) if err != nil { return nil, err } var r AddBrocadeVcsDeviceResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } b, err = getRawValue(b) if err != nil { return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
go
func (s *BrocadeVCSService) AddBrocadeVcsDevice(p *AddBrocadeVcsDeviceParams) (*AddBrocadeVcsDeviceResponse, error) { resp, err := s.cs.newRequest("addBrocadeVcsDevice", p.toURLValues()) if err != nil { return nil, err } var r AddBrocadeVcsDeviceResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } b, err = getRawValue(b) if err != nil { return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
[ "func", "(", "s", "*", "BrocadeVCSService", ")", "AddBrocadeVcsDevice", "(", "p", "*", "AddBrocadeVcsDeviceParams", ")", "(", "*", "AddBrocadeVcsDeviceResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "AddBrocadeVcsDeviceResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// If we have a async client, we need to wait for the async result", "if", "s", ".", "cs", ".", "async", "{", "b", ",", "err", ":=", "s", ".", "cs", ".", "GetAsyncJobResult", "(", "r", ".", "JobID", ",", "s", ".", "cs", ".", "timeout", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "AsyncTimeoutErr", "{", "return", "&", "r", ",", "err", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "b", ",", "err", "=", "getRawValue", "(", "b", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "b", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Adds a Brocade VCS Switch
[ "Adds", "a", "Brocade", "VCS", "Switch" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/BrocadeVCSService.go#L95-L127
train
xanzy/go-cloudstack
cloudstack/BrocadeVCSService.go
NewDeleteBrocadeVcsDeviceParams
func (s *BrocadeVCSService) NewDeleteBrocadeVcsDeviceParams(vcsdeviceid string) *DeleteBrocadeVcsDeviceParams { p := &DeleteBrocadeVcsDeviceParams{} p.p = make(map[string]interface{}) p.p["vcsdeviceid"] = vcsdeviceid return p }
go
func (s *BrocadeVCSService) NewDeleteBrocadeVcsDeviceParams(vcsdeviceid string) *DeleteBrocadeVcsDeviceParams { p := &DeleteBrocadeVcsDeviceParams{} p.p = make(map[string]interface{}) p.p["vcsdeviceid"] = vcsdeviceid return p }
[ "func", "(", "s", "*", "BrocadeVCSService", ")", "NewDeleteBrocadeVcsDeviceParams", "(", "vcsdeviceid", "string", ")", "*", "DeleteBrocadeVcsDeviceParams", "{", "p", ":=", "&", "DeleteBrocadeVcsDeviceParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "vcsdeviceid", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new DeleteBrocadeVcsDeviceParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "DeleteBrocadeVcsDeviceParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/BrocadeVCSService.go#L163-L168
train
xanzy/go-cloudstack
cloudstack/BrocadeVCSService.go
DeleteBrocadeVcsDevice
func (s *BrocadeVCSService) DeleteBrocadeVcsDevice(p *DeleteBrocadeVcsDeviceParams) (*DeleteBrocadeVcsDeviceResponse, error) { resp, err := s.cs.newRequest("deleteBrocadeVcsDevice", p.toURLValues()) if err != nil { return nil, err } var r DeleteBrocadeVcsDeviceResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
go
func (s *BrocadeVCSService) DeleteBrocadeVcsDevice(p *DeleteBrocadeVcsDeviceParams) (*DeleteBrocadeVcsDeviceResponse, error) { resp, err := s.cs.newRequest("deleteBrocadeVcsDevice", p.toURLValues()) if err != nil { return nil, err } var r DeleteBrocadeVcsDeviceResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
[ "func", "(", "s", "*", "BrocadeVCSService", ")", "DeleteBrocadeVcsDevice", "(", "p", "*", "DeleteBrocadeVcsDeviceParams", ")", "(", "*", "DeleteBrocadeVcsDeviceResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "DeleteBrocadeVcsDeviceResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// If we have a async client, we need to wait for the async result", "if", "s", ".", "cs", ".", "async", "{", "b", ",", "err", ":=", "s", ".", "cs", ".", "GetAsyncJobResult", "(", "r", ".", "JobID", ",", "s", ".", "cs", ".", "timeout", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "AsyncTimeoutErr", "{", "return", "&", "r", ",", "err", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "b", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// delete a Brocade VCS Switch
[ "delete", "a", "Brocade", "VCS", "Switch" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/BrocadeVCSService.go#L171-L198
train
xanzy/go-cloudstack
cloudstack/BrocadeVCSService.go
NewListBrocadeVcsDeviceNetworksParams
func (s *BrocadeVCSService) NewListBrocadeVcsDeviceNetworksParams(vcsdeviceid string) *ListBrocadeVcsDeviceNetworksParams { p := &ListBrocadeVcsDeviceNetworksParams{} p.p = make(map[string]interface{}) p.p["vcsdeviceid"] = vcsdeviceid return p }
go
func (s *BrocadeVCSService) NewListBrocadeVcsDeviceNetworksParams(vcsdeviceid string) *ListBrocadeVcsDeviceNetworksParams { p := &ListBrocadeVcsDeviceNetworksParams{} p.p = make(map[string]interface{}) p.p["vcsdeviceid"] = vcsdeviceid return p }
[ "func", "(", "s", "*", "BrocadeVCSService", ")", "NewListBrocadeVcsDeviceNetworksParams", "(", "vcsdeviceid", "string", ")", "*", "ListBrocadeVcsDeviceNetworksParams", "{", "p", ":=", "&", "ListBrocadeVcsDeviceNetworksParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "vcsdeviceid", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListBrocadeVcsDeviceNetworksParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListBrocadeVcsDeviceNetworksParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/BrocadeVCSService.go#L266-L271
train
xanzy/go-cloudstack
cloudstack/BrocadeVCSService.go
ListBrocadeVcsDeviceNetworks
func (s *BrocadeVCSService) ListBrocadeVcsDeviceNetworks(p *ListBrocadeVcsDeviceNetworksParams) (*ListBrocadeVcsDeviceNetworksResponse, error) { resp, err := s.cs.newRequest("listBrocadeVcsDeviceNetworks", p.toURLValues()) if err != nil { return nil, err } var r ListBrocadeVcsDeviceNetworksResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *BrocadeVCSService) ListBrocadeVcsDeviceNetworks(p *ListBrocadeVcsDeviceNetworksParams) (*ListBrocadeVcsDeviceNetworksResponse, error) { resp, err := s.cs.newRequest("listBrocadeVcsDeviceNetworks", p.toURLValues()) if err != nil { return nil, err } var r ListBrocadeVcsDeviceNetworksResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "BrocadeVCSService", ")", "ListBrocadeVcsDeviceNetworks", "(", "p", "*", "ListBrocadeVcsDeviceNetworksParams", ")", "(", "*", "ListBrocadeVcsDeviceNetworksResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "ListBrocadeVcsDeviceNetworksResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// lists network that are using a brocade vcs switch
[ "lists", "network", "that", "are", "using", "a", "brocade", "vcs", "switch" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/BrocadeVCSService.go#L311-L323
train
xanzy/go-cloudstack
cloudstack/BrocadeVCSService.go
NewListBrocadeVcsDevicesParams
func (s *BrocadeVCSService) NewListBrocadeVcsDevicesParams() *ListBrocadeVcsDevicesParams { p := &ListBrocadeVcsDevicesParams{} p.p = make(map[string]interface{}) return p }
go
func (s *BrocadeVCSService) NewListBrocadeVcsDevicesParams() *ListBrocadeVcsDevicesParams { p := &ListBrocadeVcsDevicesParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "BrocadeVCSService", ")", "NewListBrocadeVcsDevicesParams", "(", ")", "*", "ListBrocadeVcsDevicesParams", "{", "p", ":=", "&", "ListBrocadeVcsDevicesParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListBrocadeVcsDevicesParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListBrocadeVcsDevicesParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/BrocadeVCSService.go#L476-L480
train
xanzy/go-cloudstack
cloudstack/BrocadeVCSService.go
ListBrocadeVcsDevices
func (s *BrocadeVCSService) ListBrocadeVcsDevices(p *ListBrocadeVcsDevicesParams) (*ListBrocadeVcsDevicesResponse, error) { resp, err := s.cs.newRequest("listBrocadeVcsDevices", p.toURLValues()) if err != nil { return nil, err } var r ListBrocadeVcsDevicesResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *BrocadeVCSService) ListBrocadeVcsDevices(p *ListBrocadeVcsDevicesParams) (*ListBrocadeVcsDevicesResponse, error) { resp, err := s.cs.newRequest("listBrocadeVcsDevices", p.toURLValues()) if err != nil { return nil, err } var r ListBrocadeVcsDevicesResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "BrocadeVCSService", ")", "ListBrocadeVcsDevices", "(", "p", "*", "ListBrocadeVcsDevicesParams", ")", "(", "*", "ListBrocadeVcsDevicesResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "ListBrocadeVcsDevicesResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Lists Brocade VCS Switches
[ "Lists", "Brocade", "VCS", "Switches" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/BrocadeVCSService.go#L483-L495
train
xanzy/go-cloudstack
cloudstack/VLANService.go
NewCreateVlanIpRangeParams
func (s *VLANService) NewCreateVlanIpRangeParams() *CreateVlanIpRangeParams { p := &CreateVlanIpRangeParams{} p.p = make(map[string]interface{}) return p }
go
func (s *VLANService) NewCreateVlanIpRangeParams() *CreateVlanIpRangeParams { p := &CreateVlanIpRangeParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "VLANService", ")", "NewCreateVlanIpRangeParams", "(", ")", "*", "CreateVlanIpRangeParams", "{", "p", ":=", "&", "CreateVlanIpRangeParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new CreateVlanIpRangeParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "CreateVlanIpRangeParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/VLANService.go#L241-L245
train
xanzy/go-cloudstack
cloudstack/VLANService.go
NewDedicateGuestVlanRangeParams
func (s *VLANService) NewDedicateGuestVlanRangeParams(physicalnetworkid string, vlanrange string) *DedicateGuestVlanRangeParams { p := &DedicateGuestVlanRangeParams{} p.p = make(map[string]interface{}) p.p["physicalnetworkid"] = physicalnetworkid p.p["vlanrange"] = vlanrange return p }
go
func (s *VLANService) NewDedicateGuestVlanRangeParams(physicalnetworkid string, vlanrange string) *DedicateGuestVlanRangeParams { p := &DedicateGuestVlanRangeParams{} p.p = make(map[string]interface{}) p.p["physicalnetworkid"] = physicalnetworkid p.p["vlanrange"] = vlanrange return p }
[ "func", "(", "s", "*", "VLANService", ")", "NewDedicateGuestVlanRangeParams", "(", "physicalnetworkid", "string", ",", "vlanrange", "string", ")", "*", "DedicateGuestVlanRangeParams", "{", "p", ":=", "&", "DedicateGuestVlanRangeParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "physicalnetworkid", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "vlanrange", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new DedicateGuestVlanRangeParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "DedicateGuestVlanRangeParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/VLANService.go#L357-L363
train
xanzy/go-cloudstack
cloudstack/VLANService.go
DedicateGuestVlanRange
func (s *VLANService) DedicateGuestVlanRange(p *DedicateGuestVlanRangeParams) (*DedicateGuestVlanRangeResponse, error) { resp, err := s.cs.newRequest("dedicateGuestVlanRange", p.toURLValues()) if err != nil { return nil, err } var r DedicateGuestVlanRangeResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *VLANService) DedicateGuestVlanRange(p *DedicateGuestVlanRangeParams) (*DedicateGuestVlanRangeResponse, error) { resp, err := s.cs.newRequest("dedicateGuestVlanRange", p.toURLValues()) if err != nil { return nil, err } var r DedicateGuestVlanRangeResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "VLANService", ")", "DedicateGuestVlanRange", "(", "p", "*", "DedicateGuestVlanRangeParams", ")", "(", "*", "DedicateGuestVlanRangeResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "DedicateGuestVlanRangeResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Dedicates a guest vlan range to an account
[ "Dedicates", "a", "guest", "vlan", "range", "to", "an", "account" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/VLANService.go#L366-L378
train
xanzy/go-cloudstack
cloudstack/VLANService.go
NewDeleteVlanIpRangeParams
func (s *VLANService) NewDeleteVlanIpRangeParams(id string) *DeleteVlanIpRangeParams { p := &DeleteVlanIpRangeParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
go
func (s *VLANService) NewDeleteVlanIpRangeParams(id string) *DeleteVlanIpRangeParams { p := &DeleteVlanIpRangeParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
[ "func", "(", "s", "*", "VLANService", ")", "NewDeleteVlanIpRangeParams", "(", "id", "string", ")", "*", "DeleteVlanIpRangeParams", "{", "p", ":=", "&", "DeleteVlanIpRangeParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new DeleteVlanIpRangeParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "DeleteVlanIpRangeParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/VLANService.go#L417-L422
train
xanzy/go-cloudstack
cloudstack/VLANService.go
NewListDedicatedGuestVlanRangesParams
func (s *VLANService) NewListDedicatedGuestVlanRangesParams() *ListDedicatedGuestVlanRangesParams { p := &ListDedicatedGuestVlanRangesParams{} p.p = make(map[string]interface{}) return p }
go
func (s *VLANService) NewListDedicatedGuestVlanRangesParams() *ListDedicatedGuestVlanRangesParams { p := &ListDedicatedGuestVlanRangesParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "VLANService", ")", "NewListDedicatedGuestVlanRangesParams", "(", ")", "*", "ListDedicatedGuestVlanRangesParams", "{", "p", ":=", "&", "ListDedicatedGuestVlanRangesParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListDedicatedGuestVlanRangesParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListDedicatedGuestVlanRangesParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/VLANService.go#L589-L593
train
xanzy/go-cloudstack
cloudstack/VLANService.go
ListDedicatedGuestVlanRanges
func (s *VLANService) ListDedicatedGuestVlanRanges(p *ListDedicatedGuestVlanRangesParams) (*ListDedicatedGuestVlanRangesResponse, error) { resp, err := s.cs.newRequest("listDedicatedGuestVlanRanges", p.toURLValues()) if err != nil { return nil, err } var r ListDedicatedGuestVlanRangesResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *VLANService) ListDedicatedGuestVlanRanges(p *ListDedicatedGuestVlanRangesParams) (*ListDedicatedGuestVlanRangesResponse, error) { resp, err := s.cs.newRequest("listDedicatedGuestVlanRanges", p.toURLValues()) if err != nil { return nil, err } var r ListDedicatedGuestVlanRangesResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "VLANService", ")", "ListDedicatedGuestVlanRanges", "(", "p", "*", "ListDedicatedGuestVlanRangesParams", ")", "(", "*", "ListDedicatedGuestVlanRangesResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "ListDedicatedGuestVlanRangesResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Lists dedicated guest vlan ranges
[ "Lists", "dedicated", "guest", "vlan", "ranges" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/VLANService.go#L629-L641
train
xanzy/go-cloudstack
cloudstack/VLANService.go
NewListVlanIpRangesParams
func (s *VLANService) NewListVlanIpRangesParams() *ListVlanIpRangesParams { p := &ListVlanIpRangesParams{} p.p = make(map[string]interface{}) return p }
go
func (s *VLANService) NewListVlanIpRangesParams() *ListVlanIpRangesParams { p := &ListVlanIpRangesParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "VLANService", ")", "NewListVlanIpRangesParams", "(", ")", "*", "ListVlanIpRangesParams", "{", "p", ":=", "&", "ListVlanIpRangesParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListVlanIpRangesParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListVlanIpRangesParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/VLANService.go#L820-L824
train
xanzy/go-cloudstack
cloudstack/VLANService.go
ListVlanIpRanges
func (s *VLANService) ListVlanIpRanges(p *ListVlanIpRangesParams) (*ListVlanIpRangesResponse, error) { resp, err := s.cs.newRequest("listVlanIpRanges", p.toURLValues()) if err != nil { return nil, err } var r ListVlanIpRangesResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *VLANService) ListVlanIpRanges(p *ListVlanIpRangesParams) (*ListVlanIpRangesResponse, error) { resp, err := s.cs.newRequest("listVlanIpRanges", p.toURLValues()) if err != nil { return nil, err } var r ListVlanIpRangesResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "VLANService", ")", "ListVlanIpRanges", "(", "p", "*", "ListVlanIpRangesParams", ")", "(", "*", "ListVlanIpRangesResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "ListVlanIpRangesResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Lists all VLAN IP ranges.
[ "Lists", "all", "VLAN", "IP", "ranges", "." ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/VLANService.go#L860-L872
train
xanzy/go-cloudstack
cloudstack/VLANService.go
NewReleaseDedicatedGuestVlanRangeParams
func (s *VLANService) NewReleaseDedicatedGuestVlanRangeParams(id string) *ReleaseDedicatedGuestVlanRangeParams { p := &ReleaseDedicatedGuestVlanRangeParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
go
func (s *VLANService) NewReleaseDedicatedGuestVlanRangeParams(id string) *ReleaseDedicatedGuestVlanRangeParams { p := &ReleaseDedicatedGuestVlanRangeParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
[ "func", "(", "s", "*", "VLANService", ")", "NewReleaseDedicatedGuestVlanRangeParams", "(", "id", "string", ")", "*", "ReleaseDedicatedGuestVlanRangeParams", "{", "p", ":=", "&", "ReleaseDedicatedGuestVlanRangeParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ReleaseDedicatedGuestVlanRangeParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ReleaseDedicatedGuestVlanRangeParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/VLANService.go#L930-L935
train
xanzy/go-cloudstack
cloudstack/VLANService.go
ReleaseDedicatedGuestVlanRange
func (s *VLANService) ReleaseDedicatedGuestVlanRange(p *ReleaseDedicatedGuestVlanRangeParams) (*ReleaseDedicatedGuestVlanRangeResponse, error) { resp, err := s.cs.newRequest("releaseDedicatedGuestVlanRange", p.toURLValues()) if err != nil { return nil, err } var r ReleaseDedicatedGuestVlanRangeResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
go
func (s *VLANService) ReleaseDedicatedGuestVlanRange(p *ReleaseDedicatedGuestVlanRangeParams) (*ReleaseDedicatedGuestVlanRangeResponse, error) { resp, err := s.cs.newRequest("releaseDedicatedGuestVlanRange", p.toURLValues()) if err != nil { return nil, err } var r ReleaseDedicatedGuestVlanRangeResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
[ "func", "(", "s", "*", "VLANService", ")", "ReleaseDedicatedGuestVlanRange", "(", "p", "*", "ReleaseDedicatedGuestVlanRangeParams", ")", "(", "*", "ReleaseDedicatedGuestVlanRangeResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "ReleaseDedicatedGuestVlanRangeResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// If we have a async client, we need to wait for the async result", "if", "s", ".", "cs", ".", "async", "{", "b", ",", "err", ":=", "s", ".", "cs", ".", "GetAsyncJobResult", "(", "r", ".", "JobID", ",", "s", ".", "cs", ".", "timeout", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "AsyncTimeoutErr", "{", "return", "&", "r", ",", "err", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "b", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Releases a dedicated guest vlan range to the system
[ "Releases", "a", "dedicated", "guest", "vlan", "range", "to", "the", "system" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/VLANService.go#L938-L965
train