id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
144,100 | TheThingsNetwork/go-account-lib | account/components.go | GrantRouterRights | func (a *Account) GrantRouterRights(routerID, username string, rights []types.Right) error {
return a.GrantComponentRights("router", routerID, username, rights)
} | go | func (a *Account) GrantRouterRights(routerID, username string, rights []types.Right) error {
return a.GrantComponentRights("router", routerID, username, rights)
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"GrantRouterRights",
"(",
"routerID",
",",
"username",
"string",
",",
"rights",
"[",
"]",
"types",
".",
"Right",
")",
"error",
"{",
"return",
"a",
".",
"GrantComponentRights",
"(",
"\"",
"\"",
",",
"routerID",
",",
... | // GrantRouterRights grants the rights on the specified router to the specified user | [
"GrantRouterRights",
"grants",
"the",
"rights",
"on",
"the",
"specified",
"router",
"to",
"the",
"specified",
"user"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/components.go#L162-L164 |
144,101 | TheThingsNetwork/go-account-lib | account/components.go | GrantBrokerRights | func (a *Account) GrantBrokerRights(brokerID, username string, rights []types.Right) error {
return a.GrantComponentRights("broker", brokerID, username, rights)
} | go | func (a *Account) GrantBrokerRights(brokerID, username string, rights []types.Right) error {
return a.GrantComponentRights("broker", brokerID, username, rights)
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"GrantBrokerRights",
"(",
"brokerID",
",",
"username",
"string",
",",
"rights",
"[",
"]",
"types",
".",
"Right",
")",
"error",
"{",
"return",
"a",
".",
"GrantComponentRights",
"(",
"\"",
"\"",
",",
"brokerID",
",",
... | // GrantBrokerRights grants the rights on the specified broker to the specified user | [
"GrantBrokerRights",
"grants",
"the",
"rights",
"on",
"the",
"specified",
"broker",
"to",
"the",
"specified",
"user"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/components.go#L167-L169 |
144,102 | TheThingsNetwork/go-account-lib | account/components.go | GrantHandlerRights | func (a *Account) GrantHandlerRights(handlerID, username string, rights []types.Right) error {
return a.GrantComponentRights("handler", handlerID, username, rights)
} | go | func (a *Account) GrantHandlerRights(handlerID, username string, rights []types.Right) error {
return a.GrantComponentRights("handler", handlerID, username, rights)
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"GrantHandlerRights",
"(",
"handlerID",
",",
"username",
"string",
",",
"rights",
"[",
"]",
"types",
".",
"Right",
")",
"error",
"{",
"return",
"a",
".",
"GrantComponentRights",
"(",
"\"",
"\"",
",",
"handlerID",
",... | // GrantHandlerRights grants the rights on the specified handler to the specified user | [
"GrantHandlerRights",
"grants",
"the",
"rights",
"on",
"the",
"specified",
"handler",
"to",
"the",
"specified",
"user"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/components.go#L172-L174 |
144,103 | TheThingsNetwork/go-account-lib | account/components.go | RetractRouterRights | func (a *Account) RetractRouterRights(routerID, username string) error {
return a.RetractComponentRights("router", routerID, username)
} | go | func (a *Account) RetractRouterRights(routerID, username string) error {
return a.RetractComponentRights("router", routerID, username)
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"RetractRouterRights",
"(",
"routerID",
",",
"username",
"string",
")",
"error",
"{",
"return",
"a",
".",
"RetractComponentRights",
"(",
"\"",
"\"",
",",
"routerID",
",",
"username",
")",
"\n",
"}"
] | // RetractRouterRights retracts all rights on the specified router for the specified user | [
"RetractRouterRights",
"retracts",
"all",
"rights",
"on",
"the",
"specified",
"router",
"for",
"the",
"specified",
"user"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/components.go#L177-L179 |
144,104 | TheThingsNetwork/go-account-lib | account/components.go | RetractBrokerRights | func (a *Account) RetractBrokerRights(brokerID, username string) error {
return a.RetractComponentRights("broker", brokerID, username)
} | go | func (a *Account) RetractBrokerRights(brokerID, username string) error {
return a.RetractComponentRights("broker", brokerID, username)
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"RetractBrokerRights",
"(",
"brokerID",
",",
"username",
"string",
")",
"error",
"{",
"return",
"a",
".",
"RetractComponentRights",
"(",
"\"",
"\"",
",",
"brokerID",
",",
"username",
")",
"\n",
"}"
] | // RetractBrokerRights retracts all rights on the specified broker for the specified user | [
"RetractBrokerRights",
"retracts",
"all",
"rights",
"on",
"the",
"specified",
"broker",
"for",
"the",
"specified",
"user"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/components.go#L182-L184 |
144,105 | TheThingsNetwork/go-account-lib | account/components.go | RetractHandlerRights | func (a *Account) RetractHandlerRights(handlerID, username string) error {
return a.RetractComponentRights("handler", handlerID, username)
} | go | func (a *Account) RetractHandlerRights(handlerID, username string) error {
return a.RetractComponentRights("handler", handlerID, username)
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"RetractHandlerRights",
"(",
"handlerID",
",",
"username",
"string",
")",
"error",
"{",
"return",
"a",
".",
"RetractComponentRights",
"(",
"\"",
"\"",
",",
"handlerID",
",",
"username",
")",
"\n",
"}"
] | // RetractHandlerRights retracts all rights on the specified handler for the specified user | [
"RetractHandlerRights",
"retracts",
"all",
"rights",
"on",
"the",
"specified",
"handler",
"for",
"the",
"specified",
"user"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/components.go#L187-L189 |
144,106 | TheThingsNetwork/go-account-lib | util/validate.go | Validate | func Validate(val interface{}) error {
switch reflect.TypeOf(val).Kind() {
case reflect.Slice:
// validate a slice
err := validateSlice(val)
return err
case reflect.Ptr:
// try to get the valu from the ptr
v := reflect.ValueOf(val).Elem()
if v.CanInterface() {
return Validate(v.Interface())
}
case ... | go | func Validate(val interface{}) error {
switch reflect.TypeOf(val).Kind() {
case reflect.Slice:
// validate a slice
err := validateSlice(val)
return err
case reflect.Ptr:
// try to get the valu from the ptr
v := reflect.ValueOf(val).Elem()
if v.CanInterface() {
return Validate(v.Interface())
}
case ... | [
"func",
"Validate",
"(",
"val",
"interface",
"{",
"}",
")",
"error",
"{",
"switch",
"reflect",
".",
"TypeOf",
"(",
"val",
")",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".",
"Slice",
":",
"// validate a slice",
"err",
":=",
"validateSlice",
"(",
"... | // Validate recursivly validates most structures using govalidator
// struct tags. It currently works for slices, structs and pointers. | [
"Validate",
"recursivly",
"validates",
"most",
"structures",
"using",
"govalidator",
"struct",
"tags",
".",
"It",
"currently",
"works",
"for",
"slices",
"structs",
"and",
"pointers",
"."
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/util/validate.go#L26-L44 |
144,107 | TheThingsNetwork/go-account-lib | oauth/gateway_key.go | ExchangeGatewayKeyForToken | func (o *Config) ExchangeGatewayKeyForToken(gatewayID, gatewayKey string) (*oauth2.Token, error) {
strategy := auth.AccessKey(gatewayKey)
token := &tok{}
err := util.GET(log.Get(), o.Server, strategy, fmt.Sprintf("/api/v2/gateways/%s/token", gatewayID), o.Client.ExtraHeaders, token)
return token.Token(), err
} | go | func (o *Config) ExchangeGatewayKeyForToken(gatewayID, gatewayKey string) (*oauth2.Token, error) {
strategy := auth.AccessKey(gatewayKey)
token := &tok{}
err := util.GET(log.Get(), o.Server, strategy, fmt.Sprintf("/api/v2/gateways/%s/token", gatewayID), o.Client.ExtraHeaders, token)
return token.Token(), err
} | [
"func",
"(",
"o",
"*",
"Config",
")",
"ExchangeGatewayKeyForToken",
"(",
"gatewayID",
",",
"gatewayKey",
"string",
")",
"(",
"*",
"oauth2",
".",
"Token",
",",
"error",
")",
"{",
"strategy",
":=",
"auth",
".",
"AccessKey",
"(",
"gatewayKey",
")",
"\n",
"t... | // ExchangeGatewayKeyForToken exchanges an application Access Key for an equivalent | [
"ExchangeGatewayKeyForToken",
"exchanges",
"an",
"application",
"Access",
"Key",
"for",
"an",
"equivalent"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/oauth/gateway_key.go#L32-L37 |
144,108 | TheThingsNetwork/go-account-lib | account/account.go | New | func New(server string) *Account {
return &Account{
server: server,
auth: auth.Public,
ctx: wrap.Wrap(&apex.Logger{
Handler: cli.New(os.Stdout),
}),
headers: map[string]string{},
}
} | go | func New(server string) *Account {
return &Account{
server: server,
auth: auth.Public,
ctx: wrap.Wrap(&apex.Logger{
Handler: cli.New(os.Stdout),
}),
headers: map[string]string{},
}
} | [
"func",
"New",
"(",
"server",
"string",
")",
"*",
"Account",
"{",
"return",
"&",
"Account",
"{",
"server",
":",
"server",
",",
"auth",
":",
"auth",
".",
"Public",
",",
"ctx",
":",
"wrap",
".",
"Wrap",
"(",
"&",
"apex",
".",
"Logger",
"{",
"Handler"... | // New creates a new account that will use no authentication | [
"New",
"creates",
"a",
"new",
"account",
"that",
"will",
"use",
"no",
"authentication"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/account.go#L26-L35 |
144,109 | TheThingsNetwork/go-account-lib | account/account.go | WithLogger | func (a *Account) WithLogger(logger log.Interface) *Account {
a.ctx = logger
return a
} | go | func (a *Account) WithLogger(logger log.Interface) *Account {
a.ctx = logger
return a
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"WithLogger",
"(",
"logger",
"log",
".",
"Interface",
")",
"*",
"Account",
"{",
"a",
".",
"ctx",
"=",
"logger",
"\n",
"return",
"a",
"\n",
"}"
] | // WithLogger sets the logger that the account will use to log warnings | [
"WithLogger",
"sets",
"the",
"logger",
"that",
"the",
"account",
"will",
"use",
"to",
"log",
"warnings"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/account.go#L38-L41 |
144,110 | TheThingsNetwork/go-account-lib | account/account.go | WithAuth | func (a *Account) WithAuth(strategy auth.Strategy) *Account {
a.auth = strategy
return a
} | go | func (a *Account) WithAuth(strategy auth.Strategy) *Account {
a.auth = strategy
return a
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"WithAuth",
"(",
"strategy",
"auth",
".",
"Strategy",
")",
"*",
"Account",
"{",
"a",
".",
"auth",
"=",
"strategy",
"\n",
"return",
"a",
"\n",
"}"
] | // WithAuth sets the authentication strategy the account will use | [
"WithAuth",
"sets",
"the",
"authentication",
"strategy",
"the",
"account",
"will",
"use"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/account.go#L44-L47 |
144,111 | TheThingsNetwork/go-account-lib | account/account.go | WithHeader | func (a *Account) WithHeader(name, value string) *Account {
a.headers[name] = value
return a
} | go | func (a *Account) WithHeader(name, value string) *Account {
a.headers[name] = value
return a
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"WithHeader",
"(",
"name",
",",
"value",
"string",
")",
"*",
"Account",
"{",
"a",
".",
"headers",
"[",
"name",
"]",
"=",
"value",
"\n",
"return",
"a",
"\n",
"}"
] | // WithHeader adds the header to every request to the account server | [
"WithHeader",
"adds",
"the",
"header",
"to",
"every",
"request",
"to",
"the",
"account",
"server"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/account.go#L50-L53 |
144,112 | TheThingsNetwork/go-account-lib | account/account.go | NewWithAccessToken | func NewWithAccessToken(server, accessToken string) *Account {
return New(server).WithAuth(auth.AccessToken(accessToken))
} | go | func NewWithAccessToken(server, accessToken string) *Account {
return New(server).WithAuth(auth.AccessToken(accessToken))
} | [
"func",
"NewWithAccessToken",
"(",
"server",
",",
"accessToken",
"string",
")",
"*",
"Account",
"{",
"return",
"New",
"(",
"server",
")",
".",
"WithAuth",
"(",
"auth",
".",
"AccessToken",
"(",
"accessToken",
")",
")",
"\n",
"}"
] | // NewWithAccessToken creates a new account client that will use the
// accessToken to make requests to the specified account server | [
"NewWithAccessToken",
"creates",
"a",
"new",
"account",
"client",
"that",
"will",
"use",
"the",
"accessToken",
"to",
"make",
"requests",
"to",
"the",
"specified",
"account",
"server"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/account.go#L57-L59 |
144,113 | TheThingsNetwork/go-account-lib | account/account.go | NewWithManager | func NewWithManager(server, accessToken string, manager tokens.Manager) *Account {
return New(server).WithAuth(auth.AccessTokenWithManager(accessToken, manager))
} | go | func NewWithManager(server, accessToken string, manager tokens.Manager) *Account {
return New(server).WithAuth(auth.AccessTokenWithManager(accessToken, manager))
} | [
"func",
"NewWithManager",
"(",
"server",
",",
"accessToken",
"string",
",",
"manager",
"tokens",
".",
"Manager",
")",
"*",
"Account",
"{",
"return",
"New",
"(",
"server",
")",
".",
"WithAuth",
"(",
"auth",
".",
"AccessTokenWithManager",
"(",
"accessToken",
"... | // NewWithManager creates a new account client that will use the
// accessToken to make requests to the specified account server
// and the manager to request new tokens for different scopes | [
"NewWithManager",
"creates",
"a",
"new",
"account",
"client",
"that",
"will",
"use",
"the",
"accessToken",
"to",
"make",
"requests",
"to",
"the",
"specified",
"account",
"server",
"and",
"the",
"manager",
"to",
"request",
"new",
"tokens",
"for",
"different",
"... | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/account.go#L64-L66 |
144,114 | TheThingsNetwork/go-account-lib | account/account.go | NewWithKey | func NewWithKey(server, accessKey string) *Account {
return New(server).WithAuth(auth.AccessKey(accessKey))
} | go | func NewWithKey(server, accessKey string) *Account {
return New(server).WithAuth(auth.AccessKey(accessKey))
} | [
"func",
"NewWithKey",
"(",
"server",
",",
"accessKey",
"string",
")",
"*",
"Account",
"{",
"return",
"New",
"(",
"server",
")",
".",
"WithAuth",
"(",
"auth",
".",
"AccessKey",
"(",
"accessKey",
")",
")",
"\n",
"}"
] | // NewWithKey creates an account client that uses an accessKey to
// authenticate | [
"NewWithKey",
"creates",
"an",
"account",
"client",
"that",
"uses",
"an",
"accessKey",
"to",
"authenticate"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/account.go#L70-L72 |
144,115 | TheThingsNetwork/go-account-lib | account/account.go | NewWithBasicAuth | func NewWithBasicAuth(server, username, password string) *Account {
return New(server).WithAuth(auth.BasicAuth(username, password))
} | go | func NewWithBasicAuth(server, username, password string) *Account {
return New(server).WithAuth(auth.BasicAuth(username, password))
} | [
"func",
"NewWithBasicAuth",
"(",
"server",
",",
"username",
",",
"password",
"string",
")",
"*",
"Account",
"{",
"return",
"New",
"(",
"server",
")",
".",
"WithAuth",
"(",
"auth",
".",
"BasicAuth",
"(",
"username",
",",
"password",
")",
")",
"\n",
"}"
] | // NewWithBasicAuth creates an account client that uses basic authentication | [
"NewWithBasicAuth",
"creates",
"an",
"account",
"client",
"that",
"uses",
"basic",
"authentication"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/account.go#L75-L77 |
144,116 | TheThingsNetwork/go-account-lib | tokens/http_manager.go | HTTPManager | func HTTPManager(server, token string, store TokenStore) Manager {
return &httpManager{
server: server,
token: token,
store: store,
}
} | go | func HTTPManager(server, token string, store TokenStore) Manager {
return &httpManager{
server: server,
token: token,
store: store,
}
} | [
"func",
"HTTPManager",
"(",
"server",
",",
"token",
"string",
",",
"store",
"TokenStore",
")",
"Manager",
"{",
"return",
"&",
"httpManager",
"{",
"server",
":",
"server",
",",
"token",
":",
"token",
",",
"store",
":",
"store",
",",
"}",
"\n",
"}"
] | // HTTPManager creates a new token manager that uses the specified store
// to store and retrieve tokens | [
"HTTPManager",
"creates",
"a",
"new",
"token",
"manager",
"that",
"uses",
"the",
"specified",
"store",
"to",
"store",
"and",
"retrieve",
"tokens"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/tokens/http_manager.go#L16-L22 |
144,117 | TheThingsNetwork/go-account-lib | tokens/http_manager.go | TokenForScope | func (m *httpManager) TokenForScope(scope string) (string, error) {
// try to get existing token
token, err := m.store.Get(m.token, scope)
if err != nil {
return "", err
}
// return token if it exists
if token != "" {
return token, nil
}
scopes := []string{scope}
// token did not exist, get one from the... | go | func (m *httpManager) TokenForScope(scope string) (string, error) {
// try to get existing token
token, err := m.store.Get(m.token, scope)
if err != nil {
return "", err
}
// return token if it exists
if token != "" {
return token, nil
}
scopes := []string{scope}
// token did not exist, get one from the... | [
"func",
"(",
"m",
"*",
"httpManager",
")",
"TokenForScope",
"(",
"scope",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"// try to get existing token",
"token",
",",
"err",
":=",
"m",
".",
"store",
".",
"Get",
"(",
"m",
".",
"token",
",",
"scop... | // TokenForScopes returns a token that will work for the specified scopes | [
"TokenForScopes",
"returns",
"a",
"token",
"that",
"will",
"work",
"for",
"the",
"specified",
"scopes"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/tokens/http_manager.go#L25-L52 |
144,118 | TheThingsNetwork/go-account-lib | cache/const_cache.go | Get | func (c *constCache) Get(key string) ([]byte, error) {
return c.data, nil
} | go | func (c *constCache) Get(key string) ([]byte, error) {
return c.data, nil
} | [
"func",
"(",
"c",
"*",
"constCache",
")",
"Get",
"(",
"key",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"c",
".",
"data",
",",
"nil",
"\n",
"}"
] | // Get gets the same data every time | [
"Get",
"gets",
"the",
"same",
"data",
"every",
"time"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/cache/const_cache.go#L19-L21 |
144,119 | TheThingsNetwork/go-account-lib | account/types.go | HasRight | func (c *Collaborator) HasRight(right types.Right) bool {
for _, r := range c.Rights {
if r == right {
return true
}
}
return false
} | go | func (c *Collaborator) HasRight(right types.Right) bool {
for _, r := range c.Rights {
if r == right {
return true
}
}
return false
} | [
"func",
"(",
"c",
"*",
"Collaborator",
")",
"HasRight",
"(",
"right",
"types",
".",
"Right",
")",
"bool",
"{",
"for",
"_",
",",
"r",
":=",
"range",
"c",
".",
"Rights",
"{",
"if",
"r",
"==",
"right",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
... | // HasRight checks if the collaborator has a specific right | [
"HasRight",
"checks",
"if",
"the",
"collaborator",
"has",
"a",
"specific",
"right"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/types.go#L30-L37 |
144,120 | TheThingsNetwork/go-account-lib | account/types.go | Token | func (token *tokenRes) Token() *oauth2.Token {
if token == nil {
return nil
}
return &oauth2.Token{
AccessToken: token.AccessToken,
Expiry: time.Now().Add(time.Duration(token.ExpiresIn) * time.Second),
}
} | go | func (token *tokenRes) Token() *oauth2.Token {
if token == nil {
return nil
}
return &oauth2.Token{
AccessToken: token.AccessToken,
Expiry: time.Now().Add(time.Duration(token.ExpiresIn) * time.Second),
}
} | [
"func",
"(",
"token",
"*",
"tokenRes",
")",
"Token",
"(",
")",
"*",
"oauth2",
".",
"Token",
"{",
"if",
"token",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"&",
"oauth2",
".",
"Token",
"{",
"AccessToken",
":",
"token",
".",
"Acc... | // Token transfroms a gateway token to oauth token with correct expiry | [
"Token",
"transfroms",
"a",
"gateway",
"token",
"to",
"oauth",
"token",
"with",
"correct",
"expiry"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/types.go#L71-L80 |
144,121 | TheThingsNetwork/go-account-lib | oauth/oauth.go | OAuth | func OAuth(server string, client *Client) *Config {
return &Config{
Server: server,
Client: client,
cache: cache.EmptyCache,
}
} | go | func OAuth(server string, client *Client) *Config {
return &Config{
Server: server,
Client: client,
cache: cache.EmptyCache,
}
} | [
"func",
"OAuth",
"(",
"server",
"string",
",",
"client",
"*",
"Client",
")",
"*",
"Config",
"{",
"return",
"&",
"Config",
"{",
"Server",
":",
"server",
",",
"Client",
":",
"client",
",",
"cache",
":",
"cache",
".",
"EmptyCache",
",",
"}",
"\n",
"}"
] | // OAuth creates a new 3-legged OAuth client | [
"OAuth",
"creates",
"a",
"new",
"3",
"-",
"legged",
"OAuth",
"client"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/oauth/oauth.go#L33-L39 |
144,122 | TheThingsNetwork/go-account-lib | oauth/oauth.go | NewWithCache | func NewWithCache(server string, client *Client, cache cache.Cache) *Config {
return &Config{
Server: server,
Client: client,
cache: cache,
}
} | go | func NewWithCache(server string, client *Client, cache cache.Cache) *Config {
return &Config{
Server: server,
Client: client,
cache: cache,
}
} | [
"func",
"NewWithCache",
"(",
"server",
"string",
",",
"client",
"*",
"Client",
",",
"cache",
"cache",
".",
"Cache",
")",
"*",
"Config",
"{",
"return",
"&",
"Config",
"{",
"Server",
":",
"server",
",",
"Client",
":",
"client",
",",
"cache",
":",
"cache"... | // NewWithCache creates a new 3-legged OAuth client that uses a cache to cache
// tokens | [
"NewWithCache",
"creates",
"a",
"new",
"3",
"-",
"legged",
"OAuth",
"client",
"that",
"uses",
"a",
"cache",
"to",
"cache",
"tokens"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/oauth/oauth.go#L43-L49 |
144,123 | TheThingsNetwork/go-account-lib | oauth/oauth.go | getConfig | func (c *Config) getConfig() *oauth2.Config {
return &oauth2.Config{
ClientID: c.Client.ID,
ClientSecret: c.Client.Secret,
RedirectURL: c.Client.RedirectURL,
Endpoint: oauth2.Endpoint{
TokenURL: fmt.Sprintf("%s/users/token", c.Server),
AuthURL: fmt.Sprintf("%s/users/authorize", c.Server),
},
}
} | go | func (c *Config) getConfig() *oauth2.Config {
return &oauth2.Config{
ClientID: c.Client.ID,
ClientSecret: c.Client.Secret,
RedirectURL: c.Client.RedirectURL,
Endpoint: oauth2.Endpoint{
TokenURL: fmt.Sprintf("%s/users/token", c.Server),
AuthURL: fmt.Sprintf("%s/users/authorize", c.Server),
},
}
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"getConfig",
"(",
")",
"*",
"oauth2",
".",
"Config",
"{",
"return",
"&",
"oauth2",
".",
"Config",
"{",
"ClientID",
":",
"c",
".",
"Client",
".",
"ID",
",",
"ClientSecret",
":",
"c",
".",
"Client",
".",
"Secret"... | // c.getConfig builds the oauth2 config for an OAuth client | [
"c",
".",
"getConfig",
"builds",
"the",
"oauth2",
"config",
"for",
"an",
"OAuth",
"client"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/oauth/oauth.go#L52-L62 |
144,124 | TheThingsNetwork/go-account-lib | oauth/oauth.go | getContext | func (c *Config) getContext() context.Context {
client := &http.Client{
Transport: util.NewRoundTripper(log.Get(), c.Client.ExtraHeaders),
}
return context.WithValue(context.Background(), oauth2.HTTPClient, client)
} | go | func (c *Config) getContext() context.Context {
client := &http.Client{
Transport: util.NewRoundTripper(log.Get(), c.Client.ExtraHeaders),
}
return context.WithValue(context.Background(), oauth2.HTTPClient, client)
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"getContext",
"(",
")",
"context",
".",
"Context",
"{",
"client",
":=",
"&",
"http",
".",
"Client",
"{",
"Transport",
":",
"util",
".",
"NewRoundTripper",
"(",
"log",
".",
"Get",
"(",
")",
",",
"c",
".",
"Clien... | // getContext builds a new context for use in an oauth exchange | [
"getContext",
"builds",
"a",
"new",
"context",
"for",
"use",
"in",
"an",
"oauth",
"exchange"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/oauth/oauth.go#L78-L84 |
144,125 | TheThingsNetwork/go-account-lib | oauth/oauth.go | Exchange | func (c *Config) Exchange(code string) (*oauth2.Token, error) {
config := c.getConfig()
token, err := config.Exchange(c.getContext(), code)
return token, fromError(err)
} | go | func (c *Config) Exchange(code string) (*oauth2.Token, error) {
config := c.getConfig()
token, err := config.Exchange(c.getContext(), code)
return token, fromError(err)
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"Exchange",
"(",
"code",
"string",
")",
"(",
"*",
"oauth2",
".",
"Token",
",",
"error",
")",
"{",
"config",
":=",
"c",
".",
"getConfig",
"(",
")",
"\n",
"token",
",",
"err",
":=",
"config",
".",
"Exchange",
"... | // Exchange exchanges an OAuth 2.0 Authorization Code for an oauth2.Token | [
"Exchange",
"exchanges",
"an",
"OAuth",
"2",
".",
"0",
"Authorization",
"Code",
"for",
"an",
"oauth2",
".",
"Token"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/oauth/oauth.go#L87-L91 |
144,126 | TheThingsNetwork/go-account-lib | oauth/oauth.go | PasswordCredentialsToken | func (c *Config) PasswordCredentialsToken(username, password string) (*oauth2.Token, error) {
config := c.getConfig()
token, err := config.PasswordCredentialsToken(c.getContext(), username, password)
return token, fromError(err)
} | go | func (c *Config) PasswordCredentialsToken(username, password string) (*oauth2.Token, error) {
config := c.getConfig()
token, err := config.PasswordCredentialsToken(c.getContext(), username, password)
return token, fromError(err)
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"PasswordCredentialsToken",
"(",
"username",
",",
"password",
"string",
")",
"(",
"*",
"oauth2",
".",
"Token",
",",
"error",
")",
"{",
"config",
":=",
"c",
".",
"getConfig",
"(",
")",
"\n",
"token",
",",
"err",
"... | // PasswordCredentialsToken gets an oauth2.Token from username and password | [
"PasswordCredentialsToken",
"gets",
"an",
"oauth2",
".",
"Token",
"from",
"username",
"and",
"password"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/oauth/oauth.go#L94-L98 |
144,127 | TheThingsNetwork/go-account-lib | oauth/oauth.go | TokenSource | func (c *Config) TokenSource(token *oauth2.Token) oauth2.TokenSource {
config := c.getConfig()
return config.TokenSource(c.getContext(), token)
} | go | func (c *Config) TokenSource(token *oauth2.Token) oauth2.TokenSource {
config := c.getConfig()
return config.TokenSource(c.getContext(), token)
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"TokenSource",
"(",
"token",
"*",
"oauth2",
".",
"Token",
")",
"oauth2",
".",
"TokenSource",
"{",
"config",
":=",
"c",
".",
"getConfig",
"(",
")",
"\n",
"return",
"config",
".",
"TokenSource",
"(",
"c",
".",
"get... | // TokenSource creates oauth2.TokenSource from an oauht2.Token | [
"TokenSource",
"creates",
"oauth2",
".",
"TokenSource",
"from",
"an",
"oauht2",
".",
"Token"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/oauth/oauth.go#L101-L104 |
144,128 | TheThingsNetwork/go-account-lib | oauth/oauth.go | ExchangeAppKeyForToken | func (c *Config) ExchangeAppKeyForToken(appID, accessKey string) (*oauth2.Token, error) {
// application Access Token
config := c.getKeyConfig()
token, err := getTokenFromCache(c.cache, appID, accessKey)
if err != nil {
return nil, err
}
if token != nil {
return token, nil
}
token, err = config.PasswordC... | go | func (c *Config) ExchangeAppKeyForToken(appID, accessKey string) (*oauth2.Token, error) {
// application Access Token
config := c.getKeyConfig()
token, err := getTokenFromCache(c.cache, appID, accessKey)
if err != nil {
return nil, err
}
if token != nil {
return token, nil
}
token, err = config.PasswordC... | [
"func",
"(",
"c",
"*",
"Config",
")",
"ExchangeAppKeyForToken",
"(",
"appID",
",",
"accessKey",
"string",
")",
"(",
"*",
"oauth2",
".",
"Token",
",",
"error",
")",
"{",
"// application Access Token",
"config",
":=",
"c",
".",
"getKeyConfig",
"(",
")",
"\n\... | // ExchangeAppKeyForToken exchanges an application Access Key for an equivalent | [
"ExchangeAppKeyForToken",
"exchanges",
"an",
"application",
"Access",
"Key",
"for",
"an",
"equivalent"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/oauth/oauth.go#L107-L129 |
144,129 | TheThingsNetwork/go-account-lib | oauth/oauth.go | AuthCodeURL | func (c *Config) AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string {
config := c.getConfig()
return config.AuthCodeURL(state, opts...)
} | go | func (c *Config) AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string {
config := c.getConfig()
return config.AuthCodeURL(state, opts...)
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"AuthCodeURL",
"(",
"state",
"string",
",",
"opts",
"...",
"oauth2",
".",
"AuthCodeOption",
")",
"string",
"{",
"config",
":=",
"c",
".",
"getConfig",
"(",
")",
"\n",
"return",
"config",
".",
"AuthCodeURL",
"(",
"s... | // AuthCodeURL returns a URL to OAuth 2.0 provider's consent page that asks for permissions for the required scopes explicitly. | [
"AuthCodeURL",
"returns",
"a",
"URL",
"to",
"OAuth",
"2",
".",
"0",
"provider",
"s",
"consent",
"page",
"that",
"asks",
"for",
"permissions",
"for",
"the",
"required",
"scopes",
"explicitly",
"."
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/oauth/oauth.go#L132-L135 |
144,130 | TheThingsNetwork/go-account-lib | cache/file_cache.go | FileCacheWithNameFn | func FileCacheWithNameFn(dirname string, filename func(string) string) Cache {
return &fileCache{
dirname: dirname,
nameFn: filename,
}
} | go | func FileCacheWithNameFn(dirname string, filename func(string) string) Cache {
return &fileCache{
dirname: dirname,
nameFn: filename,
}
} | [
"func",
"FileCacheWithNameFn",
"(",
"dirname",
"string",
",",
"filename",
"func",
"(",
"string",
")",
"string",
")",
"Cache",
"{",
"return",
"&",
"fileCache",
"{",
"dirname",
":",
"dirname",
",",
"nameFn",
":",
"filename",
",",
"}",
"\n",
"}"
] | // FileCacheWithNameFn creates a FileCache that has a custom function to generate
// filenames | [
"FileCacheWithNameFn",
"creates",
"a",
"FileCache",
"that",
"has",
"a",
"custom",
"function",
"to",
"generate",
"filenames"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/cache/file_cache.go#L28-L33 |
144,131 | TheThingsNetwork/go-account-lib | cache/file_cache.go | FileCacheWithFormat | func FileCacheWithFormat(dirname string, format string) Cache {
return FileCacheWithNameFn(dirname, func(key string) string {
return fmt.Sprintf(format, key)
})
} | go | func FileCacheWithFormat(dirname string, format string) Cache {
return FileCacheWithNameFn(dirname, func(key string) string {
return fmt.Sprintf(format, key)
})
} | [
"func",
"FileCacheWithFormat",
"(",
"dirname",
"string",
",",
"format",
"string",
")",
"Cache",
"{",
"return",
"FileCacheWithNameFn",
"(",
"dirname",
",",
"func",
"(",
"key",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
... | // FileCacheWithFormat creates a FileCache that uses a format string to generate
// filenames | [
"FileCacheWithFormat",
"creates",
"a",
"FileCache",
"that",
"uses",
"a",
"format",
"string",
"to",
"generate",
"filenames"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/cache/file_cache.go#L37-L41 |
144,132 | TheThingsNetwork/go-account-lib | cache/file_cache.go | filename | func (c *fileCache) filename(key string) string {
return path.Join(c.dirname, c.nameFn(key))
} | go | func (c *fileCache) filename(key string) string {
return path.Join(c.dirname, c.nameFn(key))
} | [
"func",
"(",
"c",
"*",
"fileCache",
")",
"filename",
"(",
"key",
"string",
")",
"string",
"{",
"return",
"path",
".",
"Join",
"(",
"c",
".",
"dirname",
",",
"c",
".",
"nameFn",
"(",
"key",
")",
")",
"\n",
"}"
] | // filename creates the full filename for key based on configuration | [
"filename",
"creates",
"the",
"full",
"filename",
"for",
"key",
"based",
"on",
"configuration"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/cache/file_cache.go#L44-L46 |
144,133 | TheThingsNetwork/go-account-lib | cache/file_cache.go | Get | func (c *fileCache) Get(key string) ([]byte, error) {
cached, err := ioutil.ReadFile(c.filename(key))
if err != nil {
// check the error
if _, ok := err.(*os.PathError); !ok {
return nil, err
}
}
return cached, nil
} | go | func (c *fileCache) Get(key string) ([]byte, error) {
cached, err := ioutil.ReadFile(c.filename(key))
if err != nil {
// check the error
if _, ok := err.(*os.PathError); !ok {
return nil, err
}
}
return cached, nil
} | [
"func",
"(",
"c",
"*",
"fileCache",
")",
"Get",
"(",
"key",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"cached",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"c",
".",
"filename",
"(",
"key",
")",
")",
"\n",
"if",
"err",... | // Get tries to read the filename | [
"Get",
"tries",
"to",
"read",
"the",
"filename"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/cache/file_cache.go#L49-L59 |
144,134 | TheThingsNetwork/go-account-lib | cache/file_cache.go | Set | func (c *fileCache) Set(key string, data []byte) error {
err := os.MkdirAll(c.dirname, 0700)
if err != nil {
return err
}
return ioutil.WriteFile(c.filename(key), data, 0644)
} | go | func (c *fileCache) Set(key string, data []byte) error {
err := os.MkdirAll(c.dirname, 0700)
if err != nil {
return err
}
return ioutil.WriteFile(c.filename(key), data, 0644)
} | [
"func",
"(",
"c",
"*",
"fileCache",
")",
"Set",
"(",
"key",
"string",
",",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"c",
".",
"dirname",
",",
"0700",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return... | // Set saves the data to the file determined by key | [
"Set",
"saves",
"the",
"data",
"to",
"the",
"file",
"determined",
"by",
"key"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/cache/file_cache.go#L62-L68 |
144,135 | TheThingsNetwork/go-account-lib | claims/util.go | contains | func contains(slice []string, el string) bool {
for _, e := range slice {
if e == el {
return true
}
}
return false
} | go | func contains(slice []string, el string) bool {
for _, e := range slice {
if e == el {
return true
}
}
return false
} | [
"func",
"contains",
"(",
"slice",
"[",
"]",
"string",
",",
"el",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"e",
":=",
"range",
"slice",
"{",
"if",
"e",
"==",
"el",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"... | // contains checks for membership of a string in a stringmap | [
"contains",
"checks",
"for",
"membership",
"of",
"a",
"string",
"in",
"a",
"stringmap"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/claims/util.go#L9-L16 |
144,136 | TheThingsNetwork/go-account-lib | claims/parse.go | fromToken | func fromToken(provider tokenkey.Provider, token string, claims WithIssuer) error {
parsed, err := jwt.ParseWithClaims(token, claims, func(token *jwt.Token) (key interface{}, err error) {
if provider == nil {
return nil, errors.New("No token provider configured")
}
k, err := provider.Get(claims.GetIssuer(), ... | go | func fromToken(provider tokenkey.Provider, token string, claims WithIssuer) error {
parsed, err := jwt.ParseWithClaims(token, claims, func(token *jwt.Token) (key interface{}, err error) {
if provider == nil {
return nil, errors.New("No token provider configured")
}
k, err := provider.Get(claims.GetIssuer(), ... | [
"func",
"fromToken",
"(",
"provider",
"tokenkey",
".",
"Provider",
",",
"token",
"string",
",",
"claims",
"WithIssuer",
")",
"error",
"{",
"parsed",
",",
"err",
":=",
"jwt",
".",
"ParseWithClaims",
"(",
"token",
",",
"claims",
",",
"func",
"(",
"token",
... | // fromToken parser a token given the tokenkey provider into the desired claims
// structure | [
"fromToken",
"parser",
"a",
"token",
"given",
"the",
"tokenkey",
"provider",
"into",
"the",
"desired",
"claims",
"structure"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/claims/parse.go#L18-L57 |
144,137 | TheThingsNetwork/go-account-lib | claims/parse.go | fromTokenWithoutValidation | func fromTokenWithoutValidation(token string, claims jwt.Claims) error {
parts := strings.Split(token, ".")
if len(parts) != 3 {
return errors.New("Invalid access token segments")
}
segment, err := jwt.DecodeSegment(parts[1])
if err != nil {
return err
}
err = json.Unmarshal(segment, claims)
if err != nil... | go | func fromTokenWithoutValidation(token string, claims jwt.Claims) error {
parts := strings.Split(token, ".")
if len(parts) != 3 {
return errors.New("Invalid access token segments")
}
segment, err := jwt.DecodeSegment(parts[1])
if err != nil {
return err
}
err = json.Unmarshal(segment, claims)
if err != nil... | [
"func",
"fromTokenWithoutValidation",
"(",
"token",
"string",
",",
"claims",
"jwt",
".",
"Claims",
")",
"error",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"token",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"parts",
")",
"!=",
"3",
"{",
"r... | // FromTokenWithoutValidation parses a token into the desired claims structure,
// without checking the token signature | [
"FromTokenWithoutValidation",
"parses",
"a",
"token",
"into",
"the",
"desired",
"claims",
"structure",
"without",
"checking",
"the",
"token",
"signature"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/claims/parse.go#L61-L78 |
144,138 | TheThingsNetwork/go-account-lib | claims/access.go | AppAccess | func (claims *Claims) AppAccess(appID string) bool {
return claims.HasScope(scope.App(appID))
} | go | func (claims *Claims) AppAccess(appID string) bool {
return claims.HasScope(scope.App(appID))
} | [
"func",
"(",
"claims",
"*",
"Claims",
")",
"AppAccess",
"(",
"appID",
"string",
")",
"bool",
"{",
"return",
"claims",
".",
"HasScope",
"(",
"scope",
".",
"App",
"(",
"appID",
")",
")",
"\n",
"}"
] | // AppAccess checks if the token grants access to the specified app | [
"AppAccess",
"checks",
"if",
"the",
"token",
"grants",
"access",
"to",
"the",
"specified",
"app"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/claims/access.go#L9-L11 |
144,139 | TheThingsNetwork/go-account-lib | claims/access.go | GatewayAccess | func (claims *Claims) GatewayAccess(gatewayID string) bool {
return claims.HasScope(scope.Gateway(gatewayID))
} | go | func (claims *Claims) GatewayAccess(gatewayID string) bool {
return claims.HasScope(scope.Gateway(gatewayID))
} | [
"func",
"(",
"claims",
"*",
"Claims",
")",
"GatewayAccess",
"(",
"gatewayID",
"string",
")",
"bool",
"{",
"return",
"claims",
".",
"HasScope",
"(",
"scope",
".",
"Gateway",
"(",
"gatewayID",
")",
")",
"\n",
"}"
] | // GatewayAccess checks if the token grants access to the specified Gateway | [
"GatewayAccess",
"checks",
"if",
"the",
"token",
"grants",
"access",
"to",
"the",
"specified",
"Gateway"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/claims/access.go#L14-L16 |
144,140 | TheThingsNetwork/go-account-lib | claims/access.go | ComponentAccess | func (claims *Claims) ComponentAccess(componentID string) bool {
return claims.HasScope(scope.Component(componentID))
} | go | func (claims *Claims) ComponentAccess(componentID string) bool {
return claims.HasScope(scope.Component(componentID))
} | [
"func",
"(",
"claims",
"*",
"Claims",
")",
"ComponentAccess",
"(",
"componentID",
"string",
")",
"bool",
"{",
"return",
"claims",
".",
"HasScope",
"(",
"scope",
".",
"Component",
"(",
"componentID",
")",
")",
"\n",
"}"
] | // ComponentAccess checks if the token grants access to the specified Component | [
"ComponentAccess",
"checks",
"if",
"the",
"token",
"grants",
"access",
"to",
"the",
"specified",
"Component"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/claims/access.go#L19-L21 |
144,141 | TheThingsNetwork/go-account-lib | claims/scope.go | HasScope | func (claims *Claims) HasScope(scope string) bool {
return claims != nil && contains(claims.Scope, scope)
} | go | func (claims *Claims) HasScope(scope string) bool {
return claims != nil && contains(claims.Scope, scope)
} | [
"func",
"(",
"claims",
"*",
"Claims",
")",
"HasScope",
"(",
"scope",
"string",
")",
"bool",
"{",
"return",
"claims",
"!=",
"nil",
"&&",
"contains",
"(",
"claims",
".",
"Scope",
",",
"scope",
")",
"\n",
"}"
] | // HasScope checks if the token has the specified scope | [
"HasScope",
"checks",
"if",
"the",
"token",
"has",
"the",
"specified",
"scope"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/claims/scope.go#L7-L9 |
144,142 | TheThingsNetwork/go-account-lib | util/http.go | checkRedirect | func checkRedirect(req *http.Request, via []*http.Request) error {
if len(via) > MaxRedirects {
return errors.New("Maximum number of redirects reached")
}
// use the same headers as before
req.Header.Set("Authorization", via[len(via)-1].Header.Get("Authorization"))
req.Header.Set("Accept", "application/json")
... | go | func checkRedirect(req *http.Request, via []*http.Request) error {
if len(via) > MaxRedirects {
return errors.New("Maximum number of redirects reached")
}
// use the same headers as before
req.Header.Set("Authorization", via[len(via)-1].Header.Get("Authorization"))
req.Header.Set("Accept", "application/json")
... | [
"func",
"checkRedirect",
"(",
"req",
"*",
"http",
".",
"Request",
",",
"via",
"[",
"]",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"if",
"len",
"(",
"via",
")",
">",
"MaxRedirects",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
... | // checkRedirect implements this clients redirection policy | [
"checkRedirect",
"implements",
"this",
"clients",
"redirection",
"policy"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/util/http.go#L38-L48 |
144,143 | TheThingsNetwork/go-account-lib | util/http.go | newRequest | func newRequest(server, method string, URI string, body io.Reader) (*http.Request, error) {
URL := fmt.Sprintf("%s%s", server, URI)
req, err := http.NewRequest(method, URL, body)
if err != nil {
return nil, err
}
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
... | go | func newRequest(server, method string, URI string, body io.Reader) (*http.Request, error) {
URL := fmt.Sprintf("%s%s", server, URI)
req, err := http.NewRequest(method, URL, body)
if err != nil {
return nil, err
}
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
... | [
"func",
"newRequest",
"(",
"server",
",",
"method",
"string",
",",
"URI",
"string",
",",
"body",
"io",
".",
"Reader",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"URL",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"server",... | // NewRequest creates a new http.Request that has authorization set up | [
"NewRequest",
"creates",
"a",
"new",
"http",
".",
"Request",
"that",
"has",
"authorization",
"set",
"up"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/util/http.go#L51-L62 |
144,144 | TheThingsNetwork/go-account-lib | util/http.go | performRequest | func performRequest(ctx log.Interface, server string, strategy auth.Strategy, method, URI string, headers map[string]string, rbody, res interface{}, redirects int) error {
body, err := performRequestBody(ctx, server, strategy, method, URI, headers, rbody, redirects)
if err != nil {
return err
}
defer func() {
... | go | func performRequest(ctx log.Interface, server string, strategy auth.Strategy, method, URI string, headers map[string]string, rbody, res interface{}, redirects int) error {
body, err := performRequestBody(ctx, server, strategy, method, URI, headers, rbody, redirects)
if err != nil {
return err
}
defer func() {
... | [
"func",
"performRequest",
"(",
"ctx",
"log",
".",
"Interface",
",",
"server",
"string",
",",
"strategy",
"auth",
".",
"Strategy",
",",
"method",
",",
"URI",
"string",
",",
"headers",
"map",
"[",
"string",
"]",
"string",
",",
"rbody",
",",
"res",
"interfa... | // performRequest performs a request and decodes the result | [
"performRequest",
"performs",
"a",
"request",
"and",
"decodes",
"the",
"result"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/util/http.go#L156-L175 |
144,145 | TheThingsNetwork/go-account-lib | util/http.go | GET | func GET(ctx log.Interface, server string, strategy auth.Strategy, URI string, headers map[string]string, res interface{}) error {
return performRequest(ctx, server, strategy, "GET", URI, headers, nil, res, MaxRedirects)
} | go | func GET(ctx log.Interface, server string, strategy auth.Strategy, URI string, headers map[string]string, res interface{}) error {
return performRequest(ctx, server, strategy, "GET", URI, headers, nil, res, MaxRedirects)
} | [
"func",
"GET",
"(",
"ctx",
"log",
".",
"Interface",
",",
"server",
"string",
",",
"strategy",
"auth",
".",
"Strategy",
",",
"URI",
"string",
",",
"headers",
"map",
"[",
"string",
"]",
"string",
",",
"res",
"interface",
"{",
"}",
")",
"error",
"{",
"r... | // GET does a get request to the account server, decoding the result into the object pointed to byres | [
"GET",
"does",
"a",
"get",
"request",
"to",
"the",
"account",
"server",
"decoding",
"the",
"result",
"into",
"the",
"object",
"pointed",
"to",
"byres"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/util/http.go#L178-L180 |
144,146 | TheThingsNetwork/go-account-lib | util/http.go | GETBody | func GETBody(ctx log.Interface, server string, strategy auth.Strategy, URI string, headers map[string]string) (io.ReadCloser, error) {
return performRequestBody(ctx, server, strategy, "GET", URI, headers, nil, MaxRedirects)
} | go | func GETBody(ctx log.Interface, server string, strategy auth.Strategy, URI string, headers map[string]string) (io.ReadCloser, error) {
return performRequestBody(ctx, server, strategy, "GET", URI, headers, nil, MaxRedirects)
} | [
"func",
"GETBody",
"(",
"ctx",
"log",
".",
"Interface",
",",
"server",
"string",
",",
"strategy",
"auth",
".",
"Strategy",
",",
"URI",
"string",
",",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
... | // GETBody does a get request to the account server and returns the body as a
// ReadCloser | [
"GETBody",
"does",
"a",
"get",
"request",
"to",
"the",
"account",
"server",
"and",
"returns",
"the",
"body",
"as",
"a",
"ReadCloser"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/util/http.go#L184-L186 |
144,147 | TheThingsNetwork/go-account-lib | util/http.go | POST | func POST(ctx log.Interface, server string, strategy auth.Strategy, URI string, headers map[string]string, body, res interface{}) error {
return performRequest(ctx, server, strategy, "POST", URI, headers, body, res, MaxRedirects)
} | go | func POST(ctx log.Interface, server string, strategy auth.Strategy, URI string, headers map[string]string, body, res interface{}) error {
return performRequest(ctx, server, strategy, "POST", URI, headers, body, res, MaxRedirects)
} | [
"func",
"POST",
"(",
"ctx",
"log",
".",
"Interface",
",",
"server",
"string",
",",
"strategy",
"auth",
".",
"Strategy",
",",
"URI",
"string",
",",
"headers",
"map",
"[",
"string",
"]",
"string",
",",
"body",
",",
"res",
"interface",
"{",
"}",
")",
"e... | // POST creates an HTTP Post request to the specified server, with the body
// encoded as JSON, decoding the result into the object pointed to byres | [
"POST",
"creates",
"an",
"HTTP",
"Post",
"request",
"to",
"the",
"specified",
"server",
"with",
"the",
"body",
"encoded",
"as",
"JSON",
"decoding",
"the",
"result",
"into",
"the",
"object",
"pointed",
"to",
"byres"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/util/http.go#L195-L197 |
144,148 | TheThingsNetwork/go-account-lib | tokens/null_store.go | Set | func (s *nullStore) Set(parent string, scope []string, token string, TTL time.Duration) error {
return nil
} | go | func (s *nullStore) Set(parent string, scope []string, token string, TTL time.Duration) error {
return nil
} | [
"func",
"(",
"s",
"*",
"nullStore",
")",
"Set",
"(",
"parent",
"string",
",",
"scope",
"[",
"]",
"string",
",",
"token",
"string",
",",
"TTL",
"time",
".",
"Duration",
")",
"error",
"{",
"return",
"nil",
"\n",
"}"
] | // Set accepts a token but does nothing with it | [
"Set",
"accepts",
"a",
"token",
"but",
"does",
"nothing",
"with",
"it"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/tokens/null_store.go#L19-L21 |
144,149 | TheThingsNetwork/go-account-lib | account/clients.go | ListOAuthClients | func (a *Account) ListOAuthClients() (clients []*OAuthClient, err error) {
err = a.get(a.auth.WithScope(scope.Clients), "/api/v2/clients", &clients)
return clients, err
} | go | func (a *Account) ListOAuthClients() (clients []*OAuthClient, err error) {
err = a.get(a.auth.WithScope(scope.Clients), "/api/v2/clients", &clients)
return clients, err
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"ListOAuthClients",
"(",
")",
"(",
"clients",
"[",
"]",
"*",
"OAuthClient",
",",
"err",
"error",
")",
"{",
"err",
"=",
"a",
".",
"get",
"(",
"a",
".",
"auth",
".",
"WithScope",
"(",
"scope",
".",
"Clients",
... | // ListOAuthClients lists all of the users OAuth clients | [
"ListOAuthClients",
"lists",
"all",
"of",
"the",
"users",
"OAuth",
"clients"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/clients.go#L37-L40 |
144,150 | TheThingsNetwork/go-account-lib | account/clients.go | FindOAuthClient | func (a *Account) FindOAuthClient(name string) (client *OAuthClient, err error) {
err = a.get(a.auth.WithScope(scope.Clients), fmt.Sprintf("/api/v2/clients/%s", name), &client)
return client, err
} | go | func (a *Account) FindOAuthClient(name string) (client *OAuthClient, err error) {
err = a.get(a.auth.WithScope(scope.Clients), fmt.Sprintf("/api/v2/clients/%s", name), &client)
return client, err
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"FindOAuthClient",
"(",
"name",
"string",
")",
"(",
"client",
"*",
"OAuthClient",
",",
"err",
"error",
")",
"{",
"err",
"=",
"a",
".",
"get",
"(",
"a",
".",
"auth",
".",
"WithScope",
"(",
"scope",
".",
"Client... | // FindOAuthClient gets the OAuth client with the name | [
"FindOAuthClient",
"gets",
"the",
"OAuth",
"client",
"with",
"the",
"name"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/clients.go#L43-L46 |
144,151 | TheThingsNetwork/go-account-lib | account/clients.go | CreateOAuthClient | func (a *Account) CreateOAuthClient(client *OAuthClient) (c *OAuthClient, err error) {
err = a.post(a.auth.WithScope(scope.Clients), "/api/v2/clients", client, &c)
return c, err
} | go | func (a *Account) CreateOAuthClient(client *OAuthClient) (c *OAuthClient, err error) {
err = a.post(a.auth.WithScope(scope.Clients), "/api/v2/clients", client, &c)
return c, err
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"CreateOAuthClient",
"(",
"client",
"*",
"OAuthClient",
")",
"(",
"c",
"*",
"OAuthClient",
",",
"err",
"error",
")",
"{",
"err",
"=",
"a",
".",
"post",
"(",
"a",
".",
"auth",
".",
"WithScope",
"(",
"scope",
".... | // CreateOAuthClient creates a new OAuth client | [
"CreateOAuthClient",
"creates",
"a",
"new",
"OAuth",
"client"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/clients.go#L49-L52 |
144,152 | TheThingsNetwork/go-account-lib | account/clients.go | EditOAuthClient | func (a *Account) EditOAuthClient(name string, edits *OAuthClient) (err error) {
return a.patch(a.auth.WithScope(scope.Clients), fmt.Sprintf("/api/v2/clients/%s", name), edits, nil)
} | go | func (a *Account) EditOAuthClient(name string, edits *OAuthClient) (err error) {
return a.patch(a.auth.WithScope(scope.Clients), fmt.Sprintf("/api/v2/clients/%s", name), edits, nil)
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"EditOAuthClient",
"(",
"name",
"string",
",",
"edits",
"*",
"OAuthClient",
")",
"(",
"err",
"error",
")",
"{",
"return",
"a",
".",
"patch",
"(",
"a",
".",
"auth",
".",
"WithScope",
"(",
"scope",
".",
"Clients",... | // EditOAuthClient updates the OAuth client | [
"EditOAuthClient",
"updates",
"the",
"OAuth",
"client"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/clients.go#L55-L57 |
144,153 | TheThingsNetwork/go-account-lib | account/clients.go | RemoveOAuthClient | func (a *Account) RemoveOAuthClient(name string) (err error) {
return a.del(a.auth.WithScope(scope.Clients), fmt.Sprintf("/api/v2/clients/%s", name))
} | go | func (a *Account) RemoveOAuthClient(name string) (err error) {
return a.del(a.auth.WithScope(scope.Clients), fmt.Sprintf("/api/v2/clients/%s", name))
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"RemoveOAuthClient",
"(",
"name",
"string",
")",
"(",
"err",
"error",
")",
"{",
"return",
"a",
".",
"del",
"(",
"a",
".",
"auth",
".",
"WithScope",
"(",
"scope",
".",
"Clients",
")",
",",
"fmt",
".",
"Sprintf"... | // RemoveOAuthClient removes the OAuth client | [
"RemoveOAuthClient",
"removes",
"the",
"OAuth",
"client"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/clients.go#L60-L62 |
144,154 | TheThingsNetwork/go-account-lib | claims/rights.go | AppRight | func (claims *Claims) AppRight(appID string, right types.Right) bool {
return claims.AppAccess(appID) && containsRight(claims.Apps[appID], right)
} | go | func (claims *Claims) AppRight(appID string, right types.Right) bool {
return claims.AppAccess(appID) && containsRight(claims.Apps[appID], right)
} | [
"func",
"(",
"claims",
"*",
"Claims",
")",
"AppRight",
"(",
"appID",
"string",
",",
"right",
"types",
".",
"Right",
")",
"bool",
"{",
"return",
"claims",
".",
"AppAccess",
"(",
"appID",
")",
"&&",
"containsRight",
"(",
"claims",
".",
"Apps",
"[",
"appI... | // AppRight checks if the token grants the specified right for
// the app with the specified ID | [
"AppRight",
"checks",
"if",
"the",
"token",
"grants",
"the",
"specified",
"right",
"for",
"the",
"app",
"with",
"the",
"specified",
"ID"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/claims/rights.go#L10-L12 |
144,155 | TheThingsNetwork/go-account-lib | claims/rights.go | GatewayRight | func (claims *Claims) GatewayRight(gatewayID string, right types.Right) bool {
return claims.GatewayAccess(gatewayID) && containsRight(claims.Gateways[gatewayID], right)
} | go | func (claims *Claims) GatewayRight(gatewayID string, right types.Right) bool {
return claims.GatewayAccess(gatewayID) && containsRight(claims.Gateways[gatewayID], right)
} | [
"func",
"(",
"claims",
"*",
"Claims",
")",
"GatewayRight",
"(",
"gatewayID",
"string",
",",
"right",
"types",
".",
"Right",
")",
"bool",
"{",
"return",
"claims",
".",
"GatewayAccess",
"(",
"gatewayID",
")",
"&&",
"containsRight",
"(",
"claims",
".",
"Gatew... | // GatewayRight checks if the token grants the specified right for
// the Gateway with the specified ID | [
"GatewayRight",
"checks",
"if",
"the",
"token",
"grants",
"the",
"specified",
"right",
"for",
"the",
"Gateway",
"with",
"the",
"specified",
"ID"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/claims/rights.go#L16-L18 |
144,156 | TheThingsNetwork/go-account-lib | claims/rights.go | ComponentRight | func (claims *Claims) ComponentRight(componentID string, right types.Right) bool {
return claims.ComponentAccess(componentID) && containsRight(claims.Components[componentID], right)
} | go | func (claims *Claims) ComponentRight(componentID string, right types.Right) bool {
return claims.ComponentAccess(componentID) && containsRight(claims.Components[componentID], right)
} | [
"func",
"(",
"claims",
"*",
"Claims",
")",
"ComponentRight",
"(",
"componentID",
"string",
",",
"right",
"types",
".",
"Right",
")",
"bool",
"{",
"return",
"claims",
".",
"ComponentAccess",
"(",
"componentID",
")",
"&&",
"containsRight",
"(",
"claims",
".",
... | // ComponentRight checks if the token grants the specified right for
// the Component with the specified ID | [
"ComponentRight",
"checks",
"if",
"the",
"token",
"grants",
"the",
"specified",
"right",
"for",
"the",
"Component",
"with",
"the",
"specified",
"ID"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/claims/rights.go#L22-L24 |
144,157 | TheThingsNetwork/go-account-lib | tokenkey/http_provider.go | HTTPProvider | func HTTPProvider(servers map[string]string, cache cache.Cache) Provider {
return &httpProvider{
servers: servers,
cache: cache,
}
} | go | func HTTPProvider(servers map[string]string, cache cache.Cache) Provider {
return &httpProvider{
servers: servers,
cache: cache,
}
} | [
"func",
"HTTPProvider",
"(",
"servers",
"map",
"[",
"string",
"]",
"string",
",",
"cache",
"cache",
".",
"Cache",
")",
"Provider",
"{",
"return",
"&",
"httpProvider",
"{",
"servers",
":",
"servers",
",",
"cache",
":",
"cache",
",",
"}",
"\n",
"}"
] | // HTTPProvider returns a new Provider that fetches the key from a HTTP resource | [
"HTTPProvider",
"returns",
"a",
"new",
"Provider",
"that",
"fetches",
"the",
"key",
"from",
"a",
"HTTP",
"resource"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/tokenkey/http_provider.go#L22-L27 |
144,158 | TheThingsNetwork/go-account-lib | account/users.go | RegisterUser | func (a *Account) RegisterUser(username, email, password string) error {
user := registerUserReq{
Username: username,
Email: email,
Password: password,
}
err := a.post(auth.Public, "/api/v2/users", user, nil)
if err != nil {
return fmt.Errorf("Could not register user: %s", err)
}
return nil
} | go | func (a *Account) RegisterUser(username, email, password string) error {
user := registerUserReq{
Username: username,
Email: email,
Password: password,
}
err := a.post(auth.Public, "/api/v2/users", user, nil)
if err != nil {
return fmt.Errorf("Could not register user: %s", err)
}
return nil
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"RegisterUser",
"(",
"username",
",",
"email",
",",
"password",
"string",
")",
"error",
"{",
"user",
":=",
"registerUserReq",
"{",
"Username",
":",
"username",
",",
"Email",
":",
"email",
",",
"Password",
":",
"pass... | // RegisterUser registers a user on the account server | [
"RegisterUser",
"registers",
"a",
"user",
"on",
"the",
"account",
"server"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/users.go#L19-L31 |
144,159 | TheThingsNetwork/go-account-lib | account/users.go | Profile | func (a *Account) Profile() (user Profile, err error) {
err = a.get(a.auth, "/api/v2/users/me", &user)
if err != nil {
return user, fmt.Errorf("Could not get user profile: %s", err)
}
return user, nil
} | go | func (a *Account) Profile() (user Profile, err error) {
err = a.get(a.auth, "/api/v2/users/me", &user)
if err != nil {
return user, fmt.Errorf("Could not get user profile: %s", err)
}
return user, nil
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"Profile",
"(",
")",
"(",
"user",
"Profile",
",",
"err",
"error",
")",
"{",
"err",
"=",
"a",
".",
"get",
"(",
"a",
".",
"auth",
",",
"\"",
"\"",
",",
"&",
"user",
")",
"\n",
"if",
"err",
"!=",
"nil",
"... | // Profile gets the user profile of the user that is logged in | [
"Profile",
"gets",
"the",
"user",
"profile",
"of",
"the",
"user",
"that",
"is",
"logged",
"in"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/users.go#L34-L41 |
144,160 | TheThingsNetwork/go-account-lib | account/users.go | EditPassword | func (a *Account) EditPassword(oldPassword, newPassword string) error {
edits := editPasswordReq{
OldPassword: oldPassword,
Password: newPassword,
}
err := a.patch(a.auth, "/api/v2/users/me", edits, nil)
if err != nil {
return fmt.Errorf("Could change not password: %s", err)
}
return nil
} | go | func (a *Account) EditPassword(oldPassword, newPassword string) error {
edits := editPasswordReq{
OldPassword: oldPassword,
Password: newPassword,
}
err := a.patch(a.auth, "/api/v2/users/me", edits, nil)
if err != nil {
return fmt.Errorf("Could change not password: %s", err)
}
return nil
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"EditPassword",
"(",
"oldPassword",
",",
"newPassword",
"string",
")",
"error",
"{",
"edits",
":=",
"editPasswordReq",
"{",
"OldPassword",
":",
"oldPassword",
",",
"Password",
":",
"newPassword",
",",
"}",
"\n\n",
"err"... | // EditPassword edits the users password, it requires the old password
// to be given. | [
"EditPassword",
"edits",
"the",
"users",
"password",
"it",
"requires",
"the",
"old",
"password",
"to",
"be",
"given",
"."
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/users.go#L86-L97 |
144,161 | TheThingsNetwork/go-account-lib | account/users.go | AuthorizedClients | func (a *Account) AuthorizedClients() ([]*OAuthClient, error) {
var clients []*OAuthClient
err := a.get(a.auth, "/api/v2/users/me/authorized-clients", &clients)
if err != nil {
return nil, err
}
return clients, nil
} | go | func (a *Account) AuthorizedClients() ([]*OAuthClient, error) {
var clients []*OAuthClient
err := a.get(a.auth, "/api/v2/users/me/authorized-clients", &clients)
if err != nil {
return nil, err
}
return clients, nil
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"AuthorizedClients",
"(",
")",
"(",
"[",
"]",
"*",
"OAuthClient",
",",
"error",
")",
"{",
"var",
"clients",
"[",
"]",
"*",
"OAuthClient",
"\n",
"err",
":=",
"a",
".",
"get",
"(",
"a",
".",
"auth",
",",
"\"",... | // AuthorizedClients lists the authorized clients for the user | [
"AuthorizedClients",
"lists",
"the",
"authorized",
"clients",
"for",
"the",
"user"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/users.go#L100-L108 |
144,162 | TheThingsNetwork/go-account-lib | account/users.go | RemoveAuthorizedClient | func (a *Account) RemoveAuthorizedClient(name string) error {
return a.del(a.auth, fmt.Sprintf("/api/v2/users/me/authorized-clients/%s", name))
} | go | func (a *Account) RemoveAuthorizedClient(name string) error {
return a.del(a.auth, fmt.Sprintf("/api/v2/users/me/authorized-clients/%s", name))
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"RemoveAuthorizedClient",
"(",
"name",
"string",
")",
"error",
"{",
"return",
"a",
".",
"del",
"(",
"a",
".",
"auth",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"name",
")",
")",
"\n",
"}"
] | // RemoveAuthorizedClient removes a client from the users authorized clients | [
"RemoveAuthorizedClient",
"removes",
"a",
"client",
"from",
"the",
"users",
"authorized",
"clients"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/users.go#L111-L113 |
144,163 | TheThingsNetwork/go-account-lib | util/roundtripper.go | NewRoundTripper | func NewRoundTripper(ctx log.Interface, headers map[string]string) *RoundTripper {
return &RoundTripper{
ctx: ctx,
transport: http.DefaultTransport,
headers: headers,
}
} | go | func NewRoundTripper(ctx log.Interface, headers map[string]string) *RoundTripper {
return &RoundTripper{
ctx: ctx,
transport: http.DefaultTransport,
headers: headers,
}
} | [
"func",
"NewRoundTripper",
"(",
"ctx",
"log",
".",
"Interface",
",",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"RoundTripper",
"{",
"return",
"&",
"RoundTripper",
"{",
"ctx",
":",
"ctx",
",",
"transport",
":",
"http",
".",
"DefaultTransport... | // NewRoundTripper creates a new RoundTripper that will add the provided headers
// to each request | [
"NewRoundTripper",
"creates",
"a",
"new",
"RoundTripper",
"that",
"will",
"add",
"the",
"provided",
"headers",
"to",
"each",
"request"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/util/roundtripper.go#L23-L29 |
144,164 | TheThingsNetwork/go-account-lib | util/roundtripper.go | RoundTrip | func (t *RoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
t.addHeaders(req)
res, err := t.transport.RoundTrip(req)
if err != nil {
return nil, err
}
// get server warnings
if warning := res.Header.Get("Warning"); len(warning) >= 8 {
// Warning header has format: 123 - "Message"
code := ... | go | func (t *RoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
t.addHeaders(req)
res, err := t.transport.RoundTrip(req)
if err != nil {
return nil, err
}
// get server warnings
if warning := res.Header.Get("Warning"); len(warning) >= 8 {
// Warning header has format: 123 - "Message"
code := ... | [
"func",
"(",
"t",
"*",
"RoundTripper",
")",
"RoundTrip",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"t",
".",
"addHeaders",
"(",
"req",
")",
"\n",
"res",
",",
"err",
":=",
"t",
".",
... | // RoundTrip performs one HTTP roundtrip, adding the headers and checking
// warnings | [
"RoundTrip",
"performs",
"one",
"HTTP",
"roundtrip",
"adding",
"the",
"headers",
"and",
"checking",
"warnings"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/util/roundtripper.go#L43-L64 |
144,165 | TheThingsNetwork/go-account-lib | account/applications.go | ListApplications | func (a *Account) ListApplications() (apps []Application, err error) {
err = a.get(a.auth.WithScope(scope.Apps), "/api/v2/applications", &apps)
return apps, err
} | go | func (a *Account) ListApplications() (apps []Application, err error) {
err = a.get(a.auth.WithScope(scope.Apps), "/api/v2/applications", &apps)
return apps, err
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"ListApplications",
"(",
")",
"(",
"apps",
"[",
"]",
"Application",
",",
"err",
"error",
")",
"{",
"err",
"=",
"a",
".",
"get",
"(",
"a",
".",
"auth",
".",
"WithScope",
"(",
"scope",
".",
"Apps",
")",
",",
... | // ListApplications list all applications | [
"ListApplications",
"list",
"all",
"applications"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/applications.go#L18-L21 |
144,166 | TheThingsNetwork/go-account-lib | account/applications.go | Next | func (s *ApplicationStream) Next() (*Application, error) {
var application Application
if s.decoder.More() {
err := s.decoder.Decode(&application)
return &application, err
}
// parse last token
_, err := s.decoder.Token()
if err != nil {
return nil, err
}
return nil, io.EOF
} | go | func (s *ApplicationStream) Next() (*Application, error) {
var application Application
if s.decoder.More() {
err := s.decoder.Decode(&application)
return &application, err
}
// parse last token
_, err := s.decoder.Token()
if err != nil {
return nil, err
}
return nil, io.EOF
} | [
"func",
"(",
"s",
"*",
"ApplicationStream",
")",
"Next",
"(",
")",
"(",
"*",
"Application",
",",
"error",
")",
"{",
"var",
"application",
"Application",
"\n",
"if",
"s",
".",
"decoder",
".",
"More",
"(",
")",
"{",
"err",
":=",
"s",
".",
"decoder",
... | // Next requests the next application on the stream, blocking until there is one
// If there are no more applications, the error will be io.EOF | [
"Next",
"requests",
"the",
"next",
"application",
"on",
"the",
"stream",
"blocking",
"until",
"there",
"is",
"one",
"If",
"there",
"are",
"no",
"more",
"applications",
"the",
"error",
"will",
"be",
"io",
".",
"EOF"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/applications.go#L42-L56 |
144,167 | TheThingsNetwork/go-account-lib | account/applications.go | streamApplications | func (a *Account) streamApplications(deleted bool) (*ApplicationStream, error) {
uri := "/api/v2/applications"
if deleted {
uri = uri + "?deleted=1"
}
body, err := a.gets(a.auth, uri)
if err != nil {
return nil, err
}
stream := &ApplicationStream{
decoder: json.NewDecoder(body),
body: body,
}
// ... | go | func (a *Account) streamApplications(deleted bool) (*ApplicationStream, error) {
uri := "/api/v2/applications"
if deleted {
uri = uri + "?deleted=1"
}
body, err := a.gets(a.auth, uri)
if err != nil {
return nil, err
}
stream := &ApplicationStream{
decoder: json.NewDecoder(body),
body: body,
}
// ... | [
"func",
"(",
"a",
"*",
"Account",
")",
"streamApplications",
"(",
"deleted",
"bool",
")",
"(",
"*",
"ApplicationStream",
",",
"error",
")",
"{",
"uri",
":=",
"\"",
"\"",
"\n",
"if",
"deleted",
"{",
"uri",
"=",
"uri",
"+",
"\"",
"\"",
"\n",
"}",
"\n... | // streamApplications lists all applications in a streaming fashion and has a
// flag to denote wether or not to allow deleted apps | [
"streamApplications",
"lists",
"all",
"applications",
"in",
"a",
"streaming",
"fashion",
"and",
"has",
"a",
"flag",
"to",
"denote",
"wether",
"or",
"not",
"to",
"allow",
"deleted",
"apps"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/applications.go#L71-L94 |
144,168 | TheThingsNetwork/go-account-lib | account/applications.go | FindApplication | func (a *Account) FindApplication(appID string) (app Application, err error) {
err = a.get(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s", appID), &app)
return app, err
} | go | func (a *Account) FindApplication(appID string) (app Application, err error) {
err = a.get(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s", appID), &app)
return app, err
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"FindApplication",
"(",
"appID",
"string",
")",
"(",
"app",
"Application",
",",
"err",
"error",
")",
"{",
"err",
"=",
"a",
".",
"get",
"(",
"a",
".",
"auth",
".",
"WithScope",
"(",
"scope",
".",
"App",
"(",
... | // FindApplication gets a specific application from the account server | [
"FindApplication",
"gets",
"a",
"specific",
"application",
"from",
"the",
"account",
"server"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/applications.go#L97-L100 |
144,169 | TheThingsNetwork/go-account-lib | account/applications.go | CreateApplication | func (a *Account) CreateApplication(appID string, name string, EUIs []types.AppEUI) (app Application, err error) {
body := createApplicationReq{
Name: name,
AppID: appID,
EUIs: EUIs,
}
err = a.post(a.auth, "/api/v2/applications", &body, &app)
return app, err
} | go | func (a *Account) CreateApplication(appID string, name string, EUIs []types.AppEUI) (app Application, err error) {
body := createApplicationReq{
Name: name,
AppID: appID,
EUIs: EUIs,
}
err = a.post(a.auth, "/api/v2/applications", &body, &app)
return app, err
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"CreateApplication",
"(",
"appID",
"string",
",",
"name",
"string",
",",
"EUIs",
"[",
"]",
"types",
".",
"AppEUI",
")",
"(",
"app",
"Application",
",",
"err",
"error",
")",
"{",
"body",
":=",
"createApplicationReq",... | // CreateApplication creates a new application on the account server | [
"CreateApplication",
"creates",
"a",
"new",
"application",
"on",
"the",
"account",
"server"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/applications.go#L109-L118 |
144,170 | TheThingsNetwork/go-account-lib | account/applications.go | Grant | func (a *Account) Grant(appID string, username string, rights []types.Right) error {
req := grantReq{
Rights: rights,
}
return a.put(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/collaborators/%s", appID, username), req, nil)
} | go | func (a *Account) Grant(appID string, username string, rights []types.Right) error {
req := grantReq{
Rights: rights,
}
return a.put(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/collaborators/%s", appID, username), req, nil)
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"Grant",
"(",
"appID",
"string",
",",
"username",
"string",
",",
"rights",
"[",
"]",
"types",
".",
"Right",
")",
"error",
"{",
"req",
":=",
"grantReq",
"{",
"Rights",
":",
"rights",
",",
"}",
"\n",
"return",
"... | // Grant adds a collaborator to the application | [
"Grant",
"adds",
"a",
"collaborator",
"to",
"the",
"application"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/applications.go#L130-L135 |
144,171 | TheThingsNetwork/go-account-lib | account/applications.go | Retract | func (a *Account) Retract(appID string, username string) error {
return a.del(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/collaborators/%s", appID, username))
} | go | func (a *Account) Retract(appID string, username string) error {
return a.del(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/collaborators/%s", appID, username))
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"Retract",
"(",
"appID",
"string",
",",
"username",
"string",
")",
"error",
"{",
"return",
"a",
".",
"del",
"(",
"a",
".",
"auth",
".",
"WithScope",
"(",
"scope",
".",
"App",
"(",
"appID",
")",
")",
",",
"fm... | // Retract removes rights from a collaborator of the application | [
"Retract",
"removes",
"rights",
"from",
"a",
"collaborator",
"of",
"the",
"application"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/applications.go#L138-L140 |
144,172 | TheThingsNetwork/go-account-lib | account/applications.go | AddAccessKey | func (a *Account) AddAccessKey(appID string, name string, rights []types.Right) (key types.AccessKey, err error) {
body := addAccessKeyReq{
Name: name,
Rights: rights,
}
err = a.post(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/access-keys", appID), body, &key)
return key, err
} | go | func (a *Account) AddAccessKey(appID string, name string, rights []types.Right) (key types.AccessKey, err error) {
body := addAccessKeyReq{
Name: name,
Rights: rights,
}
err = a.post(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/access-keys", appID), body, &key)
return key, err
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"AddAccessKey",
"(",
"appID",
"string",
",",
"name",
"string",
",",
"rights",
"[",
"]",
"types",
".",
"Right",
")",
"(",
"key",
"types",
".",
"AccessKey",
",",
"err",
"error",
")",
"{",
"body",
":=",
"addAccessK... | // AddAccessKey adds an access key to the application with the specified name
// and rights | [
"AddAccessKey",
"adds",
"an",
"access",
"key",
"to",
"the",
"application",
"with",
"the",
"specified",
"name",
"and",
"rights"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/applications.go#L149-L156 |
144,173 | TheThingsNetwork/go-account-lib | account/applications.go | ChangeName | func (a *Account) ChangeName(appID string, name string) error {
body := editAppReq{
Name: name,
}
return a.patch(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s", appID), body, nil)
} | go | func (a *Account) ChangeName(appID string, name string) error {
body := editAppReq{
Name: name,
}
return a.patch(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s", appID), body, nil)
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"ChangeName",
"(",
"appID",
"string",
",",
"name",
"string",
")",
"error",
"{",
"body",
":=",
"editAppReq",
"{",
"Name",
":",
"name",
",",
"}",
"\n",
"return",
"a",
".",
"patch",
"(",
"a",
".",
"auth",
".",
... | // ChangeName changes the application name | [
"ChangeName",
"changes",
"the",
"application",
"name"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/applications.go#L168-L173 |
144,174 | TheThingsNetwork/go-account-lib | account/applications.go | AddEUI | func (a *Account) AddEUI(appID string, eui types.AppEUI) error {
return a.put(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/euis/%s", appID, eui.String()), nil, nil)
} | go | func (a *Account) AddEUI(appID string, eui types.AppEUI) error {
return a.put(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/euis/%s", appID, eui.String()), nil, nil)
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"AddEUI",
"(",
"appID",
"string",
",",
"eui",
"types",
".",
"AppEUI",
")",
"error",
"{",
"return",
"a",
".",
"put",
"(",
"a",
".",
"auth",
".",
"WithScope",
"(",
"scope",
".",
"App",
"(",
"appID",
")",
")",
... | // AddEUI adds an EUI to the applications list of EUIs | [
"AddEUI",
"adds",
"an",
"EUI",
"to",
"the",
"applications",
"list",
"of",
"EUIs"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/applications.go#L176-L178 |
144,175 | TheThingsNetwork/go-account-lib | account/applications.go | GenerateEUI | func (a *Account) GenerateEUI(appID string) (*types.AppEUI, error) {
var res genEUIRes
err := a.post(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/euis", appID), nil, &res)
if err != nil {
return nil, err
}
return &res.EUI, nil
} | go | func (a *Account) GenerateEUI(appID string) (*types.AppEUI, error) {
var res genEUIRes
err := a.post(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/euis", appID), nil, &res)
if err != nil {
return nil, err
}
return &res.EUI, nil
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"GenerateEUI",
"(",
"appID",
"string",
")",
"(",
"*",
"types",
".",
"AppEUI",
",",
"error",
")",
"{",
"var",
"res",
"genEUIRes",
"\n",
"err",
":=",
"a",
".",
"post",
"(",
"a",
".",
"auth",
".",
"WithScope",
... | // GenerateEUI creates a new EUI for the application | [
"GenerateEUI",
"creates",
"a",
"new",
"EUI",
"for",
"the",
"application"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/applications.go#L185-L192 |
144,176 | TheThingsNetwork/go-account-lib | account/applications.go | RemoveEUI | func (a *Account) RemoveEUI(appID string, eui types.AppEUI) error {
return a.del(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/euis/%s", appID, eui.String()))
} | go | func (a *Account) RemoveEUI(appID string, eui types.AppEUI) error {
return a.del(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/euis/%s", appID, eui.String()))
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"RemoveEUI",
"(",
"appID",
"string",
",",
"eui",
"types",
".",
"AppEUI",
")",
"error",
"{",
"return",
"a",
".",
"del",
"(",
"a",
".",
"auth",
".",
"WithScope",
"(",
"scope",
".",
"App",
"(",
"appID",
")",
")... | // RemoveEUI removes the specified EUI from the application | [
"RemoveEUI",
"removes",
"the",
"specified",
"EUI",
"from",
"the",
"application"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/applications.go#L195-L197 |
144,177 | TheThingsNetwork/go-account-lib | account/applications.go | AppRights | func (a *Account) AppRights(appID string) (rights []types.Right, err error) {
err = a.get(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/rights", appID), &rights)
if err != nil {
return nil, err
}
return rights, nil
} | go | func (a *Account) AppRights(appID string) (rights []types.Right, err error) {
err = a.get(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/rights", appID), &rights)
if err != nil {
return nil, err
}
return rights, nil
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"AppRights",
"(",
"appID",
"string",
")",
"(",
"rights",
"[",
"]",
"types",
".",
"Right",
",",
"err",
"error",
")",
"{",
"err",
"=",
"a",
".",
"get",
"(",
"a",
".",
"auth",
".",
"WithScope",
"(",
"scope",
... | // AppRights returns the rights the current account client has to a certain
// application | [
"AppRights",
"returns",
"the",
"rights",
"the",
"current",
"account",
"client",
"has",
"to",
"a",
"certain",
"application"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/applications.go#L201-L208 |
144,178 | TheThingsNetwork/go-account-lib | account/applications.go | AppCollaborators | func (a *Account) AppCollaborators(appID string) ([]Collaborator, error) {
collaborators := make([]Collaborator, 0)
err := a.get(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/collaborators", appID), &collaborators)
if err != nil {
return nil, err
}
return collaborators, nil
} | go | func (a *Account) AppCollaborators(appID string) ([]Collaborator, error) {
collaborators := make([]Collaborator, 0)
err := a.get(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/collaborators", appID), &collaborators)
if err != nil {
return nil, err
}
return collaborators, nil
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"AppCollaborators",
"(",
"appID",
"string",
")",
"(",
"[",
"]",
"Collaborator",
",",
"error",
")",
"{",
"collaborators",
":=",
"make",
"(",
"[",
"]",
"Collaborator",
",",
"0",
")",
"\n",
"err",
":=",
"a",
".",
... | // AppCollaborators fetches the application collaborators | [
"AppCollaborators",
"fetches",
"the",
"application",
"collaborators"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/applications.go#L211-L219 |
144,179 | TheThingsNetwork/go-account-lib | account/applications.go | ExchangeAppKeyForToken | func (a *Account) ExchangeAppKeyForToken(appID, accessKey string) (*oauth2.Token, error) {
req := exchangeReq{
Username: appID,
Password: accessKey,
}
var res tokenRes
err := a.post(a.auth, "/api/v2/applications/token", &req, &res)
if err != nil {
return nil, err
}
return res.Token(), nil
} | go | func (a *Account) ExchangeAppKeyForToken(appID, accessKey string) (*oauth2.Token, error) {
req := exchangeReq{
Username: appID,
Password: accessKey,
}
var res tokenRes
err := a.post(a.auth, "/api/v2/applications/token", &req, &res)
if err != nil {
return nil, err
}
return res.Token(), nil
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"ExchangeAppKeyForToken",
"(",
"appID",
",",
"accessKey",
"string",
")",
"(",
"*",
"oauth2",
".",
"Token",
",",
"error",
")",
"{",
"req",
":=",
"exchangeReq",
"{",
"Username",
":",
"appID",
",",
"Password",
":",
"... | // ExchangeAppKeyForToken exchanges an app ID and app Key for an app token | [
"ExchangeAppKeyForToken",
"exchanges",
"an",
"app",
"ID",
"and",
"app",
"Key",
"for",
"an",
"app",
"token"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/applications.go#L232-L246 |
144,180 | TheThingsNetwork/go-account-lib | account/applications.go | RestoreApp | func (a *Account) RestoreApp(appID string) error {
return a.post(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/restore", appID), nil, nil)
} | go | func (a *Account) RestoreApp(appID string) error {
return a.post(a.auth.WithScope(scope.App(appID)), fmt.Sprintf("/api/v2/applications/%s/restore", appID), nil, nil)
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"RestoreApp",
"(",
"appID",
"string",
")",
"error",
"{",
"return",
"a",
".",
"post",
"(",
"a",
".",
"auth",
".",
"WithScope",
"(",
"scope",
".",
"App",
"(",
"appID",
")",
")",
",",
"fmt",
".",
"Sprintf",
"("... | // RestoreApp restores a previously deleted app | [
"RestoreApp",
"restores",
"a",
"previously",
"deleted",
"app"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/applications.go#L249-L251 |
144,181 | TheThingsNetwork/go-account-lib | keys/keys.go | KeyIssuer | func KeyIssuer(accessKey string) string {
parts := strings.Split(accessKey, ".")
if len(parts) != 2 {
return ""
}
return parts[0]
} | go | func KeyIssuer(accessKey string) string {
parts := strings.Split(accessKey, ".")
if len(parts) != 2 {
return ""
}
return parts[0]
} | [
"func",
"KeyIssuer",
"(",
"accessKey",
"string",
")",
"string",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"accessKey",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"parts",
")",
"!=",
"2",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"ret... | // KeyIssuer returns the account server issuer id that issued the key,
// if no issuer id is found, it returns the empty string. | [
"KeyIssuer",
"returns",
"the",
"account",
"server",
"issuer",
"id",
"that",
"issued",
"the",
"key",
"if",
"no",
"issuer",
"id",
"is",
"found",
"it",
"returns",
"the",
"empty",
"string",
"."
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/keys/keys.go#L10-L17 |
144,182 | TheThingsNetwork/go-account-lib | claims/parse_component_token.go | FromComponentToken | func FromComponentToken(provider tokenkey.Provider, accessToken string) (*ComponentClaims, error) {
claims := &ComponentClaims{}
err := fromToken(provider, accessToken, claims)
if err != nil {
return nil, err
}
switch claims.Type {
case RouterType, BrokerType, HandlerType:
return claims, nil
default:
ret... | go | func FromComponentToken(provider tokenkey.Provider, accessToken string) (*ComponentClaims, error) {
claims := &ComponentClaims{}
err := fromToken(provider, accessToken, claims)
if err != nil {
return nil, err
}
switch claims.Type {
case RouterType, BrokerType, HandlerType:
return claims, nil
default:
ret... | [
"func",
"FromComponentToken",
"(",
"provider",
"tokenkey",
".",
"Provider",
",",
"accessToken",
"string",
")",
"(",
"*",
"ComponentClaims",
",",
"error",
")",
"{",
"claims",
":=",
"&",
"ComponentClaims",
"{",
"}",
"\n\n",
"err",
":=",
"fromToken",
"(",
"prov... | // FromComponentToken uses the tokenkey provider to parse and validate a token into its
// corresponding claims | [
"FromComponentToken",
"uses",
"the",
"tokenkey",
"provider",
"to",
"parse",
"and",
"validate",
"a",
"token",
"into",
"its",
"corresponding",
"claims"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/claims/parse_component_token.go#L25-L39 |
144,183 | TheThingsNetwork/go-account-lib | claims/parse_component_token.go | FromComponentTokenWithoutValidation | func FromComponentTokenWithoutValidation(accessToken string) (*ComponentClaims, error) {
claims := &ComponentClaims{}
return claims, fromTokenWithoutValidation(accessToken, claims)
} | go | func FromComponentTokenWithoutValidation(accessToken string) (*ComponentClaims, error) {
claims := &ComponentClaims{}
return claims, fromTokenWithoutValidation(accessToken, claims)
} | [
"func",
"FromComponentTokenWithoutValidation",
"(",
"accessToken",
"string",
")",
"(",
"*",
"ComponentClaims",
",",
"error",
")",
"{",
"claims",
":=",
"&",
"ComponentClaims",
"{",
"}",
"\n",
"return",
"claims",
",",
"fromTokenWithoutValidation",
"(",
"accessToken",
... | // FromComponentTokenWithoutValidation parses a token into its corresponding claims,
// without checking the token signature | [
"FromComponentTokenWithoutValidation",
"parses",
"a",
"token",
"into",
"its",
"corresponding",
"claims",
"without",
"checking",
"the",
"token",
"signature"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/claims/parse_component_token.go#L43-L46 |
144,184 | TheThingsNetwork/go-account-lib | tokens/restrict.go | RestrictScope | func RestrictScope(server string, token string, scope []string) (string, error) {
URL := fmt.Sprintf("%s/users/restrict-token", server)
body := restrictRequest{
Scope: scope,
}
buf := new(bytes.Buffer)
encoder := json.NewEncoder(buf)
err := encoder.Encode(body)
if err != nil {
return "", err
}
req, err :... | go | func RestrictScope(server string, token string, scope []string) (string, error) {
URL := fmt.Sprintf("%s/users/restrict-token", server)
body := restrictRequest{
Scope: scope,
}
buf := new(bytes.Buffer)
encoder := json.NewEncoder(buf)
err := encoder.Encode(body)
if err != nil {
return "", err
}
req, err :... | [
"func",
"RestrictScope",
"(",
"server",
"string",
",",
"token",
"string",
",",
"scope",
"[",
"]",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"URL",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"server",
")",
"\n\n",
"body",
":=",
"... | // RestrictScope requests a new token with a different, more specific scope | [
"RestrictScope",
"requests",
"a",
"new",
"token",
"with",
"a",
"different",
"more",
"specific",
"scope"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/tokens/restrict.go#L32-L93 |
144,185 | TheThingsNetwork/go-account-lib | account/gateways.go | ListGateways | func (a *Account) ListGateways() (gateways []Gateway, err error) {
err = a.get(a.auth, "/api/v2/gateways", &gateways)
return gateways, err
} | go | func (a *Account) ListGateways() (gateways []Gateway, err error) {
err = a.get(a.auth, "/api/v2/gateways", &gateways)
return gateways, err
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"ListGateways",
"(",
")",
"(",
"gateways",
"[",
"]",
"Gateway",
",",
"err",
"error",
")",
"{",
"err",
"=",
"a",
".",
"get",
"(",
"a",
".",
"auth",
",",
"\"",
"\"",
",",
"&",
"gateways",
")",
"\n",
"return"... | // ListGateways list all gateways | [
"ListGateways",
"list",
"all",
"gateways"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/gateways.go#L18-L21 |
144,186 | TheThingsNetwork/go-account-lib | account/gateways.go | Next | func (s *GatewayStream) Next() (*Gateway, error) {
var res gatewayRes
if s.decoder.More() {
err := s.decoder.Decode(&res)
gateway := res.ToGateway()
return &gateway, err
}
// parse last token
_, err := s.decoder.Token()
if err != nil {
return nil, err
}
return nil, io.EOF
} | go | func (s *GatewayStream) Next() (*Gateway, error) {
var res gatewayRes
if s.decoder.More() {
err := s.decoder.Decode(&res)
gateway := res.ToGateway()
return &gateway, err
}
// parse last token
_, err := s.decoder.Token()
if err != nil {
return nil, err
}
return nil, io.EOF
} | [
"func",
"(",
"s",
"*",
"GatewayStream",
")",
"Next",
"(",
")",
"(",
"*",
"Gateway",
",",
"error",
")",
"{",
"var",
"res",
"gatewayRes",
"\n",
"if",
"s",
".",
"decoder",
".",
"More",
"(",
")",
"{",
"err",
":=",
"s",
".",
"decoder",
".",
"Decode",
... | // Next requests the next gateway on the stream, blocking until there is one
// If there are no more gateways, the error will be io.EOF | [
"Next",
"requests",
"the",
"next",
"gateway",
"on",
"the",
"stream",
"blocking",
"until",
"there",
"is",
"one",
"If",
"there",
"are",
"no",
"more",
"gateways",
"the",
"error",
"will",
"be",
"io",
".",
"EOF"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/gateways.go#L36-L51 |
144,187 | TheThingsNetwork/go-account-lib | account/gateways.go | StreamGateways | func (a *Account) StreamGateways() (*GatewayStream, error) {
body, err := a.gets(a.auth, "/api/v2/gateways")
if err != nil {
return nil, err
}
stream := &GatewayStream{
decoder: json.NewDecoder(body),
body: body,
}
// parse the first array bracket
_, err = stream.decoder.Token()
if err != nil {
ret... | go | func (a *Account) StreamGateways() (*GatewayStream, error) {
body, err := a.gets(a.auth, "/api/v2/gateways")
if err != nil {
return nil, err
}
stream := &GatewayStream{
decoder: json.NewDecoder(body),
body: body,
}
// parse the first array bracket
_, err = stream.decoder.Token()
if err != nil {
ret... | [
"func",
"(",
"a",
"*",
"Account",
")",
"StreamGateways",
"(",
")",
"(",
"*",
"GatewayStream",
",",
"error",
")",
"{",
"body",
",",
"err",
":=",
"a",
".",
"gets",
"(",
"a",
".",
"auth",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // StreamGateways lists all gateways in a streaming fashion | [
"StreamGateways",
"lists",
"all",
"gateways",
"in",
"a",
"streaming",
"fashion"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/gateways.go#L54-L72 |
144,188 | TheThingsNetwork/go-account-lib | account/gateways.go | FindGateway | func (a *Account) FindGateway(gatewayID string) (gateway Gateway, err error) {
var res gatewayRes
err = a.get(a.auth.WithScope(scope.Gateway(gatewayID)), fmt.Sprintf("/api/v2/gateways/%s", gatewayID), &res)
if err != nil {
return gateway, err
}
return res.ToGateway(), err
} | go | func (a *Account) FindGateway(gatewayID string) (gateway Gateway, err error) {
var res gatewayRes
err = a.get(a.auth.WithScope(scope.Gateway(gatewayID)), fmt.Sprintf("/api/v2/gateways/%s", gatewayID), &res)
if err != nil {
return gateway, err
}
return res.ToGateway(), err
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"FindGateway",
"(",
"gatewayID",
"string",
")",
"(",
"gateway",
"Gateway",
",",
"err",
"error",
")",
"{",
"var",
"res",
"gatewayRes",
"\n",
"err",
"=",
"a",
".",
"get",
"(",
"a",
".",
"auth",
".",
"WithScope",
... | // FindGateway returns the information about a specific gateay | [
"FindGateway",
"returns",
"the",
"information",
"about",
"a",
"specific",
"gateay"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/gateways.go#L88-L95 |
144,189 | TheThingsNetwork/go-account-lib | account/gateways.go | RegisterGateway | func (a *Account) RegisterGateway(gatewayID string, frequencyPlan string, opts GatewaySettings) (gateway Gateway, err error) {
if gatewayID == "" {
return gateway, errors.New("Cannot create gateway: no ID given")
}
if frequencyPlan == "" {
return gateway, errors.New("Cannot create gateway: no frequency plan giv... | go | func (a *Account) RegisterGateway(gatewayID string, frequencyPlan string, opts GatewaySettings) (gateway Gateway, err error) {
if gatewayID == "" {
return gateway, errors.New("Cannot create gateway: no ID given")
}
if frequencyPlan == "" {
return gateway, errors.New("Cannot create gateway: no frequency plan giv... | [
"func",
"(",
"a",
"*",
"Account",
")",
"RegisterGateway",
"(",
"gatewayID",
"string",
",",
"frequencyPlan",
"string",
",",
"opts",
"GatewaySettings",
")",
"(",
"gateway",
"Gateway",
",",
"err",
"error",
")",
"{",
"if",
"gatewayID",
"==",
"\"",
"\"",
"{",
... | // RegisterGateway registers a new gateway on the account server | [
"RegisterGateway",
"registers",
"a",
"new",
"gateway",
"on",
"the",
"account",
"server"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/gateways.go#L131-L150 |
144,190 | TheThingsNetwork/go-account-lib | account/gateways.go | GetGatewayToken | func (a *Account) GetGatewayToken(gatewayID string) (*oauth2.Token, error) {
token := new(tokenRes)
err := a.get(a.auth.WithScope(scope.Gateway(gatewayID)), fmt.Sprintf("/api/v2/gateways/%s/token", gatewayID), token)
if err != nil {
return nil, err
}
return token.Token(), nil
} | go | func (a *Account) GetGatewayToken(gatewayID string) (*oauth2.Token, error) {
token := new(tokenRes)
err := a.get(a.auth.WithScope(scope.Gateway(gatewayID)), fmt.Sprintf("/api/v2/gateways/%s/token", gatewayID), token)
if err != nil {
return nil, err
}
return token.Token(), nil
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"GetGatewayToken",
"(",
"gatewayID",
"string",
")",
"(",
"*",
"oauth2",
".",
"Token",
",",
"error",
")",
"{",
"token",
":=",
"new",
"(",
"tokenRes",
")",
"\n",
"err",
":=",
"a",
".",
"get",
"(",
"a",
".",
"a... | // GetGatewayToken gets the gateway token | [
"GetGatewayToken",
"gets",
"the",
"gateway",
"token"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/gateways.go#L153-L161 |
144,191 | TheThingsNetwork/go-account-lib | account/gateways.go | DeleteGateway | func (a *Account) DeleteGateway(gatewayID string) error {
return a.del(a.auth.WithScope(scope.Gateway(gatewayID)), fmt.Sprintf("/api/v2/gateways/%s", gatewayID))
} | go | func (a *Account) DeleteGateway(gatewayID string) error {
return a.del(a.auth.WithScope(scope.Gateway(gatewayID)), fmt.Sprintf("/api/v2/gateways/%s", gatewayID))
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"DeleteGateway",
"(",
"gatewayID",
"string",
")",
"error",
"{",
"return",
"a",
".",
"del",
"(",
"a",
".",
"auth",
".",
"WithScope",
"(",
"scope",
".",
"Gateway",
"(",
"gatewayID",
")",
")",
",",
"fmt",
".",
"S... | // DeleteGateway removes a gateway from the account server | [
"DeleteGateway",
"removes",
"a",
"gateway",
"from",
"the",
"account",
"server"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/gateways.go#L164-L166 |
144,192 | TheThingsNetwork/go-account-lib | account/gateways.go | GrantGatewayRights | func (a *Account) GrantGatewayRights(gatewayID string, username string, rights []types.Right) error {
req := grantReq{
Rights: rights,
}
return a.put(a.auth.WithScope(scope.Gateway(gatewayID)), fmt.Sprintf("/api/v2/gateways/%s/collaborators/%s", gatewayID, username), req, nil)
} | go | func (a *Account) GrantGatewayRights(gatewayID string, username string, rights []types.Right) error {
req := grantReq{
Rights: rights,
}
return a.put(a.auth.WithScope(scope.Gateway(gatewayID)), fmt.Sprintf("/api/v2/gateways/%s/collaborators/%s", gatewayID, username), req, nil)
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"GrantGatewayRights",
"(",
"gatewayID",
"string",
",",
"username",
"string",
",",
"rights",
"[",
"]",
"types",
".",
"Right",
")",
"error",
"{",
"req",
":=",
"grantReq",
"{",
"Rights",
":",
"rights",
",",
"}",
"\n"... | // GrantGatewayRights grants rights to a collaborator of the gateway | [
"GrantGatewayRights",
"grants",
"rights",
"to",
"a",
"collaborator",
"of",
"the",
"gateway"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/gateways.go#L169-L174 |
144,193 | TheThingsNetwork/go-account-lib | account/gateways.go | EditGateway | func (a *Account) EditGateway(gatewayID string, edits GatewayEdits) error {
return a.patch(a.auth.WithScope(scope.Gateway(gatewayID)), fmt.Sprintf("/api/v2/gateways/%s", gatewayID), edits, nil)
} | go | func (a *Account) EditGateway(gatewayID string, edits GatewayEdits) error {
return a.patch(a.auth.WithScope(scope.Gateway(gatewayID)), fmt.Sprintf("/api/v2/gateways/%s", gatewayID), edits, nil)
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"EditGateway",
"(",
"gatewayID",
"string",
",",
"edits",
"GatewayEdits",
")",
"error",
"{",
"return",
"a",
".",
"patch",
"(",
"a",
".",
"auth",
".",
"WithScope",
"(",
"scope",
".",
"Gateway",
"(",
"gatewayID",
")"... | // EditGateway edits the fields of a gateway | [
"EditGateway",
"edits",
"the",
"fields",
"of",
"a",
"gateway"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/gateways.go#L197-L199 |
144,194 | TheThingsNetwork/go-account-lib | account/gateways.go | TransferOwnership | func (a *Account) TransferOwnership(gatewayID, username string) error {
return a.EditGateway(gatewayID, GatewayEdits{
Owner: username,
})
} | go | func (a *Account) TransferOwnership(gatewayID, username string) error {
return a.EditGateway(gatewayID, GatewayEdits{
Owner: username,
})
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"TransferOwnership",
"(",
"gatewayID",
",",
"username",
"string",
")",
"error",
"{",
"return",
"a",
".",
"EditGateway",
"(",
"gatewayID",
",",
"GatewayEdits",
"{",
"Owner",
":",
"username",
",",
"}",
")",
"\n",
"}"
... | // TransferOwnership transfers the owenership of the gateway to another user | [
"TransferOwnership",
"transfers",
"the",
"owenership",
"of",
"the",
"gateway",
"to",
"another",
"user"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/gateways.go#L202-L206 |
144,195 | TheThingsNetwork/go-account-lib | account/gateways.go | ChangeFrequencyPlan | func (a *Account) ChangeFrequencyPlan(gatewayID, plan string) error {
return a.EditGateway(gatewayID, GatewayEdits{
FrequencyPlan: plan,
})
} | go | func (a *Account) ChangeFrequencyPlan(gatewayID, plan string) error {
return a.EditGateway(gatewayID, GatewayEdits{
FrequencyPlan: plan,
})
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"ChangeFrequencyPlan",
"(",
"gatewayID",
",",
"plan",
"string",
")",
"error",
"{",
"return",
"a",
".",
"EditGateway",
"(",
"gatewayID",
",",
"GatewayEdits",
"{",
"FrequencyPlan",
":",
"plan",
",",
"}",
")",
"\n",
"}... | // ChangeFrequencyPlan changes the requency plan of a gateway | [
"ChangeFrequencyPlan",
"changes",
"the",
"requency",
"plan",
"of",
"a",
"gateway"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/gateways.go#L209-L213 |
144,196 | TheThingsNetwork/go-account-lib | account/gateways.go | ChangeLocation | func (a *Account) ChangeLocation(gatewayID string, latitude, longitude float64) error {
return a.EditGateway(gatewayID, GatewayEdits{
AntennaLocation: &Location{
Longitude: longitude,
Latitude: latitude,
},
})
} | go | func (a *Account) ChangeLocation(gatewayID string, latitude, longitude float64) error {
return a.EditGateway(gatewayID, GatewayEdits{
AntennaLocation: &Location{
Longitude: longitude,
Latitude: latitude,
},
})
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"ChangeLocation",
"(",
"gatewayID",
"string",
",",
"latitude",
",",
"longitude",
"float64",
")",
"error",
"{",
"return",
"a",
".",
"EditGateway",
"(",
"gatewayID",
",",
"GatewayEdits",
"{",
"AntennaLocation",
":",
"&",
... | // ChangeLocation changes the location of the gateway, set to nil, nil if you
// want to remove the location | [
"ChangeLocation",
"changes",
"the",
"location",
"of",
"the",
"gateway",
"set",
"to",
"nil",
"nil",
"if",
"you",
"want",
"to",
"remove",
"the",
"location"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/gateways.go#L217-L224 |
144,197 | TheThingsNetwork/go-account-lib | account/gateways.go | ChangeAltitude | func (a *Account) ChangeAltitude(gatewayID string, altitude int) error {
return a.EditGateway(gatewayID, GatewayEdits{
AntennaLocation: &Location{
Altitude: altitude,
},
})
} | go | func (a *Account) ChangeAltitude(gatewayID string, altitude int) error {
return a.EditGateway(gatewayID, GatewayEdits{
AntennaLocation: &Location{
Altitude: altitude,
},
})
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"ChangeAltitude",
"(",
"gatewayID",
"string",
",",
"altitude",
"int",
")",
"error",
"{",
"return",
"a",
".",
"EditGateway",
"(",
"gatewayID",
",",
"GatewayEdits",
"{",
"AntennaLocation",
":",
"&",
"Location",
"{",
"Al... | // ChangeAltitude changes the altitude of the gateway with the specified ID | [
"ChangeAltitude",
"changes",
"the",
"altitude",
"of",
"the",
"gateway",
"with",
"the",
"specified",
"ID"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/gateways.go#L227-L233 |
144,198 | TheThingsNetwork/go-account-lib | account/gateways.go | ChangeRouter | func (a *Account) ChangeRouter(gatewayID string, router string) error {
return a.EditGateway(gatewayID, GatewayEdits{
Router: &router,
})
} | go | func (a *Account) ChangeRouter(gatewayID string, router string) error {
return a.EditGateway(gatewayID, GatewayEdits{
Router: &router,
})
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"ChangeRouter",
"(",
"gatewayID",
"string",
",",
"router",
"string",
")",
"error",
"{",
"return",
"a",
".",
"EditGateway",
"(",
"gatewayID",
",",
"GatewayEdits",
"{",
"Router",
":",
"&",
"router",
",",
"}",
")",
"... | // ChangeRouter changes the router the gateway talks to | [
"ChangeRouter",
"changes",
"the",
"router",
"the",
"gateway",
"talks",
"to"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/gateways.go#L236-L240 |
144,199 | TheThingsNetwork/go-account-lib | account/gateways.go | GatewayRights | func (a *Account) GatewayRights(gatewayID string) (rights []types.Right, err error) {
err = a.get(a.auth.WithScope(scope.Gateway(gatewayID)), fmt.Sprintf("/api/v2/gateways/%s/rights", gatewayID), &rights)
if err != nil {
return nil, err
}
return rights, nil
} | go | func (a *Account) GatewayRights(gatewayID string) (rights []types.Right, err error) {
err = a.get(a.auth.WithScope(scope.Gateway(gatewayID)), fmt.Sprintf("/api/v2/gateways/%s/rights", gatewayID), &rights)
if err != nil {
return nil, err
}
return rights, nil
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"GatewayRights",
"(",
"gatewayID",
"string",
")",
"(",
"rights",
"[",
"]",
"types",
".",
"Right",
",",
"err",
"error",
")",
"{",
"err",
"=",
"a",
".",
"get",
"(",
"a",
".",
"auth",
".",
"WithScope",
"(",
"sc... | // GatewayRights returns the rights the current account client has to a certain
// gateway | [
"GatewayRights",
"returns",
"the",
"rights",
"the",
"current",
"account",
"client",
"has",
"to",
"a",
"certain",
"gateway"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/gateways.go#L244-L251 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.