repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
secsy/goftp
client.go
getIdleConn
func (c *Client) getIdleConn() (*persistentConn, error) { // First check for available connections in the channel. Loop: for { select { case pconn := <-c.freeConnCh: if pconn.broken { c.debug("#%d was ready (broken)", pconn.idx) c.mu.Lock() c.numConnsPerHost[pconn.host]-- c.mu.Unlock() c.removeConn(pconn) } else { c.debug("#%d was ready", pconn.idx) return pconn, nil } default: break Loop } } // No available connections. Loop until we can open a new one, or // one becomes available. for { c.mu.Lock() // can we open a connection to some host if c.numOpenConns() < len(c.hosts)*c.config.ConnectionsPerHost { c.connIdx++ idx := c.connIdx // find the next host with less than ConnectionsPerHost connections var host string for i := idx; i < idx+len(c.hosts); i++ { if c.numConnsPerHost[c.hosts[i%len(c.hosts)]] < c.config.ConnectionsPerHost { host = c.hosts[i%len(c.hosts)] break } } if host == "" { panic("this shouldn't be possible") } c.numConnsPerHost[host]++ c.mu.Unlock() pconn, err := c.openConn(idx, host) if err != nil { c.mu.Lock() c.numConnsPerHost[host]-- c.mu.Unlock() c.debug("#%d error connecting: %s", idx, err) } return pconn, err } c.mu.Unlock() // block waiting for a free connection pconn := <-c.freeConnCh if pconn.broken { c.debug("waited and got #%d (broken)", pconn.idx) c.mu.Lock() c.numConnsPerHost[pconn.host]-- c.mu.Unlock() c.removeConn(pconn) } else { c.debug("waited and got #%d", pconn.idx) return pconn, nil } } }
go
func (c *Client) getIdleConn() (*persistentConn, error) { // First check for available connections in the channel. Loop: for { select { case pconn := <-c.freeConnCh: if pconn.broken { c.debug("#%d was ready (broken)", pconn.idx) c.mu.Lock() c.numConnsPerHost[pconn.host]-- c.mu.Unlock() c.removeConn(pconn) } else { c.debug("#%d was ready", pconn.idx) return pconn, nil } default: break Loop } } // No available connections. Loop until we can open a new one, or // one becomes available. for { c.mu.Lock() // can we open a connection to some host if c.numOpenConns() < len(c.hosts)*c.config.ConnectionsPerHost { c.connIdx++ idx := c.connIdx // find the next host with less than ConnectionsPerHost connections var host string for i := idx; i < idx+len(c.hosts); i++ { if c.numConnsPerHost[c.hosts[i%len(c.hosts)]] < c.config.ConnectionsPerHost { host = c.hosts[i%len(c.hosts)] break } } if host == "" { panic("this shouldn't be possible") } c.numConnsPerHost[host]++ c.mu.Unlock() pconn, err := c.openConn(idx, host) if err != nil { c.mu.Lock() c.numConnsPerHost[host]-- c.mu.Unlock() c.debug("#%d error connecting: %s", idx, err) } return pconn, err } c.mu.Unlock() // block waiting for a free connection pconn := <-c.freeConnCh if pconn.broken { c.debug("waited and got #%d (broken)", pconn.idx) c.mu.Lock() c.numConnsPerHost[pconn.host]-- c.mu.Unlock() c.removeConn(pconn) } else { c.debug("waited and got #%d", pconn.idx) return pconn, nil } } }
[ "func", "(", "c", "*", "Client", ")", "getIdleConn", "(", ")", "(", "*", "persistentConn", ",", "error", ")", "{", "// First check for available connections in the channel.", "Loop", ":", "for", "{", "select", "{", "case", "pconn", ":=", "<-", "c", ".", "freeConnCh", ":", "if", "pconn", ".", "broken", "{", "c", ".", "debug", "(", "\"", "\"", ",", "pconn", ".", "idx", ")", "\n", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "c", ".", "numConnsPerHost", "[", "pconn", ".", "host", "]", "--", "\n", "c", ".", "mu", ".", "Unlock", "(", ")", "\n", "c", ".", "removeConn", "(", "pconn", ")", "\n", "}", "else", "{", "c", ".", "debug", "(", "\"", "\"", ",", "pconn", ".", "idx", ")", "\n", "return", "pconn", ",", "nil", "\n", "}", "\n", "default", ":", "break", "Loop", "\n", "}", "\n", "}", "\n\n", "// No available connections. Loop until we can open a new one, or", "// one becomes available.", "for", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n\n", "// can we open a connection to some host", "if", "c", ".", "numOpenConns", "(", ")", "<", "len", "(", "c", ".", "hosts", ")", "*", "c", ".", "config", ".", "ConnectionsPerHost", "{", "c", ".", "connIdx", "++", "\n", "idx", ":=", "c", ".", "connIdx", "\n\n", "// find the next host with less than ConnectionsPerHost connections", "var", "host", "string", "\n", "for", "i", ":=", "idx", ";", "i", "<", "idx", "+", "len", "(", "c", ".", "hosts", ")", ";", "i", "++", "{", "if", "c", ".", "numConnsPerHost", "[", "c", ".", "hosts", "[", "i", "%", "len", "(", "c", ".", "hosts", ")", "]", "]", "<", "c", ".", "config", ".", "ConnectionsPerHost", "{", "host", "=", "c", ".", "hosts", "[", "i", "%", "len", "(", "c", ".", "hosts", ")", "]", "\n", "break", "\n", "}", "\n", "}", "\n\n", "if", "host", "==", "\"", "\"", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "c", ".", "numConnsPerHost", "[", "host", "]", "++", "\n\n", "c", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "pconn", ",", "err", ":=", "c", ".", "openConn", "(", "idx", ",", "host", ")", "\n", "if", "err", "!=", "nil", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "c", ".", "numConnsPerHost", "[", "host", "]", "--", "\n", "c", ".", "mu", ".", "Unlock", "(", ")", "\n", "c", ".", "debug", "(", "\"", "\"", ",", "idx", ",", "err", ")", "\n", "}", "\n", "return", "pconn", ",", "err", "\n", "}", "\n\n", "c", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "// block waiting for a free connection", "pconn", ":=", "<-", "c", ".", "freeConnCh", "\n\n", "if", "pconn", ".", "broken", "{", "c", ".", "debug", "(", "\"", "\"", ",", "pconn", ".", "idx", ")", "\n", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "c", ".", "numConnsPerHost", "[", "pconn", ".", "host", "]", "--", "\n", "c", ".", "mu", ".", "Unlock", "(", ")", "\n", "c", ".", "removeConn", "(", "pconn", ")", "\n", "}", "else", "{", "c", ".", "debug", "(", "\"", "\"", ",", "pconn", ".", "idx", ")", "\n", "return", "pconn", ",", "nil", "\n\n", "}", "\n", "}", "\n", "}" ]
// Get an idle connection.
[ "Get", "an", "idle", "connection", "." ]
012609e90524f0bfde77100facdc47f807794c27
https://github.com/secsy/goftp/blob/012609e90524f0bfde77100facdc47f807794c27/client.go#L257-L333
train
secsy/goftp
client.go
openConn
func (c *Client) openConn(idx int, host string) (pconn *persistentConn, err error) { pconn = &persistentConn{ idx: idx, features: make(map[string]string), config: c.config, t0: c.t0, currentType: "A", host: host, epsvNotSupported: c.config.DisableEPSV, } var conn net.Conn if c.config.TLSConfig != nil && c.config.TLSMode == TLSImplicit { pconn.debug("opening TLS control connection to %s", host) dialer := &net.Dialer{ Timeout: c.config.Timeout, } conn, err = tls.DialWithDialer(dialer, "tcp", host, pconn.config.TLSConfig) } else { pconn.debug("opening control connection to %s", host) conn, err = net.DialTimeout("tcp", host, c.config.Timeout) } var ( code int msg string ) if err != nil { var isTemporary bool if ne, ok := err.(net.Error); ok { isTemporary = ne.Temporary() } err = ftpError{ err: err, temporary: isTemporary, } goto Error } pconn.setControlConn(conn) code, msg, err = pconn.readResponse() if err != nil { goto Error } if code != replyServiceReady { err = ftpError{code: code, msg: msg} goto Error } if c.config.TLSConfig != nil && c.config.TLSMode == TLSExplicit { err = pconn.logInTLS() } else { err = pconn.logIn() } if err != nil { goto Error } if err = pconn.fetchFeatures(); err != nil { goto Error } c.mu.Lock() defer c.mu.Unlock() if c.closed { err = ftpError{err: errors.New("client closed")} goto Error } if idx >= 0 { c.allCons[idx] = pconn } return pconn, nil Error: pconn.close() return nil, err }
go
func (c *Client) openConn(idx int, host string) (pconn *persistentConn, err error) { pconn = &persistentConn{ idx: idx, features: make(map[string]string), config: c.config, t0: c.t0, currentType: "A", host: host, epsvNotSupported: c.config.DisableEPSV, } var conn net.Conn if c.config.TLSConfig != nil && c.config.TLSMode == TLSImplicit { pconn.debug("opening TLS control connection to %s", host) dialer := &net.Dialer{ Timeout: c.config.Timeout, } conn, err = tls.DialWithDialer(dialer, "tcp", host, pconn.config.TLSConfig) } else { pconn.debug("opening control connection to %s", host) conn, err = net.DialTimeout("tcp", host, c.config.Timeout) } var ( code int msg string ) if err != nil { var isTemporary bool if ne, ok := err.(net.Error); ok { isTemporary = ne.Temporary() } err = ftpError{ err: err, temporary: isTemporary, } goto Error } pconn.setControlConn(conn) code, msg, err = pconn.readResponse() if err != nil { goto Error } if code != replyServiceReady { err = ftpError{code: code, msg: msg} goto Error } if c.config.TLSConfig != nil && c.config.TLSMode == TLSExplicit { err = pconn.logInTLS() } else { err = pconn.logIn() } if err != nil { goto Error } if err = pconn.fetchFeatures(); err != nil { goto Error } c.mu.Lock() defer c.mu.Unlock() if c.closed { err = ftpError{err: errors.New("client closed")} goto Error } if idx >= 0 { c.allCons[idx] = pconn } return pconn, nil Error: pconn.close() return nil, err }
[ "func", "(", "c", "*", "Client", ")", "openConn", "(", "idx", "int", ",", "host", "string", ")", "(", "pconn", "*", "persistentConn", ",", "err", "error", ")", "{", "pconn", "=", "&", "persistentConn", "{", "idx", ":", "idx", ",", "features", ":", "make", "(", "map", "[", "string", "]", "string", ")", ",", "config", ":", "c", ".", "config", ",", "t0", ":", "c", ".", "t0", ",", "currentType", ":", "\"", "\"", ",", "host", ":", "host", ",", "epsvNotSupported", ":", "c", ".", "config", ".", "DisableEPSV", ",", "}", "\n\n", "var", "conn", "net", ".", "Conn", "\n\n", "if", "c", ".", "config", ".", "TLSConfig", "!=", "nil", "&&", "c", ".", "config", ".", "TLSMode", "==", "TLSImplicit", "{", "pconn", ".", "debug", "(", "\"", "\"", ",", "host", ")", "\n", "dialer", ":=", "&", "net", ".", "Dialer", "{", "Timeout", ":", "c", ".", "config", ".", "Timeout", ",", "}", "\n", "conn", ",", "err", "=", "tls", ".", "DialWithDialer", "(", "dialer", ",", "\"", "\"", ",", "host", ",", "pconn", ".", "config", ".", "TLSConfig", ")", "\n", "}", "else", "{", "pconn", ".", "debug", "(", "\"", "\"", ",", "host", ")", "\n", "conn", ",", "err", "=", "net", ".", "DialTimeout", "(", "\"", "\"", ",", "host", ",", "c", ".", "config", ".", "Timeout", ")", "\n", "}", "\n\n", "var", "(", "code", "int", "\n", "msg", "string", "\n", ")", "\n\n", "if", "err", "!=", "nil", "{", "var", "isTemporary", "bool", "\n", "if", "ne", ",", "ok", ":=", "err", ".", "(", "net", ".", "Error", ")", ";", "ok", "{", "isTemporary", "=", "ne", ".", "Temporary", "(", ")", "\n", "}", "\n", "err", "=", "ftpError", "{", "err", ":", "err", ",", "temporary", ":", "isTemporary", ",", "}", "\n", "goto", "Error", "\n", "}", "\n\n", "pconn", ".", "setControlConn", "(", "conn", ")", "\n\n", "code", ",", "msg", ",", "err", "=", "pconn", ".", "readResponse", "(", ")", "\n", "if", "err", "!=", "nil", "{", "goto", "Error", "\n", "}", "\n\n", "if", "code", "!=", "replyServiceReady", "{", "err", "=", "ftpError", "{", "code", ":", "code", ",", "msg", ":", "msg", "}", "\n", "goto", "Error", "\n", "}", "\n\n", "if", "c", ".", "config", ".", "TLSConfig", "!=", "nil", "&&", "c", ".", "config", ".", "TLSMode", "==", "TLSExplicit", "{", "err", "=", "pconn", ".", "logInTLS", "(", ")", "\n", "}", "else", "{", "err", "=", "pconn", ".", "logIn", "(", ")", "\n", "}", "\n\n", "if", "err", "!=", "nil", "{", "goto", "Error", "\n", "}", "\n\n", "if", "err", "=", "pconn", ".", "fetchFeatures", "(", ")", ";", "err", "!=", "nil", "{", "goto", "Error", "\n", "}", "\n\n", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "c", ".", "closed", "{", "err", "=", "ftpError", "{", "err", ":", "errors", ".", "New", "(", "\"", "\"", ")", "}", "\n", "goto", "Error", "\n", "}", "\n\n", "if", "idx", ">=", "0", "{", "c", ".", "allCons", "[", "idx", "]", "=", "pconn", "\n", "}", "\n", "return", "pconn", ",", "nil", "\n\n", "Error", ":", "pconn", ".", "close", "(", ")", "\n", "return", "nil", ",", "err", "\n", "}" ]
// Open and set up a control connection.
[ "Open", "and", "set", "up", "a", "control", "connection", "." ]
012609e90524f0bfde77100facdc47f807794c27
https://github.com/secsy/goftp/blob/012609e90524f0bfde77100facdc47f807794c27/client.go#L359-L442
train
secsy/goftp
persistent_connection.go
requestPassive
func (pconn *persistentConn) requestPassive() (string, error) { var ( startIdx int endIdx int port int remoteHost string code int msg string err error ) if pconn.epsvNotSupported { goto PASV } // Extended PaSsiVe (same idea as PASV, but works with IPv6). // See http://tools.ietf.org/html/rfc2428. code, msg, err = pconn.sendCommand("EPSV") if err != nil { return "", err } if code != replyEnteringExtendedPassiveMode { pconn.debug("server doesn't support EPSV: %d-%s", code, msg) pconn.epsvNotSupported = true goto PASV } startIdx = strings.Index(msg, "|||") endIdx = strings.LastIndex(msg, "|") if startIdx == -1 || endIdx == -1 || startIdx+3 > endIdx { pconn.debug("failed parsing EPSV response: %s", msg) goto PASV } port, err = strconv.Atoi(msg[startIdx+3 : endIdx]) if err != nil { pconn.debug("EPSV response didn't contain port: %s", msg) goto PASV } remoteHost, _, err = net.SplitHostPort(pconn.controlConn.RemoteAddr().String()) if err != nil { pconn.debug("failed determining remote host: %s", err) goto PASV } return fmt.Sprintf("[%s]:%d", remoteHost, port), nil PASV: code, msg, err = pconn.sendCommand("PASV") if err != nil { return "", err } if code != replyEnteringPassiveMode { return "", ftpError{code: code, msg: msg} } parseError := ftpError{ err: fmt.Errorf("error parsing PASV response (%s)", msg), } // "Entering Passive Mode (162,138,208,11,223,57)." startIdx = strings.Index(msg, "(") endIdx = strings.LastIndex(msg, ")") if startIdx == -1 || endIdx == -1 || startIdx > endIdx { return "", parseError } addrParts := strings.Split(msg[startIdx+1:endIdx], ",") if len(addrParts) != 6 { return "", parseError } ip := net.ParseIP(strings.Join(addrParts[0:4], ".")) if ip == nil { return "", parseError } port = 0 for i, part := range addrParts[4:6] { portOctet, err := strconv.Atoi(part) if err != nil { return "", parseError } port |= portOctet << (byte(1-i) * 8) } return net.JoinHostPort(ip.String(), strconv.Itoa(port)), nil }
go
func (pconn *persistentConn) requestPassive() (string, error) { var ( startIdx int endIdx int port int remoteHost string code int msg string err error ) if pconn.epsvNotSupported { goto PASV } // Extended PaSsiVe (same idea as PASV, but works with IPv6). // See http://tools.ietf.org/html/rfc2428. code, msg, err = pconn.sendCommand("EPSV") if err != nil { return "", err } if code != replyEnteringExtendedPassiveMode { pconn.debug("server doesn't support EPSV: %d-%s", code, msg) pconn.epsvNotSupported = true goto PASV } startIdx = strings.Index(msg, "|||") endIdx = strings.LastIndex(msg, "|") if startIdx == -1 || endIdx == -1 || startIdx+3 > endIdx { pconn.debug("failed parsing EPSV response: %s", msg) goto PASV } port, err = strconv.Atoi(msg[startIdx+3 : endIdx]) if err != nil { pconn.debug("EPSV response didn't contain port: %s", msg) goto PASV } remoteHost, _, err = net.SplitHostPort(pconn.controlConn.RemoteAddr().String()) if err != nil { pconn.debug("failed determining remote host: %s", err) goto PASV } return fmt.Sprintf("[%s]:%d", remoteHost, port), nil PASV: code, msg, err = pconn.sendCommand("PASV") if err != nil { return "", err } if code != replyEnteringPassiveMode { return "", ftpError{code: code, msg: msg} } parseError := ftpError{ err: fmt.Errorf("error parsing PASV response (%s)", msg), } // "Entering Passive Mode (162,138,208,11,223,57)." startIdx = strings.Index(msg, "(") endIdx = strings.LastIndex(msg, ")") if startIdx == -1 || endIdx == -1 || startIdx > endIdx { return "", parseError } addrParts := strings.Split(msg[startIdx+1:endIdx], ",") if len(addrParts) != 6 { return "", parseError } ip := net.ParseIP(strings.Join(addrParts[0:4], ".")) if ip == nil { return "", parseError } port = 0 for i, part := range addrParts[4:6] { portOctet, err := strconv.Atoi(part) if err != nil { return "", parseError } port |= portOctet << (byte(1-i) * 8) } return net.JoinHostPort(ip.String(), strconv.Itoa(port)), nil }
[ "func", "(", "pconn", "*", "persistentConn", ")", "requestPassive", "(", ")", "(", "string", ",", "error", ")", "{", "var", "(", "startIdx", "int", "\n", "endIdx", "int", "\n", "port", "int", "\n", "remoteHost", "string", "\n", "code", "int", "\n", "msg", "string", "\n", "err", "error", "\n", ")", "\n\n", "if", "pconn", ".", "epsvNotSupported", "{", "goto", "PASV", "\n", "}", "\n\n", "// Extended PaSsiVe (same idea as PASV, but works with IPv6).", "// See http://tools.ietf.org/html/rfc2428.", "code", ",", "msg", ",", "err", "=", "pconn", ".", "sendCommand", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "if", "code", "!=", "replyEnteringExtendedPassiveMode", "{", "pconn", ".", "debug", "(", "\"", "\"", ",", "code", ",", "msg", ")", "\n", "pconn", ".", "epsvNotSupported", "=", "true", "\n", "goto", "PASV", "\n", "}", "\n\n", "startIdx", "=", "strings", ".", "Index", "(", "msg", ",", "\"", "\"", ")", "\n", "endIdx", "=", "strings", ".", "LastIndex", "(", "msg", ",", "\"", "\"", ")", "\n", "if", "startIdx", "==", "-", "1", "||", "endIdx", "==", "-", "1", "||", "startIdx", "+", "3", ">", "endIdx", "{", "pconn", ".", "debug", "(", "\"", "\"", ",", "msg", ")", "\n", "goto", "PASV", "\n", "}", "\n\n", "port", ",", "err", "=", "strconv", ".", "Atoi", "(", "msg", "[", "startIdx", "+", "3", ":", "endIdx", "]", ")", "\n", "if", "err", "!=", "nil", "{", "pconn", ".", "debug", "(", "\"", "\"", ",", "msg", ")", "\n", "goto", "PASV", "\n", "}", "\n\n", "remoteHost", ",", "_", ",", "err", "=", "net", ".", "SplitHostPort", "(", "pconn", ".", "controlConn", ".", "RemoteAddr", "(", ")", ".", "String", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "pconn", ".", "debug", "(", "\"", "\"", ",", "err", ")", "\n", "goto", "PASV", "\n", "}", "\n\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "remoteHost", ",", "port", ")", ",", "nil", "\n\n", "PASV", ":", "code", ",", "msg", ",", "err", "=", "pconn", ".", "sendCommand", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "if", "code", "!=", "replyEnteringPassiveMode", "{", "return", "\"", "\"", ",", "ftpError", "{", "code", ":", "code", ",", "msg", ":", "msg", "}", "\n", "}", "\n\n", "parseError", ":=", "ftpError", "{", "err", ":", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "msg", ")", ",", "}", "\n\n", "// \"Entering Passive Mode (162,138,208,11,223,57).\"", "startIdx", "=", "strings", ".", "Index", "(", "msg", ",", "\"", "\"", ")", "\n", "endIdx", "=", "strings", ".", "LastIndex", "(", "msg", ",", "\"", "\"", ")", "\n", "if", "startIdx", "==", "-", "1", "||", "endIdx", "==", "-", "1", "||", "startIdx", ">", "endIdx", "{", "return", "\"", "\"", ",", "parseError", "\n", "}", "\n\n", "addrParts", ":=", "strings", ".", "Split", "(", "msg", "[", "startIdx", "+", "1", ":", "endIdx", "]", ",", "\"", "\"", ")", "\n", "if", "len", "(", "addrParts", ")", "!=", "6", "{", "return", "\"", "\"", ",", "parseError", "\n", "}", "\n\n", "ip", ":=", "net", ".", "ParseIP", "(", "strings", ".", "Join", "(", "addrParts", "[", "0", ":", "4", "]", ",", "\"", "\"", ")", ")", "\n", "if", "ip", "==", "nil", "{", "return", "\"", "\"", ",", "parseError", "\n", "}", "\n\n", "port", "=", "0", "\n", "for", "i", ",", "part", ":=", "range", "addrParts", "[", "4", ":", "6", "]", "{", "portOctet", ",", "err", ":=", "strconv", ".", "Atoi", "(", "part", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "parseError", "\n", "}", "\n", "port", "|=", "portOctet", "<<", "(", "byte", "(", "1", "-", "i", ")", "*", "8", ")", "\n", "}", "\n\n", "return", "net", ".", "JoinHostPort", "(", "ip", ".", "String", "(", ")", ",", "strconv", ".", "Itoa", "(", "port", ")", ")", ",", "nil", "\n", "}" ]
// Request that the server enters passive mode, allowing us to connect to it. // This lets transfers work with the client behind NAT, so you almost always // want it. First try EPSV, then fall back to PASV.
[ "Request", "that", "the", "server", "enters", "passive", "mode", "allowing", "us", "to", "connect", "to", "it", ".", "This", "lets", "transfers", "work", "with", "the", "client", "behind", "NAT", "so", "you", "almost", "always", "want", "it", ".", "First", "try", "EPSV", "then", "fall", "back", "to", "PASV", "." ]
012609e90524f0bfde77100facdc47f807794c27
https://github.com/secsy/goftp/blob/012609e90524f0bfde77100facdc47f807794c27/persistent_connection.go#L259-L349
train
huin/goupnp
scpd/scpd.go
Clean
func (scpd *SCPD) Clean() { cleanWhitespace(&scpd.ConfigId) for i := range scpd.Actions { scpd.Actions[i].clean() } for i := range scpd.StateVariables { scpd.StateVariables[i].clean() } }
go
func (scpd *SCPD) Clean() { cleanWhitespace(&scpd.ConfigId) for i := range scpd.Actions { scpd.Actions[i].clean() } for i := range scpd.StateVariables { scpd.StateVariables[i].clean() } }
[ "func", "(", "scpd", "*", "SCPD", ")", "Clean", "(", ")", "{", "cleanWhitespace", "(", "&", "scpd", ".", "ConfigId", ")", "\n", "for", "i", ":=", "range", "scpd", ".", "Actions", "{", "scpd", ".", "Actions", "[", "i", "]", ".", "clean", "(", ")", "\n", "}", "\n", "for", "i", ":=", "range", "scpd", ".", "StateVariables", "{", "scpd", ".", "StateVariables", "[", "i", "]", ".", "clean", "(", ")", "\n", "}", "\n", "}" ]
// Clean attempts to remove stray whitespace etc. in the structure. It seems // unfortunately common for stray whitespace to be present in SCPD documents, // this method attempts to make it easy to clean them out.
[ "Clean", "attempts", "to", "remove", "stray", "whitespace", "etc", ".", "in", "the", "structure", ".", "It", "seems", "unfortunately", "common", "for", "stray", "whitespace", "to", "be", "present", "in", "SCPD", "documents", "this", "method", "attempts", "to", "make", "it", "easy", "to", "clean", "them", "out", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/scpd/scpd.go#L30-L38
train
huin/goupnp
soap/types.go
MarshalFixed14_4
func MarshalFixed14_4(v float64) (string, error) { if v >= 1e14 || v <= -1e14 { return "", fmt.Errorf("soap fixed14.4: value %v out of bounds", v) } return strconv.FormatFloat(v, 'f', 4, 64), nil }
go
func MarshalFixed14_4(v float64) (string, error) { if v >= 1e14 || v <= -1e14 { return "", fmt.Errorf("soap fixed14.4: value %v out of bounds", v) } return strconv.FormatFloat(v, 'f', 4, 64), nil }
[ "func", "MarshalFixed14_4", "(", "v", "float64", ")", "(", "string", ",", "error", ")", "{", "if", "v", ">=", "1e14", "||", "v", "<=", "-", "1e14", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "v", ")", "\n", "}", "\n", "return", "strconv", ".", "FormatFloat", "(", "v", ",", "'f'", ",", "4", ",", "64", ")", ",", "nil", "\n", "}" ]
// MarshalFixed14_4 marshals float64 to SOAP "fixed.14.4" type.
[ "MarshalFixed14_4", "marshals", "float64", "to", "SOAP", "fixed", ".", "14", ".", "4", "type", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/soap/types.go#L113-L118
train
huin/goupnp
soap/types.go
UnmarshalFixed14_4
func UnmarshalFixed14_4(s string) (float64, error) { v, err := strconv.ParseFloat(s, 64) if err != nil { return 0, err } if v >= 1e14 || v <= -1e14 { return 0, fmt.Errorf("soap fixed14.4: value %q out of bounds", s) } return v, nil }
go
func UnmarshalFixed14_4(s string) (float64, error) { v, err := strconv.ParseFloat(s, 64) if err != nil { return 0, err } if v >= 1e14 || v <= -1e14 { return 0, fmt.Errorf("soap fixed14.4: value %q out of bounds", s) } return v, nil }
[ "func", "UnmarshalFixed14_4", "(", "s", "string", ")", "(", "float64", ",", "error", ")", "{", "v", ",", "err", ":=", "strconv", ".", "ParseFloat", "(", "s", ",", "64", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "if", "v", ">=", "1e14", "||", "v", "<=", "-", "1e14", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ")", "\n", "}", "\n", "return", "v", ",", "nil", "\n", "}" ]
// UnmarshalFixed14_4 unmarshals float64 from SOAP "fixed.14.4" type.
[ "UnmarshalFixed14_4", "unmarshals", "float64", "from", "SOAP", "fixed", ".", "14", ".", "4", "type", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/soap/types.go#L121-L130
train
huin/goupnp
soap/types.go
MarshalChar
func MarshalChar(v rune) (string, error) { if v == 0 { return "", errors.New("soap char: rune 0 is not allowed") } return string(v), nil }
go
func MarshalChar(v rune) (string, error) { if v == 0 { return "", errors.New("soap char: rune 0 is not allowed") } return string(v), nil }
[ "func", "MarshalChar", "(", "v", "rune", ")", "(", "string", ",", "error", ")", "{", "if", "v", "==", "0", "{", "return", "\"", "\"", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "string", "(", "v", ")", ",", "nil", "\n", "}" ]
// MarshalChar marshals rune to SOAP "char" type.
[ "MarshalChar", "marshals", "rune", "to", "SOAP", "char", "type", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/soap/types.go#L133-L138
train
huin/goupnp
soap/types.go
UnmarshalChar
func UnmarshalChar(s string) (rune, error) { if len(s) == 0 { return 0, errors.New("soap char: got empty string") } r, n := utf8.DecodeRune([]byte(s)) if n != len(s) { return 0, fmt.Errorf("soap char: value %q is not a single rune", s) } return r, nil }
go
func UnmarshalChar(s string) (rune, error) { if len(s) == 0 { return 0, errors.New("soap char: got empty string") } r, n := utf8.DecodeRune([]byte(s)) if n != len(s) { return 0, fmt.Errorf("soap char: value %q is not a single rune", s) } return r, nil }
[ "func", "UnmarshalChar", "(", "s", "string", ")", "(", "rune", ",", "error", ")", "{", "if", "len", "(", "s", ")", "==", "0", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "r", ",", "n", ":=", "utf8", ".", "DecodeRune", "(", "[", "]", "byte", "(", "s", ")", ")", "\n", "if", "n", "!=", "len", "(", "s", ")", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ")", "\n", "}", "\n", "return", "r", ",", "nil", "\n", "}" ]
// UnmarshalChar unmarshals rune from SOAP "char" type.
[ "UnmarshalChar", "unmarshals", "rune", "from", "SOAP", "char", "type", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/soap/types.go#L141-L150
train
huin/goupnp
soap/types.go
UnmarshalDate
func UnmarshalDate(s string) (time.Time, error) { year, month, day, err := parseDateParts(s) if err != nil { return time.Time{}, err } return time.Date(year, time.Month(month), day, 0, 0, 0, 0, localLoc), nil }
go
func UnmarshalDate(s string) (time.Time, error) { year, month, day, err := parseDateParts(s) if err != nil { return time.Time{}, err } return time.Date(year, time.Month(month), day, 0, 0, 0, 0, localLoc), nil }
[ "func", "UnmarshalDate", "(", "s", "string", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "year", ",", "month", ",", "day", ",", "err", ":=", "parseDateParts", "(", "s", ")", "\n", "if", "err", "!=", "nil", "{", "return", "time", ".", "Time", "{", "}", ",", "err", "\n", "}", "\n", "return", "time", ".", "Date", "(", "year", ",", "time", ".", "Month", "(", "month", ")", ",", "day", ",", "0", ",", "0", ",", "0", ",", "0", ",", "localLoc", ")", ",", "nil", "\n", "}" ]
// UnmarshalDate unmarshals time.Time from SOAP "date" type. This outputs the // date as midnight in the local time zone.
[ "UnmarshalDate", "unmarshals", "time", ".", "Time", "from", "SOAP", "date", "type", ".", "This", "outputs", "the", "date", "as", "midnight", "in", "the", "local", "time", "zone", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/soap/types.go#L297-L303
train
huin/goupnp
soap/types.go
MarshalTimeOfDay
func MarshalTimeOfDay(v TimeOfDay) (string, error) { d := int64(v.FromMidnight / time.Second) hour := d / 3600 d = d % 3600 minute := d / 60 second := d % 60 return fmt.Sprintf("%02d:%02d:%02d", hour, minute, second), nil }
go
func MarshalTimeOfDay(v TimeOfDay) (string, error) { d := int64(v.FromMidnight / time.Second) hour := d / 3600 d = d % 3600 minute := d / 60 second := d % 60 return fmt.Sprintf("%02d:%02d:%02d", hour, minute, second), nil }
[ "func", "MarshalTimeOfDay", "(", "v", "TimeOfDay", ")", "(", "string", ",", "error", ")", "{", "d", ":=", "int64", "(", "v", ".", "FromMidnight", "/", "time", ".", "Second", ")", "\n", "hour", ":=", "d", "/", "3600", "\n", "d", "=", "d", "%", "3600", "\n", "minute", ":=", "d", "/", "60", "\n", "second", ":=", "d", "%", "60", "\n\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "hour", ",", "minute", ",", "second", ")", ",", "nil", "\n", "}" ]
// MarshalTimeOfDay marshals TimeOfDay to the "time" type.
[ "MarshalTimeOfDay", "marshals", "TimeOfDay", "to", "the", "time", "type", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/soap/types.go#L321-L329
train
huin/goupnp
soap/types.go
UnmarshalTimeOfDay
func UnmarshalTimeOfDay(s string) (TimeOfDay, error) { t, err := UnmarshalTimeOfDayTz(s) if err != nil { return TimeOfDay{}, err } else if t.HasOffset { return TimeOfDay{}, fmt.Errorf("soap time: value %q contains unexpected timezone", s) } return t, nil }
go
func UnmarshalTimeOfDay(s string) (TimeOfDay, error) { t, err := UnmarshalTimeOfDayTz(s) if err != nil { return TimeOfDay{}, err } else if t.HasOffset { return TimeOfDay{}, fmt.Errorf("soap time: value %q contains unexpected timezone", s) } return t, nil }
[ "func", "UnmarshalTimeOfDay", "(", "s", "string", ")", "(", "TimeOfDay", ",", "error", ")", "{", "t", ",", "err", ":=", "UnmarshalTimeOfDayTz", "(", "s", ")", "\n", "if", "err", "!=", "nil", "{", "return", "TimeOfDay", "{", "}", ",", "err", "\n", "}", "else", "if", "t", ".", "HasOffset", "{", "return", "TimeOfDay", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ")", "\n", "}", "\n", "return", "t", ",", "nil", "\n", "}" ]
// UnmarshalTimeOfDay unmarshals TimeOfDay from the "time" type.
[ "UnmarshalTimeOfDay", "unmarshals", "TimeOfDay", "from", "the", "time", "type", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/soap/types.go#L332-L340
train
huin/goupnp
soap/types.go
MarshalTimeOfDayTz
func MarshalTimeOfDayTz(v TimeOfDay) (string, error) { d := int64(v.FromMidnight / time.Second) hour := d / 3600 d = d % 3600 minute := d / 60 second := d % 60 tz := "" if v.HasOffset { if v.Offset == 0 { tz = "Z" } else { offsetMins := v.Offset / 60 sign := '+' if offsetMins < 1 { offsetMins = -offsetMins sign = '-' } tz = fmt.Sprintf("%c%02d:%02d", sign, offsetMins/60, offsetMins%60) } } return fmt.Sprintf("%02d:%02d:%02d%s", hour, minute, second, tz), nil }
go
func MarshalTimeOfDayTz(v TimeOfDay) (string, error) { d := int64(v.FromMidnight / time.Second) hour := d / 3600 d = d % 3600 minute := d / 60 second := d % 60 tz := "" if v.HasOffset { if v.Offset == 0 { tz = "Z" } else { offsetMins := v.Offset / 60 sign := '+' if offsetMins < 1 { offsetMins = -offsetMins sign = '-' } tz = fmt.Sprintf("%c%02d:%02d", sign, offsetMins/60, offsetMins%60) } } return fmt.Sprintf("%02d:%02d:%02d%s", hour, minute, second, tz), nil }
[ "func", "MarshalTimeOfDayTz", "(", "v", "TimeOfDay", ")", "(", "string", ",", "error", ")", "{", "d", ":=", "int64", "(", "v", ".", "FromMidnight", "/", "time", ".", "Second", ")", "\n", "hour", ":=", "d", "/", "3600", "\n", "d", "=", "d", "%", "3600", "\n", "minute", ":=", "d", "/", "60", "\n", "second", ":=", "d", "%", "60", "\n\n", "tz", ":=", "\"", "\"", "\n", "if", "v", ".", "HasOffset", "{", "if", "v", ".", "Offset", "==", "0", "{", "tz", "=", "\"", "\"", "\n", "}", "else", "{", "offsetMins", ":=", "v", ".", "Offset", "/", "60", "\n", "sign", ":=", "'+'", "\n", "if", "offsetMins", "<", "1", "{", "offsetMins", "=", "-", "offsetMins", "\n", "sign", "=", "'-'", "\n", "}", "\n", "tz", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "sign", ",", "offsetMins", "/", "60", ",", "offsetMins", "%", "60", ")", "\n", "}", "\n", "}", "\n\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "hour", ",", "minute", ",", "second", ",", "tz", ")", ",", "nil", "\n", "}" ]
// MarshalTimeOfDayTz marshals TimeOfDay to the "time.tz" type.
[ "MarshalTimeOfDayTz", "marshals", "TimeOfDay", "to", "the", "time", ".", "tz", "type", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/soap/types.go#L343-L366
train
huin/goupnp
soap/types.go
UnmarshalTimeOfDayTz
func UnmarshalTimeOfDayTz(s string) (tod TimeOfDay, err error) { zoneIndex := strings.IndexAny(s, "Z+-") var timePart string var hasOffset bool var offset int if zoneIndex == -1 { hasOffset = false timePart = s } else { hasOffset = true timePart = s[:zoneIndex] if offset, err = parseTimezone(s[zoneIndex:]); err != nil { return } } hour, minute, second, err := parseTimeParts(timePart) if err != nil { return } fromMidnight := time.Duration(hour*3600+minute*60+second) * time.Second // ISO8601 special case - values up to 24:00:00 are allowed, so using // strictly greater-than for the maximum value. if fromMidnight > 24*time.Hour || minute >= 60 || second >= 60 { return TimeOfDay{}, fmt.Errorf("soap time.tz: value %q has value(s) out of range", s) } return TimeOfDay{ FromMidnight: time.Duration(hour*3600+minute*60+second) * time.Second, HasOffset: hasOffset, Offset: offset, }, nil }
go
func UnmarshalTimeOfDayTz(s string) (tod TimeOfDay, err error) { zoneIndex := strings.IndexAny(s, "Z+-") var timePart string var hasOffset bool var offset int if zoneIndex == -1 { hasOffset = false timePart = s } else { hasOffset = true timePart = s[:zoneIndex] if offset, err = parseTimezone(s[zoneIndex:]); err != nil { return } } hour, minute, second, err := parseTimeParts(timePart) if err != nil { return } fromMidnight := time.Duration(hour*3600+minute*60+second) * time.Second // ISO8601 special case - values up to 24:00:00 are allowed, so using // strictly greater-than for the maximum value. if fromMidnight > 24*time.Hour || minute >= 60 || second >= 60 { return TimeOfDay{}, fmt.Errorf("soap time.tz: value %q has value(s) out of range", s) } return TimeOfDay{ FromMidnight: time.Duration(hour*3600+minute*60+second) * time.Second, HasOffset: hasOffset, Offset: offset, }, nil }
[ "func", "UnmarshalTimeOfDayTz", "(", "s", "string", ")", "(", "tod", "TimeOfDay", ",", "err", "error", ")", "{", "zoneIndex", ":=", "strings", ".", "IndexAny", "(", "s", ",", "\"", "\"", ")", "\n", "var", "timePart", "string", "\n", "var", "hasOffset", "bool", "\n", "var", "offset", "int", "\n", "if", "zoneIndex", "==", "-", "1", "{", "hasOffset", "=", "false", "\n", "timePart", "=", "s", "\n", "}", "else", "{", "hasOffset", "=", "true", "\n", "timePart", "=", "s", "[", ":", "zoneIndex", "]", "\n", "if", "offset", ",", "err", "=", "parseTimezone", "(", "s", "[", "zoneIndex", ":", "]", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "}", "\n\n", "hour", ",", "minute", ",", "second", ",", "err", ":=", "parseTimeParts", "(", "timePart", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "fromMidnight", ":=", "time", ".", "Duration", "(", "hour", "*", "3600", "+", "minute", "*", "60", "+", "second", ")", "*", "time", ".", "Second", "\n\n", "// ISO8601 special case - values up to 24:00:00 are allowed, so using", "// strictly greater-than for the maximum value.", "if", "fromMidnight", ">", "24", "*", "time", ".", "Hour", "||", "minute", ">=", "60", "||", "second", ">=", "60", "{", "return", "TimeOfDay", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ")", "\n", "}", "\n\n", "return", "TimeOfDay", "{", "FromMidnight", ":", "time", ".", "Duration", "(", "hour", "*", "3600", "+", "minute", "*", "60", "+", "second", ")", "*", "time", ".", "Second", ",", "HasOffset", ":", "hasOffset", ",", "Offset", ":", "offset", ",", "}", ",", "nil", "\n", "}" ]
// UnmarshalTimeOfDayTz unmarshals TimeOfDay from the "time.tz" type.
[ "UnmarshalTimeOfDayTz", "unmarshals", "TimeOfDay", "from", "the", "time", ".", "tz", "type", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/soap/types.go#L369-L403
train
huin/goupnp
soap/types.go
MarshalDateTime
func MarshalDateTime(v time.Time) (string, error) { return v.In(localLoc).Format("2006-01-02T15:04:05"), nil }
go
func MarshalDateTime(v time.Time) (string, error) { return v.In(localLoc).Format("2006-01-02T15:04:05"), nil }
[ "func", "MarshalDateTime", "(", "v", "time", ".", "Time", ")", "(", "string", ",", "error", ")", "{", "return", "v", ".", "In", "(", "localLoc", ")", ".", "Format", "(", "\"", "\"", ")", ",", "nil", "\n", "}" ]
// MarshalDateTime marshals time.Time to SOAP "dateTime" type. Note that this // converts to local time.
[ "MarshalDateTime", "marshals", "time", ".", "Time", "to", "SOAP", "dateTime", "type", ".", "Note", "that", "this", "converts", "to", "local", "time", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/soap/types.go#L407-L409
train
huin/goupnp
soap/types.go
UnmarshalDateTime
func UnmarshalDateTime(s string) (result time.Time, err error) { dateStr, timeStr, zoneStr, err := splitCompleteDateTimeZone(s) if err != nil { return } if len(zoneStr) != 0 { err = fmt.Errorf("soap datetime: unexpected timezone in %q", s) return } year, month, day, err := parseDateParts(dateStr) if err != nil { return } var hour, minute, second int if len(timeStr) != 0 { hour, minute, second, err = parseTimeParts(timeStr) if err != nil { return } } result = time.Date(year, time.Month(month), day, hour, minute, second, 0, localLoc) return }
go
func UnmarshalDateTime(s string) (result time.Time, err error) { dateStr, timeStr, zoneStr, err := splitCompleteDateTimeZone(s) if err != nil { return } if len(zoneStr) != 0 { err = fmt.Errorf("soap datetime: unexpected timezone in %q", s) return } year, month, day, err := parseDateParts(dateStr) if err != nil { return } var hour, minute, second int if len(timeStr) != 0 { hour, minute, second, err = parseTimeParts(timeStr) if err != nil { return } } result = time.Date(year, time.Month(month), day, hour, minute, second, 0, localLoc) return }
[ "func", "UnmarshalDateTime", "(", "s", "string", ")", "(", "result", "time", ".", "Time", ",", "err", "error", ")", "{", "dateStr", ",", "timeStr", ",", "zoneStr", ",", "err", ":=", "splitCompleteDateTimeZone", "(", "s", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "if", "len", "(", "zoneStr", ")", "!=", "0", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ")", "\n", "return", "\n", "}", "\n\n", "year", ",", "month", ",", "day", ",", "err", ":=", "parseDateParts", "(", "dateStr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "var", "hour", ",", "minute", ",", "second", "int", "\n", "if", "len", "(", "timeStr", ")", "!=", "0", "{", "hour", ",", "minute", ",", "second", ",", "err", "=", "parseTimeParts", "(", "timeStr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "}", "\n\n", "result", "=", "time", ".", "Date", "(", "year", ",", "time", ".", "Month", "(", "month", ")", ",", "day", ",", "hour", ",", "minute", ",", "second", ",", "0", ",", "localLoc", ")", "\n", "return", "\n", "}" ]
// UnmarshalDateTime unmarshals time.Time from the SOAP "dateTime" type. This // returns a value in the local timezone.
[ "UnmarshalDateTime", "unmarshals", "time", ".", "Time", "from", "the", "SOAP", "dateTime", "type", ".", "This", "returns", "a", "value", "in", "the", "local", "timezone", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/soap/types.go#L413-L439
train
huin/goupnp
soap/types.go
UnmarshalDateTimeTz
func UnmarshalDateTimeTz(s string) (result time.Time, err error) { dateStr, timeStr, zoneStr, err := splitCompleteDateTimeZone(s) if err != nil { return } year, month, day, err := parseDateParts(dateStr) if err != nil { return } var hour, minute, second int var location *time.Location = localLoc if len(timeStr) != 0 { hour, minute, second, err = parseTimeParts(timeStr) if err != nil { return } if len(zoneStr) != 0 { var offset int offset, err = parseTimezone(zoneStr) if offset == 0 { location = time.UTC } else { location = time.FixedZone("", offset) } } } result = time.Date(year, time.Month(month), day, hour, minute, second, 0, location) return }
go
func UnmarshalDateTimeTz(s string) (result time.Time, err error) { dateStr, timeStr, zoneStr, err := splitCompleteDateTimeZone(s) if err != nil { return } year, month, day, err := parseDateParts(dateStr) if err != nil { return } var hour, minute, second int var location *time.Location = localLoc if len(timeStr) != 0 { hour, minute, second, err = parseTimeParts(timeStr) if err != nil { return } if len(zoneStr) != 0 { var offset int offset, err = parseTimezone(zoneStr) if offset == 0 { location = time.UTC } else { location = time.FixedZone("", offset) } } } result = time.Date(year, time.Month(month), day, hour, minute, second, 0, location) return }
[ "func", "UnmarshalDateTimeTz", "(", "s", "string", ")", "(", "result", "time", ".", "Time", ",", "err", "error", ")", "{", "dateStr", ",", "timeStr", ",", "zoneStr", ",", "err", ":=", "splitCompleteDateTimeZone", "(", "s", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "year", ",", "month", ",", "day", ",", "err", ":=", "parseDateParts", "(", "dateStr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "var", "hour", ",", "minute", ",", "second", "int", "\n", "var", "location", "*", "time", ".", "Location", "=", "localLoc", "\n", "if", "len", "(", "timeStr", ")", "!=", "0", "{", "hour", ",", "minute", ",", "second", ",", "err", "=", "parseTimeParts", "(", "timeStr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "if", "len", "(", "zoneStr", ")", "!=", "0", "{", "var", "offset", "int", "\n", "offset", ",", "err", "=", "parseTimezone", "(", "zoneStr", ")", "\n", "if", "offset", "==", "0", "{", "location", "=", "time", ".", "UTC", "\n", "}", "else", "{", "location", "=", "time", ".", "FixedZone", "(", "\"", "\"", ",", "offset", ")", "\n", "}", "\n", "}", "\n", "}", "\n\n", "result", "=", "time", ".", "Date", "(", "year", ",", "time", ".", "Month", "(", "month", ")", ",", "day", ",", "hour", ",", "minute", ",", "second", ",", "0", ",", "location", ")", "\n", "return", "\n", "}" ]
// UnmarshalDateTimeTz unmarshals time.Time from the SOAP "dateTime.tz" type. // This returns a value in the local timezone when the timezone is unspecified.
[ "UnmarshalDateTimeTz", "unmarshals", "time", ".", "Time", "from", "the", "SOAP", "dateTime", ".", "tz", "type", ".", "This", "returns", "a", "value", "in", "the", "local", "timezone", "when", "the", "timezone", "is", "unspecified", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/soap/types.go#L448-L479
train
huin/goupnp
soap/types.go
UnmarshalBoolean
func UnmarshalBoolean(s string) (bool, error) { switch s { case "0", "false", "no": return false, nil case "1", "true", "yes": return true, nil } return false, fmt.Errorf("soap boolean: %q is not a valid boolean value", s) }
go
func UnmarshalBoolean(s string) (bool, error) { switch s { case "0", "false", "no": return false, nil case "1", "true", "yes": return true, nil } return false, fmt.Errorf("soap boolean: %q is not a valid boolean value", s) }
[ "func", "UnmarshalBoolean", "(", "s", "string", ")", "(", "bool", ",", "error", ")", "{", "switch", "s", "{", "case", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ":", "return", "false", ",", "nil", "\n", "case", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ":", "return", "true", ",", "nil", "\n", "}", "\n", "return", "false", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ")", "\n", "}" ]
// UnmarshalBoolean unmarshals bool from the SOAP "boolean" type.
[ "UnmarshalBoolean", "unmarshals", "bool", "from", "the", "SOAP", "boolean", "type", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/soap/types.go#L490-L498
train
huin/goupnp
soap/soap.go
encodeRequestAction
func encodeRequestAction(actionNamespace, actionName string, inAction interface{}) ([]byte, error) { requestBuf := new(bytes.Buffer) requestBuf.WriteString(soapPrefix) requestBuf.WriteString(`<u:`) xml.EscapeText(requestBuf, []byte(actionName)) requestBuf.WriteString(` xmlns:u="`) xml.EscapeText(requestBuf, []byte(actionNamespace)) requestBuf.WriteString(`">`) if inAction != nil { if err := encodeRequestArgs(requestBuf, inAction); err != nil { return nil, err } } requestBuf.WriteString(`</u:`) xml.EscapeText(requestBuf, []byte(actionName)) requestBuf.WriteString(`>`) requestBuf.WriteString(soapSuffix) return requestBuf.Bytes(), nil }
go
func encodeRequestAction(actionNamespace, actionName string, inAction interface{}) ([]byte, error) { requestBuf := new(bytes.Buffer) requestBuf.WriteString(soapPrefix) requestBuf.WriteString(`<u:`) xml.EscapeText(requestBuf, []byte(actionName)) requestBuf.WriteString(` xmlns:u="`) xml.EscapeText(requestBuf, []byte(actionNamespace)) requestBuf.WriteString(`">`) if inAction != nil { if err := encodeRequestArgs(requestBuf, inAction); err != nil { return nil, err } } requestBuf.WriteString(`</u:`) xml.EscapeText(requestBuf, []byte(actionName)) requestBuf.WriteString(`>`) requestBuf.WriteString(soapSuffix) return requestBuf.Bytes(), nil }
[ "func", "encodeRequestAction", "(", "actionNamespace", ",", "actionName", "string", ",", "inAction", "interface", "{", "}", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "requestBuf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n", "requestBuf", ".", "WriteString", "(", "soapPrefix", ")", "\n", "requestBuf", ".", "WriteString", "(", "`<u:`", ")", "\n", "xml", ".", "EscapeText", "(", "requestBuf", ",", "[", "]", "byte", "(", "actionName", ")", ")", "\n", "requestBuf", ".", "WriteString", "(", "` xmlns:u=\"`", ")", "\n", "xml", ".", "EscapeText", "(", "requestBuf", ",", "[", "]", "byte", "(", "actionNamespace", ")", ")", "\n", "requestBuf", ".", "WriteString", "(", "`\">`", ")", "\n", "if", "inAction", "!=", "nil", "{", "if", "err", ":=", "encodeRequestArgs", "(", "requestBuf", ",", "inAction", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "requestBuf", ".", "WriteString", "(", "`</u:`", ")", "\n", "xml", ".", "EscapeText", "(", "requestBuf", ",", "[", "]", "byte", "(", "actionName", ")", ")", "\n", "requestBuf", ".", "WriteString", "(", "`>`", ")", "\n", "requestBuf", ".", "WriteString", "(", "soapSuffix", ")", "\n", "return", "requestBuf", ".", "Bytes", "(", ")", ",", "nil", "\n", "}" ]
// encodeRequestAction is a hacky way to create an encoded SOAP envelope // containing the given action. Experiments with one router have shown that it // 500s for requests where the outer default xmlns is set to the SOAP // namespace, and then reassigning the default namespace within that to the // service namespace. Hand-coding the outer XML to work-around this.
[ "encodeRequestAction", "is", "a", "hacky", "way", "to", "create", "an", "encoded", "SOAP", "envelope", "containing", "the", "given", "action", ".", "Experiments", "with", "one", "router", "have", "shown", "that", "it", "500s", "for", "requests", "where", "the", "outer", "default", "xmlns", "is", "set", "to", "the", "SOAP", "namespace", "and", "then", "reassigning", "the", "default", "namespace", "within", "that", "to", "the", "service", "namespace", ".", "Hand", "-", "coding", "the", "outer", "XML", "to", "work", "-", "around", "this", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/soap/soap.go#L92-L110
train
huin/goupnp
httpu/httpu.go
NewHTTPUClient
func NewHTTPUClient() (*HTTPUClient, error) { conn, err := net.ListenPacket("udp", ":0") if err != nil { return nil, err } return &HTTPUClient{conn: conn}, nil }
go
func NewHTTPUClient() (*HTTPUClient, error) { conn, err := net.ListenPacket("udp", ":0") if err != nil { return nil, err } return &HTTPUClient{conn: conn}, nil }
[ "func", "NewHTTPUClient", "(", ")", "(", "*", "HTTPUClient", ",", "error", ")", "{", "conn", ",", "err", ":=", "net", ".", "ListenPacket", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "HTTPUClient", "{", "conn", ":", "conn", "}", ",", "nil", "\n", "}" ]
// NewHTTPUClient creates a new HTTPUClient, opening up a new UDP socket for the // purpose.
[ "NewHTTPUClient", "creates", "a", "new", "HTTPUClient", "opening", "up", "a", "new", "UDP", "socket", "for", "the", "purpose", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/httpu/httpu.go#L24-L30
train
huin/goupnp
httpu/httpu.go
NewHTTPUClientAddr
func NewHTTPUClientAddr(addr string) (*HTTPUClient, error) { ip := net.ParseIP(addr) if ip == nil { return nil, errors.New("Invalid listening address") } conn, err := net.ListenPacket("udp", ip.String()+":0") if err != nil { return nil, err } return &HTTPUClient{conn: conn}, nil }
go
func NewHTTPUClientAddr(addr string) (*HTTPUClient, error) { ip := net.ParseIP(addr) if ip == nil { return nil, errors.New("Invalid listening address") } conn, err := net.ListenPacket("udp", ip.String()+":0") if err != nil { return nil, err } return &HTTPUClient{conn: conn}, nil }
[ "func", "NewHTTPUClientAddr", "(", "addr", "string", ")", "(", "*", "HTTPUClient", ",", "error", ")", "{", "ip", ":=", "net", ".", "ParseIP", "(", "addr", ")", "\n", "if", "ip", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "conn", ",", "err", ":=", "net", ".", "ListenPacket", "(", "\"", "\"", ",", "ip", ".", "String", "(", ")", "+", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "HTTPUClient", "{", "conn", ":", "conn", "}", ",", "nil", "\n", "}" ]
// NewHTTPUClientAddr creates a new HTTPUClient which will broadcast packets // from the specified address, opening up a new UDP socket for the purpose
[ "NewHTTPUClientAddr", "creates", "a", "new", "HTTPUClient", "which", "will", "broadcast", "packets", "from", "the", "specified", "address", "opening", "up", "a", "new", "UDP", "socket", "for", "the", "purpose" ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/httpu/httpu.go#L34-L44
train
huin/goupnp
httpu/httpu.go
Close
func (httpu *HTTPUClient) Close() error { httpu.connLock.Lock() defer httpu.connLock.Unlock() return httpu.conn.Close() }
go
func (httpu *HTTPUClient) Close() error { httpu.connLock.Lock() defer httpu.connLock.Unlock() return httpu.conn.Close() }
[ "func", "(", "httpu", "*", "HTTPUClient", ")", "Close", "(", ")", "error", "{", "httpu", ".", "connLock", ".", "Lock", "(", ")", "\n", "defer", "httpu", ".", "connLock", ".", "Unlock", "(", ")", "\n", "return", "httpu", ".", "conn", ".", "Close", "(", ")", "\n", "}" ]
// Close shuts down the client. The client will no longer be useful following // this.
[ "Close", "shuts", "down", "the", "client", ".", "The", "client", "will", "no", "longer", "be", "useful", "following", "this", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/httpu/httpu.go#L48-L52
train
huin/goupnp
httpu/httpu.go
Do
func (httpu *HTTPUClient) Do(req *http.Request, timeout time.Duration, numSends int) ([]*http.Response, error) { httpu.connLock.Lock() defer httpu.connLock.Unlock() // Create the request. This is a subset of what http.Request.Write does // deliberately to avoid creating extra fields which may confuse some // devices. var requestBuf bytes.Buffer method := req.Method if method == "" { method = "GET" } if _, err := fmt.Fprintf(&requestBuf, "%s %s HTTP/1.1\r\n", method, req.URL.RequestURI()); err != nil { return nil, err } if err := req.Header.Write(&requestBuf); err != nil { return nil, err } if _, err := requestBuf.Write([]byte{'\r', '\n'}); err != nil { return nil, err } destAddr, err := net.ResolveUDPAddr("udp", req.Host) if err != nil { return nil, err } if err = httpu.conn.SetDeadline(time.Now().Add(timeout)); err != nil { return nil, err } // Send request. for i := 0; i < numSends; i++ { if n, err := httpu.conn.WriteTo(requestBuf.Bytes(), destAddr); err != nil { return nil, err } else if n < len(requestBuf.Bytes()) { return nil, fmt.Errorf("httpu: wrote %d bytes rather than full %d in request", n, len(requestBuf.Bytes())) } time.Sleep(5 * time.Millisecond) } // Await responses until timeout. var responses []*http.Response responseBytes := make([]byte, 2048) for { // 2048 bytes should be sufficient for most networks. n, _, err := httpu.conn.ReadFrom(responseBytes) if err != nil { if err, ok := err.(net.Error); ok { if err.Timeout() { break } if err.Temporary() { // Sleep in case this is a persistent error to avoid pegging CPU until deadline. time.Sleep(10 * time.Millisecond) continue } } return nil, err } // Parse response. response, err := http.ReadResponse(bufio.NewReader(bytes.NewBuffer(responseBytes[:n])), req) if err != nil { log.Printf("httpu: error while parsing response: %v", err) continue } responses = append(responses, response) } // Timeout reached - return discovered responses. return responses, nil }
go
func (httpu *HTTPUClient) Do(req *http.Request, timeout time.Duration, numSends int) ([]*http.Response, error) { httpu.connLock.Lock() defer httpu.connLock.Unlock() // Create the request. This is a subset of what http.Request.Write does // deliberately to avoid creating extra fields which may confuse some // devices. var requestBuf bytes.Buffer method := req.Method if method == "" { method = "GET" } if _, err := fmt.Fprintf(&requestBuf, "%s %s HTTP/1.1\r\n", method, req.URL.RequestURI()); err != nil { return nil, err } if err := req.Header.Write(&requestBuf); err != nil { return nil, err } if _, err := requestBuf.Write([]byte{'\r', '\n'}); err != nil { return nil, err } destAddr, err := net.ResolveUDPAddr("udp", req.Host) if err != nil { return nil, err } if err = httpu.conn.SetDeadline(time.Now().Add(timeout)); err != nil { return nil, err } // Send request. for i := 0; i < numSends; i++ { if n, err := httpu.conn.WriteTo(requestBuf.Bytes(), destAddr); err != nil { return nil, err } else if n < len(requestBuf.Bytes()) { return nil, fmt.Errorf("httpu: wrote %d bytes rather than full %d in request", n, len(requestBuf.Bytes())) } time.Sleep(5 * time.Millisecond) } // Await responses until timeout. var responses []*http.Response responseBytes := make([]byte, 2048) for { // 2048 bytes should be sufficient for most networks. n, _, err := httpu.conn.ReadFrom(responseBytes) if err != nil { if err, ok := err.(net.Error); ok { if err.Timeout() { break } if err.Temporary() { // Sleep in case this is a persistent error to avoid pegging CPU until deadline. time.Sleep(10 * time.Millisecond) continue } } return nil, err } // Parse response. response, err := http.ReadResponse(bufio.NewReader(bytes.NewBuffer(responseBytes[:n])), req) if err != nil { log.Printf("httpu: error while parsing response: %v", err) continue } responses = append(responses, response) } // Timeout reached - return discovered responses. return responses, nil }
[ "func", "(", "httpu", "*", "HTTPUClient", ")", "Do", "(", "req", "*", "http", ".", "Request", ",", "timeout", "time", ".", "Duration", ",", "numSends", "int", ")", "(", "[", "]", "*", "http", ".", "Response", ",", "error", ")", "{", "httpu", ".", "connLock", ".", "Lock", "(", ")", "\n", "defer", "httpu", ".", "connLock", ".", "Unlock", "(", ")", "\n\n", "// Create the request. This is a subset of what http.Request.Write does", "// deliberately to avoid creating extra fields which may confuse some", "// devices.", "var", "requestBuf", "bytes", ".", "Buffer", "\n", "method", ":=", "req", ".", "Method", "\n", "if", "method", "==", "\"", "\"", "{", "method", "=", "\"", "\"", "\n", "}", "\n", "if", "_", ",", "err", ":=", "fmt", ".", "Fprintf", "(", "&", "requestBuf", ",", "\"", "\\r", "\\n", "\"", ",", "method", ",", "req", ".", "URL", ".", "RequestURI", "(", ")", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "err", ":=", "req", ".", "Header", ".", "Write", "(", "&", "requestBuf", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "_", ",", "err", ":=", "requestBuf", ".", "Write", "(", "[", "]", "byte", "{", "'\\r'", ",", "'\\n'", "}", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "destAddr", ",", "err", ":=", "net", ".", "ResolveUDPAddr", "(", "\"", "\"", ",", "req", ".", "Host", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "err", "=", "httpu", ".", "conn", ".", "SetDeadline", "(", "time", ".", "Now", "(", ")", ".", "Add", "(", "timeout", ")", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Send request.", "for", "i", ":=", "0", ";", "i", "<", "numSends", ";", "i", "++", "{", "if", "n", ",", "err", ":=", "httpu", ".", "conn", ".", "WriteTo", "(", "requestBuf", ".", "Bytes", "(", ")", ",", "destAddr", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "else", "if", "n", "<", "len", "(", "requestBuf", ".", "Bytes", "(", ")", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "n", ",", "len", "(", "requestBuf", ".", "Bytes", "(", ")", ")", ")", "\n", "}", "\n", "time", ".", "Sleep", "(", "5", "*", "time", ".", "Millisecond", ")", "\n", "}", "\n\n", "// Await responses until timeout.", "var", "responses", "[", "]", "*", "http", ".", "Response", "\n", "responseBytes", ":=", "make", "(", "[", "]", "byte", ",", "2048", ")", "\n", "for", "{", "// 2048 bytes should be sufficient for most networks.", "n", ",", "_", ",", "err", ":=", "httpu", ".", "conn", ".", "ReadFrom", "(", "responseBytes", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", ",", "ok", ":=", "err", ".", "(", "net", ".", "Error", ")", ";", "ok", "{", "if", "err", ".", "Timeout", "(", ")", "{", "break", "\n", "}", "\n", "if", "err", ".", "Temporary", "(", ")", "{", "// Sleep in case this is a persistent error to avoid pegging CPU until deadline.", "time", ".", "Sleep", "(", "10", "*", "time", ".", "Millisecond", ")", "\n", "continue", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Parse response.", "response", ",", "err", ":=", "http", ".", "ReadResponse", "(", "bufio", ".", "NewReader", "(", "bytes", ".", "NewBuffer", "(", "responseBytes", "[", ":", "n", "]", ")", ")", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "err", ")", "\n", "continue", "\n", "}", "\n\n", "responses", "=", "append", "(", "responses", ",", "response", ")", "\n", "}", "\n\n", "// Timeout reached - return discovered responses.", "return", "responses", ",", "nil", "\n", "}" ]
// Do performs a request. The timeout is how long to wait for before returning // the responses that were received. An error is only returned for failing to // send the request. Failures in receipt simply do not add to the resulting // responses. // // Note that at present only one concurrent connection will happen per // HTTPUClient.
[ "Do", "performs", "a", "request", ".", "The", "timeout", "is", "how", "long", "to", "wait", "for", "before", "returning", "the", "responses", "that", "were", "received", ".", "An", "error", "is", "only", "returned", "for", "failing", "to", "send", "the", "request", ".", "Failures", "in", "receipt", "simply", "do", "not", "add", "to", "the", "resulting", "responses", ".", "Note", "that", "at", "present", "only", "one", "concurrent", "connection", "will", "happen", "per", "HTTPUClient", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/httpu/httpu.go#L61-L134
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewDeviceProtection1Clients
func NewDeviceProtection1Clients() (clients []*DeviceProtection1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_DeviceProtection_1); err != nil { return } clients = newDeviceProtection1ClientsFromGenericClients(genericClients) return }
go
func NewDeviceProtection1Clients() (clients []*DeviceProtection1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_DeviceProtection_1); err != nil { return } clients = newDeviceProtection1ClientsFromGenericClients(genericClients) return }
[ "func", "NewDeviceProtection1Clients", "(", ")", "(", "clients", "[", "]", "*", "DeviceProtection1", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_DeviceProtection_1", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newDeviceProtection1ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewDeviceProtection1Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewDeviceProtection1Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L61-L68
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewDeviceProtection1ClientsByURL
func NewDeviceProtection1ClientsByURL(loc *url.URL) ([]*DeviceProtection1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_DeviceProtection_1) if err != nil { return nil, err } return newDeviceProtection1ClientsFromGenericClients(genericClients), nil }
go
func NewDeviceProtection1ClientsByURL(loc *url.URL) ([]*DeviceProtection1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_DeviceProtection_1) if err != nil { return nil, err } return newDeviceProtection1ClientsFromGenericClients(genericClients), nil }
[ "func", "NewDeviceProtection1ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "DeviceProtection1", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_DeviceProtection_1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newDeviceProtection1ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewDeviceProtection1ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewDeviceProtection1ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L76-L82
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewLANHostConfigManagement1Clients
func NewLANHostConfigManagement1Clients() (clients []*LANHostConfigManagement1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_LANHostConfigManagement_1); err != nil { return } clients = newLANHostConfigManagement1ClientsFromGenericClients(genericClients) return }
go
func NewLANHostConfigManagement1Clients() (clients []*LANHostConfigManagement1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_LANHostConfigManagement_1); err != nil { return } clients = newLANHostConfigManagement1ClientsFromGenericClients(genericClients) return }
[ "func", "NewLANHostConfigManagement1Clients", "(", ")", "(", "clients", "[", "]", "*", "LANHostConfigManagement1", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_LANHostConfigManagement_1", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newLANHostConfigManagement1ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewLANHostConfigManagement1Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewLANHostConfigManagement1Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L526-L533
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewLANHostConfigManagement1ClientsByURL
func NewLANHostConfigManagement1ClientsByURL(loc *url.URL) ([]*LANHostConfigManagement1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_LANHostConfigManagement_1) if err != nil { return nil, err } return newLANHostConfigManagement1ClientsFromGenericClients(genericClients), nil }
go
func NewLANHostConfigManagement1ClientsByURL(loc *url.URL) ([]*LANHostConfigManagement1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_LANHostConfigManagement_1) if err != nil { return nil, err } return newLANHostConfigManagement1ClientsFromGenericClients(genericClients), nil }
[ "func", "NewLANHostConfigManagement1ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "LANHostConfigManagement1", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_LANHostConfigManagement_1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newLANHostConfigManagement1ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewLANHostConfigManagement1ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewLANHostConfigManagement1ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L541-L547
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewLayer3Forwarding1Clients
func NewLayer3Forwarding1Clients() (clients []*Layer3Forwarding1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_Layer3Forwarding_1); err != nil { return } clients = newLayer3Forwarding1ClientsFromGenericClients(genericClients) return }
go
func NewLayer3Forwarding1Clients() (clients []*Layer3Forwarding1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_Layer3Forwarding_1); err != nil { return } clients = newLayer3Forwarding1ClientsFromGenericClients(genericClients) return }
[ "func", "NewLayer3Forwarding1Clients", "(", ")", "(", "clients", "[", "]", "*", "Layer3Forwarding1", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_Layer3Forwarding_1", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newLayer3Forwarding1ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewLayer3Forwarding1Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewLayer3Forwarding1Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L1088-L1095
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewLayer3Forwarding1ClientsByURL
func NewLayer3Forwarding1ClientsByURL(loc *url.URL) ([]*Layer3Forwarding1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_Layer3Forwarding_1) if err != nil { return nil, err } return newLayer3Forwarding1ClientsFromGenericClients(genericClients), nil }
go
func NewLayer3Forwarding1ClientsByURL(loc *url.URL) ([]*Layer3Forwarding1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_Layer3Forwarding_1) if err != nil { return nil, err } return newLayer3Forwarding1ClientsFromGenericClients(genericClients), nil }
[ "func", "NewLayer3Forwarding1ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "Layer3Forwarding1", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_Layer3Forwarding_1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newLayer3Forwarding1ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewLayer3Forwarding1ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewLayer3Forwarding1ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L1103-L1109
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewWANCableLinkConfig1Clients
func NewWANCableLinkConfig1Clients() (clients []*WANCableLinkConfig1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_WANCableLinkConfig_1); err != nil { return } clients = newWANCableLinkConfig1ClientsFromGenericClients(genericClients) return }
go
func NewWANCableLinkConfig1Clients() (clients []*WANCableLinkConfig1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_WANCableLinkConfig_1); err != nil { return } clients = newWANCableLinkConfig1ClientsFromGenericClients(genericClients) return }
[ "func", "NewWANCableLinkConfig1Clients", "(", ")", "(", "clients", "[", "]", "*", "WANCableLinkConfig1", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_WANCableLinkConfig_1", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newWANCableLinkConfig1ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewWANCableLinkConfig1Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewWANCableLinkConfig1Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L1200-L1207
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewWANCableLinkConfig1ClientsByURL
func NewWANCableLinkConfig1ClientsByURL(loc *url.URL) ([]*WANCableLinkConfig1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANCableLinkConfig_1) if err != nil { return nil, err } return newWANCableLinkConfig1ClientsFromGenericClients(genericClients), nil }
go
func NewWANCableLinkConfig1ClientsByURL(loc *url.URL) ([]*WANCableLinkConfig1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANCableLinkConfig_1) if err != nil { return nil, err } return newWANCableLinkConfig1ClientsFromGenericClients(genericClients), nil }
[ "func", "NewWANCableLinkConfig1ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "WANCableLinkConfig1", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_WANCableLinkConfig_1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newWANCableLinkConfig1ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewWANCableLinkConfig1ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewWANCableLinkConfig1ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L1215-L1221
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewWANCommonInterfaceConfig1Clients
func NewWANCommonInterfaceConfig1Clients() (clients []*WANCommonInterfaceConfig1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_WANCommonInterfaceConfig_1); err != nil { return } clients = newWANCommonInterfaceConfig1ClientsFromGenericClients(genericClients) return }
go
func NewWANCommonInterfaceConfig1Clients() (clients []*WANCommonInterfaceConfig1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_WANCommonInterfaceConfig_1); err != nil { return } clients = newWANCommonInterfaceConfig1ClientsFromGenericClients(genericClients) return }
[ "func", "NewWANCommonInterfaceConfig1Clients", "(", ")", "(", "clients", "[", "]", "*", "WANCommonInterfaceConfig1", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_WANCommonInterfaceConfig_1", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newWANCommonInterfaceConfig1ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewWANCommonInterfaceConfig1Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewWANCommonInterfaceConfig1Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L1538-L1545
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewWANCommonInterfaceConfig1ClientsByURL
func NewWANCommonInterfaceConfig1ClientsByURL(loc *url.URL) ([]*WANCommonInterfaceConfig1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANCommonInterfaceConfig_1) if err != nil { return nil, err } return newWANCommonInterfaceConfig1ClientsFromGenericClients(genericClients), nil }
go
func NewWANCommonInterfaceConfig1ClientsByURL(loc *url.URL) ([]*WANCommonInterfaceConfig1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANCommonInterfaceConfig_1) if err != nil { return nil, err } return newWANCommonInterfaceConfig1ClientsFromGenericClients(genericClients), nil }
[ "func", "NewWANCommonInterfaceConfig1ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "WANCommonInterfaceConfig1", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_WANCommonInterfaceConfig_1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newWANCommonInterfaceConfig1ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewWANCommonInterfaceConfig1ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewWANCommonInterfaceConfig1ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L1553-L1559
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewWANDSLLinkConfig1Clients
func NewWANDSLLinkConfig1Clients() (clients []*WANDSLLinkConfig1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_WANDSLLinkConfig_1); err != nil { return } clients = newWANDSLLinkConfig1ClientsFromGenericClients(genericClients) return }
go
func NewWANDSLLinkConfig1Clients() (clients []*WANDSLLinkConfig1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_WANDSLLinkConfig_1); err != nil { return } clients = newWANDSLLinkConfig1ClientsFromGenericClients(genericClients) return }
[ "func", "NewWANDSLLinkConfig1Clients", "(", ")", "(", "clients", "[", "]", "*", "WANDSLLinkConfig1", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_WANDSLLinkConfig_1", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newWANDSLLinkConfig1ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewWANDSLLinkConfig1Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewWANDSLLinkConfig1Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L1889-L1896
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewWANDSLLinkConfig1ClientsByURL
func NewWANDSLLinkConfig1ClientsByURL(loc *url.URL) ([]*WANDSLLinkConfig1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANDSLLinkConfig_1) if err != nil { return nil, err } return newWANDSLLinkConfig1ClientsFromGenericClients(genericClients), nil }
go
func NewWANDSLLinkConfig1ClientsByURL(loc *url.URL) ([]*WANDSLLinkConfig1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANDSLLinkConfig_1) if err != nil { return nil, err } return newWANDSLLinkConfig1ClientsFromGenericClients(genericClients), nil }
[ "func", "NewWANDSLLinkConfig1ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "WANDSLLinkConfig1", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_WANDSLLinkConfig_1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newWANDSLLinkConfig1ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewWANDSLLinkConfig1ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewWANDSLLinkConfig1ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L1904-L1910
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewWANEthernetLinkConfig1Clients
func NewWANEthernetLinkConfig1Clients() (clients []*WANEthernetLinkConfig1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_WANEthernetLinkConfig_1); err != nil { return } clients = newWANEthernetLinkConfig1ClientsFromGenericClients(genericClients) return }
go
func NewWANEthernetLinkConfig1Clients() (clients []*WANEthernetLinkConfig1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_WANEthernetLinkConfig_1); err != nil { return } clients = newWANEthernetLinkConfig1ClientsFromGenericClients(genericClients) return }
[ "func", "NewWANEthernetLinkConfig1Clients", "(", ")", "(", "clients", "[", "]", "*", "WANEthernetLinkConfig1", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_WANEthernetLinkConfig_1", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newWANEthernetLinkConfig1ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewWANEthernetLinkConfig1Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewWANEthernetLinkConfig1Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L2217-L2224
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewWANEthernetLinkConfig1ClientsByURL
func NewWANEthernetLinkConfig1ClientsByURL(loc *url.URL) ([]*WANEthernetLinkConfig1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANEthernetLinkConfig_1) if err != nil { return nil, err } return newWANEthernetLinkConfig1ClientsFromGenericClients(genericClients), nil }
go
func NewWANEthernetLinkConfig1ClientsByURL(loc *url.URL) ([]*WANEthernetLinkConfig1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANEthernetLinkConfig_1) if err != nil { return nil, err } return newWANEthernetLinkConfig1ClientsFromGenericClients(genericClients), nil }
[ "func", "NewWANEthernetLinkConfig1ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "WANEthernetLinkConfig1", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_WANEthernetLinkConfig_1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newWANEthernetLinkConfig1ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewWANEthernetLinkConfig1ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewWANEthernetLinkConfig1ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L2232-L2238
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewWANIPConnection1ClientsByURL
func NewWANIPConnection1ClientsByURL(loc *url.URL) ([]*WANIPConnection1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANIPConnection_1) if err != nil { return nil, err } return newWANIPConnection1ClientsFromGenericClients(genericClients), nil }
go
func NewWANIPConnection1ClientsByURL(loc *url.URL) ([]*WANIPConnection1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANIPConnection_1) if err != nil { return nil, err } return newWANIPConnection1ClientsFromGenericClients(genericClients), nil }
[ "func", "NewWANIPConnection1ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "WANIPConnection1", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_WANIPConnection_1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newWANIPConnection1ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewWANIPConnection1ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewWANIPConnection1ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L2322-L2328
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewWANIPConnection2Clients
func NewWANIPConnection2Clients() (clients []*WANIPConnection2, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_WANIPConnection_2); err != nil { return } clients = newWANIPConnection2ClientsFromGenericClients(genericClients) return }
go
func NewWANIPConnection2Clients() (clients []*WANIPConnection2, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_WANIPConnection_2); err != nil { return } clients = newWANIPConnection2ClientsFromGenericClients(genericClients) return }
[ "func", "NewWANIPConnection2Clients", "(", ")", "(", "clients", "[", "]", "*", "WANIPConnection2", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_WANIPConnection_2", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newWANIPConnection2ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewWANIPConnection2Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewWANIPConnection2Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L2963-L2970
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewWANIPConnection2ClientsByURL
func NewWANIPConnection2ClientsByURL(loc *url.URL) ([]*WANIPConnection2, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANIPConnection_2) if err != nil { return nil, err } return newWANIPConnection2ClientsFromGenericClients(genericClients), nil }
go
func NewWANIPConnection2ClientsByURL(loc *url.URL) ([]*WANIPConnection2, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANIPConnection_2) if err != nil { return nil, err } return newWANIPConnection2ClientsFromGenericClients(genericClients), nil }
[ "func", "NewWANIPConnection2ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "WANIPConnection2", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_WANIPConnection_2", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newWANIPConnection2ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewWANIPConnection2ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewWANIPConnection2ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L2978-L2984
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewWANIPv6FirewallControl1Clients
func NewWANIPv6FirewallControl1Clients() (clients []*WANIPv6FirewallControl1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_WANIPv6FirewallControl_1); err != nil { return } clients = newWANIPv6FirewallControl1ClientsFromGenericClients(genericClients) return }
go
func NewWANIPv6FirewallControl1Clients() (clients []*WANIPv6FirewallControl1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_WANIPv6FirewallControl_1); err != nil { return } clients = newWANIPv6FirewallControl1ClientsFromGenericClients(genericClients) return }
[ "func", "NewWANIPv6FirewallControl1Clients", "(", ")", "(", "clients", "[", "]", "*", "WANIPv6FirewallControl1", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_WANIPv6FirewallControl_1", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newWANIPv6FirewallControl1ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewWANIPv6FirewallControl1Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewWANIPv6FirewallControl1Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L3774-L3781
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewWANIPv6FirewallControl1ClientsByURL
func NewWANIPv6FirewallControl1ClientsByURL(loc *url.URL) ([]*WANIPv6FirewallControl1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANIPv6FirewallControl_1) if err != nil { return nil, err } return newWANIPv6FirewallControl1ClientsFromGenericClients(genericClients), nil }
go
func NewWANIPv6FirewallControl1ClientsByURL(loc *url.URL) ([]*WANIPv6FirewallControl1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANIPv6FirewallControl_1) if err != nil { return nil, err } return newWANIPv6FirewallControl1ClientsFromGenericClients(genericClients), nil }
[ "func", "NewWANIPv6FirewallControl1ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "WANIPv6FirewallControl1", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_WANIPv6FirewallControl_1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newWANIPv6FirewallControl1ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewWANIPv6FirewallControl1ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewWANIPv6FirewallControl1ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L3789-L3795
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewWANPOTSLinkConfig1Clients
func NewWANPOTSLinkConfig1Clients() (clients []*WANPOTSLinkConfig1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_WANPOTSLinkConfig_1); err != nil { return } clients = newWANPOTSLinkConfig1ClientsFromGenericClients(genericClients) return }
go
func NewWANPOTSLinkConfig1Clients() (clients []*WANPOTSLinkConfig1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_WANPOTSLinkConfig_1); err != nil { return } clients = newWANPOTSLinkConfig1ClientsFromGenericClients(genericClients) return }
[ "func", "NewWANPOTSLinkConfig1Clients", "(", ")", "(", "clients", "[", "]", "*", "WANPOTSLinkConfig1", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_WANPOTSLinkConfig_1", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newWANPOTSLinkConfig1ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewWANPOTSLinkConfig1Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewWANPOTSLinkConfig1Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L4090-L4097
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewWANPOTSLinkConfig1ClientsByURL
func NewWANPOTSLinkConfig1ClientsByURL(loc *url.URL) ([]*WANPOTSLinkConfig1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANPOTSLinkConfig_1) if err != nil { return nil, err } return newWANPOTSLinkConfig1ClientsFromGenericClients(genericClients), nil }
go
func NewWANPOTSLinkConfig1ClientsByURL(loc *url.URL) ([]*WANPOTSLinkConfig1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANPOTSLinkConfig_1) if err != nil { return nil, err } return newWANPOTSLinkConfig1ClientsFromGenericClients(genericClients), nil }
[ "func", "NewWANPOTSLinkConfig1ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "WANPOTSLinkConfig1", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_WANPOTSLinkConfig_1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newWANPOTSLinkConfig1ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewWANPOTSLinkConfig1ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewWANPOTSLinkConfig1ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L4105-L4111
train
huin/goupnp
dcps/internetgateway2/internetgateway2.go
NewWANPPPConnection1ClientsByURL
func NewWANPPPConnection1ClientsByURL(loc *url.URL) ([]*WANPPPConnection1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANPPPConnection_1) if err != nil { return nil, err } return newWANPPPConnection1ClientsFromGenericClients(genericClients), nil }
go
func NewWANPPPConnection1ClientsByURL(loc *url.URL) ([]*WANPPPConnection1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANPPPConnection_1) if err != nil { return nil, err } return newWANPPPConnection1ClientsFromGenericClients(genericClients), nil }
[ "func", "NewWANPPPConnection1ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "WANPPPConnection1", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_WANPPPConnection_1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newWANPPPConnection1ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewWANPPPConnection1ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewWANPPPConnection1ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/internetgateway2/internetgateway2.go#L4432-L4438
train
huin/goupnp
cmd/goupnpdcpgen/dcp.go
extractURNParts
func extractURNParts(urn, expectedPrefix string) (*URNParts, error) { if !strings.HasPrefix(urn, expectedPrefix) { return nil, fmt.Errorf("%q does not have expected prefix %q", urn, expectedPrefix) } parts := strings.SplitN(strings.TrimPrefix(urn, expectedPrefix), ":", 2) if len(parts) != 2 { return nil, fmt.Errorf("%q does not have a name and version", urn) } name, version := parts[0], parts[1] return &URNParts{urn, name, version}, nil }
go
func extractURNParts(urn, expectedPrefix string) (*URNParts, error) { if !strings.HasPrefix(urn, expectedPrefix) { return nil, fmt.Errorf("%q does not have expected prefix %q", urn, expectedPrefix) } parts := strings.SplitN(strings.TrimPrefix(urn, expectedPrefix), ":", 2) if len(parts) != 2 { return nil, fmt.Errorf("%q does not have a name and version", urn) } name, version := parts[0], parts[1] return &URNParts{urn, name, version}, nil }
[ "func", "extractURNParts", "(", "urn", ",", "expectedPrefix", "string", ")", "(", "*", "URNParts", ",", "error", ")", "{", "if", "!", "strings", ".", "HasPrefix", "(", "urn", ",", "expectedPrefix", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "urn", ",", "expectedPrefix", ")", "\n", "}", "\n", "parts", ":=", "strings", ".", "SplitN", "(", "strings", ".", "TrimPrefix", "(", "urn", ",", "expectedPrefix", ")", ",", "\"", "\"", ",", "2", ")", "\n", "if", "len", "(", "parts", ")", "!=", "2", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "urn", ")", "\n", "}", "\n", "name", ",", "version", ":=", "parts", "[", "0", "]", ",", "parts", "[", "1", "]", "\n", "return", "&", "URNParts", "{", "urn", ",", "name", ",", "version", "}", ",", "nil", "\n", "}" ]
// extractURNParts extracts the name and version from a URN string.
[ "extractURNParts", "extracts", "the", "name", "and", "version", "from", "a", "URN", "string", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/cmd/goupnpdcpgen/dcp.go#L212-L222
train
huin/goupnp
httpu/serve.go
Serve
func (srv *Server) Serve(l net.PacketConn) error { maxMessageBytes := DefaultMaxMessageBytes if srv.MaxMessageBytes != 0 { maxMessageBytes = srv.MaxMessageBytes } for { buf := make([]byte, maxMessageBytes) n, peerAddr, err := l.ReadFrom(buf) if err != nil { return err } buf = buf[:n] go func(buf []byte, peerAddr net.Addr) { // At least one router's UPnP implementation has added a trailing space // after "HTTP/1.1" - trim it. buf = trailingWhitespaceRx.ReplaceAllLiteral(buf, crlf) req, err := http.ReadRequest(bufio.NewReader(bytes.NewBuffer(buf))) if err != nil { log.Printf("httpu: Failed to parse request: %v", err) return } req.RemoteAddr = peerAddr.String() srv.Handler.ServeMessage(req) // No need to call req.Body.Close - underlying reader is bytes.Buffer. }(buf, peerAddr) } }
go
func (srv *Server) Serve(l net.PacketConn) error { maxMessageBytes := DefaultMaxMessageBytes if srv.MaxMessageBytes != 0 { maxMessageBytes = srv.MaxMessageBytes } for { buf := make([]byte, maxMessageBytes) n, peerAddr, err := l.ReadFrom(buf) if err != nil { return err } buf = buf[:n] go func(buf []byte, peerAddr net.Addr) { // At least one router's UPnP implementation has added a trailing space // after "HTTP/1.1" - trim it. buf = trailingWhitespaceRx.ReplaceAllLiteral(buf, crlf) req, err := http.ReadRequest(bufio.NewReader(bytes.NewBuffer(buf))) if err != nil { log.Printf("httpu: Failed to parse request: %v", err) return } req.RemoteAddr = peerAddr.String() srv.Handler.ServeMessage(req) // No need to call req.Body.Close - underlying reader is bytes.Buffer. }(buf, peerAddr) } }
[ "func", "(", "srv", "*", "Server", ")", "Serve", "(", "l", "net", ".", "PacketConn", ")", "error", "{", "maxMessageBytes", ":=", "DefaultMaxMessageBytes", "\n", "if", "srv", ".", "MaxMessageBytes", "!=", "0", "{", "maxMessageBytes", "=", "srv", ".", "MaxMessageBytes", "\n", "}", "\n", "for", "{", "buf", ":=", "make", "(", "[", "]", "byte", ",", "maxMessageBytes", ")", "\n", "n", ",", "peerAddr", ",", "err", ":=", "l", ".", "ReadFrom", "(", "buf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "buf", "=", "buf", "[", ":", "n", "]", "\n\n", "go", "func", "(", "buf", "[", "]", "byte", ",", "peerAddr", "net", ".", "Addr", ")", "{", "// At least one router's UPnP implementation has added a trailing space", "// after \"HTTP/1.1\" - trim it.", "buf", "=", "trailingWhitespaceRx", ".", "ReplaceAllLiteral", "(", "buf", ",", "crlf", ")", "\n\n", "req", ",", "err", ":=", "http", ".", "ReadRequest", "(", "bufio", ".", "NewReader", "(", "bytes", ".", "NewBuffer", "(", "buf", ")", ")", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "\n", "}", "\n", "req", ".", "RemoteAddr", "=", "peerAddr", ".", "String", "(", ")", "\n", "srv", ".", "Handler", ".", "ServeMessage", "(", "req", ")", "\n", "// No need to call req.Body.Close - underlying reader is bytes.Buffer.", "}", "(", "buf", ",", "peerAddr", ")", "\n", "}", "\n", "}" ]
// Serve messages received on the given packet listener to the srv.Handler.
[ "Serve", "messages", "received", "on", "the", "given", "packet", "listener", "to", "the", "srv", ".", "Handler", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/httpu/serve.go#L71-L99
train
huin/goupnp
httpu/serve.go
Serve
func Serve(l net.PacketConn, handler Handler) error { srv := Server{ Handler: handler, MaxMessageBytes: DefaultMaxMessageBytes, } return srv.Serve(l) }
go
func Serve(l net.PacketConn, handler Handler) error { srv := Server{ Handler: handler, MaxMessageBytes: DefaultMaxMessageBytes, } return srv.Serve(l) }
[ "func", "Serve", "(", "l", "net", ".", "PacketConn", ",", "handler", "Handler", ")", "error", "{", "srv", ":=", "Server", "{", "Handler", ":", "handler", ",", "MaxMessageBytes", ":", "DefaultMaxMessageBytes", ",", "}", "\n", "return", "srv", ".", "Serve", "(", "l", ")", "\n", "}" ]
// Serve messages received on the given packet listener to the given handler.
[ "Serve", "messages", "received", "on", "the", "given", "packet", "listener", "to", "the", "given", "handler", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/httpu/serve.go#L102-L108
train
huin/goupnp
dcps/av1/av1.go
NewAVTransport1Clients
func NewAVTransport1Clients() (clients []*AVTransport1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_AVTransport_1); err != nil { return } clients = newAVTransport1ClientsFromGenericClients(genericClients) return }
go
func NewAVTransport1Clients() (clients []*AVTransport1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_AVTransport_1); err != nil { return } clients = newAVTransport1ClientsFromGenericClients(genericClients) return }
[ "func", "NewAVTransport1Clients", "(", ")", "(", "clients", "[", "]", "*", "AVTransport1", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_AVTransport_1", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newAVTransport1ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewAVTransport1Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewAVTransport1Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L54-L61
train
huin/goupnp
dcps/av1/av1.go
NewAVTransport1ClientsByURL
func NewAVTransport1ClientsByURL(loc *url.URL) ([]*AVTransport1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_AVTransport_1) if err != nil { return nil, err } return newAVTransport1ClientsFromGenericClients(genericClients), nil }
go
func NewAVTransport1ClientsByURL(loc *url.URL) ([]*AVTransport1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_AVTransport_1) if err != nil { return nil, err } return newAVTransport1ClientsFromGenericClients(genericClients), nil }
[ "func", "NewAVTransport1ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "AVTransport1", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_AVTransport_1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newAVTransport1ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewAVTransport1ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewAVTransport1ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L69-L75
train
huin/goupnp
dcps/av1/av1.go
NewAVTransport2Clients
func NewAVTransport2Clients() (clients []*AVTransport2, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_AVTransport_2); err != nil { return } clients = newAVTransport2ClientsFromGenericClients(genericClients) return }
go
func NewAVTransport2Clients() (clients []*AVTransport2, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_AVTransport_2); err != nil { return } clients = newAVTransport2ClientsFromGenericClients(genericClients) return }
[ "func", "NewAVTransport2Clients", "(", ")", "(", "clients", "[", "]", "*", "AVTransport2", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_AVTransport_2", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newAVTransport2ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewAVTransport2Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewAVTransport2Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L737-L744
train
huin/goupnp
dcps/av1/av1.go
NewAVTransport2ClientsByURL
func NewAVTransport2ClientsByURL(loc *url.URL) ([]*AVTransport2, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_AVTransport_2) if err != nil { return nil, err } return newAVTransport2ClientsFromGenericClients(genericClients), nil }
go
func NewAVTransport2ClientsByURL(loc *url.URL) ([]*AVTransport2, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_AVTransport_2) if err != nil { return nil, err } return newAVTransport2ClientsFromGenericClients(genericClients), nil }
[ "func", "NewAVTransport2ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "AVTransport2", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_AVTransport_2", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newAVTransport2ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewAVTransport2ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewAVTransport2ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L752-L758
train
huin/goupnp
dcps/av1/av1.go
NewConnectionManager1Clients
func NewConnectionManager1Clients() (clients []*ConnectionManager1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_ConnectionManager_1); err != nil { return } clients = newConnectionManager1ClientsFromGenericClients(genericClients) return }
go
func NewConnectionManager1Clients() (clients []*ConnectionManager1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_ConnectionManager_1); err != nil { return } clients = newConnectionManager1ClientsFromGenericClients(genericClients) return }
[ "func", "NewConnectionManager1Clients", "(", ")", "(", "clients", "[", "]", "*", "ConnectionManager1", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_ConnectionManager_1", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newConnectionManager1ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewConnectionManager1Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewConnectionManager1Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L1610-L1617
train
huin/goupnp
dcps/av1/av1.go
NewConnectionManager1ClientsByURL
func NewConnectionManager1ClientsByURL(loc *url.URL) ([]*ConnectionManager1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ConnectionManager_1) if err != nil { return nil, err } return newConnectionManager1ClientsFromGenericClients(genericClients), nil }
go
func NewConnectionManager1ClientsByURL(loc *url.URL) ([]*ConnectionManager1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ConnectionManager_1) if err != nil { return nil, err } return newConnectionManager1ClientsFromGenericClients(genericClients), nil }
[ "func", "NewConnectionManager1ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "ConnectionManager1", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_ConnectionManager_1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newConnectionManager1ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewConnectionManager1ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewConnectionManager1ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L1625-L1631
train
huin/goupnp
dcps/av1/av1.go
NewConnectionManager2Clients
func NewConnectionManager2Clients() (clients []*ConnectionManager2, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_ConnectionManager_2); err != nil { return } clients = newConnectionManager2ClientsFromGenericClients(genericClients) return }
go
func NewConnectionManager2Clients() (clients []*ConnectionManager2, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_ConnectionManager_2); err != nil { return } clients = newConnectionManager2ClientsFromGenericClients(genericClients) return }
[ "func", "NewConnectionManager2Clients", "(", ")", "(", "clients", "[", "]", "*", "ConnectionManager2", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_ConnectionManager_2", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newConnectionManager2ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewConnectionManager2Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewConnectionManager2Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L1869-L1876
train
huin/goupnp
dcps/av1/av1.go
NewConnectionManager2ClientsByURL
func NewConnectionManager2ClientsByURL(loc *url.URL) ([]*ConnectionManager2, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ConnectionManager_2) if err != nil { return nil, err } return newConnectionManager2ClientsFromGenericClients(genericClients), nil }
go
func NewConnectionManager2ClientsByURL(loc *url.URL) ([]*ConnectionManager2, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ConnectionManager_2) if err != nil { return nil, err } return newConnectionManager2ClientsFromGenericClients(genericClients), nil }
[ "func", "NewConnectionManager2ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "ConnectionManager2", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_ConnectionManager_2", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newConnectionManager2ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewConnectionManager2ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewConnectionManager2ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L1884-L1890
train
huin/goupnp
dcps/av1/av1.go
NewContentDirectory1Clients
func NewContentDirectory1Clients() (clients []*ContentDirectory1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_ContentDirectory_1); err != nil { return } clients = newContentDirectory1ClientsFromGenericClients(genericClients) return }
go
func NewContentDirectory1Clients() (clients []*ContentDirectory1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_ContentDirectory_1); err != nil { return } clients = newContentDirectory1ClientsFromGenericClients(genericClients) return }
[ "func", "NewContentDirectory1Clients", "(", ")", "(", "clients", "[", "]", "*", "ContentDirectory1", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_ContentDirectory_1", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newContentDirectory1ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewContentDirectory1Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewContentDirectory1Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L2128-L2135
train
huin/goupnp
dcps/av1/av1.go
NewContentDirectory1ClientsByURL
func NewContentDirectory1ClientsByURL(loc *url.URL) ([]*ContentDirectory1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ContentDirectory_1) if err != nil { return nil, err } return newContentDirectory1ClientsFromGenericClients(genericClients), nil }
go
func NewContentDirectory1ClientsByURL(loc *url.URL) ([]*ContentDirectory1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ContentDirectory_1) if err != nil { return nil, err } return newContentDirectory1ClientsFromGenericClients(genericClients), nil }
[ "func", "NewContentDirectory1ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "ContentDirectory1", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_ContentDirectory_1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newContentDirectory1ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewContentDirectory1ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewContentDirectory1ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L2143-L2149
train
huin/goupnp
dcps/av1/av1.go
NewContentDirectory2Clients
func NewContentDirectory2Clients() (clients []*ContentDirectory2, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_ContentDirectory_2); err != nil { return } clients = newContentDirectory2ClientsFromGenericClients(genericClients) return }
go
func NewContentDirectory2Clients() (clients []*ContentDirectory2, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_ContentDirectory_2); err != nil { return } clients = newContentDirectory2ClientsFromGenericClients(genericClients) return }
[ "func", "NewContentDirectory2Clients", "(", ")", "(", "clients", "[", "]", "*", "ContentDirectory2", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_ContentDirectory_2", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newContentDirectory2ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewContentDirectory2Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewContentDirectory2Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L2696-L2703
train
huin/goupnp
dcps/av1/av1.go
NewContentDirectory2ClientsByURL
func NewContentDirectory2ClientsByURL(loc *url.URL) ([]*ContentDirectory2, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ContentDirectory_2) if err != nil { return nil, err } return newContentDirectory2ClientsFromGenericClients(genericClients), nil }
go
func NewContentDirectory2ClientsByURL(loc *url.URL) ([]*ContentDirectory2, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ContentDirectory_2) if err != nil { return nil, err } return newContentDirectory2ClientsFromGenericClients(genericClients), nil }
[ "func", "NewContentDirectory2ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "ContentDirectory2", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_ContentDirectory_2", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newContentDirectory2ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewContentDirectory2ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewContentDirectory2ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L2711-L2717
train
huin/goupnp
dcps/av1/av1.go
NewContentDirectory3Clients
func NewContentDirectory3Clients() (clients []*ContentDirectory3, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_ContentDirectory_3); err != nil { return } clients = newContentDirectory3ClientsFromGenericClients(genericClients) return }
go
func NewContentDirectory3Clients() (clients []*ContentDirectory3, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_ContentDirectory_3); err != nil { return } clients = newContentDirectory3ClientsFromGenericClients(genericClients) return }
[ "func", "NewContentDirectory3Clients", "(", ")", "(", "clients", "[", "]", "*", "ContentDirectory3", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_ContentDirectory_3", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newContentDirectory3ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewContentDirectory3Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewContentDirectory3Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L3351-L3358
train
huin/goupnp
dcps/av1/av1.go
NewContentDirectory3ClientsByURL
func NewContentDirectory3ClientsByURL(loc *url.URL) ([]*ContentDirectory3, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ContentDirectory_3) if err != nil { return nil, err } return newContentDirectory3ClientsFromGenericClients(genericClients), nil }
go
func NewContentDirectory3ClientsByURL(loc *url.URL) ([]*ContentDirectory3, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ContentDirectory_3) if err != nil { return nil, err } return newContentDirectory3ClientsFromGenericClients(genericClients), nil }
[ "func", "NewContentDirectory3ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "ContentDirectory3", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_ContentDirectory_3", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newContentDirectory3ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewContentDirectory3ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewContentDirectory3ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L3366-L3372
train
huin/goupnp
dcps/av1/av1.go
NewRenderingControl1Clients
func NewRenderingControl1Clients() (clients []*RenderingControl1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_RenderingControl_1); err != nil { return } clients = newRenderingControl1ClientsFromGenericClients(genericClients) return }
go
func NewRenderingControl1Clients() (clients []*RenderingControl1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_RenderingControl_1); err != nil { return } clients = newRenderingControl1ClientsFromGenericClients(genericClients) return }
[ "func", "NewRenderingControl1Clients", "(", ")", "(", "clients", "[", "]", "*", "RenderingControl1", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_RenderingControl_1", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newRenderingControl1ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewRenderingControl1Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewRenderingControl1Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L4101-L4108
train
huin/goupnp
dcps/av1/av1.go
NewRenderingControl1ClientsByURL
func NewRenderingControl1ClientsByURL(loc *url.URL) ([]*RenderingControl1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_RenderingControl_1) if err != nil { return nil, err } return newRenderingControl1ClientsFromGenericClients(genericClients), nil }
go
func NewRenderingControl1ClientsByURL(loc *url.URL) ([]*RenderingControl1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_RenderingControl_1) if err != nil { return nil, err } return newRenderingControl1ClientsFromGenericClients(genericClients), nil }
[ "func", "NewRenderingControl1ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "RenderingControl1", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_RenderingControl_1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newRenderingControl1ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewRenderingControl1ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewRenderingControl1ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L4116-L4122
train
huin/goupnp
dcps/av1/av1.go
NewRenderingControl2Clients
func NewRenderingControl2Clients() (clients []*RenderingControl2, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_RenderingControl_2); err != nil { return } clients = newRenderingControl2ClientsFromGenericClients(genericClients) return }
go
func NewRenderingControl2Clients() (clients []*RenderingControl2, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_RenderingControl_2); err != nil { return } clients = newRenderingControl2ClientsFromGenericClients(genericClients) return }
[ "func", "NewRenderingControl2Clients", "(", ")", "(", "clients", "[", "]", "*", "RenderingControl2", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_RenderingControl_2", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newRenderingControl2ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewRenderingControl2Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewRenderingControl2Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L5424-L5431
train
huin/goupnp
dcps/av1/av1.go
NewRenderingControl2ClientsByURL
func NewRenderingControl2ClientsByURL(loc *url.URL) ([]*RenderingControl2, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_RenderingControl_2) if err != nil { return nil, err } return newRenderingControl2ClientsFromGenericClients(genericClients), nil }
go
func NewRenderingControl2ClientsByURL(loc *url.URL) ([]*RenderingControl2, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_RenderingControl_2) if err != nil { return nil, err } return newRenderingControl2ClientsFromGenericClients(genericClients), nil }
[ "func", "NewRenderingControl2ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "RenderingControl2", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_RenderingControl_2", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newRenderingControl2ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewRenderingControl2ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewRenderingControl2ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L5439-L5445
train
huin/goupnp
dcps/av1/av1.go
NewScheduledRecording1Clients
func NewScheduledRecording1Clients() (clients []*ScheduledRecording1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_ScheduledRecording_1); err != nil { return } clients = newScheduledRecording1ClientsFromGenericClients(genericClients) return }
go
func NewScheduledRecording1Clients() (clients []*ScheduledRecording1, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_ScheduledRecording_1); err != nil { return } clients = newScheduledRecording1ClientsFromGenericClients(genericClients) return }
[ "func", "NewScheduledRecording1Clients", "(", ")", "(", "clients", "[", "]", "*", "ScheduledRecording1", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_ScheduledRecording_1", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newScheduledRecording1ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewScheduledRecording1Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewScheduledRecording1Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L6838-L6845
train
huin/goupnp
dcps/av1/av1.go
NewScheduledRecording1ClientsByURL
func NewScheduledRecording1ClientsByURL(loc *url.URL) ([]*ScheduledRecording1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ScheduledRecording_1) if err != nil { return nil, err } return newScheduledRecording1ClientsFromGenericClients(genericClients), nil }
go
func NewScheduledRecording1ClientsByURL(loc *url.URL) ([]*ScheduledRecording1, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ScheduledRecording_1) if err != nil { return nil, err } return newScheduledRecording1ClientsFromGenericClients(genericClients), nil }
[ "func", "NewScheduledRecording1ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "ScheduledRecording1", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_ScheduledRecording_1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newScheduledRecording1ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewScheduledRecording1ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewScheduledRecording1ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L6853-L6859
train
huin/goupnp
dcps/av1/av1.go
NewScheduledRecording2Clients
func NewScheduledRecording2Clients() (clients []*ScheduledRecording2, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_ScheduledRecording_2); err != nil { return } clients = newScheduledRecording2ClientsFromGenericClients(genericClients) return }
go
func NewScheduledRecording2Clients() (clients []*ScheduledRecording2, errors []error, err error) { var genericClients []goupnp.ServiceClient if genericClients, errors, err = goupnp.NewServiceClients(URN_ScheduledRecording_2); err != nil { return } clients = newScheduledRecording2ClientsFromGenericClients(genericClients) return }
[ "func", "NewScheduledRecording2Clients", "(", ")", "(", "clients", "[", "]", "*", "ScheduledRecording2", ",", "errors", "[", "]", "error", ",", "err", "error", ")", "{", "var", "genericClients", "[", "]", "goupnp", ".", "ServiceClient", "\n", "if", "genericClients", ",", "errors", ",", "err", "=", "goupnp", ".", "NewServiceClients", "(", "URN_ScheduledRecording_2", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "clients", "=", "newScheduledRecording2ClientsFromGenericClients", "(", "genericClients", ")", "\n", "return", "\n", "}" ]
// NewScheduledRecording2Clients discovers instances of the service on the network, // and returns clients to any that are found. errors will contain an error for // any devices that replied but which could not be queried, and err will be set // if the discovery process failed outright. // // This is a typical entry calling point into this package.
[ "NewScheduledRecording2Clients", "discovers", "instances", "of", "the", "service", "on", "the", "network", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "errors", "will", "contain", "an", "error", "for", "any", "devices", "that", "replied", "but", "which", "could", "not", "be", "queried", "and", "err", "will", "be", "set", "if", "the", "discovery", "process", "failed", "outright", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L7513-L7520
train
huin/goupnp
dcps/av1/av1.go
NewScheduledRecording2ClientsByURL
func NewScheduledRecording2ClientsByURL(loc *url.URL) ([]*ScheduledRecording2, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ScheduledRecording_2) if err != nil { return nil, err } return newScheduledRecording2ClientsFromGenericClients(genericClients), nil }
go
func NewScheduledRecording2ClientsByURL(loc *url.URL) ([]*ScheduledRecording2, error) { genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ScheduledRecording_2) if err != nil { return nil, err } return newScheduledRecording2ClientsFromGenericClients(genericClients), nil }
[ "func", "NewScheduledRecording2ClientsByURL", "(", "loc", "*", "url", ".", "URL", ")", "(", "[", "]", "*", "ScheduledRecording2", ",", "error", ")", "{", "genericClients", ",", "err", ":=", "goupnp", ".", "NewServiceClientsByURL", "(", "loc", ",", "URN_ScheduledRecording_2", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newScheduledRecording2ClientsFromGenericClients", "(", "genericClients", ")", ",", "nil", "\n", "}" ]
// NewScheduledRecording2ClientsByURL discovers instances of the service at the given // URL, and returns clients to any that are found. An error is returned if // there was an error probing the service. // // This is a typical entry calling point into this package when reusing an // previously discovered service URL.
[ "NewScheduledRecording2ClientsByURL", "discovers", "instances", "of", "the", "service", "at", "the", "given", "URL", "and", "returns", "clients", "to", "any", "that", "are", "found", ".", "An", "error", "is", "returned", "if", "there", "was", "an", "error", "probing", "the", "service", ".", "This", "is", "a", "typical", "entry", "calling", "point", "into", "this", "package", "when", "reusing", "an", "previously", "discovered", "service", "URL", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/dcps/av1/av1.go#L7528-L7534
train
huin/goupnp
ssdp/registry.go
NewServerAndRegistry
func NewServerAndRegistry() (*httpu.Server, *Registry) { reg := NewRegistry() srv := &httpu.Server{ Addr: ssdpUDP4Addr, Multicast: true, Handler: reg, } return srv, reg }
go
func NewServerAndRegistry() (*httpu.Server, *Registry) { reg := NewRegistry() srv := &httpu.Server{ Addr: ssdpUDP4Addr, Multicast: true, Handler: reg, } return srv, reg }
[ "func", "NewServerAndRegistry", "(", ")", "(", "*", "httpu", ".", "Server", ",", "*", "Registry", ")", "{", "reg", ":=", "NewRegistry", "(", ")", "\n", "srv", ":=", "&", "httpu", ".", "Server", "{", "Addr", ":", "ssdpUDP4Addr", ",", "Multicast", ":", "true", ",", "Handler", ":", "reg", ",", "}", "\n", "return", "srv", ",", "reg", "\n", "}" ]
// NewServerAndRegistry is a convenience function to create a registry, and an // httpu server to pass it messages. Call ListenAndServe on the server for // messages to be processed.
[ "NewServerAndRegistry", "is", "a", "convenience", "function", "to", "create", "a", "registry", "and", "an", "httpu", "server", "to", "pass", "it", "messages", ".", "Call", "ListenAndServe", "on", "the", "server", "for", "messages", "to", "be", "processed", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/ssdp/registry.go#L183-L191
train
huin/goupnp
device.go
SetURLBase
func (root *RootDevice) SetURLBase(urlBase *url.URL) { root.URLBase = *urlBase root.URLBaseStr = urlBase.String() root.Device.SetURLBase(urlBase) }
go
func (root *RootDevice) SetURLBase(urlBase *url.URL) { root.URLBase = *urlBase root.URLBaseStr = urlBase.String() root.Device.SetURLBase(urlBase) }
[ "func", "(", "root", "*", "RootDevice", ")", "SetURLBase", "(", "urlBase", "*", "url", ".", "URL", ")", "{", "root", ".", "URLBase", "=", "*", "urlBase", "\n", "root", ".", "URLBaseStr", "=", "urlBase", ".", "String", "(", ")", "\n", "root", ".", "Device", ".", "SetURLBase", "(", "urlBase", ")", "\n", "}" ]
// SetURLBase sets the URLBase for the RootDevice and its underlying components.
[ "SetURLBase", "sets", "the", "URLBase", "for", "the", "RootDevice", "and", "its", "underlying", "components", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/device.go#L31-L35
train
huin/goupnp
device.go
VisitDevices
func (device *Device) VisitDevices(visitor func(*Device)) { visitor(device) for i := range device.Devices { device.Devices[i].VisitDevices(visitor) } }
go
func (device *Device) VisitDevices(visitor func(*Device)) { visitor(device) for i := range device.Devices { device.Devices[i].VisitDevices(visitor) } }
[ "func", "(", "device", "*", "Device", ")", "VisitDevices", "(", "visitor", "func", "(", "*", "Device", ")", ")", "{", "visitor", "(", "device", ")", "\n", "for", "i", ":=", "range", "device", ".", "Devices", "{", "device", ".", "Devices", "[", "i", "]", ".", "VisitDevices", "(", "visitor", ")", "\n", "}", "\n", "}" ]
// VisitDevices calls visitor for the device, and all its descendent devices.
[ "VisitDevices", "calls", "visitor", "for", "the", "device", "and", "all", "its", "descendent", "devices", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/device.go#L66-L71
train
huin/goupnp
device.go
VisitServices
func (device *Device) VisitServices(visitor func(*Service)) { device.VisitDevices(func(d *Device) { for i := range d.Services { visitor(&d.Services[i]) } }) }
go
func (device *Device) VisitServices(visitor func(*Service)) { device.VisitDevices(func(d *Device) { for i := range d.Services { visitor(&d.Services[i]) } }) }
[ "func", "(", "device", "*", "Device", ")", "VisitServices", "(", "visitor", "func", "(", "*", "Service", ")", ")", "{", "device", ".", "VisitDevices", "(", "func", "(", "d", "*", "Device", ")", "{", "for", "i", ":=", "range", "d", ".", "Services", "{", "visitor", "(", "&", "d", ".", "Services", "[", "i", "]", ")", "\n", "}", "\n", "}", ")", "\n", "}" ]
// VisitServices calls visitor for all Services under the device and all its // descendent devices.
[ "VisitServices", "calls", "visitor", "for", "all", "Services", "under", "the", "device", "and", "all", "its", "descendent", "devices", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/device.go#L75-L81
train
huin/goupnp
device.go
SetURLBase
func (device *Device) SetURLBase(urlBase *url.URL) { device.ManufacturerURL.SetURLBase(urlBase) device.ModelURL.SetURLBase(urlBase) device.PresentationURL.SetURLBase(urlBase) for i := range device.Icons { device.Icons[i].SetURLBase(urlBase) } for i := range device.Services { device.Services[i].SetURLBase(urlBase) } for i := range device.Devices { device.Devices[i].SetURLBase(urlBase) } }
go
func (device *Device) SetURLBase(urlBase *url.URL) { device.ManufacturerURL.SetURLBase(urlBase) device.ModelURL.SetURLBase(urlBase) device.PresentationURL.SetURLBase(urlBase) for i := range device.Icons { device.Icons[i].SetURLBase(urlBase) } for i := range device.Services { device.Services[i].SetURLBase(urlBase) } for i := range device.Devices { device.Devices[i].SetURLBase(urlBase) } }
[ "func", "(", "device", "*", "Device", ")", "SetURLBase", "(", "urlBase", "*", "url", ".", "URL", ")", "{", "device", ".", "ManufacturerURL", ".", "SetURLBase", "(", "urlBase", ")", "\n", "device", ".", "ModelURL", ".", "SetURLBase", "(", "urlBase", ")", "\n", "device", ".", "PresentationURL", ".", "SetURLBase", "(", "urlBase", ")", "\n", "for", "i", ":=", "range", "device", ".", "Icons", "{", "device", ".", "Icons", "[", "i", "]", ".", "SetURLBase", "(", "urlBase", ")", "\n", "}", "\n", "for", "i", ":=", "range", "device", ".", "Services", "{", "device", ".", "Services", "[", "i", "]", ".", "SetURLBase", "(", "urlBase", ")", "\n", "}", "\n", "for", "i", ":=", "range", "device", ".", "Devices", "{", "device", ".", "Devices", "[", "i", "]", ".", "SetURLBase", "(", "urlBase", ")", "\n", "}", "\n", "}" ]
// SetURLBase sets the URLBase for the Device and its underlying components.
[ "SetURLBase", "sets", "the", "URLBase", "for", "the", "Device", "and", "its", "underlying", "components", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/device.go#L96-L109
train
huin/goupnp
device.go
SetURLBase
func (icon *Icon) SetURLBase(url *url.URL) { icon.URL.SetURLBase(url) }
go
func (icon *Icon) SetURLBase(url *url.URL) { icon.URL.SetURLBase(url) }
[ "func", "(", "icon", "*", "Icon", ")", "SetURLBase", "(", "url", "*", "url", ".", "URL", ")", "{", "icon", ".", "URL", ".", "SetURLBase", "(", "url", ")", "\n", "}" ]
// SetURLBase sets the URLBase for the Icon.
[ "SetURLBase", "sets", "the", "URLBase", "for", "the", "Icon", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/device.go#L126-L128
train
huin/goupnp
device.go
SetURLBase
func (srv *Service) SetURLBase(urlBase *url.URL) { srv.SCPDURL.SetURLBase(urlBase) srv.ControlURL.SetURLBase(urlBase) srv.EventSubURL.SetURLBase(urlBase) }
go
func (srv *Service) SetURLBase(urlBase *url.URL) { srv.SCPDURL.SetURLBase(urlBase) srv.ControlURL.SetURLBase(urlBase) srv.EventSubURL.SetURLBase(urlBase) }
[ "func", "(", "srv", "*", "Service", ")", "SetURLBase", "(", "urlBase", "*", "url", ".", "URL", ")", "{", "srv", ".", "SCPDURL", ".", "SetURLBase", "(", "urlBase", ")", "\n", "srv", ".", "ControlURL", ".", "SetURLBase", "(", "urlBase", ")", "\n", "srv", ".", "EventSubURL", ".", "SetURLBase", "(", "urlBase", ")", "\n", "}" ]
// SetURLBase sets the URLBase for the Service.
[ "SetURLBase", "sets", "the", "URLBase", "for", "the", "Service", "." ]
656e61dfadd241c7cbdd22a023fa81ecb6860ea8
https://github.com/huin/goupnp/blob/656e61dfadd241c7cbdd22a023fa81ecb6860ea8/device.go#L140-L144
train
apcera/libretto
virtualmachine/vsphere/util.go
GetDatacenter
func GetDatacenter(vm *VM) (*mo.Datacenter, error) { dcList, err := vm.finder.DatacenterList(vm.ctx, "*") if err != nil { return nil, NewErrorObjectNotFound(err, vm.Datacenter) } for _, dc := range dcList { dcMo := mo.Datacenter{} ps := []string{"name", "hostFolder", "vmFolder", "datastore"} err := vm.collector.RetrieveOne(vm.ctx, dc.Reference(), ps, &dcMo) if err != nil { return nil, NewErrorPropertyRetrieval(dc.Reference(), ps, err) } if dcMo.Name == vm.Datacenter { return &dcMo, err } } return nil, NewErrorObjectNotFound(err, vm.Datacenter) }
go
func GetDatacenter(vm *VM) (*mo.Datacenter, error) { dcList, err := vm.finder.DatacenterList(vm.ctx, "*") if err != nil { return nil, NewErrorObjectNotFound(err, vm.Datacenter) } for _, dc := range dcList { dcMo := mo.Datacenter{} ps := []string{"name", "hostFolder", "vmFolder", "datastore"} err := vm.collector.RetrieveOne(vm.ctx, dc.Reference(), ps, &dcMo) if err != nil { return nil, NewErrorPropertyRetrieval(dc.Reference(), ps, err) } if dcMo.Name == vm.Datacenter { return &dcMo, err } } return nil, NewErrorObjectNotFound(err, vm.Datacenter) }
[ "func", "GetDatacenter", "(", "vm", "*", "VM", ")", "(", "*", "mo", ".", "Datacenter", ",", "error", ")", "{", "dcList", ",", "err", ":=", "vm", ".", "finder", ".", "DatacenterList", "(", "vm", ".", "ctx", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "NewErrorObjectNotFound", "(", "err", ",", "vm", ".", "Datacenter", ")", "\n", "}", "\n", "for", "_", ",", "dc", ":=", "range", "dcList", "{", "dcMo", ":=", "mo", ".", "Datacenter", "{", "}", "\n", "ps", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", "\n", "err", ":=", "vm", ".", "collector", ".", "RetrieveOne", "(", "vm", ".", "ctx", ",", "dc", ".", "Reference", "(", ")", ",", "ps", ",", "&", "dcMo", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "NewErrorPropertyRetrieval", "(", "dc", ".", "Reference", "(", ")", ",", "ps", ",", "err", ")", "\n", "}", "\n", "if", "dcMo", ".", "Name", "==", "vm", ".", "Datacenter", "{", "return", "&", "dcMo", ",", "err", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "NewErrorObjectNotFound", "(", "err", ",", "vm", ".", "Datacenter", ")", "\n", "}" ]
// GetDatacenter retrieves the datacenter that the provisioner was configured // against.
[ "GetDatacenter", "retrieves", "the", "datacenter", "that", "the", "provisioner", "was", "configured", "against", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/vsphere/util.go#L84-L101
train
apcera/libretto
virtualmachine/vsphere/util.go
validateHost
func validateHost(vm *VM, hsMor types.ManagedObjectReference) (bool, error) { nwValid := true dsValid := false // Fetch the managed object for the host system to populate the datastore and the network folders hsMo := mo.HostSystem{} err := vm.collector.RetrieveOne(vm.ctx, hsMor, []string{"network", "datastore"}, &hsMo) if err != nil { return false, err } hostNetworks := map[string]struct{}{} for _, nw := range hsMo.Network { name, err := getNetworkName(vm, nw) if err != nil { return false, err } if name == "" { return false, fmt.Errorf("Network name empty for: %s", nw.Value) } hostNetworks[name] = struct{}{} } for _, v := range vm.Networks { if _, ok := hostNetworks[v]; !ok { nwValid = false break } } for _, ds := range hsMo.Datastore { dsMo := mo.Datastore{} err := vm.collector.RetrieveOne(vm.ctx, ds, []string{"name"}, &dsMo) if err != nil { return false, err } if dsMo.Name == vm.datastore { dsValid = true break } } return (nwValid && dsValid), nil }
go
func validateHost(vm *VM, hsMor types.ManagedObjectReference) (bool, error) { nwValid := true dsValid := false // Fetch the managed object for the host system to populate the datastore and the network folders hsMo := mo.HostSystem{} err := vm.collector.RetrieveOne(vm.ctx, hsMor, []string{"network", "datastore"}, &hsMo) if err != nil { return false, err } hostNetworks := map[string]struct{}{} for _, nw := range hsMo.Network { name, err := getNetworkName(vm, nw) if err != nil { return false, err } if name == "" { return false, fmt.Errorf("Network name empty for: %s", nw.Value) } hostNetworks[name] = struct{}{} } for _, v := range vm.Networks { if _, ok := hostNetworks[v]; !ok { nwValid = false break } } for _, ds := range hsMo.Datastore { dsMo := mo.Datastore{} err := vm.collector.RetrieveOne(vm.ctx, ds, []string{"name"}, &dsMo) if err != nil { return false, err } if dsMo.Name == vm.datastore { dsValid = true break } } return (nwValid && dsValid), nil }
[ "func", "validateHost", "(", "vm", "*", "VM", ",", "hsMor", "types", ".", "ManagedObjectReference", ")", "(", "bool", ",", "error", ")", "{", "nwValid", ":=", "true", "\n", "dsValid", ":=", "false", "\n", "// Fetch the managed object for the host system to populate the datastore and the network folders", "hsMo", ":=", "mo", ".", "HostSystem", "{", "}", "\n", "err", ":=", "vm", ".", "collector", ".", "RetrieveOne", "(", "vm", ".", "ctx", ",", "hsMor", ",", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", "}", ",", "&", "hsMo", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "hostNetworks", ":=", "map", "[", "string", "]", "struct", "{", "}", "{", "}", "\n", "for", "_", ",", "nw", ":=", "range", "hsMo", ".", "Network", "{", "name", ",", "err", ":=", "getNetworkName", "(", "vm", ",", "nw", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "if", "name", "==", "\"", "\"", "{", "return", "false", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "nw", ".", "Value", ")", "\n", "}", "\n", "hostNetworks", "[", "name", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "for", "_", ",", "v", ":=", "range", "vm", ".", "Networks", "{", "if", "_", ",", "ok", ":=", "hostNetworks", "[", "v", "]", ";", "!", "ok", "{", "nwValid", "=", "false", "\n", "break", "\n", "}", "\n", "}", "\n\n", "for", "_", ",", "ds", ":=", "range", "hsMo", ".", "Datastore", "{", "dsMo", ":=", "mo", ".", "Datastore", "{", "}", "\n", "err", ":=", "vm", ".", "collector", ".", "RetrieveOne", "(", "vm", ".", "ctx", ",", "ds", ",", "[", "]", "string", "{", "\"", "\"", "}", ",", "&", "dsMo", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "if", "dsMo", ".", "Name", "==", "vm", ".", "datastore", "{", "dsValid", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n", "return", "(", "nwValid", "&&", "dsValid", ")", ",", "nil", "\n", "}" ]
// validateHost validates that the host-system contains the network and the datastore passed in
[ "validateHost", "validates", "that", "the", "host", "-", "system", "contains", "the", "network", "and", "the", "datastore", "passed", "in" ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/vsphere/util.go#L736-L775
train
apcera/libretto
virtualmachine/vsphere/util.go
answerQuestion
func (vm *VM) answerQuestion(vmMo *mo.VirtualMachine) error { q := vmMo.Runtime.Question if q == nil { return nil } for qre, ans := range vm.QuestionResponses { if match, err := regexp.MatchString(qre, q.Text); err != nil { return fmt.Errorf("error while parsing automated responses: %v", err) } else if match { ans, validOptions := resolveAnswerAndOptions(q.Choice.ChoiceInfo, ans) err = answerVSphereQuestion(vm, vmMo, q.Id, ans) if err != nil { return fmt.Errorf("error with answer %q to question %q: %v. Valid answers: %v", ans, q.Text, err, validOptions) } } } return nil }
go
func (vm *VM) answerQuestion(vmMo *mo.VirtualMachine) error { q := vmMo.Runtime.Question if q == nil { return nil } for qre, ans := range vm.QuestionResponses { if match, err := regexp.MatchString(qre, q.Text); err != nil { return fmt.Errorf("error while parsing automated responses: %v", err) } else if match { ans, validOptions := resolveAnswerAndOptions(q.Choice.ChoiceInfo, ans) err = answerVSphereQuestion(vm, vmMo, q.Id, ans) if err != nil { return fmt.Errorf("error with answer %q to question %q: %v. Valid answers: %v", ans, q.Text, err, validOptions) } } } return nil }
[ "func", "(", "vm", "*", "VM", ")", "answerQuestion", "(", "vmMo", "*", "mo", ".", "VirtualMachine", ")", "error", "{", "q", ":=", "vmMo", ".", "Runtime", ".", "Question", "\n", "if", "q", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "for", "qre", ",", "ans", ":=", "range", "vm", ".", "QuestionResponses", "{", "if", "match", ",", "err", ":=", "regexp", ".", "MatchString", "(", "qre", ",", "q", ".", "Text", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "else", "if", "match", "{", "ans", ",", "validOptions", ":=", "resolveAnswerAndOptions", "(", "q", ".", "Choice", ".", "ChoiceInfo", ",", "ans", ")", "\n", "err", "=", "answerVSphereQuestion", "(", "vm", ",", "vmMo", ",", "q", ".", "Id", ",", "ans", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "ans", ",", "q", ".", "Text", ",", "err", ",", "validOptions", ")", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// answerQuestion checks to see if there are currently pending questions on the // VM which prevent further actions. If so, it automatically responds to the // question based on the the vm.QuestionResponses map. If there is a problem // responding to the question, the error is returned. If there are no pending // questions or it does not map to any predefined response, nil is returned.
[ "answerQuestion", "checks", "to", "see", "if", "there", "are", "currently", "pending", "questions", "on", "the", "VM", "which", "prevent", "further", "actions", ".", "If", "so", "it", "automatically", "responds", "to", "the", "question", "based", "on", "the", "the", "vm", ".", "QuestionResponses", "map", ".", "If", "there", "is", "a", "problem", "responding", "to", "the", "question", "the", "error", "is", "returned", ".", "If", "there", "are", "no", "pending", "questions", "or", "it", "does", "not", "map", "to", "any", "predefined", "response", "nil", "is", "returned", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/vsphere/util.go#L796-L815
train
apcera/libretto
virtualmachine/exoscale/util.go
WaitVMCreation
func (vm *VM) WaitVMCreation(timeoutSeconds int, pollIntervalSeconds int) error { if vm.JobID == "" { return fmt.Errorf("No JobID informed. Cannot poll machine creation state") } jobCh := make(chan *egoscale.QueryAsyncJobResultResponse, 1) errCh := make(chan error, 1) go func() { params := url.Values{} params.Set("jobid", vm.JobID) for { client := vm.getExoClient() resp, err := client.Request("queryAsyncJobResult", params) if err != nil { errCh <- err } jobResult := &egoscale.QueryAsyncJobResultResponse{} err = json.Unmarshal(resp, jobResult) if err != nil { errCh <- err } if jobResult.Jobstatus == 1 { jobCh <- jobResult break } time.Sleep(time.Duration(pollIntervalSeconds) * time.Second) } }() select { case jobResult := <-jobCh: var vmWrap egoscale.DeployVirtualMachineWrappedResponse if err := json.Unmarshal(jobResult.Jobresult, &vmWrap); err != nil { return err } vm.ID = vmWrap.Wrapped.Id case err := <-errCh: return err case <-time.After(time.Duration(timeoutSeconds) * time.Second): return fmt.Errorf("Create VM Job has not completed after %d seconds", timeoutSeconds) } return nil }
go
func (vm *VM) WaitVMCreation(timeoutSeconds int, pollIntervalSeconds int) error { if vm.JobID == "" { return fmt.Errorf("No JobID informed. Cannot poll machine creation state") } jobCh := make(chan *egoscale.QueryAsyncJobResultResponse, 1) errCh := make(chan error, 1) go func() { params := url.Values{} params.Set("jobid", vm.JobID) for { client := vm.getExoClient() resp, err := client.Request("queryAsyncJobResult", params) if err != nil { errCh <- err } jobResult := &egoscale.QueryAsyncJobResultResponse{} err = json.Unmarshal(resp, jobResult) if err != nil { errCh <- err } if jobResult.Jobstatus == 1 { jobCh <- jobResult break } time.Sleep(time.Duration(pollIntervalSeconds) * time.Second) } }() select { case jobResult := <-jobCh: var vmWrap egoscale.DeployVirtualMachineWrappedResponse if err := json.Unmarshal(jobResult.Jobresult, &vmWrap); err != nil { return err } vm.ID = vmWrap.Wrapped.Id case err := <-errCh: return err case <-time.After(time.Duration(timeoutSeconds) * time.Second): return fmt.Errorf("Create VM Job has not completed after %d seconds", timeoutSeconds) } return nil }
[ "func", "(", "vm", "*", "VM", ")", "WaitVMCreation", "(", "timeoutSeconds", "int", ",", "pollIntervalSeconds", "int", ")", "error", "{", "if", "vm", ".", "JobID", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "jobCh", ":=", "make", "(", "chan", "*", "egoscale", ".", "QueryAsyncJobResultResponse", ",", "1", ")", "\n", "errCh", ":=", "make", "(", "chan", "error", ",", "1", ")", "\n\n", "go", "func", "(", ")", "{", "params", ":=", "url", ".", "Values", "{", "}", "\n", "params", ".", "Set", "(", "\"", "\"", ",", "vm", ".", "JobID", ")", "\n\n", "for", "{", "client", ":=", "vm", ".", "getExoClient", "(", ")", "\n", "resp", ",", "err", ":=", "client", ".", "Request", "(", "\"", "\"", ",", "params", ")", "\n", "if", "err", "!=", "nil", "{", "errCh", "<-", "err", "\n", "}", "\n\n", "jobResult", ":=", "&", "egoscale", ".", "QueryAsyncJobResultResponse", "{", "}", "\n", "err", "=", "json", ".", "Unmarshal", "(", "resp", ",", "jobResult", ")", "\n", "if", "err", "!=", "nil", "{", "errCh", "<-", "err", "\n", "}", "\n\n", "if", "jobResult", ".", "Jobstatus", "==", "1", "{", "jobCh", "<-", "jobResult", "\n", "break", "\n", "}", "\n", "time", ".", "Sleep", "(", "time", ".", "Duration", "(", "pollIntervalSeconds", ")", "*", "time", ".", "Second", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "select", "{", "case", "jobResult", ":=", "<-", "jobCh", ":", "var", "vmWrap", "egoscale", ".", "DeployVirtualMachineWrappedResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "jobResult", ".", "Jobresult", ",", "&", "vmWrap", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "vm", ".", "ID", "=", "vmWrap", ".", "Wrapped", ".", "Id", "\n", "case", "err", ":=", "<-", "errCh", ":", "return", "err", "\n", "case", "<-", "time", ".", "After", "(", "time", ".", "Duration", "(", "timeoutSeconds", ")", "*", "time", ".", "Second", ")", ":", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "timeoutSeconds", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// WaitVMCreation waits for the virtual machine to be created, and stores the virtual machine ID // VM structure must contain a valid JobID.
[ "WaitVMCreation", "waits", "for", "the", "virtual", "machine", "to", "be", "created", "and", "stores", "the", "virtual", "machine", "ID", "VM", "structure", "must", "contain", "a", "valid", "JobID", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/exoscale/util.go#L20-L68
train
apcera/libretto
virtualmachine/exoscale/util.go
fillTemplateID
func (vm *VM) fillTemplateID() error { params := url.Values{} params.Set("Name", vm.Template.Name) params.Set("templatefilter", "featured") client := vm.getExoClient() resp, err := client.Request("listTemplates", params) if err != nil { return fmt.Errorf("Getting template ID for '%s/%d/%s': %s", vm.Template.Name, vm.Template.StorageGB, vm.Template.ZoneName, err) } templates := &egoscale.ListTemplatesResponse{} if err := json.Unmarshal(resp, templates); err != nil { return fmt.Errorf("Decoding response for template '%s/%d/%s': %s", vm.Template.Name, vm.Template.StorageGB, vm.Template.ZoneName, err) } // iterate templates to get ID matching size and zone name storage := int64(vm.Template.StorageGB) << 30 zoneName := strings.ToLower(vm.Template.ZoneName) for _, template := range templates.Templates { if template.Size == storage { if template.Zonename == zoneName { vm.Template.ID = template.Id return nil } } } return fmt.Errorf("Template ID for '%s/%d/%s' could not be found", vm.Template.Name, vm.Template.StorageGB, vm.Template.ZoneName) }
go
func (vm *VM) fillTemplateID() error { params := url.Values{} params.Set("Name", vm.Template.Name) params.Set("templatefilter", "featured") client := vm.getExoClient() resp, err := client.Request("listTemplates", params) if err != nil { return fmt.Errorf("Getting template ID for '%s/%d/%s': %s", vm.Template.Name, vm.Template.StorageGB, vm.Template.ZoneName, err) } templates := &egoscale.ListTemplatesResponse{} if err := json.Unmarshal(resp, templates); err != nil { return fmt.Errorf("Decoding response for template '%s/%d/%s': %s", vm.Template.Name, vm.Template.StorageGB, vm.Template.ZoneName, err) } // iterate templates to get ID matching size and zone name storage := int64(vm.Template.StorageGB) << 30 zoneName := strings.ToLower(vm.Template.ZoneName) for _, template := range templates.Templates { if template.Size == storage { if template.Zonename == zoneName { vm.Template.ID = template.Id return nil } } } return fmt.Errorf("Template ID for '%s/%d/%s' could not be found", vm.Template.Name, vm.Template.StorageGB, vm.Template.ZoneName) }
[ "func", "(", "vm", "*", "VM", ")", "fillTemplateID", "(", ")", "error", "{", "params", ":=", "url", ".", "Values", "{", "}", "\n", "params", ".", "Set", "(", "\"", "\"", ",", "vm", ".", "Template", ".", "Name", ")", "\n", "params", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "client", ":=", "vm", ".", "getExoClient", "(", ")", "\n", "resp", ",", "err", ":=", "client", ".", "Request", "(", "\"", "\"", ",", "params", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "vm", ".", "Template", ".", "Name", ",", "vm", ".", "Template", ".", "StorageGB", ",", "vm", ".", "Template", ".", "ZoneName", ",", "err", ")", "\n", "}", "\n\n", "templates", ":=", "&", "egoscale", ".", "ListTemplatesResponse", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "templates", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "vm", ".", "Template", ".", "Name", ",", "vm", ".", "Template", ".", "StorageGB", ",", "vm", ".", "Template", ".", "ZoneName", ",", "err", ")", "\n", "}", "\n\n", "// iterate templates to get ID matching size and zone name", "storage", ":=", "int64", "(", "vm", ".", "Template", ".", "StorageGB", ")", "<<", "30", "\n", "zoneName", ":=", "strings", ".", "ToLower", "(", "vm", ".", "Template", ".", "ZoneName", ")", "\n\n", "for", "_", ",", "template", ":=", "range", "templates", ".", "Templates", "{", "if", "template", ".", "Size", "==", "storage", "{", "if", "template", ".", "Zonename", "==", "zoneName", "{", "vm", ".", "Template", ".", "ID", "=", "template", ".", "Id", "\n", "return", "nil", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "vm", ".", "Template", ".", "Name", ",", "vm", ".", "Template", ".", "StorageGB", ",", "vm", ".", "Template", ".", "ZoneName", ")", "\n", "}" ]
// fillTemplateID fills the template identifier based on name, storage and zone name. // If no matching template is found, ID remains unchanged and an error is returned.
[ "fillTemplateID", "fills", "the", "template", "identifier", "based", "on", "name", "storage", "and", "zone", "name", ".", "If", "no", "matching", "template", "is", "found", "ID", "remains", "unchanged", "and", "an", "error", "is", "returned", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/exoscale/util.go#L72-L103
train
apcera/libretto
virtualmachine/exoscale/util.go
fillServiceOfferingID
func (vm *VM) fillServiceOfferingID() error { params := url.Values{} params.Set("name", strings.ToLower(string(vm.ServiceOffering.Name))) client := vm.getExoClient() resp, err := client.Request("listServiceOfferings", params) if err != nil { return fmt.Errorf("Getting service offering ID for %q: %s", vm.ServiceOffering.Name, err) } so := &egoscale.ListServiceOfferingsResponse{} if err := json.Unmarshal(resp, so); err != nil { return fmt.Errorf("Decoding response for service offering %q: %s", vm.ServiceOffering.Name, err) } if so.Count != 1 { return fmt.Errorf("Expected 1 service offering matching %q, but returned %d", vm.ServiceOffering.Name, so.Count) } vm.ServiceOffering.ID = so.ServiceOfferings[0].Id return nil }
go
func (vm *VM) fillServiceOfferingID() error { params := url.Values{} params.Set("name", strings.ToLower(string(vm.ServiceOffering.Name))) client := vm.getExoClient() resp, err := client.Request("listServiceOfferings", params) if err != nil { return fmt.Errorf("Getting service offering ID for %q: %s", vm.ServiceOffering.Name, err) } so := &egoscale.ListServiceOfferingsResponse{} if err := json.Unmarshal(resp, so); err != nil { return fmt.Errorf("Decoding response for service offering %q: %s", vm.ServiceOffering.Name, err) } if so.Count != 1 { return fmt.Errorf("Expected 1 service offering matching %q, but returned %d", vm.ServiceOffering.Name, so.Count) } vm.ServiceOffering.ID = so.ServiceOfferings[0].Id return nil }
[ "func", "(", "vm", "*", "VM", ")", "fillServiceOfferingID", "(", ")", "error", "{", "params", ":=", "url", ".", "Values", "{", "}", "\n", "params", ".", "Set", "(", "\"", "\"", ",", "strings", ".", "ToLower", "(", "string", "(", "vm", ".", "ServiceOffering", ".", "Name", ")", ")", ")", "\n\n", "client", ":=", "vm", ".", "getExoClient", "(", ")", "\n", "resp", ",", "err", ":=", "client", ".", "Request", "(", "\"", "\"", ",", "params", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "vm", ".", "ServiceOffering", ".", "Name", ",", "err", ")", "\n", "}", "\n\n", "so", ":=", "&", "egoscale", ".", "ListServiceOfferingsResponse", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "so", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "vm", ".", "ServiceOffering", ".", "Name", ",", "err", ")", "\n", "}", "\n\n", "if", "so", ".", "Count", "!=", "1", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "vm", ".", "ServiceOffering", ".", "Name", ",", "so", ".", "Count", ")", "\n", "}", "\n\n", "vm", ".", "ServiceOffering", ".", "ID", "=", "so", ".", "ServiceOfferings", "[", "0", "]", ".", "Id", "\n\n", "return", "nil", "\n", "}" ]
// fillServiceOfferingID fills the service offering identifier based on name. // If no matching service offering is found, ID remains unchanged and an error is returned.
[ "fillServiceOfferingID", "fills", "the", "service", "offering", "identifier", "based", "on", "name", ".", "If", "no", "matching", "service", "offering", "is", "found", "ID", "remains", "unchanged", "and", "an", "error", "is", "returned", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/exoscale/util.go#L107-L130
train
apcera/libretto
virtualmachine/exoscale/util.go
fillSecurityGroupsID
func (vm *VM) fillSecurityGroupsID() error { params := url.Values{} client := vm.getExoClient() resp, err := client.Request("listSecurityGroups", params) if err != nil { return fmt.Errorf("Getting security groups: %s", err) } sgRemotes := &egoscale.ListSecurityGroupsResponse{} if err := json.Unmarshal(resp, sgRemotes); err != nil { return fmt.Errorf("Decoding response for security groups: %s", err) } for i, sg := range vm.SecurityGroups { if sg.ID != "" { continue } newID := "" for _, sgRemote := range sgRemotes.SecurityGroups { if sg.Name == sgRemote.Name { newID = sgRemote.Id break } } if newID == "" { return fmt.Errorf("Could not find security group ID for %q", sg.Name) } vm.SecurityGroups[i].ID = newID } return nil }
go
func (vm *VM) fillSecurityGroupsID() error { params := url.Values{} client := vm.getExoClient() resp, err := client.Request("listSecurityGroups", params) if err != nil { return fmt.Errorf("Getting security groups: %s", err) } sgRemotes := &egoscale.ListSecurityGroupsResponse{} if err := json.Unmarshal(resp, sgRemotes); err != nil { return fmt.Errorf("Decoding response for security groups: %s", err) } for i, sg := range vm.SecurityGroups { if sg.ID != "" { continue } newID := "" for _, sgRemote := range sgRemotes.SecurityGroups { if sg.Name == sgRemote.Name { newID = sgRemote.Id break } } if newID == "" { return fmt.Errorf("Could not find security group ID for %q", sg.Name) } vm.SecurityGroups[i].ID = newID } return nil }
[ "func", "(", "vm", "*", "VM", ")", "fillSecurityGroupsID", "(", ")", "error", "{", "params", ":=", "url", ".", "Values", "{", "}", "\n\n", "client", ":=", "vm", ".", "getExoClient", "(", ")", "\n", "resp", ",", "err", ":=", "client", ".", "Request", "(", "\"", "\"", ",", "params", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "sgRemotes", ":=", "&", "egoscale", ".", "ListSecurityGroupsResponse", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "sgRemotes", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "for", "i", ",", "sg", ":=", "range", "vm", ".", "SecurityGroups", "{", "if", "sg", ".", "ID", "!=", "\"", "\"", "{", "continue", "\n", "}", "\n\n", "newID", ":=", "\"", "\"", "\n", "for", "_", ",", "sgRemote", ":=", "range", "sgRemotes", ".", "SecurityGroups", "{", "if", "sg", ".", "Name", "==", "sgRemote", ".", "Name", "{", "newID", "=", "sgRemote", ".", "Id", "\n", "break", "\n", "}", "\n", "}", "\n\n", "if", "newID", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "sg", ".", "Name", ")", "\n", "}", "\n", "vm", ".", "SecurityGroups", "[", "i", "]", ".", "ID", "=", "newID", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// fillSecurityGroupsID fills the security group identifiers based on name. // If a security group already has the ID, it will remain unchanged. // If any of the security groups is not founds error is returned.
[ "fillSecurityGroupsID", "fills", "the", "security", "group", "identifiers", "based", "on", "name", ".", "If", "a", "security", "group", "already", "has", "the", "ID", "it", "will", "remain", "unchanged", ".", "If", "any", "of", "the", "security", "groups", "is", "not", "founds", "error", "is", "returned", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/exoscale/util.go#L135-L171
train
apcera/libretto
virtualmachine/exoscale/util.go
fillZoneID
func (vm *VM) fillZoneID() error { params := url.Values{} params.Set("name", strings.ToLower(string(vm.Zone.Name))) client := vm.getExoClient() resp, err := client.Request("listZones", params) if err != nil { return fmt.Errorf("Getting zones ID for %q: %s", vm.ServiceOffering.Name, err) } zones := &egoscale.ListZonesResponse{} if err := json.Unmarshal(resp, zones); err != nil { return fmt.Errorf("Decoding response for zones list: %s", err) } for _, zone := range zones.Zones { if zone.Name == vm.Zone.Name { vm.Zone.ID = zone.Id return nil } } return fmt.Errorf("Zone ID for %q could not be found", vm.Zone.Name) }
go
func (vm *VM) fillZoneID() error { params := url.Values{} params.Set("name", strings.ToLower(string(vm.Zone.Name))) client := vm.getExoClient() resp, err := client.Request("listZones", params) if err != nil { return fmt.Errorf("Getting zones ID for %q: %s", vm.ServiceOffering.Name, err) } zones := &egoscale.ListZonesResponse{} if err := json.Unmarshal(resp, zones); err != nil { return fmt.Errorf("Decoding response for zones list: %s", err) } for _, zone := range zones.Zones { if zone.Name == vm.Zone.Name { vm.Zone.ID = zone.Id return nil } } return fmt.Errorf("Zone ID for %q could not be found", vm.Zone.Name) }
[ "func", "(", "vm", "*", "VM", ")", "fillZoneID", "(", ")", "error", "{", "params", ":=", "url", ".", "Values", "{", "}", "\n", "params", ".", "Set", "(", "\"", "\"", ",", "strings", ".", "ToLower", "(", "string", "(", "vm", ".", "Zone", ".", "Name", ")", ")", ")", "\n\n", "client", ":=", "vm", ".", "getExoClient", "(", ")", "\n", "resp", ",", "err", ":=", "client", ".", "Request", "(", "\"", "\"", ",", "params", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "vm", ".", "ServiceOffering", ".", "Name", ",", "err", ")", "\n", "}", "\n\n", "zones", ":=", "&", "egoscale", ".", "ListZonesResponse", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "zones", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "for", "_", ",", "zone", ":=", "range", "zones", ".", "Zones", "{", "if", "zone", ".", "Name", "==", "vm", ".", "Zone", ".", "Name", "{", "vm", ".", "Zone", ".", "ID", "=", "zone", ".", "Id", "\n", "return", "nil", "\n", "}", "\n", "}", "\n\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "vm", ".", "Zone", ".", "Name", ")", "\n", "}" ]
// fillZoneID fills the zone identifier based on name. // If no matching zone is found, ID remains unchanged and an error is returned.
[ "fillZoneID", "fills", "the", "zone", "identifier", "based", "on", "name", ".", "If", "no", "matching", "zone", "is", "found", "ID", "remains", "unchanged", "and", "an", "error", "is", "returned", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/exoscale/util.go#L175-L199
train
apcera/libretto
virtualmachine/gcp/vm.go
Provision
func (vm *VM) Provision() error { s, err := vm.getService() if err != nil { return err } return s.provision() }
go
func (vm *VM) Provision() error { s, err := vm.getService() if err != nil { return err } return s.provision() }
[ "func", "(", "vm", "*", "VM", ")", "Provision", "(", ")", "error", "{", "s", ",", "err", ":=", "vm", ".", "getService", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "s", ".", "provision", "(", ")", "\n", "}" ]
// Provision creates a virtual machine on GCE. It returns an error if // there was a problem during creation.
[ "Provision", "creates", "a", "virtual", "machine", "on", "GCE", ".", "It", "returns", "an", "error", "if", "there", "was", "a", "problem", "during", "creation", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/vm.go#L79-L86
train
apcera/libretto
virtualmachine/gcp/vm.go
GetIPs
func (vm *VM) GetIPs() ([]net.IP, error) { s, err := vm.getService() if err != nil { return nil, err } return s.getIPs() }
go
func (vm *VM) GetIPs() ([]net.IP, error) { s, err := vm.getService() if err != nil { return nil, err } return s.getIPs() }
[ "func", "(", "vm", "*", "VM", ")", "GetIPs", "(", ")", "(", "[", "]", "net", ".", "IP", ",", "error", ")", "{", "s", ",", "err", ":=", "vm", ".", "getService", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "s", ".", "getIPs", "(", ")", "\n", "}" ]
// GetIPs returns a slice of IP addresses assigned to the VM.
[ "GetIPs", "returns", "a", "slice", "of", "IP", "addresses", "assigned", "to", "the", "VM", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/vm.go#L89-L96
train
apcera/libretto
virtualmachine/gcp/vm.go
Destroy
func (vm *VM) Destroy() error { s, err := vm.getService() if err != nil { return err } return s.delete() }
go
func (vm *VM) Destroy() error { s, err := vm.getService() if err != nil { return err } return s.delete() }
[ "func", "(", "vm", "*", "VM", ")", "Destroy", "(", ")", "error", "{", "s", ",", "err", ":=", "vm", ".", "getService", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "s", ".", "delete", "(", ")", "\n", "}" ]
// Destroy deletes the VM on GCE.
[ "Destroy", "deletes", "the", "VM", "on", "GCE", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/vm.go#L99-L106
train
apcera/libretto
virtualmachine/gcp/vm.go
GetState
func (vm *VM) GetState() (string, error) { s, err := vm.getService() if err != nil { return "", err } instance, err := s.getInstance() if err != nil { return "", err } switch instance.Status { case "PROVISIONING", "STAGING": return virtualmachine.VMStarting, nil case "RUNNING": return virtualmachine.VMRunning, nil case "STOPPING", "STOPPED", "TERMINATED": return virtualmachine.VMHalted, nil default: return virtualmachine.VMUnknown, nil } }
go
func (vm *VM) GetState() (string, error) { s, err := vm.getService() if err != nil { return "", err } instance, err := s.getInstance() if err != nil { return "", err } switch instance.Status { case "PROVISIONING", "STAGING": return virtualmachine.VMStarting, nil case "RUNNING": return virtualmachine.VMRunning, nil case "STOPPING", "STOPPED", "TERMINATED": return virtualmachine.VMHalted, nil default: return virtualmachine.VMUnknown, nil } }
[ "func", "(", "vm", "*", "VM", ")", "GetState", "(", ")", "(", "string", ",", "error", ")", "{", "s", ",", "err", ":=", "vm", ".", "getService", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "instance", ",", "err", ":=", "s", ".", "getInstance", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "switch", "instance", ".", "Status", "{", "case", "\"", "\"", ",", "\"", "\"", ":", "return", "virtualmachine", ".", "VMStarting", ",", "nil", "\n", "case", "\"", "\"", ":", "return", "virtualmachine", ".", "VMRunning", ",", "nil", "\n", "case", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ":", "return", "virtualmachine", ".", "VMHalted", ",", "nil", "\n", "default", ":", "return", "virtualmachine", ".", "VMUnknown", ",", "nil", "\n", "}", "\n", "}" ]
// GetState retrieve the instance status.
[ "GetState", "retrieve", "the", "instance", "status", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/vm.go#L109-L130
train
apcera/libretto
virtualmachine/gcp/vm.go
Halt
func (vm *VM) Halt() error { s, err := vm.getService() if err != nil { return err } return s.stop() }
go
func (vm *VM) Halt() error { s, err := vm.getService() if err != nil { return err } return s.stop() }
[ "func", "(", "vm", "*", "VM", ")", "Halt", "(", ")", "error", "{", "s", ",", "err", ":=", "vm", ".", "getService", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "s", ".", "stop", "(", ")", "\n", "}" ]
// Halt stops a GCE instance.
[ "Halt", "stops", "a", "GCE", "instance", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/vm.go#L143-L150
train
apcera/libretto
virtualmachine/gcp/vm.go
Start
func (vm *VM) Start() error { s, err := vm.getService() if err != nil { return err } return s.start() }
go
func (vm *VM) Start() error { s, err := vm.getService() if err != nil { return err } return s.start() }
[ "func", "(", "vm", "*", "VM", ")", "Start", "(", ")", "error", "{", "s", ",", "err", ":=", "vm", ".", "getService", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "s", ".", "start", "(", ")", "\n", "}" ]
// Start a stopped GCE instance.
[ "Start", "a", "stopped", "GCE", "instance", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/vm.go#L153-L160
train
apcera/libretto
virtualmachine/gcp/vm.go
InsertSSHKey
func (vm *VM) InsertSSHKey(publicKey string) error { s, err := vm.getService() if err != nil { return err } return s.insertSSHKey() }
go
func (vm *VM) InsertSSHKey(publicKey string) error { s, err := vm.getService() if err != nil { return err } return s.insertSSHKey() }
[ "func", "(", "vm", "*", "VM", ")", "InsertSSHKey", "(", "publicKey", "string", ")", "error", "{", "s", ",", "err", ":=", "vm", ".", "getService", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "s", ".", "insertSSHKey", "(", ")", "\n", "}" ]
// InsertSSHKey uploads new ssh key into the GCE instance.
[ "InsertSSHKey", "uploads", "new", "ssh", "key", "into", "the", "GCE", "instance", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/vm.go#L184-L191
train
apcera/libretto
virtualmachine/gcp/vm.go
DeleteDisks
func (vm *VM) DeleteDisks() error { s, err := vm.getService() if err != nil { return err } errs := s.deleteDisks() if len(errs) > 0 { err = util.CombineErrors(": ", errs...) return err } return nil }
go
func (vm *VM) DeleteDisks() error { s, err := vm.getService() if err != nil { return err } errs := s.deleteDisks() if len(errs) > 0 { err = util.CombineErrors(": ", errs...) return err } return nil }
[ "func", "(", "vm", "*", "VM", ")", "DeleteDisks", "(", ")", "error", "{", "s", ",", "err", ":=", "vm", ".", "getService", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "errs", ":=", "s", ".", "deleteDisks", "(", ")", "\n", "if", "len", "(", "errs", ")", ">", "0", "{", "err", "=", "util", ".", "CombineErrors", "(", "\"", "\"", ",", "errs", "...", ")", "\n", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// DeleteDisks cleans up all the disks attached to the GCE instance.
[ "DeleteDisks", "cleans", "up", "all", "the", "disks", "attached", "to", "the", "GCE", "instance", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/vm.go#L194-L207
train
apcera/libretto
virtualmachine/azure/arm/util.go
getServicePrincipalToken
func getServicePrincipalToken(creds *OAuthCredentials, scope string) (*adal.ServicePrincipalToken, error) { oauthConfig, err := adal.NewOAuthConfig(azure.PublicCloud.ActiveDirectoryEndpoint, creds.TenantID) if err != nil { return nil, err } return adal.NewServicePrincipalToken(*oauthConfig, creds.ClientID, creds.ClientSecret, scope) }
go
func getServicePrincipalToken(creds *OAuthCredentials, scope string) (*adal.ServicePrincipalToken, error) { oauthConfig, err := adal.NewOAuthConfig(azure.PublicCloud.ActiveDirectoryEndpoint, creds.TenantID) if err != nil { return nil, err } return adal.NewServicePrincipalToken(*oauthConfig, creds.ClientID, creds.ClientSecret, scope) }
[ "func", "getServicePrincipalToken", "(", "creds", "*", "OAuthCredentials", ",", "scope", "string", ")", "(", "*", "adal", ".", "ServicePrincipalToken", ",", "error", ")", "{", "oauthConfig", ",", "err", ":=", "adal", ".", "NewOAuthConfig", "(", "azure", ".", "PublicCloud", ".", "ActiveDirectoryEndpoint", ",", "creds", ".", "TenantID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "adal", ".", "NewServicePrincipalToken", "(", "*", "oauthConfig", ",", "creds", ".", "ClientID", ",", "creds", ".", "ClientSecret", ",", "scope", ")", "\n", "}" ]
// getServicePrincipalToken retrieves a new ServicePrincipalToken using values of the // passed credentials map.
[ "getServicePrincipalToken", "retrieves", "a", "new", "ServicePrincipalToken", "using", "values", "of", "the", "passed", "credentials", "map", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/arm/util.go#L26-L32
train
apcera/libretto
virtualmachine/azure/arm/util.go
toARMParameters
func (vm *VM) toARMParameters() *armParameters { out := &armParameters{ AdminUsername: &armParameter{vm.SSHCreds.SSHUser}, AdminPassword: &armParameter{vm.SSHCreds.SSHPassword}, ImageOffer: &armParameter{vm.ImageOffer}, ImagePublisher: &armParameter{vm.ImagePublisher}, ImageSku: &armParameter{vm.ImageSku}, NetworkSecurityGroup: &armParameter{vm.NetworkSecurityGroup}, NicName: &armParameter{vm.Nic}, OSFileName: &armParameter{vm.OsFile}, PublicIPName: &armParameter{vm.PublicIP}, SSHAuthorizedKey: &armParameter{vm.SSHPublicKey}, StorageAccountName: &armParameter{vm.StorageAccount}, StorageContainerName: &armParameter{vm.StorageContainer}, SubnetName: &armParameter{vm.Subnet}, VirtualNetworkName: &armParameter{vm.VirtualNetwork}, VMSize: &armParameter{vm.Size}, VMName: &armParameter{vm.Name}, DiskSize: &armParameter{strconv.Itoa(vm.DiskSize)}, DiskFile: &armParameter{vm.DiskFile}, AdditionalDisk: &armParameter{"false"}, } if vm.DiskSize > 0 { out.AdditionalDisk = &armParameter{"true"} } return out }
go
func (vm *VM) toARMParameters() *armParameters { out := &armParameters{ AdminUsername: &armParameter{vm.SSHCreds.SSHUser}, AdminPassword: &armParameter{vm.SSHCreds.SSHPassword}, ImageOffer: &armParameter{vm.ImageOffer}, ImagePublisher: &armParameter{vm.ImagePublisher}, ImageSku: &armParameter{vm.ImageSku}, NetworkSecurityGroup: &armParameter{vm.NetworkSecurityGroup}, NicName: &armParameter{vm.Nic}, OSFileName: &armParameter{vm.OsFile}, PublicIPName: &armParameter{vm.PublicIP}, SSHAuthorizedKey: &armParameter{vm.SSHPublicKey}, StorageAccountName: &armParameter{vm.StorageAccount}, StorageContainerName: &armParameter{vm.StorageContainer}, SubnetName: &armParameter{vm.Subnet}, VirtualNetworkName: &armParameter{vm.VirtualNetwork}, VMSize: &armParameter{vm.Size}, VMName: &armParameter{vm.Name}, DiskSize: &armParameter{strconv.Itoa(vm.DiskSize)}, DiskFile: &armParameter{vm.DiskFile}, AdditionalDisk: &armParameter{"false"}, } if vm.DiskSize > 0 { out.AdditionalDisk = &armParameter{"true"} } return out }
[ "func", "(", "vm", "*", "VM", ")", "toARMParameters", "(", ")", "*", "armParameters", "{", "out", ":=", "&", "armParameters", "{", "AdminUsername", ":", "&", "armParameter", "{", "vm", ".", "SSHCreds", ".", "SSHUser", "}", ",", "AdminPassword", ":", "&", "armParameter", "{", "vm", ".", "SSHCreds", ".", "SSHPassword", "}", ",", "ImageOffer", ":", "&", "armParameter", "{", "vm", ".", "ImageOffer", "}", ",", "ImagePublisher", ":", "&", "armParameter", "{", "vm", ".", "ImagePublisher", "}", ",", "ImageSku", ":", "&", "armParameter", "{", "vm", ".", "ImageSku", "}", ",", "NetworkSecurityGroup", ":", "&", "armParameter", "{", "vm", ".", "NetworkSecurityGroup", "}", ",", "NicName", ":", "&", "armParameter", "{", "vm", ".", "Nic", "}", ",", "OSFileName", ":", "&", "armParameter", "{", "vm", ".", "OsFile", "}", ",", "PublicIPName", ":", "&", "armParameter", "{", "vm", ".", "PublicIP", "}", ",", "SSHAuthorizedKey", ":", "&", "armParameter", "{", "vm", ".", "SSHPublicKey", "}", ",", "StorageAccountName", ":", "&", "armParameter", "{", "vm", ".", "StorageAccount", "}", ",", "StorageContainerName", ":", "&", "armParameter", "{", "vm", ".", "StorageContainer", "}", ",", "SubnetName", ":", "&", "armParameter", "{", "vm", ".", "Subnet", "}", ",", "VirtualNetworkName", ":", "&", "armParameter", "{", "vm", ".", "VirtualNetwork", "}", ",", "VMSize", ":", "&", "armParameter", "{", "vm", ".", "Size", "}", ",", "VMName", ":", "&", "armParameter", "{", "vm", ".", "Name", "}", ",", "DiskSize", ":", "&", "armParameter", "{", "strconv", ".", "Itoa", "(", "vm", ".", "DiskSize", ")", "}", ",", "DiskFile", ":", "&", "armParameter", "{", "vm", ".", "DiskFile", "}", ",", "AdditionalDisk", ":", "&", "armParameter", "{", "\"", "\"", "}", ",", "}", "\n\n", "if", "vm", ".", "DiskSize", ">", "0", "{", "out", ".", "AdditionalDisk", "=", "&", "armParameter", "{", "\"", "\"", "}", "\n", "}", "\n\n", "return", "out", "\n", "}" ]
// Translates the given VM to arm parameters
[ "Translates", "the", "given", "VM", "to", "arm", "parameters" ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/arm/util.go#L61-L89
train
apcera/libretto
virtualmachine/azure/arm/util.go
validateVM
func validateVM(vm *VM) error { // Validate the OAUTH Credentials if vm.Creds.ClientID == "" { return fmt.Errorf("a client id must be specified") } if vm.Creds.ClientSecret == "" { return fmt.Errorf("a client secret must be specified") } if vm.Creds.TenantID == "" { return fmt.Errorf("a tenant id must be specified") } if vm.Creds.SubscriptionID == "" { return fmt.Errorf("a subscription id must be specified") } // Validate the image if vm.ImagePublisher == "" { return fmt.Errorf("an image publisher must be specified") } if vm.ImageOffer == "" { return fmt.Errorf("an image offer must be specified") } if vm.ImageSku == "" { return fmt.Errorf("an image sku must be specified") } // Validate the deployment if vm.ResourceGroup == "" { return fmt.Errorf("a resource group must be specified") } if vm.StorageAccount == "" { return fmt.Errorf("a storage account must be specified") } // Validate the network if vm.NetworkSecurityGroup == "" { return fmt.Errorf("a network security group must be specified") } if vm.Subnet == "" { return fmt.Errorf("a subnet must be specified") } if vm.VirtualNetwork == "" { return fmt.Errorf("a virtual network must be specified") } return nil }
go
func validateVM(vm *VM) error { // Validate the OAUTH Credentials if vm.Creds.ClientID == "" { return fmt.Errorf("a client id must be specified") } if vm.Creds.ClientSecret == "" { return fmt.Errorf("a client secret must be specified") } if vm.Creds.TenantID == "" { return fmt.Errorf("a tenant id must be specified") } if vm.Creds.SubscriptionID == "" { return fmt.Errorf("a subscription id must be specified") } // Validate the image if vm.ImagePublisher == "" { return fmt.Errorf("an image publisher must be specified") } if vm.ImageOffer == "" { return fmt.Errorf("an image offer must be specified") } if vm.ImageSku == "" { return fmt.Errorf("an image sku must be specified") } // Validate the deployment if vm.ResourceGroup == "" { return fmt.Errorf("a resource group must be specified") } if vm.StorageAccount == "" { return fmt.Errorf("a storage account must be specified") } // Validate the network if vm.NetworkSecurityGroup == "" { return fmt.Errorf("a network security group must be specified") } if vm.Subnet == "" { return fmt.Errorf("a subnet must be specified") } if vm.VirtualNetwork == "" { return fmt.Errorf("a virtual network must be specified") } return nil }
[ "func", "validateVM", "(", "vm", "*", "VM", ")", "error", "{", "// Validate the OAUTH Credentials", "if", "vm", ".", "Creds", ".", "ClientID", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "vm", ".", "Creds", ".", "ClientSecret", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "vm", ".", "Creds", ".", "TenantID", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "vm", ".", "Creds", ".", "SubscriptionID", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Validate the image", "if", "vm", ".", "ImagePublisher", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "vm", ".", "ImageOffer", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "vm", ".", "ImageSku", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Validate the deployment", "if", "vm", ".", "ResourceGroup", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "vm", ".", "StorageAccount", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Validate the network", "if", "vm", ".", "NetworkSecurityGroup", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "vm", ".", "Subnet", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "vm", ".", "VirtualNetwork", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// validateVM validates the members of given VM object
[ "validateVM", "validates", "the", "members", "of", "given", "VM", "object" ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/arm/util.go#L92-L146
train
apcera/libretto
virtualmachine/azure/arm/util.go
deploy
func (vm *VM) deploy() error { // Get the auth token. tok, err := getServicePrincipalToken(&vm.Creds, azure.PublicCloud.ResourceManagerEndpoint) if err != nil { return err } // Pass the parameters to the arm templacte vmParams := vm.toARMParameters() deployment, err := createDeployment(Linux, *vmParams) if err != nil { return err } // Create and send the deployment to the resource group deploymentsClient := resources.NewDeploymentsClient(vm.Creds.SubscriptionID) deploymentsClient.Authorizer = autorest.NewBearerAuthorizer(tok) _, errc := deploymentsClient.CreateOrUpdate(vm.ResourceGroup, vm.DeploymentName, *deployment, nil) if err := <-errc; err != nil { return err } // Make sure the deployment is succeeded for i := 0; i < actionTimeout; i++ { result, err := deploymentsClient.Get(vm.ResourceGroup, vm.DeploymentName) if err != nil { return err } if result.Properties != nil && result.Properties.ProvisioningState != nil { if *result.Properties.ProvisioningState == succeeded { return nil } } time.Sleep(1 * time.Second) } return ErrActionTimeout }
go
func (vm *VM) deploy() error { // Get the auth token. tok, err := getServicePrincipalToken(&vm.Creds, azure.PublicCloud.ResourceManagerEndpoint) if err != nil { return err } // Pass the parameters to the arm templacte vmParams := vm.toARMParameters() deployment, err := createDeployment(Linux, *vmParams) if err != nil { return err } // Create and send the deployment to the resource group deploymentsClient := resources.NewDeploymentsClient(vm.Creds.SubscriptionID) deploymentsClient.Authorizer = autorest.NewBearerAuthorizer(tok) _, errc := deploymentsClient.CreateOrUpdate(vm.ResourceGroup, vm.DeploymentName, *deployment, nil) if err := <-errc; err != nil { return err } // Make sure the deployment is succeeded for i := 0; i < actionTimeout; i++ { result, err := deploymentsClient.Get(vm.ResourceGroup, vm.DeploymentName) if err != nil { return err } if result.Properties != nil && result.Properties.ProvisioningState != nil { if *result.Properties.ProvisioningState == succeeded { return nil } } time.Sleep(1 * time.Second) } return ErrActionTimeout }
[ "func", "(", "vm", "*", "VM", ")", "deploy", "(", ")", "error", "{", "// Get the auth token.", "tok", ",", "err", ":=", "getServicePrincipalToken", "(", "&", "vm", ".", "Creds", ",", "azure", ".", "PublicCloud", ".", "ResourceManagerEndpoint", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Pass the parameters to the arm templacte", "vmParams", ":=", "vm", ".", "toARMParameters", "(", ")", "\n", "deployment", ",", "err", ":=", "createDeployment", "(", "Linux", ",", "*", "vmParams", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Create and send the deployment to the resource group", "deploymentsClient", ":=", "resources", ".", "NewDeploymentsClient", "(", "vm", ".", "Creds", ".", "SubscriptionID", ")", "\n", "deploymentsClient", ".", "Authorizer", "=", "autorest", ".", "NewBearerAuthorizer", "(", "tok", ")", "\n\n", "_", ",", "errc", ":=", "deploymentsClient", ".", "CreateOrUpdate", "(", "vm", ".", "ResourceGroup", ",", "vm", ".", "DeploymentName", ",", "*", "deployment", ",", "nil", ")", "\n", "if", "err", ":=", "<-", "errc", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Make sure the deployment is succeeded", "for", "i", ":=", "0", ";", "i", "<", "actionTimeout", ";", "i", "++", "{", "result", ",", "err", ":=", "deploymentsClient", ".", "Get", "(", "vm", ".", "ResourceGroup", ",", "vm", ".", "DeploymentName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "result", ".", "Properties", "!=", "nil", "&&", "result", ".", "Properties", ".", "ProvisioningState", "!=", "nil", "{", "if", "*", "result", ".", "Properties", ".", "ProvisioningState", "==", "succeeded", "{", "return", "nil", "\n", "}", "\n", "}", "\n\n", "time", ".", "Sleep", "(", "1", "*", "time", ".", "Second", ")", "\n", "}", "\n\n", "return", "ErrActionTimeout", "\n", "}" ]
// deploy deploys the given VM based on the default Linux arm template over the // VM's resource group.
[ "deploy", "deploys", "the", "given", "VM", "based", "on", "the", "default", "Linux", "arm", "template", "over", "the", "VM", "s", "resource", "group", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/arm/util.go#L150-L189
train
apcera/libretto
virtualmachine/azure/arm/util.go
getPublicIP
func (vm *VM) getPublicIP(authorizer autorest.Authorizer) (net.IP, error) { publicIPAddressesClient := network.NewPublicIPAddressesClient(vm.Creds.SubscriptionID) publicIPAddressesClient.Authorizer = authorizer resPublicIP, err := publicIPAddressesClient.Get(vm.ResourceGroup, vm.PublicIP, "") if err != nil { return nil, err } if resPublicIP.PublicIPAddressPropertiesFormat == nil || resPublicIP.PublicIPAddressPropertiesFormat.IPAddress == nil || *resPublicIP.PublicIPAddressPropertiesFormat.IPAddress == "" { return nil, fmt.Errorf("VM has no public IP address") } return net.ParseIP(*resPublicIP.PublicIPAddressPropertiesFormat.IPAddress), nil }
go
func (vm *VM) getPublicIP(authorizer autorest.Authorizer) (net.IP, error) { publicIPAddressesClient := network.NewPublicIPAddressesClient(vm.Creds.SubscriptionID) publicIPAddressesClient.Authorizer = authorizer resPublicIP, err := publicIPAddressesClient.Get(vm.ResourceGroup, vm.PublicIP, "") if err != nil { return nil, err } if resPublicIP.PublicIPAddressPropertiesFormat == nil || resPublicIP.PublicIPAddressPropertiesFormat.IPAddress == nil || *resPublicIP.PublicIPAddressPropertiesFormat.IPAddress == "" { return nil, fmt.Errorf("VM has no public IP address") } return net.ParseIP(*resPublicIP.PublicIPAddressPropertiesFormat.IPAddress), nil }
[ "func", "(", "vm", "*", "VM", ")", "getPublicIP", "(", "authorizer", "autorest", ".", "Authorizer", ")", "(", "net", ".", "IP", ",", "error", ")", "{", "publicIPAddressesClient", ":=", "network", ".", "NewPublicIPAddressesClient", "(", "vm", ".", "Creds", ".", "SubscriptionID", ")", "\n", "publicIPAddressesClient", ".", "Authorizer", "=", "authorizer", "\n\n", "resPublicIP", ",", "err", ":=", "publicIPAddressesClient", ".", "Get", "(", "vm", ".", "ResourceGroup", ",", "vm", ".", "PublicIP", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "resPublicIP", ".", "PublicIPAddressPropertiesFormat", "==", "nil", "||", "resPublicIP", ".", "PublicIPAddressPropertiesFormat", ".", "IPAddress", "==", "nil", "||", "*", "resPublicIP", ".", "PublicIPAddressPropertiesFormat", ".", "IPAddress", "==", "\"", "\"", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "net", ".", "ParseIP", "(", "*", "resPublicIP", ".", "PublicIPAddressPropertiesFormat", ".", "IPAddress", ")", ",", "nil", "\n", "}" ]
// getPublicIP returns the public IP of the given VM, if exists one.
[ "getPublicIP", "returns", "the", "public", "IP", "of", "the", "given", "VM", "if", "exists", "one", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/arm/util.go#L192-L206
train
apcera/libretto
virtualmachine/azure/arm/util.go
getPrivateIP
func (vm *VM) getPrivateIP(authorizer autorest.Authorizer) (net.IP, error) { interfaceClient := network.NewInterfacesClient(vm.Creds.SubscriptionID) interfaceClient.Authorizer = authorizer iface, err := interfaceClient.Get(vm.ResourceGroup, vm.Nic, "") if err != nil { return nil, err } if iface.InterfacePropertiesFormat == nil || iface.InterfacePropertiesFormat.IPConfigurations == nil || len(*iface.InterfacePropertiesFormat.IPConfigurations) == 0 { return nil, fmt.Errorf("VM has no private IP address") } ipConfigs := *iface.InterfacePropertiesFormat.IPConfigurations if len(ipConfigs) > 1 { return nil, fmt.Errorf("VM has multiple private IP addresses") } return net.ParseIP(*ipConfigs[0].InterfaceIPConfigurationPropertiesFormat.PrivateIPAddress), nil }
go
func (vm *VM) getPrivateIP(authorizer autorest.Authorizer) (net.IP, error) { interfaceClient := network.NewInterfacesClient(vm.Creds.SubscriptionID) interfaceClient.Authorizer = authorizer iface, err := interfaceClient.Get(vm.ResourceGroup, vm.Nic, "") if err != nil { return nil, err } if iface.InterfacePropertiesFormat == nil || iface.InterfacePropertiesFormat.IPConfigurations == nil || len(*iface.InterfacePropertiesFormat.IPConfigurations) == 0 { return nil, fmt.Errorf("VM has no private IP address") } ipConfigs := *iface.InterfacePropertiesFormat.IPConfigurations if len(ipConfigs) > 1 { return nil, fmt.Errorf("VM has multiple private IP addresses") } return net.ParseIP(*ipConfigs[0].InterfaceIPConfigurationPropertiesFormat.PrivateIPAddress), nil }
[ "func", "(", "vm", "*", "VM", ")", "getPrivateIP", "(", "authorizer", "autorest", ".", "Authorizer", ")", "(", "net", ".", "IP", ",", "error", ")", "{", "interfaceClient", ":=", "network", ".", "NewInterfacesClient", "(", "vm", ".", "Creds", ".", "SubscriptionID", ")", "\n", "interfaceClient", ".", "Authorizer", "=", "authorizer", "\n\n", "iface", ",", "err", ":=", "interfaceClient", ".", "Get", "(", "vm", ".", "ResourceGroup", ",", "vm", ".", "Nic", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "iface", ".", "InterfacePropertiesFormat", "==", "nil", "||", "iface", ".", "InterfacePropertiesFormat", ".", "IPConfigurations", "==", "nil", "||", "len", "(", "*", "iface", ".", "InterfacePropertiesFormat", ".", "IPConfigurations", ")", "==", "0", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "ipConfigs", ":=", "*", "iface", ".", "InterfacePropertiesFormat", ".", "IPConfigurations", "\n", "if", "len", "(", "ipConfigs", ")", ">", "1", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "net", ".", "ParseIP", "(", "*", "ipConfigs", "[", "0", "]", ".", "InterfaceIPConfigurationPropertiesFormat", ".", "PrivateIPAddress", ")", ",", "nil", "\n", "}" ]
// getPrivateIP returns the private IP of the given VM, if exists one.
[ "getPrivateIP", "returns", "the", "private", "IP", "of", "the", "given", "VM", "if", "exists", "one", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/arm/util.go#L209-L227
train
apcera/libretto
virtualmachine/azure/arm/util.go
deleteVMFiles
func (vm *VM) deleteVMFiles(authorizer autorest.Authorizer) error { storageAccountsClient := armStorage.NewAccountsClient(vm.Creds.SubscriptionID) storageAccountsClient.Authorizer = authorizer result, err := storageAccountsClient.ListKeys(vm.ResourceGroup, vm.StorageAccount) if err != nil { return err } accountKeys := result.Keys if accountKeys == nil || len(*accountKeys) == 0 { return fmt.Errorf("no account keys for storage account %q", vm.StorageAccount) } accountKey := *(*accountKeys)[0].Value storageClient, err := storage.NewBasicClient(vm.StorageAccount, accountKey) if err != nil { return err } // Get a reference to the OS file. blobStorageClient := storageClient.GetBlobService() container := blobStorageClient.GetContainerReference(vm.StorageContainer) osFileBlob := container.GetBlobReference(vm.OsFile) // Delete the OS file. opts := &storage.DeleteBlobOptions{Timeout: 30} // 30s timeout err = osFileBlob.Delete(opts) if vm.DiskSize <= 0 { return err } // Delete the disk file. diskFileBlob := container.GetBlobReference(vm.DiskFile) diskFileErr := diskFileBlob.Delete(opts) if err != nil { return fmt.Errorf("failed to delete OS file and disk file: %v, %v", err, diskFileErr) } return diskFileErr }
go
func (vm *VM) deleteVMFiles(authorizer autorest.Authorizer) error { storageAccountsClient := armStorage.NewAccountsClient(vm.Creds.SubscriptionID) storageAccountsClient.Authorizer = authorizer result, err := storageAccountsClient.ListKeys(vm.ResourceGroup, vm.StorageAccount) if err != nil { return err } accountKeys := result.Keys if accountKeys == nil || len(*accountKeys) == 0 { return fmt.Errorf("no account keys for storage account %q", vm.StorageAccount) } accountKey := *(*accountKeys)[0].Value storageClient, err := storage.NewBasicClient(vm.StorageAccount, accountKey) if err != nil { return err } // Get a reference to the OS file. blobStorageClient := storageClient.GetBlobService() container := blobStorageClient.GetContainerReference(vm.StorageContainer) osFileBlob := container.GetBlobReference(vm.OsFile) // Delete the OS file. opts := &storage.DeleteBlobOptions{Timeout: 30} // 30s timeout err = osFileBlob.Delete(opts) if vm.DiskSize <= 0 { return err } // Delete the disk file. diskFileBlob := container.GetBlobReference(vm.DiskFile) diskFileErr := diskFileBlob.Delete(opts) if err != nil { return fmt.Errorf("failed to delete OS file and disk file: %v, %v", err, diskFileErr) } return diskFileErr }
[ "func", "(", "vm", "*", "VM", ")", "deleteVMFiles", "(", "authorizer", "autorest", ".", "Authorizer", ")", "error", "{", "storageAccountsClient", ":=", "armStorage", ".", "NewAccountsClient", "(", "vm", ".", "Creds", ".", "SubscriptionID", ")", "\n", "storageAccountsClient", ".", "Authorizer", "=", "authorizer", "\n\n", "result", ",", "err", ":=", "storageAccountsClient", ".", "ListKeys", "(", "vm", ".", "ResourceGroup", ",", "vm", ".", "StorageAccount", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "accountKeys", ":=", "result", ".", "Keys", "\n", "if", "accountKeys", "==", "nil", "||", "len", "(", "*", "accountKeys", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "vm", ".", "StorageAccount", ")", "\n", "}", "\n\n", "accountKey", ":=", "*", "(", "*", "accountKeys", ")", "[", "0", "]", ".", "Value", "\n", "storageClient", ",", "err", ":=", "storage", ".", "NewBasicClient", "(", "vm", ".", "StorageAccount", ",", "accountKey", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Get a reference to the OS file.", "blobStorageClient", ":=", "storageClient", ".", "GetBlobService", "(", ")", "\n", "container", ":=", "blobStorageClient", ".", "GetContainerReference", "(", "vm", ".", "StorageContainer", ")", "\n", "osFileBlob", ":=", "container", ".", "GetBlobReference", "(", "vm", ".", "OsFile", ")", "\n\n", "// Delete the OS file.", "opts", ":=", "&", "storage", ".", "DeleteBlobOptions", "{", "Timeout", ":", "30", "}", "// 30s timeout", "\n", "err", "=", "osFileBlob", ".", "Delete", "(", "opts", ")", "\n\n", "if", "vm", ".", "DiskSize", "<=", "0", "{", "return", "err", "\n", "}", "\n\n", "// Delete the disk file.", "diskFileBlob", ":=", "container", ".", "GetBlobReference", "(", "vm", ".", "DiskFile", ")", "\n", "diskFileErr", ":=", "diskFileBlob", ".", "Delete", "(", "opts", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ",", "diskFileErr", ")", "\n", "}", "\n\n", "return", "diskFileErr", "\n", "}" ]
// deleteOSFile deletes the OS file from the VM's storage account, returns an error if the operation // does not succeed.
[ "deleteOSFile", "deletes", "the", "OS", "file", "from", "the", "VM", "s", "storage", "account", "returns", "an", "error", "if", "the", "operation", "does", "not", "succeed", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/arm/util.go#L231-L272
train
apcera/libretto
virtualmachine/azure/arm/util.go
deleteNic
func (vm *VM) deleteNic(authorizer autorest.Authorizer) error { interfaceClient := network.NewInterfacesClient(vm.Creds.SubscriptionID) interfaceClient.Authorizer = authorizer _, errc := interfaceClient.Delete(vm.ResourceGroup, vm.Nic, nil) return <-errc }
go
func (vm *VM) deleteNic(authorizer autorest.Authorizer) error { interfaceClient := network.NewInterfacesClient(vm.Creds.SubscriptionID) interfaceClient.Authorizer = authorizer _, errc := interfaceClient.Delete(vm.ResourceGroup, vm.Nic, nil) return <-errc }
[ "func", "(", "vm", "*", "VM", ")", "deleteNic", "(", "authorizer", "autorest", ".", "Authorizer", ")", "error", "{", "interfaceClient", ":=", "network", ".", "NewInterfacesClient", "(", "vm", ".", "Creds", ".", "SubscriptionID", ")", "\n", "interfaceClient", ".", "Authorizer", "=", "authorizer", "\n\n", "_", ",", "errc", ":=", "interfaceClient", ".", "Delete", "(", "vm", ".", "ResourceGroup", ",", "vm", ".", "Nic", ",", "nil", ")", "\n", "return", "<-", "errc", "\n", "}" ]
// deleteNic deletes the network interface for the given VM from the VM's resource group, returns an error // if the operation does not succeed.
[ "deleteNic", "deletes", "the", "network", "interface", "for", "the", "given", "VM", "from", "the", "VM", "s", "resource", "group", "returns", "an", "error", "if", "the", "operation", "does", "not", "succeed", "." ]
3178799fbb1e39c74b02e3ecf46330b3ef0ed486
https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/arm/util.go#L276-L282
train