id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
145,900
xanzy/go-cloudstack
cloudstack/BaremetalService.go
ListBaremetalPxeServers
func (s *BaremetalService) ListBaremetalPxeServers(p *ListBaremetalPxeServersParams) (*ListBaremetalPxeServersResponse, error) { resp, err := s.cs.newRequest("listBaremetalPxeServers", p.toURLValues()) if err != nil { return nil, err } var r ListBaremetalPxeServersResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *BaremetalService) ListBaremetalPxeServers(p *ListBaremetalPxeServersParams) (*ListBaremetalPxeServersResponse, error) { resp, err := s.cs.newRequest("listBaremetalPxeServers", p.toURLValues()) if err != nil { return nil, err } var r ListBaremetalPxeServersResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "BaremetalService", ")", "ListBaremetalPxeServers", "(", "p", "*", "ListBaremetalPxeServersParams", ")", "(", "*", "ListBaremetalPxeServersResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "ListBaremetalPxeServersResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// list baremetal pxe server
[ "list", "baremetal", "pxe", "server" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/BaremetalService.go#L822-L834
145,901
xanzy/go-cloudstack
cloudstack/BaremetalService.go
NewListBaremetalRctParams
func (s *BaremetalService) NewListBaremetalRctParams() *ListBaremetalRctParams { p := &ListBaremetalRctParams{} p.p = make(map[string]interface{}) return p }
go
func (s *BaremetalService) NewListBaremetalRctParams() *ListBaremetalRctParams { p := &ListBaremetalRctParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "BaremetalService", ")", "NewListBaremetalRctParams", "(", ")", "*", "ListBaremetalRctParams", "{", "p", ":=", "&", "ListBaremetalRctParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListBaremetalRctParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListBaremetalRctParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/BaremetalService.go#L897-L901
145,902
xanzy/go-cloudstack
cloudstack/BaremetalService.go
ListBaremetalRct
func (s *BaremetalService) ListBaremetalRct(p *ListBaremetalRctParams) (*ListBaremetalRctResponse, error) { resp, err := s.cs.newRequest("listBaremetalRct", p.toURLValues()) if err != nil { return nil, err } var r ListBaremetalRctResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *BaremetalService) ListBaremetalRct(p *ListBaremetalRctParams) (*ListBaremetalRctResponse, error) { resp, err := s.cs.newRequest("listBaremetalRct", p.toURLValues()) if err != nil { return nil, err } var r ListBaremetalRctResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "BaremetalService", ")", "ListBaremetalRct", "(", "p", "*", "ListBaremetalRctParams", ")", "(", "*", "ListBaremetalRctResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "ListBaremetalRctResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// list baremetal rack configuration
[ "list", "baremetal", "rack", "configuration" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/BaremetalService.go#L904-L916
145,903
xanzy/go-cloudstack
cloudstack/BaremetalService.go
NewNotifyBaremetalProvisionDoneParams
func (s *BaremetalService) NewNotifyBaremetalProvisionDoneParams(mac string) *NotifyBaremetalProvisionDoneParams { p := &NotifyBaremetalProvisionDoneParams{} p.p = make(map[string]interface{}) p.p["mac"] = mac return p }
go
func (s *BaremetalService) NewNotifyBaremetalProvisionDoneParams(mac string) *NotifyBaremetalProvisionDoneParams { p := &NotifyBaremetalProvisionDoneParams{} p.p = make(map[string]interface{}) p.p["mac"] = mac return p }
[ "func", "(", "s", "*", "BaremetalService", ")", "NewNotifyBaremetalProvisionDoneParams", "(", "mac", "string", ")", "*", "NotifyBaremetalProvisionDoneParams", "{", "p", ":=", "&", "NotifyBaremetalProvisionDoneParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "mac", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new NotifyBaremetalProvisionDoneParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "NotifyBaremetalProvisionDoneParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/BaremetalService.go#L953-L958
145,904
xanzy/go-cloudstack
cloudstack/BaremetalService.go
NotifyBaremetalProvisionDone
func (s *BaremetalService) NotifyBaremetalProvisionDone(p *NotifyBaremetalProvisionDoneParams) (*NotifyBaremetalProvisionDoneResponse, error) { resp, err := s.cs.newRequest("notifyBaremetalProvisionDone", p.toURLValues()) if err != nil { return nil, err } var r NotifyBaremetalProvisionDoneResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
go
func (s *BaremetalService) NotifyBaremetalProvisionDone(p *NotifyBaremetalProvisionDoneParams) (*NotifyBaremetalProvisionDoneResponse, error) { resp, err := s.cs.newRequest("notifyBaremetalProvisionDone", p.toURLValues()) if err != nil { return nil, err } var r NotifyBaremetalProvisionDoneResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
[ "func", "(", "s", "*", "BaremetalService", ")", "NotifyBaremetalProvisionDone", "(", "p", "*", "NotifyBaremetalProvisionDoneParams", ")", "(", "*", "NotifyBaremetalProvisionDoneResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "NotifyBaremetalProvisionDoneResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// If we have a async client, we need to wait for the async result", "if", "s", ".", "cs", ".", "async", "{", "b", ",", "err", ":=", "s", ".", "cs", ".", "GetAsyncJobResult", "(", "r", ".", "JobID", ",", "s", ".", "cs", ".", "timeout", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "AsyncTimeoutErr", "{", "return", "&", "r", ",", "err", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "b", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Notify provision has been done on a host. This api is for baremetal virtual router service, not for end user
[ "Notify", "provision", "has", "been", "done", "on", "a", "host", ".", "This", "api", "is", "for", "baremetal", "virtual", "router", "service", "not", "for", "end", "user" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/BaremetalService.go#L961-L988
145,905
xanzy/go-cloudstack
cloudstack/PortableIPService.go
NewCreatePortableIpRangeParams
func (s *PortableIPService) NewCreatePortableIpRangeParams(endip string, gateway string, netmask string, regionid int, startip string) *CreatePortableIpRangeParams { p := &CreatePortableIpRangeParams{} p.p = make(map[string]interface{}) p.p["endip"] = endip p.p["gateway"] = gateway p.p["netmask"] = netmask p.p["regionid"] = regionid p.p["startip"] = startip return p }
go
func (s *PortableIPService) NewCreatePortableIpRangeParams(endip string, gateway string, netmask string, regionid int, startip string) *CreatePortableIpRangeParams { p := &CreatePortableIpRangeParams{} p.p = make(map[string]interface{}) p.p["endip"] = endip p.p["gateway"] = gateway p.p["netmask"] = netmask p.p["regionid"] = regionid p.p["startip"] = startip return p }
[ "func", "(", "s", "*", "PortableIPService", ")", "NewCreatePortableIpRangeParams", "(", "endip", "string", ",", "gateway", "string", ",", "netmask", "string", ",", "regionid", "int", ",", "startip", "string", ")", "*", "CreatePortableIpRangeParams", "{", "p", ":=", "&", "CreatePortableIpRangeParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "endip", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "gateway", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "netmask", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "regionid", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "startip", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new CreatePortableIpRangeParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "CreatePortableIpRangeParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/PortableIPService.go#L108-L117
145,906
xanzy/go-cloudstack
cloudstack/PortableIPService.go
CreatePortableIpRange
func (s *PortableIPService) CreatePortableIpRange(p *CreatePortableIpRangeParams) (*CreatePortableIpRangeResponse, error) { resp, err := s.cs.newRequest("createPortableIpRange", p.toURLValues()) if err != nil { return nil, err } var r CreatePortableIpRangeResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } b, err = getRawValue(b) if err != nil { return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
go
func (s *PortableIPService) CreatePortableIpRange(p *CreatePortableIpRangeParams) (*CreatePortableIpRangeResponse, error) { resp, err := s.cs.newRequest("createPortableIpRange", p.toURLValues()) if err != nil { return nil, err } var r CreatePortableIpRangeResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } b, err = getRawValue(b) if err != nil { return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
[ "func", "(", "s", "*", "PortableIPService", ")", "CreatePortableIpRange", "(", "p", "*", "CreatePortableIpRangeParams", ")", "(", "*", "CreatePortableIpRangeResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "CreatePortableIpRangeResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// If we have a async client, we need to wait for the async result", "if", "s", ".", "cs", ".", "async", "{", "b", ",", "err", ":=", "s", ".", "cs", ".", "GetAsyncJobResult", "(", "r", ".", "JobID", ",", "s", ".", "cs", ".", "timeout", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "AsyncTimeoutErr", "{", "return", "&", "r", ",", "err", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "b", ",", "err", "=", "getRawValue", "(", "b", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "b", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// adds a range of portable public IP's to a region
[ "adds", "a", "range", "of", "portable", "public", "IP", "s", "to", "a", "region" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/PortableIPService.go#L120-L152
145,907
xanzy/go-cloudstack
cloudstack/PortableIPService.go
NewDeletePortableIpRangeParams
func (s *PortableIPService) NewDeletePortableIpRangeParams(id string) *DeletePortableIpRangeParams { p := &DeletePortableIpRangeParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
go
func (s *PortableIPService) NewDeletePortableIpRangeParams(id string) *DeletePortableIpRangeParams { p := &DeletePortableIpRangeParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
[ "func", "(", "s", "*", "PortableIPService", ")", "NewDeletePortableIpRangeParams", "(", "id", "string", ")", "*", "DeletePortableIpRangeParams", "{", "p", ":=", "&", "DeletePortableIpRangeParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new DeletePortableIpRangeParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "DeletePortableIpRangeParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/PortableIPService.go#L204-L209
145,908
xanzy/go-cloudstack
cloudstack/PortableIPService.go
DeletePortableIpRange
func (s *PortableIPService) DeletePortableIpRange(p *DeletePortableIpRangeParams) (*DeletePortableIpRangeResponse, error) { resp, err := s.cs.newRequest("deletePortableIpRange", p.toURLValues()) if err != nil { return nil, err } var r DeletePortableIpRangeResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
go
func (s *PortableIPService) DeletePortableIpRange(p *DeletePortableIpRangeParams) (*DeletePortableIpRangeResponse, error) { resp, err := s.cs.newRequest("deletePortableIpRange", p.toURLValues()) if err != nil { return nil, err } var r DeletePortableIpRangeResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
[ "func", "(", "s", "*", "PortableIPService", ")", "DeletePortableIpRange", "(", "p", "*", "DeletePortableIpRangeParams", ")", "(", "*", "DeletePortableIpRangeResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "DeletePortableIpRangeResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// If we have a async client, we need to wait for the async result", "if", "s", ".", "cs", ".", "async", "{", "b", ",", "err", ":=", "s", ".", "cs", ".", "GetAsyncJobResult", "(", "r", ".", "JobID", ",", "s", ".", "cs", ".", "timeout", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "AsyncTimeoutErr", "{", "return", "&", "r", ",", "err", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "b", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// deletes a range of portable public IP's associated with a region
[ "deletes", "a", "range", "of", "portable", "public", "IP", "s", "associated", "with", "a", "region" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/PortableIPService.go#L212-L239
145,909
xanzy/go-cloudstack
cloudstack/PortableIPService.go
NewListPortableIpRangesParams
func (s *PortableIPService) NewListPortableIpRangesParams() *ListPortableIpRangesParams { p := &ListPortableIpRangesParams{} p.p = make(map[string]interface{}) return p }
go
func (s *PortableIPService) NewListPortableIpRangesParams() *ListPortableIpRangesParams { p := &ListPortableIpRangesParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "PortableIPService", ")", "NewListPortableIpRangesParams", "(", ")", "*", "ListPortableIpRangesParams", "{", "p", ":=", "&", "ListPortableIpRangesParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListPortableIpRangesParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListPortableIpRangesParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/PortableIPService.go#L319-L323
145,910
xanzy/go-cloudstack
cloudstack/PortableIPService.go
ListPortableIpRanges
func (s *PortableIPService) ListPortableIpRanges(p *ListPortableIpRangesParams) (*ListPortableIpRangesResponse, error) { resp, err := s.cs.newRequest("listPortableIpRanges", p.toURLValues()) if err != nil { return nil, err } var r ListPortableIpRangesResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *PortableIPService) ListPortableIpRanges(p *ListPortableIpRangesParams) (*ListPortableIpRangesResponse, error) { resp, err := s.cs.newRequest("listPortableIpRanges", p.toURLValues()) if err != nil { return nil, err } var r ListPortableIpRangesResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "PortableIPService", ")", "ListPortableIpRanges", "(", "p", "*", "ListPortableIpRangesParams", ")", "(", "*", "ListPortableIpRangesResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "ListPortableIpRangesResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// list portable IP ranges
[ "list", "portable", "IP", "ranges" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/PortableIPService.go#L359-L371
145,911
xanzy/go-cloudstack
cloudstack/ResourcetagsService.go
NewCreateTagsParams
func (s *ResourcetagsService) NewCreateTagsParams(resourceids []string, resourcetype string, tags map[string]string) *CreateTagsParams { p := &CreateTagsParams{} p.p = make(map[string]interface{}) p.p["resourceids"] = resourceids p.p["resourcetype"] = resourcetype p.p["tags"] = tags return p }
go
func (s *ResourcetagsService) NewCreateTagsParams(resourceids []string, resourcetype string, tags map[string]string) *CreateTagsParams { p := &CreateTagsParams{} p.p = make(map[string]interface{}) p.p["resourceids"] = resourceids p.p["resourcetype"] = resourcetype p.p["tags"] = tags return p }
[ "func", "(", "s", "*", "ResourcetagsService", ")", "NewCreateTagsParams", "(", "resourceids", "[", "]", "string", ",", "resourcetype", "string", ",", "tags", "map", "[", "string", "]", "string", ")", "*", "CreateTagsParams", "{", "p", ":=", "&", "CreateTagsParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "resourceids", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "resourcetype", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "tags", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new CreateTagsParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "CreateTagsParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/ResourcetagsService.go#L91-L98
145,912
xanzy/go-cloudstack
cloudstack/ResourcetagsService.go
NewDeleteTagsParams
func (s *ResourcetagsService) NewDeleteTagsParams(resourceids []string, resourcetype string) *DeleteTagsParams { p := &DeleteTagsParams{} p.p = make(map[string]interface{}) p.p["resourceids"] = resourceids p.p["resourcetype"] = resourcetype return p }
go
func (s *ResourcetagsService) NewDeleteTagsParams(resourceids []string, resourcetype string) *DeleteTagsParams { p := &DeleteTagsParams{} p.p = make(map[string]interface{}) p.p["resourceids"] = resourceids p.p["resourcetype"] = resourcetype return p }
[ "func", "(", "s", "*", "ResourcetagsService", ")", "NewDeleteTagsParams", "(", "resourceids", "[", "]", "string", ",", "resourcetype", "string", ")", "*", "DeleteTagsParams", "{", "p", ":=", "&", "DeleteTagsParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "resourceids", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "resourcetype", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new DeleteTagsParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "DeleteTagsParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/ResourcetagsService.go#L189-L195
145,913
xanzy/go-cloudstack
cloudstack/ResourcetagsService.go
NewListStorageTagsParams
func (s *ResourcetagsService) NewListStorageTagsParams() *ListStorageTagsParams { p := &ListStorageTagsParams{} p.p = make(map[string]interface{}) return p }
go
func (s *ResourcetagsService) NewListStorageTagsParams() *ListStorageTagsParams { p := &ListStorageTagsParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "ResourcetagsService", ")", "NewListStorageTagsParams", "(", ")", "*", "ListStorageTagsParams", "{", "p", ":=", "&", "ListStorageTagsParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListStorageTagsParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListStorageTagsParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/ResourcetagsService.go#L282-L286
145,914
xanzy/go-cloudstack
cloudstack/ResourcetagsService.go
NewListTagsParams
func (s *ResourcetagsService) NewListTagsParams() *ListTagsParams { p := &ListTagsParams{} p.p = make(map[string]interface{}) return p }
go
func (s *ResourcetagsService) NewListTagsParams() *ListTagsParams { p := &ListTagsParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "ResourcetagsService", ")", "NewListTagsParams", "(", ")", "*", "ListTagsParams", "{", "p", ":=", "&", "ListTagsParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListTagsParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListTagsParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/ResourcetagsService.go#L511-L515
145,915
xanzy/go-cloudstack
cloudstack/NetworkOfferingService.go
NewCreateNetworkOfferingParams
func (s *NetworkOfferingService) NewCreateNetworkOfferingParams(displaytext string, guestiptype string, name string, supportedservices []string, traffictype string) *CreateNetworkOfferingParams { p := &CreateNetworkOfferingParams{} p.p = make(map[string]interface{}) p.p["displaytext"] = displaytext p.p["guestiptype"] = guestiptype p.p["name"] = name p.p["supportedservices"] = supportedservices p.p["traffictype"] = traffictype return p }
go
func (s *NetworkOfferingService) NewCreateNetworkOfferingParams(displaytext string, guestiptype string, name string, supportedservices []string, traffictype string) *CreateNetworkOfferingParams { p := &CreateNetworkOfferingParams{} p.p = make(map[string]interface{}) p.p["displaytext"] = displaytext p.p["guestiptype"] = guestiptype p.p["name"] = name p.p["supportedservices"] = supportedservices p.p["traffictype"] = traffictype return p }
[ "func", "(", "s", "*", "NetworkOfferingService", ")", "NewCreateNetworkOfferingParams", "(", "displaytext", "string", ",", "guestiptype", "string", ",", "name", "string", ",", "supportedservices", "[", "]", "string", ",", "traffictype", "string", ")", "*", "CreateNetworkOfferingParams", "{", "p", ":=", "&", "CreateNetworkOfferingParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "displaytext", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "guestiptype", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "name", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "supportedservices", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "traffictype", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new CreateNetworkOfferingParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "CreateNetworkOfferingParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/NetworkOfferingService.go#L285-L294
145,916
xanzy/go-cloudstack
cloudstack/NetworkOfferingService.go
NewDeleteNetworkOfferingParams
func (s *NetworkOfferingService) NewDeleteNetworkOfferingParams(id string) *DeleteNetworkOfferingParams { p := &DeleteNetworkOfferingParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
go
func (s *NetworkOfferingService) NewDeleteNetworkOfferingParams(id string) *DeleteNetworkOfferingParams { p := &DeleteNetworkOfferingParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
[ "func", "(", "s", "*", "NetworkOfferingService", ")", "NewDeleteNetworkOfferingParams", "(", "id", "string", ")", "*", "DeleteNetworkOfferingParams", "{", "p", ":=", "&", "DeleteNetworkOfferingParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new DeleteNetworkOfferingParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "DeleteNetworkOfferingParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/NetworkOfferingService.go#L388-L393
145,917
xanzy/go-cloudstack
cloudstack/NetworkOfferingService.go
NewListNetworkOfferingsParams
func (s *NetworkOfferingService) NewListNetworkOfferingsParams() *ListNetworkOfferingsParams { p := &ListNetworkOfferingsParams{} p.p = make(map[string]interface{}) return p }
go
func (s *NetworkOfferingService) NewListNetworkOfferingsParams() *ListNetworkOfferingsParams { p := &ListNetworkOfferingsParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "NetworkOfferingService", ")", "NewListNetworkOfferingsParams", "(", ")", "*", "ListNetworkOfferingsParams", "{", "p", ":=", "&", "ListNetworkOfferingsParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListNetworkOfferingsParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListNetworkOfferingsParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/NetworkOfferingService.go#L677-L681
145,918
xanzy/go-cloudstack
cloudstack/NetworkOfferingService.go
NewUpdateNetworkOfferingParams
func (s *NetworkOfferingService) NewUpdateNetworkOfferingParams() *UpdateNetworkOfferingParams { p := &UpdateNetworkOfferingParams{} p.p = make(map[string]interface{}) return p }
go
func (s *NetworkOfferingService) NewUpdateNetworkOfferingParams() *UpdateNetworkOfferingParams { p := &UpdateNetworkOfferingParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "NetworkOfferingService", ")", "NewUpdateNetworkOfferingParams", "(", ")", "*", "UpdateNetworkOfferingParams", "{", "p", ":=", "&", "UpdateNetworkOfferingParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new UpdateNetworkOfferingParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "UpdateNetworkOfferingParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/NetworkOfferingService.go#L950-L954
145,919
xanzy/go-cloudstack
cloudstack/AffinityGroupService.go
NewCreateAffinityGroupParams
func (s *AffinityGroupService) NewCreateAffinityGroupParams(name string, affinityGroupType string) *CreateAffinityGroupParams { p := &CreateAffinityGroupParams{} p.p = make(map[string]interface{}) p.p["name"] = name p.p["type"] = affinityGroupType return p }
go
func (s *AffinityGroupService) NewCreateAffinityGroupParams(name string, affinityGroupType string) *CreateAffinityGroupParams { p := &CreateAffinityGroupParams{} p.p = make(map[string]interface{}) p.p["name"] = name p.p["type"] = affinityGroupType return p }
[ "func", "(", "s", "*", "AffinityGroupService", ")", "NewCreateAffinityGroupParams", "(", "name", "string", ",", "affinityGroupType", "string", ")", "*", "CreateAffinityGroupParams", "{", "p", ":=", "&", "CreateAffinityGroupParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "name", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "affinityGroupType", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new CreateAffinityGroupParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "CreateAffinityGroupParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/AffinityGroupService.go#L107-L113
145,920
xanzy/go-cloudstack
cloudstack/AffinityGroupService.go
NewDeleteAffinityGroupParams
func (s *AffinityGroupService) NewDeleteAffinityGroupParams() *DeleteAffinityGroupParams { p := &DeleteAffinityGroupParams{} p.p = make(map[string]interface{}) return p }
go
func (s *AffinityGroupService) NewDeleteAffinityGroupParams() *DeleteAffinityGroupParams { p := &DeleteAffinityGroupParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "AffinityGroupService", ")", "NewDeleteAffinityGroupParams", "(", ")", "*", "DeleteAffinityGroupParams", "{", "p", ":=", "&", "DeleteAffinityGroupParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new DeleteAffinityGroupParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "DeleteAffinityGroupParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/AffinityGroupService.go#L233-L237
145,921
xanzy/go-cloudstack
cloudstack/AffinityGroupService.go
NewListAffinityGroupTypesParams
func (s *AffinityGroupService) NewListAffinityGroupTypesParams() *ListAffinityGroupTypesParams { p := &ListAffinityGroupTypesParams{} p.p = make(map[string]interface{}) return p }
go
func (s *AffinityGroupService) NewListAffinityGroupTypesParams() *ListAffinityGroupTypesParams { p := &ListAffinityGroupTypesParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "AffinityGroupService", ")", "NewListAffinityGroupTypesParams", "(", ")", "*", "ListAffinityGroupTypesParams", "{", "p", ":=", "&", "ListAffinityGroupTypesParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListAffinityGroupTypesParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListAffinityGroupTypesParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/AffinityGroupService.go#L324-L328
145,922
xanzy/go-cloudstack
cloudstack/AffinityGroupService.go
NewListAffinityGroupsParams
func (s *AffinityGroupService) NewListAffinityGroupsParams() *ListAffinityGroupsParams { p := &ListAffinityGroupsParams{} p.p = make(map[string]interface{}) return p }
go
func (s *AffinityGroupService) NewListAffinityGroupsParams() *ListAffinityGroupsParams { p := &ListAffinityGroupsParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "AffinityGroupService", ")", "NewListAffinityGroupsParams", "(", ")", "*", "ListAffinityGroupsParams", "{", "p", ":=", "&", "ListAffinityGroupsParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListAffinityGroupsParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListAffinityGroupsParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/AffinityGroupService.go#L504-L508
145,923
xanzy/go-cloudstack
cloudstack/AffinityGroupService.go
NewUpdateVMAffinityGroupParams
func (s *AffinityGroupService) NewUpdateVMAffinityGroupParams(id string) *UpdateVMAffinityGroupParams { p := &UpdateVMAffinityGroupParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
go
func (s *AffinityGroupService) NewUpdateVMAffinityGroupParams(id string) *UpdateVMAffinityGroupParams { p := &UpdateVMAffinityGroupParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
[ "func", "(", "s", "*", "AffinityGroupService", ")", "NewUpdateVMAffinityGroupParams", "(", "id", "string", ")", "*", "UpdateVMAffinityGroupParams", "{", "p", ":=", "&", "UpdateVMAffinityGroupParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new UpdateVMAffinityGroupParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "UpdateVMAffinityGroupParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/AffinityGroupService.go#L683-L688
145,924
xanzy/go-cloudstack
cloudstack/StratosphereSSPService.go
NewAddStratosphereSspParams
func (s *StratosphereSSPService) NewAddStratosphereSspParams(name string, url string, zoneid string) *AddStratosphereSspParams { p := &AddStratosphereSspParams{} p.p = make(map[string]interface{}) p.p["name"] = name p.p["url"] = url p.p["zoneid"] = zoneid return p }
go
func (s *StratosphereSSPService) NewAddStratosphereSspParams(name string, url string, zoneid string) *AddStratosphereSspParams { p := &AddStratosphereSspParams{} p.p = make(map[string]interface{}) p.p["name"] = name p.p["url"] = url p.p["zoneid"] = zoneid return p }
[ "func", "(", "s", "*", "StratosphereSSPService", ")", "NewAddStratosphereSspParams", "(", "name", "string", ",", "url", "string", ",", "zoneid", "string", ")", "*", "AddStratosphereSspParams", "{", "p", ":=", "&", "AddStratosphereSspParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "name", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "url", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "zoneid", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new AddStratosphereSspParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "AddStratosphereSspParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/StratosphereSSPService.go#L104-L111
145,925
xanzy/go-cloudstack
cloudstack/StratosphereSSPService.go
AddStratosphereSsp
func (s *StratosphereSSPService) AddStratosphereSsp(p *AddStratosphereSspParams) (*AddStratosphereSspResponse, error) { resp, err := s.cs.newRequest("addStratosphereSsp", p.toURLValues()) if err != nil { return nil, err } var r AddStratosphereSspResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *StratosphereSSPService) AddStratosphereSsp(p *AddStratosphereSspParams) (*AddStratosphereSspResponse, error) { resp, err := s.cs.newRequest("addStratosphereSsp", p.toURLValues()) if err != nil { return nil, err } var r AddStratosphereSspResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "StratosphereSSPService", ")", "AddStratosphereSsp", "(", "p", "*", "AddStratosphereSspParams", ")", "(", "*", "AddStratosphereSspResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "AddStratosphereSspResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Adds stratosphere ssp server
[ "Adds", "stratosphere", "ssp", "server" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/StratosphereSSPService.go#L114-L126
145,926
xanzy/go-cloudstack
cloudstack/StratosphereSSPService.go
NewDeleteStratosphereSspParams
func (s *StratosphereSSPService) NewDeleteStratosphereSspParams(hostid string) *DeleteStratosphereSspParams { p := &DeleteStratosphereSspParams{} p.p = make(map[string]interface{}) p.p["hostid"] = hostid return p }
go
func (s *StratosphereSSPService) NewDeleteStratosphereSspParams(hostid string) *DeleteStratosphereSspParams { p := &DeleteStratosphereSspParams{} p.p = make(map[string]interface{}) p.p["hostid"] = hostid return p }
[ "func", "(", "s", "*", "StratosphereSSPService", ")", "NewDeleteStratosphereSspParams", "(", "hostid", "string", ")", "*", "DeleteStratosphereSspParams", "{", "p", ":=", "&", "DeleteStratosphereSspParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "hostid", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new DeleteStratosphereSspParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "DeleteStratosphereSspParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/StratosphereSSPService.go#L160-L165
145,927
xanzy/go-cloudstack
cloudstack/StratosphereSSPService.go
DeleteStratosphereSsp
func (s *StratosphereSSPService) DeleteStratosphereSsp(p *DeleteStratosphereSspParams) (*DeleteStratosphereSspResponse, error) { resp, err := s.cs.newRequest("deleteStratosphereSsp", p.toURLValues()) if err != nil { return nil, err } var r DeleteStratosphereSspResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *StratosphereSSPService) DeleteStratosphereSsp(p *DeleteStratosphereSspParams) (*DeleteStratosphereSspResponse, error) { resp, err := s.cs.newRequest("deleteStratosphereSsp", p.toURLValues()) if err != nil { return nil, err } var r DeleteStratosphereSspResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "StratosphereSSPService", ")", "DeleteStratosphereSsp", "(", "p", "*", "DeleteStratosphereSspParams", ")", "(", "*", "DeleteStratosphereSspResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "DeleteStratosphereSspResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Removes stratosphere ssp server
[ "Removes", "stratosphere", "ssp", "server" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/StratosphereSSPService.go#L168-L180
145,928
xanzy/go-cloudstack
cloudstack/AlertService.go
NewArchiveAlertsParams
func (s *AlertService) NewArchiveAlertsParams() *ArchiveAlertsParams { p := &ArchiveAlertsParams{} p.p = make(map[string]interface{}) return p }
go
func (s *AlertService) NewArchiveAlertsParams() *ArchiveAlertsParams { p := &ArchiveAlertsParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "AlertService", ")", "NewArchiveAlertsParams", "(", ")", "*", "ArchiveAlertsParams", "{", "p", ":=", "&", "ArchiveAlertsParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ArchiveAlertsParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ArchiveAlertsParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/AlertService.go#L86-L90
145,929
xanzy/go-cloudstack
cloudstack/AlertService.go
ArchiveAlerts
func (s *AlertService) ArchiveAlerts(p *ArchiveAlertsParams) (*ArchiveAlertsResponse, error) { resp, err := s.cs.newRequest("archiveAlerts", p.toURLValues()) if err != nil { return nil, err } var r ArchiveAlertsResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *AlertService) ArchiveAlerts(p *ArchiveAlertsParams) (*ArchiveAlertsResponse, error) { resp, err := s.cs.newRequest("archiveAlerts", p.toURLValues()) if err != nil { return nil, err } var r ArchiveAlertsResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "AlertService", ")", "ArchiveAlerts", "(", "p", "*", "ArchiveAlertsParams", ")", "(", "*", "ArchiveAlertsResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "ArchiveAlertsResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Archive one or more alerts.
[ "Archive", "one", "or", "more", "alerts", "." ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/AlertService.go#L93-L105
145,930
xanzy/go-cloudstack
cloudstack/AlertService.go
NewDeleteAlertsParams
func (s *AlertService) NewDeleteAlertsParams() *DeleteAlertsParams { p := &DeleteAlertsParams{} p.p = make(map[string]interface{}) return p }
go
func (s *AlertService) NewDeleteAlertsParams() *DeleteAlertsParams { p := &DeleteAlertsParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "AlertService", ")", "NewDeleteAlertsParams", "(", ")", "*", "DeleteAlertsParams", "{", "p", ":=", "&", "DeleteAlertsParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new DeleteAlertsParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "DeleteAlertsParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/AlertService.go#L190-L194
145,931
xanzy/go-cloudstack
cloudstack/AlertService.go
DeleteAlerts
func (s *AlertService) DeleteAlerts(p *DeleteAlertsParams) (*DeleteAlertsResponse, error) { resp, err := s.cs.newRequest("deleteAlerts", p.toURLValues()) if err != nil { return nil, err } var r DeleteAlertsResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *AlertService) DeleteAlerts(p *DeleteAlertsParams) (*DeleteAlertsResponse, error) { resp, err := s.cs.newRequest("deleteAlerts", p.toURLValues()) if err != nil { return nil, err } var r DeleteAlertsResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "AlertService", ")", "DeleteAlerts", "(", "p", "*", "DeleteAlertsParams", ")", "(", "*", "DeleteAlertsResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "DeleteAlertsResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Delete one or more alerts.
[ "Delete", "one", "or", "more", "alerts", "." ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/AlertService.go#L197-L209
145,932
xanzy/go-cloudstack
cloudstack/AlertService.go
NewGenerateAlertParams
func (s *AlertService) NewGenerateAlertParams(description string, name string, alertType int) *GenerateAlertParams { p := &GenerateAlertParams{} p.p = make(map[string]interface{}) p.p["description"] = description p.p["name"] = name p.p["type"] = alertType return p }
go
func (s *AlertService) NewGenerateAlertParams(description string, name string, alertType int) *GenerateAlertParams { p := &GenerateAlertParams{} p.p = make(map[string]interface{}) p.p["description"] = description p.p["name"] = name p.p["type"] = alertType return p }
[ "func", "(", "s", "*", "AlertService", ")", "NewGenerateAlertParams", "(", "description", "string", ",", "name", "string", ",", "alertType", "int", ")", "*", "GenerateAlertParams", "{", "p", ":=", "&", "GenerateAlertParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "description", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "name", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "alertType", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new GenerateAlertParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "GenerateAlertParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/AlertService.go#L305-L312
145,933
xanzy/go-cloudstack
cloudstack/AlertService.go
GenerateAlert
func (s *AlertService) GenerateAlert(p *GenerateAlertParams) (*GenerateAlertResponse, error) { resp, err := s.cs.newRequest("generateAlert", p.toURLValues()) if err != nil { return nil, err } var r GenerateAlertResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
go
func (s *AlertService) GenerateAlert(p *GenerateAlertParams) (*GenerateAlertResponse, error) { resp, err := s.cs.newRequest("generateAlert", p.toURLValues()) if err != nil { return nil, err } var r GenerateAlertResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
[ "func", "(", "s", "*", "AlertService", ")", "GenerateAlert", "(", "p", "*", "GenerateAlertParams", ")", "(", "*", "GenerateAlertResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "GenerateAlertResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// If we have a async client, we need to wait for the async result", "if", "s", ".", "cs", ".", "async", "{", "b", ",", "err", ":=", "s", ".", "cs", ".", "GetAsyncJobResult", "(", "r", ".", "JobID", ",", "s", ".", "cs", ".", "timeout", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "AsyncTimeoutErr", "{", "return", "&", "r", ",", "err", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "b", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Generates an alert
[ "Generates", "an", "alert" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/AlertService.go#L315-L342
145,934
xanzy/go-cloudstack
cloudstack/AlertService.go
NewListAlertsParams
func (s *AlertService) NewListAlertsParams() *ListAlertsParams { p := &ListAlertsParams{} p.p = make(map[string]interface{}) return p }
go
func (s *AlertService) NewListAlertsParams() *ListAlertsParams { p := &ListAlertsParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "AlertService", ")", "NewListAlertsParams", "(", ")", "*", "ListAlertsParams", "{", "p", ":=", "&", "ListAlertsParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListAlertsParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListAlertsParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/AlertService.go#L432-L436
145,935
xanzy/go-cloudstack
cloudstack/AlertService.go
ListAlerts
func (s *AlertService) ListAlerts(p *ListAlertsParams) (*ListAlertsResponse, error) { resp, err := s.cs.newRequest("listAlerts", p.toURLValues()) if err != nil { return nil, err } var r ListAlertsResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *AlertService) ListAlerts(p *ListAlertsParams) (*ListAlertsResponse, error) { resp, err := s.cs.newRequest("listAlerts", p.toURLValues()) if err != nil { return nil, err } var r ListAlertsResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "AlertService", ")", "ListAlerts", "(", "p", "*", "ListAlertsParams", ")", "(", "*", "ListAlertsResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "ListAlertsResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Lists all alerts.
[ "Lists", "all", "alerts", "." ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/AlertService.go#L522-L534
145,936
xanzy/go-cloudstack
cloudstack/RouterService.go
NewChangeServiceForRouterParams
func (s *RouterService) NewChangeServiceForRouterParams(id string, serviceofferingid string) *ChangeServiceForRouterParams { p := &ChangeServiceForRouterParams{} p.p = make(map[string]interface{}) p.p["id"] = id p.p["serviceofferingid"] = serviceofferingid return p }
go
func (s *RouterService) NewChangeServiceForRouterParams(id string, serviceofferingid string) *ChangeServiceForRouterParams { p := &ChangeServiceForRouterParams{} p.p = make(map[string]interface{}) p.p["id"] = id p.p["serviceofferingid"] = serviceofferingid return p }
[ "func", "(", "s", "*", "RouterService", ")", "NewChangeServiceForRouterParams", "(", "id", "string", ",", "serviceofferingid", "string", ")", "*", "ChangeServiceForRouterParams", "{", "p", ":=", "&", "ChangeServiceForRouterParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "serviceofferingid", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ChangeServiceForRouterParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ChangeServiceForRouterParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RouterService.go#L63-L69
145,937
xanzy/go-cloudstack
cloudstack/RouterService.go
ChangeServiceForRouter
func (s *RouterService) ChangeServiceForRouter(p *ChangeServiceForRouterParams) (*ChangeServiceForRouterResponse, error) { resp, err := s.cs.newRequest("changeServiceForRouter", p.toURLValues()) if err != nil { return nil, err } var r ChangeServiceForRouterResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *RouterService) ChangeServiceForRouter(p *ChangeServiceForRouterParams) (*ChangeServiceForRouterResponse, error) { resp, err := s.cs.newRequest("changeServiceForRouter", p.toURLValues()) if err != nil { return nil, err } var r ChangeServiceForRouterResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "RouterService", ")", "ChangeServiceForRouter", "(", "p", "*", "ChangeServiceForRouterParams", ")", "(", "*", "ChangeServiceForRouterResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "ChangeServiceForRouterResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Upgrades domain router to a new service offering
[ "Upgrades", "domain", "router", "to", "a", "new", "service", "offering" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RouterService.go#L72-L84
145,938
xanzy/go-cloudstack
cloudstack/RouterService.go
NewConfigureVirtualRouterElementParams
func (s *RouterService) NewConfigureVirtualRouterElementParams(enabled bool, id string) *ConfigureVirtualRouterElementParams { p := &ConfigureVirtualRouterElementParams{} p.p = make(map[string]interface{}) p.p["enabled"] = enabled p.p["id"] = id return p }
go
func (s *RouterService) NewConfigureVirtualRouterElementParams(enabled bool, id string) *ConfigureVirtualRouterElementParams { p := &ConfigureVirtualRouterElementParams{} p.p = make(map[string]interface{}) p.p["enabled"] = enabled p.p["id"] = id return p }
[ "func", "(", "s", "*", "RouterService", ")", "NewConfigureVirtualRouterElementParams", "(", "enabled", "bool", ",", "id", "string", ")", "*", "ConfigureVirtualRouterElementParams", "{", "p", ":=", "&", "ConfigureVirtualRouterElementParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "enabled", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ConfigureVirtualRouterElementParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ConfigureVirtualRouterElementParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RouterService.go#L172-L178
145,939
xanzy/go-cloudstack
cloudstack/RouterService.go
ConfigureVirtualRouterElement
func (s *RouterService) ConfigureVirtualRouterElement(p *ConfigureVirtualRouterElementParams) (*VirtualRouterElementResponse, error) { resp, err := s.cs.newRequest("configureVirtualRouterElement", p.toURLValues()) if err != nil { return nil, err } var r VirtualRouterElementResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } b, err = getRawValue(b) if err != nil { return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
go
func (s *RouterService) ConfigureVirtualRouterElement(p *ConfigureVirtualRouterElementParams) (*VirtualRouterElementResponse, error) { resp, err := s.cs.newRequest("configureVirtualRouterElement", p.toURLValues()) if err != nil { return nil, err } var r VirtualRouterElementResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } b, err = getRawValue(b) if err != nil { return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
[ "func", "(", "s", "*", "RouterService", ")", "ConfigureVirtualRouterElement", "(", "p", "*", "ConfigureVirtualRouterElementParams", ")", "(", "*", "VirtualRouterElementResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "VirtualRouterElementResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// If we have a async client, we need to wait for the async result", "if", "s", ".", "cs", ".", "async", "{", "b", ",", "err", ":=", "s", ".", "cs", ".", "GetAsyncJobResult", "(", "r", ".", "JobID", ",", "s", ".", "cs", ".", "timeout", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "AsyncTimeoutErr", "{", "return", "&", "r", ",", "err", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "b", ",", "err", "=", "getRawValue", "(", "b", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "b", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Configures a virtual router element.
[ "Configures", "a", "virtual", "router", "element", "." ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RouterService.go#L181-L213
145,940
xanzy/go-cloudstack
cloudstack/RouterService.go
NewCreateVirtualRouterElementParams
func (s *RouterService) NewCreateVirtualRouterElementParams(nspid string) *CreateVirtualRouterElementParams { p := &CreateVirtualRouterElementParams{} p.p = make(map[string]interface{}) p.p["nspid"] = nspid return p }
go
func (s *RouterService) NewCreateVirtualRouterElementParams(nspid string) *CreateVirtualRouterElementParams { p := &CreateVirtualRouterElementParams{} p.p = make(map[string]interface{}) p.p["nspid"] = nspid return p }
[ "func", "(", "s", "*", "RouterService", ")", "NewCreateVirtualRouterElementParams", "(", "nspid", "string", ")", "*", "CreateVirtualRouterElementParams", "{", "p", ":=", "&", "CreateVirtualRouterElementParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "nspid", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new CreateVirtualRouterElementParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "CreateVirtualRouterElementParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RouterService.go#L263-L268
145,941
xanzy/go-cloudstack
cloudstack/RouterService.go
CreateVirtualRouterElement
func (s *RouterService) CreateVirtualRouterElement(p *CreateVirtualRouterElementParams) (*CreateVirtualRouterElementResponse, error) { resp, err := s.cs.newRequest("createVirtualRouterElement", p.toURLValues()) if err != nil { return nil, err } var r CreateVirtualRouterElementResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } b, err = getRawValue(b) if err != nil { return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
go
func (s *RouterService) CreateVirtualRouterElement(p *CreateVirtualRouterElementParams) (*CreateVirtualRouterElementResponse, error) { resp, err := s.cs.newRequest("createVirtualRouterElement", p.toURLValues()) if err != nil { return nil, err } var r CreateVirtualRouterElementResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } b, err = getRawValue(b) if err != nil { return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
[ "func", "(", "s", "*", "RouterService", ")", "CreateVirtualRouterElement", "(", "p", "*", "CreateVirtualRouterElementParams", ")", "(", "*", "CreateVirtualRouterElementResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "CreateVirtualRouterElementResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// If we have a async client, we need to wait for the async result", "if", "s", ".", "cs", ".", "async", "{", "b", ",", "err", ":=", "s", ".", "cs", ".", "GetAsyncJobResult", "(", "r", ".", "JobID", ",", "s", ".", "cs", ".", "timeout", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "AsyncTimeoutErr", "{", "return", "&", "r", ",", "err", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "b", ",", "err", "=", "getRawValue", "(", "b", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "b", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Create a virtual router element.
[ "Create", "a", "virtual", "router", "element", "." ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RouterService.go#L271-L303
145,942
xanzy/go-cloudstack
cloudstack/RouterService.go
NewDestroyRouterParams
func (s *RouterService) NewDestroyRouterParams(id string) *DestroyRouterParams { p := &DestroyRouterParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
go
func (s *RouterService) NewDestroyRouterParams(id string) *DestroyRouterParams { p := &DestroyRouterParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
[ "func", "(", "s", "*", "RouterService", ")", "NewDestroyRouterParams", "(", "id", "string", ")", "*", "DestroyRouterParams", "{", "p", ":=", "&", "DestroyRouterParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new DestroyRouterParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "DestroyRouterParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RouterService.go#L342-L347
145,943
xanzy/go-cloudstack
cloudstack/RouterService.go
DestroyRouter
func (s *RouterService) DestroyRouter(p *DestroyRouterParams) (*DestroyRouterResponse, error) { resp, err := s.cs.newRequest("destroyRouter", p.toURLValues()) if err != nil { return nil, err } var r DestroyRouterResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } b, err = getRawValue(b) if err != nil { return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
go
func (s *RouterService) DestroyRouter(p *DestroyRouterParams) (*DestroyRouterResponse, error) { resp, err := s.cs.newRequest("destroyRouter", p.toURLValues()) if err != nil { return nil, err } var r DestroyRouterResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } b, err = getRawValue(b) if err != nil { return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
[ "func", "(", "s", "*", "RouterService", ")", "DestroyRouter", "(", "p", "*", "DestroyRouterParams", ")", "(", "*", "DestroyRouterResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "DestroyRouterResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// If we have a async client, we need to wait for the async result", "if", "s", ".", "cs", ".", "async", "{", "b", ",", "err", ":=", "s", ".", "cs", ".", "GetAsyncJobResult", "(", "r", ".", "JobID", ",", "s", ".", "cs", ".", "timeout", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "AsyncTimeoutErr", "{", "return", "&", "r", ",", "err", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "b", ",", "err", "=", "getRawValue", "(", "b", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "b", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Destroys a router.
[ "Destroys", "a", "router", "." ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RouterService.go#L350-L382
145,944
xanzy/go-cloudstack
cloudstack/RouterService.go
NewListRoutersParams
func (s *RouterService) NewListRoutersParams() *ListRoutersParams { p := &ListRoutersParams{} p.p = make(map[string]interface{}) return p }
go
func (s *RouterService) NewListRoutersParams() *ListRoutersParams { p := &ListRoutersParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "RouterService", ")", "NewListRoutersParams", "(", ")", "*", "ListRoutersParams", "{", "p", ":=", "&", "ListRoutersParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListRoutersParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListRoutersParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RouterService.go#L662-L666
145,945
xanzy/go-cloudstack
cloudstack/RouterService.go
ListRouters
func (s *RouterService) ListRouters(p *ListRoutersParams) (*ListRoutersResponse, error) { resp, err := s.cs.newRequest("listRouters", p.toURLValues()) if err != nil { return nil, err } var r ListRoutersResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *RouterService) ListRouters(p *ListRoutersParams) (*ListRoutersResponse, error) { resp, err := s.cs.newRequest("listRouters", p.toURLValues()) if err != nil { return nil, err } var r ListRoutersResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "RouterService", ")", "ListRouters", "(", "p", "*", "ListRoutersParams", ")", "(", "*", "ListRoutersResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "ListRoutersResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// List routers.
[ "List", "routers", "." ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RouterService.go#L752-L764
145,946
xanzy/go-cloudstack
cloudstack/RouterService.go
NewListVirtualRouterElementsParams
func (s *RouterService) NewListVirtualRouterElementsParams() *ListVirtualRouterElementsParams { p := &ListVirtualRouterElementsParams{} p.p = make(map[string]interface{}) return p }
go
func (s *RouterService) NewListVirtualRouterElementsParams() *ListVirtualRouterElementsParams { p := &ListVirtualRouterElementsParams{} p.p = make(map[string]interface{}) return p }
[ "func", "(", "s", "*", "RouterService", ")", "NewListVirtualRouterElementsParams", "(", ")", "*", "ListVirtualRouterElementsParams", "{", "p", ":=", "&", "ListVirtualRouterElementsParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new ListVirtualRouterElementsParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "ListVirtualRouterElementsParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RouterService.go#L903-L907
145,947
xanzy/go-cloudstack
cloudstack/RouterService.go
ListVirtualRouterElements
func (s *RouterService) ListVirtualRouterElements(p *ListVirtualRouterElementsParams) (*ListVirtualRouterElementsResponse, error) { resp, err := s.cs.newRequest("listVirtualRouterElements", p.toURLValues()) if err != nil { return nil, err } var r ListVirtualRouterElementsResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
go
func (s *RouterService) ListVirtualRouterElements(p *ListVirtualRouterElementsParams) (*ListVirtualRouterElementsResponse, error) { resp, err := s.cs.newRequest("listVirtualRouterElements", p.toURLValues()) if err != nil { return nil, err } var r ListVirtualRouterElementsResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } return &r, nil }
[ "func", "(", "s", "*", "RouterService", ")", "ListVirtualRouterElements", "(", "p", "*", "ListVirtualRouterElementsParams", ")", "(", "*", "ListVirtualRouterElementsResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "ListVirtualRouterElementsResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Lists all available virtual router elements.
[ "Lists", "all", "available", "virtual", "router", "elements", "." ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RouterService.go#L943-L955
145,948
xanzy/go-cloudstack
cloudstack/RouterService.go
NewRebootRouterParams
func (s *RouterService) NewRebootRouterParams(id string) *RebootRouterParams { p := &RebootRouterParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
go
func (s *RouterService) NewRebootRouterParams(id string) *RebootRouterParams { p := &RebootRouterParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
[ "func", "(", "s", "*", "RouterService", ")", "NewRebootRouterParams", "(", "id", "string", ")", "*", "RebootRouterParams", "{", "p", ":=", "&", "RebootRouterParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new RebootRouterParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "RebootRouterParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RouterService.go#L998-L1003
145,949
xanzy/go-cloudstack
cloudstack/RouterService.go
NewStartRouterParams
func (s *RouterService) NewStartRouterParams(id string) *StartRouterParams { p := &StartRouterParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
go
func (s *RouterService) NewStartRouterParams(id string) *StartRouterParams { p := &StartRouterParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
[ "func", "(", "s", "*", "RouterService", ")", "NewStartRouterParams", "(", "id", "string", ")", "*", "StartRouterParams", "{", "p", ":=", "&", "StartRouterParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new StartRouterParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "StartRouterParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RouterService.go#L1115-L1120
145,950
xanzy/go-cloudstack
cloudstack/RouterService.go
NewStopRouterParams
func (s *RouterService) NewStopRouterParams(id string) *StopRouterParams { p := &StopRouterParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
go
func (s *RouterService) NewStopRouterParams(id string) *StopRouterParams { p := &StopRouterParams{} p.p = make(map[string]interface{}) p.p["id"] = id return p }
[ "func", "(", "s", "*", "RouterService", ")", "NewStopRouterParams", "(", "id", "string", ")", "*", "StopRouterParams", "{", "p", ":=", "&", "StopRouterParams", "{", "}", "\n", "p", ".", "p", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "p", ".", "p", "[", "\"", "\"", "]", "=", "id", "\n", "return", "p", "\n", "}" ]
// You should always use this function to get a new StopRouterParams instance, // as then you are sure you have configured all required params
[ "You", "should", "always", "use", "this", "function", "to", "get", "a", "new", "StopRouterParams", "instance", "as", "then", "you", "are", "sure", "you", "have", "configured", "all", "required", "params" ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RouterService.go#L1244-L1249
145,951
xanzy/go-cloudstack
cloudstack/RouterService.go
StopRouter
func (s *RouterService) StopRouter(p *StopRouterParams) (*StopRouterResponse, error) { resp, err := s.cs.newRequest("stopRouter", p.toURLValues()) if err != nil { return nil, err } var r StopRouterResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } b, err = getRawValue(b) if err != nil { return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
go
func (s *RouterService) StopRouter(p *StopRouterParams) (*StopRouterResponse, error) { resp, err := s.cs.newRequest("stopRouter", p.toURLValues()) if err != nil { return nil, err } var r StopRouterResponse if err := json.Unmarshal(resp, &r); err != nil { return nil, err } // If we have a async client, we need to wait for the async result if s.cs.async { b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { if err == AsyncTimeoutErr { return &r, err } return nil, err } b, err = getRawValue(b) if err != nil { return nil, err } if err := json.Unmarshal(b, &r); err != nil { return nil, err } } return &r, nil }
[ "func", "(", "s", "*", "RouterService", ")", "StopRouter", "(", "p", "*", "StopRouterParams", ")", "(", "*", "StopRouterResponse", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "cs", ".", "newRequest", "(", "\"", "\"", ",", "p", ".", "toURLValues", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "r", "StopRouterResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// If we have a async client, we need to wait for the async result", "if", "s", ".", "cs", ".", "async", "{", "b", ",", "err", ":=", "s", ".", "cs", ".", "GetAsyncJobResult", "(", "r", ".", "JobID", ",", "s", ".", "cs", ".", "timeout", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "AsyncTimeoutErr", "{", "return", "&", "r", ",", "err", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "b", ",", "err", "=", "getRawValue", "(", "b", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "b", ",", "&", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "&", "r", ",", "nil", "\n", "}" ]
// Stops a router.
[ "Stops", "a", "router", "." ]
b6f53ed3282d22b6446422879587b0a78e1b0f11
https://github.com/xanzy/go-cloudstack/blob/b6f53ed3282d22b6446422879587b0a78e1b0f11/cloudstack/RouterService.go#L1252-L1284
145,952
hashicorp/go-rootcerts
rootcerts.go
ConfigureTLS
func ConfigureTLS(t *tls.Config, c *Config) error { if t == nil { return nil } pool, err := LoadCACerts(c) if err != nil { return err } t.RootCAs = pool return nil }
go
func ConfigureTLS(t *tls.Config, c *Config) error { if t == nil { return nil } pool, err := LoadCACerts(c) if err != nil { return err } t.RootCAs = pool return nil }
[ "func", "ConfigureTLS", "(", "t", "*", "tls", ".", "Config", ",", "c", "*", "Config", ")", "error", "{", "if", "t", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "pool", ",", "err", ":=", "LoadCACerts", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "t", ".", "RootCAs", "=", "pool", "\n", "return", "nil", "\n", "}" ]
// ConfigureTLS sets up the RootCAs on the provided tls.Config based on the // Config specified.
[ "ConfigureTLS", "sets", "up", "the", "RootCAs", "on", "the", "provided", "tls", ".", "Config", "based", "on", "the", "Config", "specified", "." ]
63503fb4e1eca22f9ae0f90b49c5d5538a0e87eb
https://github.com/hashicorp/go-rootcerts/blob/63503fb4e1eca22f9ae0f90b49c5d5538a0e87eb/rootcerts.go#L27-L37
145,953
hashicorp/go-rootcerts
rootcerts.go
LoadCACerts
func LoadCACerts(c *Config) (*x509.CertPool, error) { if c == nil { c = &Config{} } if c.CAFile != "" { return LoadCAFile(c.CAFile) } if c.CAPath != "" { return LoadCAPath(c.CAPath) } return LoadSystemCAs() }
go
func LoadCACerts(c *Config) (*x509.CertPool, error) { if c == nil { c = &Config{} } if c.CAFile != "" { return LoadCAFile(c.CAFile) } if c.CAPath != "" { return LoadCAPath(c.CAPath) } return LoadSystemCAs() }
[ "func", "LoadCACerts", "(", "c", "*", "Config", ")", "(", "*", "x509", ".", "CertPool", ",", "error", ")", "{", "if", "c", "==", "nil", "{", "c", "=", "&", "Config", "{", "}", "\n", "}", "\n", "if", "c", ".", "CAFile", "!=", "\"", "\"", "{", "return", "LoadCAFile", "(", "c", ".", "CAFile", ")", "\n", "}", "\n", "if", "c", ".", "CAPath", "!=", "\"", "\"", "{", "return", "LoadCAPath", "(", "c", ".", "CAPath", ")", "\n", "}", "\n\n", "return", "LoadSystemCAs", "(", ")", "\n", "}" ]
// LoadCACerts loads a CertPool based on the Config specified.
[ "LoadCACerts", "loads", "a", "CertPool", "based", "on", "the", "Config", "specified", "." ]
63503fb4e1eca22f9ae0f90b49c5d5538a0e87eb
https://github.com/hashicorp/go-rootcerts/blob/63503fb4e1eca22f9ae0f90b49c5d5538a0e87eb/rootcerts.go#L40-L52
145,954
hashicorp/go-rootcerts
rootcerts.go
LoadCAFile
func LoadCAFile(caFile string) (*x509.CertPool, error) { pool := x509.NewCertPool() pem, err := ioutil.ReadFile(caFile) if err != nil { return nil, fmt.Errorf("Error loading CA File: %s", err) } ok := pool.AppendCertsFromPEM(pem) if !ok { return nil, fmt.Errorf("Error loading CA File: Couldn't parse PEM in: %s", caFile) } return pool, nil }
go
func LoadCAFile(caFile string) (*x509.CertPool, error) { pool := x509.NewCertPool() pem, err := ioutil.ReadFile(caFile) if err != nil { return nil, fmt.Errorf("Error loading CA File: %s", err) } ok := pool.AppendCertsFromPEM(pem) if !ok { return nil, fmt.Errorf("Error loading CA File: Couldn't parse PEM in: %s", caFile) } return pool, nil }
[ "func", "LoadCAFile", "(", "caFile", "string", ")", "(", "*", "x509", ".", "CertPool", ",", "error", ")", "{", "pool", ":=", "x509", ".", "NewCertPool", "(", ")", "\n\n", "pem", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "caFile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "ok", ":=", "pool", ".", "AppendCertsFromPEM", "(", "pem", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "caFile", ")", "\n", "}", "\n\n", "return", "pool", ",", "nil", "\n", "}" ]
// LoadCAFile loads a single PEM-encoded file from the path specified.
[ "LoadCAFile", "loads", "a", "single", "PEM", "-", "encoded", "file", "from", "the", "path", "specified", "." ]
63503fb4e1eca22f9ae0f90b49c5d5538a0e87eb
https://github.com/hashicorp/go-rootcerts/blob/63503fb4e1eca22f9ae0f90b49c5d5538a0e87eb/rootcerts.go#L55-L69
145,955
hashicorp/go-rootcerts
rootcerts.go
LoadCAPath
func LoadCAPath(caPath string) (*x509.CertPool, error) { pool := x509.NewCertPool() walkFn := func(path string, info os.FileInfo, err error) error { if err != nil { return err } if info.IsDir() { return nil } pem, err := ioutil.ReadFile(path) if err != nil { return fmt.Errorf("Error loading file from CAPath: %s", err) } ok := pool.AppendCertsFromPEM(pem) if !ok { return fmt.Errorf("Error loading CA Path: Couldn't parse PEM in: %s", path) } return nil } err := filepath.Walk(caPath, walkFn) if err != nil { return nil, err } return pool, nil }
go
func LoadCAPath(caPath string) (*x509.CertPool, error) { pool := x509.NewCertPool() walkFn := func(path string, info os.FileInfo, err error) error { if err != nil { return err } if info.IsDir() { return nil } pem, err := ioutil.ReadFile(path) if err != nil { return fmt.Errorf("Error loading file from CAPath: %s", err) } ok := pool.AppendCertsFromPEM(pem) if !ok { return fmt.Errorf("Error loading CA Path: Couldn't parse PEM in: %s", path) } return nil } err := filepath.Walk(caPath, walkFn) if err != nil { return nil, err } return pool, nil }
[ "func", "LoadCAPath", "(", "caPath", "string", ")", "(", "*", "x509", ".", "CertPool", ",", "error", ")", "{", "pool", ":=", "x509", ".", "NewCertPool", "(", ")", "\n", "walkFn", ":=", "func", "(", "path", "string", ",", "info", "os", ".", "FileInfo", ",", "err", "error", ")", "error", "{", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "info", ".", "IsDir", "(", ")", "{", "return", "nil", "\n", "}", "\n\n", "pem", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "ok", ":=", "pool", ".", "AppendCertsFromPEM", "(", "pem", ")", "\n", "if", "!", "ok", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "path", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}", "\n\n", "err", ":=", "filepath", ".", "Walk", "(", "caPath", ",", "walkFn", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "pool", ",", "nil", "\n", "}" ]
// LoadCAPath walks the provided path and loads all certificates encounted into // a pool.
[ "LoadCAPath", "walks", "the", "provided", "path", "and", "loads", "all", "certificates", "encounted", "into", "a", "pool", "." ]
63503fb4e1eca22f9ae0f90b49c5d5538a0e87eb
https://github.com/hashicorp/go-rootcerts/blob/63503fb4e1eca22f9ae0f90b49c5d5538a0e87eb/rootcerts.go#L73-L103
145,956
hashicorp/go-rootcerts
rootcerts_darwin.go
LoadSystemCAs
func LoadSystemCAs() (*x509.CertPool, error) { pool := x509.NewCertPool() for _, keychain := range certKeychains() { err := addCertsFromKeychain(pool, keychain) if err != nil { return nil, err } } return pool, nil }
go
func LoadSystemCAs() (*x509.CertPool, error) { pool := x509.NewCertPool() for _, keychain := range certKeychains() { err := addCertsFromKeychain(pool, keychain) if err != nil { return nil, err } } return pool, nil }
[ "func", "LoadSystemCAs", "(", ")", "(", "*", "x509", ".", "CertPool", ",", "error", ")", "{", "pool", ":=", "x509", ".", "NewCertPool", "(", ")", "\n\n", "for", "_", ",", "keychain", ":=", "range", "certKeychains", "(", ")", "{", "err", ":=", "addCertsFromKeychain", "(", "pool", ",", "keychain", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "pool", ",", "nil", "\n", "}" ]
// LoadSystemCAs has special behavior on Darwin systems to work around
[ "LoadSystemCAs", "has", "special", "behavior", "on", "Darwin", "systems", "to", "work", "around" ]
63503fb4e1eca22f9ae0f90b49c5d5538a0e87eb
https://github.com/hashicorp/go-rootcerts/blob/63503fb4e1eca22f9ae0f90b49c5d5538a0e87eb/rootcerts_darwin.go#L12-L23
145,957
beevik/ntp
ntp.go
Duration
func (t ntpTime) Duration() time.Duration { sec := (t >> 32) * nanoPerSec frac := (t & 0xffffffff) * nanoPerSec >> 32 return time.Duration(sec + frac) }
go
func (t ntpTime) Duration() time.Duration { sec := (t >> 32) * nanoPerSec frac := (t & 0xffffffff) * nanoPerSec >> 32 return time.Duration(sec + frac) }
[ "func", "(", "t", "ntpTime", ")", "Duration", "(", ")", "time", ".", "Duration", "{", "sec", ":=", "(", "t", ">>", "32", ")", "*", "nanoPerSec", "\n", "frac", ":=", "(", "t", "&", "0xffffffff", ")", "*", "nanoPerSec", ">>", "32", "\n", "return", "time", ".", "Duration", "(", "sec", "+", "frac", ")", "\n", "}" ]
// Duration interprets the fixed-point ntpTime as a number of elapsed seconds // and returns the corresponding time.Duration value.
[ "Duration", "interprets", "the", "fixed", "-", "point", "ntpTime", "as", "a", "number", "of", "elapsed", "seconds", "and", "returns", "the", "corresponding", "time", ".", "Duration", "value", "." ]
53ffc1864695f04a9261eaaba263b1e85e5795f3
https://github.com/beevik/ntp/blob/53ffc1864695f04a9261eaaba263b1e85e5795f3/ntp.go#L77-L81
145,958
beevik/ntp
ntp.go
toNtpTime
func toNtpTime(t time.Time) ntpTime { nsec := uint64(t.Sub(ntpEpoch)) sec := nsec / nanoPerSec // Round up the fractional component so that repeated conversions // between time.Time and ntpTime do not yield continually decreasing // results. frac := (((nsec - sec*nanoPerSec) << 32) + nanoPerSec - 1) / nanoPerSec return ntpTime(sec<<32 | frac) }
go
func toNtpTime(t time.Time) ntpTime { nsec := uint64(t.Sub(ntpEpoch)) sec := nsec / nanoPerSec // Round up the fractional component so that repeated conversions // between time.Time and ntpTime do not yield continually decreasing // results. frac := (((nsec - sec*nanoPerSec) << 32) + nanoPerSec - 1) / nanoPerSec return ntpTime(sec<<32 | frac) }
[ "func", "toNtpTime", "(", "t", "time", ".", "Time", ")", "ntpTime", "{", "nsec", ":=", "uint64", "(", "t", ".", "Sub", "(", "ntpEpoch", ")", ")", "\n", "sec", ":=", "nsec", "/", "nanoPerSec", "\n", "// Round up the fractional component so that repeated conversions", "// between time.Time and ntpTime do not yield continually decreasing", "// results.", "frac", ":=", "(", "(", "(", "nsec", "-", "sec", "*", "nanoPerSec", ")", "<<", "32", ")", "+", "nanoPerSec", "-", "1", ")", "/", "nanoPerSec", "\n", "return", "ntpTime", "(", "sec", "<<", "32", "|", "frac", ")", "\n", "}" ]
// toNtpTime converts the time.Time value t into its 64-bit fixed-point // ntpTime representation.
[ "toNtpTime", "converts", "the", "time", ".", "Time", "value", "t", "into", "its", "64", "-", "bit", "fixed", "-", "point", "ntpTime", "representation", "." ]
53ffc1864695f04a9261eaaba263b1e85e5795f3
https://github.com/beevik/ntp/blob/53ffc1864695f04a9261eaaba263b1e85e5795f3/ntp.go#L91-L99
145,959
beevik/ntp
ntp.go
Duration
func (t ntpTimeShort) Duration() time.Duration { t64 := uint64(t) sec := (t64 >> 16) * nanoPerSec frac := (t64 & 0xffff) * nanoPerSec >> 16 return time.Duration(sec + frac) }
go
func (t ntpTimeShort) Duration() time.Duration { t64 := uint64(t) sec := (t64 >> 16) * nanoPerSec frac := (t64 & 0xffff) * nanoPerSec >> 16 return time.Duration(sec + frac) }
[ "func", "(", "t", "ntpTimeShort", ")", "Duration", "(", ")", "time", ".", "Duration", "{", "t64", ":=", "uint64", "(", "t", ")", "\n", "sec", ":=", "(", "t64", ">>", "16", ")", "*", "nanoPerSec", "\n", "frac", ":=", "(", "t64", "&", "0xffff", ")", "*", "nanoPerSec", ">>", "16", "\n", "return", "time", ".", "Duration", "(", "sec", "+", "frac", ")", "\n", "}" ]
// Duration interprets the fixed-point ntpTimeShort as a number of elapsed // seconds and returns the corresponding time.Duration value.
[ "Duration", "interprets", "the", "fixed", "-", "point", "ntpTimeShort", "as", "a", "number", "of", "elapsed", "seconds", "and", "returns", "the", "corresponding", "time", ".", "Duration", "value", "." ]
53ffc1864695f04a9261eaaba263b1e85e5795f3
https://github.com/beevik/ntp/blob/53ffc1864695f04a9261eaaba263b1e85e5795f3/ntp.go#L107-L112
145,960
beevik/ntp
ntp.go
setVersion
func (m *msg) setVersion(v int) { m.LiVnMode = (m.LiVnMode & 0xc7) | uint8(v)<<3 }
go
func (m *msg) setVersion(v int) { m.LiVnMode = (m.LiVnMode & 0xc7) | uint8(v)<<3 }
[ "func", "(", "m", "*", "msg", ")", "setVersion", "(", "v", "int", ")", "{", "m", ".", "LiVnMode", "=", "(", "m", ".", "LiVnMode", "&", "0xc7", ")", "|", "uint8", "(", "v", ")", "<<", "3", "\n", "}" ]
// setVersion sets the NTP protocol version on the message.
[ "setVersion", "sets", "the", "NTP", "protocol", "version", "on", "the", "message", "." ]
53ffc1864695f04a9261eaaba263b1e85e5795f3
https://github.com/beevik/ntp/blob/53ffc1864695f04a9261eaaba263b1e85e5795f3/ntp.go#L130-L132
145,961
beevik/ntp
ntp.go
setMode
func (m *msg) setMode(md mode) { m.LiVnMode = (m.LiVnMode & 0xf8) | uint8(md) }
go
func (m *msg) setMode(md mode) { m.LiVnMode = (m.LiVnMode & 0xf8) | uint8(md) }
[ "func", "(", "m", "*", "msg", ")", "setMode", "(", "md", "mode", ")", "{", "m", ".", "LiVnMode", "=", "(", "m", ".", "LiVnMode", "&", "0xf8", ")", "|", "uint8", "(", "md", ")", "\n", "}" ]
// setMode sets the NTP protocol mode on the message.
[ "setMode", "sets", "the", "NTP", "protocol", "mode", "on", "the", "message", "." ]
53ffc1864695f04a9261eaaba263b1e85e5795f3
https://github.com/beevik/ntp/blob/53ffc1864695f04a9261eaaba263b1e85e5795f3/ntp.go#L135-L137
145,962
beevik/ntp
ntp.go
setLeap
func (m *msg) setLeap(li LeapIndicator) { m.LiVnMode = (m.LiVnMode & 0x3f) | uint8(li)<<6 }
go
func (m *msg) setLeap(li LeapIndicator) { m.LiVnMode = (m.LiVnMode & 0x3f) | uint8(li)<<6 }
[ "func", "(", "m", "*", "msg", ")", "setLeap", "(", "li", "LeapIndicator", ")", "{", "m", ".", "LiVnMode", "=", "(", "m", ".", "LiVnMode", "&", "0x3f", ")", "|", "uint8", "(", "li", ")", "<<", "6", "\n", "}" ]
// setLeap modifies the leap indicator on the message.
[ "setLeap", "modifies", "the", "leap", "indicator", "on", "the", "message", "." ]
53ffc1864695f04a9261eaaba263b1e85e5795f3
https://github.com/beevik/ntp/blob/53ffc1864695f04a9261eaaba263b1e85e5795f3/ntp.go#L140-L142
145,963
beevik/ntp
ntp.go
Validate
func (r *Response) Validate() error { // Handle invalid stratum values. if r.Stratum == 0 { return fmt.Errorf("kiss of death received: %s", r.KissCode) } if r.Stratum >= maxStratum { return errors.New("invalid stratum in response") } // Handle invalid leap second indicator. if r.Leap == LeapNotInSync { return errors.New("invalid leap second") } // Estimate the "freshness" of the time. If it exceeds the maximum // polling interval (~36 hours), then it cannot be considered "fresh". freshness := r.Time.Sub(r.ReferenceTime) if freshness > maxPollInterval { return errors.New("server clock not fresh") } // Calculate the peer synchronization distance, lambda: // lambda := RootDelay/2 + RootDispersion // If this value exceeds MAXDISP (16s), then the time is not suitable // for synchronization purposes. // https://tools.ietf.org/html/rfc5905#appendix-A.5.1.1. lambda := r.RootDelay/2 + r.RootDispersion if lambda > maxDispersion { return errors.New("invalid dispersion") } // If the server's transmit time is before its reference time, the // response is invalid. if r.Time.Before(r.ReferenceTime) { return errors.New("invalid time reported") } // nil means the response is valid. return nil }
go
func (r *Response) Validate() error { // Handle invalid stratum values. if r.Stratum == 0 { return fmt.Errorf("kiss of death received: %s", r.KissCode) } if r.Stratum >= maxStratum { return errors.New("invalid stratum in response") } // Handle invalid leap second indicator. if r.Leap == LeapNotInSync { return errors.New("invalid leap second") } // Estimate the "freshness" of the time. If it exceeds the maximum // polling interval (~36 hours), then it cannot be considered "fresh". freshness := r.Time.Sub(r.ReferenceTime) if freshness > maxPollInterval { return errors.New("server clock not fresh") } // Calculate the peer synchronization distance, lambda: // lambda := RootDelay/2 + RootDispersion // If this value exceeds MAXDISP (16s), then the time is not suitable // for synchronization purposes. // https://tools.ietf.org/html/rfc5905#appendix-A.5.1.1. lambda := r.RootDelay/2 + r.RootDispersion if lambda > maxDispersion { return errors.New("invalid dispersion") } // If the server's transmit time is before its reference time, the // response is invalid. if r.Time.Before(r.ReferenceTime) { return errors.New("invalid time reported") } // nil means the response is valid. return nil }
[ "func", "(", "r", "*", "Response", ")", "Validate", "(", ")", "error", "{", "// Handle invalid stratum values.", "if", "r", ".", "Stratum", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "r", ".", "KissCode", ")", "\n", "}", "\n", "if", "r", ".", "Stratum", ">=", "maxStratum", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Handle invalid leap second indicator.", "if", "r", ".", "Leap", "==", "LeapNotInSync", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Estimate the \"freshness\" of the time. If it exceeds the maximum", "// polling interval (~36 hours), then it cannot be considered \"fresh\".", "freshness", ":=", "r", ".", "Time", ".", "Sub", "(", "r", ".", "ReferenceTime", ")", "\n", "if", "freshness", ">", "maxPollInterval", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Calculate the peer synchronization distance, lambda:", "// \tlambda := RootDelay/2 + RootDispersion", "// If this value exceeds MAXDISP (16s), then the time is not suitable", "// for synchronization purposes.", "// https://tools.ietf.org/html/rfc5905#appendix-A.5.1.1.", "lambda", ":=", "r", ".", "RootDelay", "/", "2", "+", "r", ".", "RootDispersion", "\n", "if", "lambda", ">", "maxDispersion", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// If the server's transmit time is before its reference time, the", "// response is invalid.", "if", "r", ".", "Time", ".", "Before", "(", "r", ".", "ReferenceTime", ")", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// nil means the response is valid.", "return", "nil", "\n", "}" ]
// Validate checks if the response is valid for the purposes of time // synchronization.
[ "Validate", "checks", "if", "the", "response", "is", "valid", "for", "the", "purposes", "of", "time", "synchronization", "." ]
53ffc1864695f04a9261eaaba263b1e85e5795f3
https://github.com/beevik/ntp/blob/53ffc1864695f04a9261eaaba263b1e85e5795f3/ntp.go#L240-L279
145,964
beevik/ntp
ntp.go
QueryWithOptions
func QueryWithOptions(host string, opt QueryOptions) (*Response, error) { m, now, err := getTime(host, opt) if err != nil { return nil, err } return parseTime(m, now), nil }
go
func QueryWithOptions(host string, opt QueryOptions) (*Response, error) { m, now, err := getTime(host, opt) if err != nil { return nil, err } return parseTime(m, now), nil }
[ "func", "QueryWithOptions", "(", "host", "string", ",", "opt", "QueryOptions", ")", "(", "*", "Response", ",", "error", ")", "{", "m", ",", "now", ",", "err", ":=", "getTime", "(", "host", ",", "opt", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "parseTime", "(", "m", ",", "now", ")", ",", "nil", "\n", "}" ]
// QueryWithOptions performs the same function as Query but allows for the // customization of several query options.
[ "QueryWithOptions", "performs", "the", "same", "function", "as", "Query", "but", "allows", "for", "the", "customization", "of", "several", "query", "options", "." ]
53ffc1864695f04a9261eaaba263b1e85e5795f3
https://github.com/beevik/ntp/blob/53ffc1864695f04a9261eaaba263b1e85e5795f3/ntp.go#L290-L296
145,965
beevik/ntp
ntp.go
parseTime
func parseTime(m *msg, recvTime ntpTime) *Response { r := &Response{ Time: m.TransmitTime.Time(), ClockOffset: offset(m.OriginTime, m.ReceiveTime, m.TransmitTime, recvTime), RTT: rtt(m.OriginTime, m.ReceiveTime, m.TransmitTime, recvTime), Precision: toInterval(m.Precision), Stratum: m.Stratum, ReferenceID: m.ReferenceID, ReferenceTime: m.ReferenceTime.Time(), RootDelay: m.RootDelay.Duration(), RootDispersion: m.RootDispersion.Duration(), Leap: m.getLeap(), MinError: minError(m.OriginTime, m.ReceiveTime, m.TransmitTime, recvTime), Poll: toInterval(m.Poll), } // Calculate values depending on other calculated values r.RootDistance = rootDistance(r.RTT, r.RootDelay, r.RootDispersion) // If a kiss of death was received, interpret the reference ID as // a kiss code. if r.Stratum == 0 { r.KissCode = kissCode(r.ReferenceID) } return r }
go
func parseTime(m *msg, recvTime ntpTime) *Response { r := &Response{ Time: m.TransmitTime.Time(), ClockOffset: offset(m.OriginTime, m.ReceiveTime, m.TransmitTime, recvTime), RTT: rtt(m.OriginTime, m.ReceiveTime, m.TransmitTime, recvTime), Precision: toInterval(m.Precision), Stratum: m.Stratum, ReferenceID: m.ReferenceID, ReferenceTime: m.ReferenceTime.Time(), RootDelay: m.RootDelay.Duration(), RootDispersion: m.RootDispersion.Duration(), Leap: m.getLeap(), MinError: minError(m.OriginTime, m.ReceiveTime, m.TransmitTime, recvTime), Poll: toInterval(m.Poll), } // Calculate values depending on other calculated values r.RootDistance = rootDistance(r.RTT, r.RootDelay, r.RootDispersion) // If a kiss of death was received, interpret the reference ID as // a kiss code. if r.Stratum == 0 { r.KissCode = kissCode(r.ReferenceID) } return r }
[ "func", "parseTime", "(", "m", "*", "msg", ",", "recvTime", "ntpTime", ")", "*", "Response", "{", "r", ":=", "&", "Response", "{", "Time", ":", "m", ".", "TransmitTime", ".", "Time", "(", ")", ",", "ClockOffset", ":", "offset", "(", "m", ".", "OriginTime", ",", "m", ".", "ReceiveTime", ",", "m", ".", "TransmitTime", ",", "recvTime", ")", ",", "RTT", ":", "rtt", "(", "m", ".", "OriginTime", ",", "m", ".", "ReceiveTime", ",", "m", ".", "TransmitTime", ",", "recvTime", ")", ",", "Precision", ":", "toInterval", "(", "m", ".", "Precision", ")", ",", "Stratum", ":", "m", ".", "Stratum", ",", "ReferenceID", ":", "m", ".", "ReferenceID", ",", "ReferenceTime", ":", "m", ".", "ReferenceTime", ".", "Time", "(", ")", ",", "RootDelay", ":", "m", ".", "RootDelay", ".", "Duration", "(", ")", ",", "RootDispersion", ":", "m", ".", "RootDispersion", ".", "Duration", "(", ")", ",", "Leap", ":", "m", ".", "getLeap", "(", ")", ",", "MinError", ":", "minError", "(", "m", ".", "OriginTime", ",", "m", ".", "ReceiveTime", ",", "m", ".", "TransmitTime", ",", "recvTime", ")", ",", "Poll", ":", "toInterval", "(", "m", ".", "Poll", ")", ",", "}", "\n\n", "// Calculate values depending on other calculated values", "r", ".", "RootDistance", "=", "rootDistance", "(", "r", ".", "RTT", ",", "r", ".", "RootDelay", ",", "r", ".", "RootDispersion", ")", "\n\n", "// If a kiss of death was received, interpret the reference ID as", "// a kiss code.", "if", "r", ".", "Stratum", "==", "0", "{", "r", ".", "KissCode", "=", "kissCode", "(", "r", ".", "ReferenceID", ")", "\n", "}", "\n\n", "return", "r", "\n", "}" ]
// parseTime parses the NTP packet along with the packet receive time to // generate a Response record.
[ "parseTime", "parses", "the", "NTP", "packet", "along", "with", "the", "packet", "receive", "time", "to", "generate", "a", "Response", "record", "." ]
53ffc1864695f04a9261eaaba263b1e85e5795f3
https://github.com/beevik/ntp/blob/53ffc1864695f04a9261eaaba263b1e85e5795f3/ntp.go#L452-L478
145,966
secsy/goftp
file_system.go
Delete
func (c *Client) Delete(path string) error { pconn, err := c.getIdleConn() if err != nil { return err } defer c.returnConn(pconn) return pconn.sendCommandExpected(replyFileActionOkay, "DELE %s", path) }
go
func (c *Client) Delete(path string) error { pconn, err := c.getIdleConn() if err != nil { return err } defer c.returnConn(pconn) return pconn.sendCommandExpected(replyFileActionOkay, "DELE %s", path) }
[ "func", "(", "c", "*", "Client", ")", "Delete", "(", "path", "string", ")", "error", "{", "pconn", ",", "err", ":=", "c", ".", "getIdleConn", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "defer", "c", ".", "returnConn", "(", "pconn", ")", "\n\n", "return", "pconn", ".", "sendCommandExpected", "(", "replyFileActionOkay", ",", "\"", "\"", ",", "path", ")", "\n", "}" ]
// Delete deletes the file "path".
[ "Delete", "deletes", "the", "file", "path", "." ]
012609e90524f0bfde77100facdc47f807794c27
https://github.com/secsy/goftp/blob/012609e90524f0bfde77100facdc47f807794c27/file_system.go#L22-L31
145,967
secsy/goftp
file_system.go
Rename
func (c *Client) Rename(from, to string) error { pconn, err := c.getIdleConn() if err != nil { return err } defer c.returnConn(pconn) err = pconn.sendCommandExpected(replyFileActionPending, "RNFR %s", from) if err != nil { return err } return pconn.sendCommandExpected(replyFileActionOkay, "RNTO %s", to) }
go
func (c *Client) Rename(from, to string) error { pconn, err := c.getIdleConn() if err != nil { return err } defer c.returnConn(pconn) err = pconn.sendCommandExpected(replyFileActionPending, "RNFR %s", from) if err != nil { return err } return pconn.sendCommandExpected(replyFileActionOkay, "RNTO %s", to) }
[ "func", "(", "c", "*", "Client", ")", "Rename", "(", "from", ",", "to", "string", ")", "error", "{", "pconn", ",", "err", ":=", "c", ".", "getIdleConn", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "defer", "c", ".", "returnConn", "(", "pconn", ")", "\n\n", "err", "=", "pconn", ".", "sendCommandExpected", "(", "replyFileActionPending", ",", "\"", "\"", ",", "from", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "pconn", ".", "sendCommandExpected", "(", "replyFileActionOkay", ",", "\"", "\"", ",", "to", ")", "\n", "}" ]
// Rename renames file "from" to "to".
[ "Rename", "renames", "file", "from", "to", "to", "." ]
012609e90524f0bfde77100facdc47f807794c27
https://github.com/secsy/goftp/blob/012609e90524f0bfde77100facdc47f807794c27/file_system.go#L34-L48
145,968
secsy/goftp
file_system.go
Mkdir
func (c *Client) Mkdir(path string) (string, error) { pconn, err := c.getIdleConn() if err != nil { return "", err } defer c.returnConn(pconn) code, msg, err := pconn.sendCommand("MKD %s", path) if err != nil { return "", err } if code != replyDirCreated { return "", ftpError{code: code, msg: msg} } dir, err := extractDirName(msg) if err != nil { return "", err } return dir, nil }
go
func (c *Client) Mkdir(path string) (string, error) { pconn, err := c.getIdleConn() if err != nil { return "", err } defer c.returnConn(pconn) code, msg, err := pconn.sendCommand("MKD %s", path) if err != nil { return "", err } if code != replyDirCreated { return "", ftpError{code: code, msg: msg} } dir, err := extractDirName(msg) if err != nil { return "", err } return dir, nil }
[ "func", "(", "c", "*", "Client", ")", "Mkdir", "(", "path", "string", ")", "(", "string", ",", "error", ")", "{", "pconn", ",", "err", ":=", "c", ".", "getIdleConn", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "defer", "c", ".", "returnConn", "(", "pconn", ")", "\n\n", "code", ",", "msg", ",", "err", ":=", "pconn", ".", "sendCommand", "(", "\"", "\"", ",", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "if", "code", "!=", "replyDirCreated", "{", "return", "\"", "\"", ",", "ftpError", "{", "code", ":", "code", ",", "msg", ":", "msg", "}", "\n", "}", "\n\n", "dir", ",", "err", ":=", "extractDirName", "(", "msg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "return", "dir", ",", "nil", "\n", "}" ]
// Mkdir creates directory "path". The returned string is how the client // should refer to the created directory.
[ "Mkdir", "creates", "directory", "path", ".", "The", "returned", "string", "is", "how", "the", "client", "should", "refer", "to", "the", "created", "directory", "." ]
012609e90524f0bfde77100facdc47f807794c27
https://github.com/secsy/goftp/blob/012609e90524f0bfde77100facdc47f807794c27/file_system.go#L52-L75
145,969
secsy/goftp
transfer.go
Retrieve
func (c *Client) Retrieve(path string, dest io.Writer) error { // fetch file size to check against how much we transferred size, err := c.size(path) if err != nil { return err } canResume := c.canResume() var bytesSoFar int64 for { n, err := c.transferFromOffset(path, dest, nil, bytesSoFar) bytesSoFar += n if err == nil { break } else if n == 0 { return err } else if !canResume { return ftpError{ err: fmt.Errorf("%s (can't resume)", err), temporary: true, } } } if size != -1 && bytesSoFar != size { return ftpError{ err: fmt.Errorf("expected %d bytes, got %d", size, bytesSoFar), temporary: true, } } return nil }
go
func (c *Client) Retrieve(path string, dest io.Writer) error { // fetch file size to check against how much we transferred size, err := c.size(path) if err != nil { return err } canResume := c.canResume() var bytesSoFar int64 for { n, err := c.transferFromOffset(path, dest, nil, bytesSoFar) bytesSoFar += n if err == nil { break } else if n == 0 { return err } else if !canResume { return ftpError{ err: fmt.Errorf("%s (can't resume)", err), temporary: true, } } } if size != -1 && bytesSoFar != size { return ftpError{ err: fmt.Errorf("expected %d bytes, got %d", size, bytesSoFar), temporary: true, } } return nil }
[ "func", "(", "c", "*", "Client", ")", "Retrieve", "(", "path", "string", ",", "dest", "io", ".", "Writer", ")", "error", "{", "// fetch file size to check against how much we transferred", "size", ",", "err", ":=", "c", ".", "size", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "canResume", ":=", "c", ".", "canResume", "(", ")", "\n\n", "var", "bytesSoFar", "int64", "\n", "for", "{", "n", ",", "err", ":=", "c", ".", "transferFromOffset", "(", "path", ",", "dest", ",", "nil", ",", "bytesSoFar", ")", "\n\n", "bytesSoFar", "+=", "n", "\n\n", "if", "err", "==", "nil", "{", "break", "\n", "}", "else", "if", "n", "==", "0", "{", "return", "err", "\n", "}", "else", "if", "!", "canResume", "{", "return", "ftpError", "{", "err", ":", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", ",", "temporary", ":", "true", ",", "}", "\n", "}", "\n", "}", "\n\n", "if", "size", "!=", "-", "1", "&&", "bytesSoFar", "!=", "size", "{", "return", "ftpError", "{", "err", ":", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "size", ",", "bytesSoFar", ")", ",", "temporary", ":", "true", ",", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Retrieve file "path" from server and write bytes to "dest". If the // server supports resuming stream transfers, Retrieve will continue // resuming a failed download as long as it continues making progress. // Retrieve will also verify the file's size after the transfer if the // server supports the SIZE command.
[ "Retrieve", "file", "path", "from", "server", "and", "write", "bytes", "to", "dest", ".", "If", "the", "server", "supports", "resuming", "stream", "transfers", "Retrieve", "will", "continue", "resuming", "a", "failed", "download", "as", "long", "as", "it", "continues", "making", "progress", ".", "Retrieve", "will", "also", "verify", "the", "file", "s", "size", "after", "the", "transfer", "if", "the", "server", "supports", "the", "SIZE", "command", "." ]
012609e90524f0bfde77100facdc47f807794c27
https://github.com/secsy/goftp/blob/012609e90524f0bfde77100facdc47f807794c27/transfer.go#L19-L54
145,970
secsy/goftp
transfer.go
size
func (c *Client) size(path string) (int64, error) { pconn, err := c.getIdleConn() if err != nil { return -1, err } defer c.returnConn(pconn) if !pconn.hasFeature("SIZE") { pconn.debug("server doesn't support SIZE") return -1, nil } if err = pconn.setType("I"); err != nil { return 0, err } code, msg, err := pconn.sendCommand("SIZE %s", path) if err != nil { return -1, err } if code != replyFileStatus { pconn.debug("unexpected SIZE response: %d (%s)", code, msg) return -1, nil } size, err := strconv.ParseInt(msg, 10, 64) if err != nil { pconn.debug(`failed parsing SIZE response "%s": %s`, msg, err) return -1, nil } return size, nil }
go
func (c *Client) size(path string) (int64, error) { pconn, err := c.getIdleConn() if err != nil { return -1, err } defer c.returnConn(pconn) if !pconn.hasFeature("SIZE") { pconn.debug("server doesn't support SIZE") return -1, nil } if err = pconn.setType("I"); err != nil { return 0, err } code, msg, err := pconn.sendCommand("SIZE %s", path) if err != nil { return -1, err } if code != replyFileStatus { pconn.debug("unexpected SIZE response: %d (%s)", code, msg) return -1, nil } size, err := strconv.ParseInt(msg, 10, 64) if err != nil { pconn.debug(`failed parsing SIZE response "%s": %s`, msg, err) return -1, nil } return size, nil }
[ "func", "(", "c", "*", "Client", ")", "size", "(", "path", "string", ")", "(", "int64", ",", "error", ")", "{", "pconn", ",", "err", ":=", "c", ".", "getIdleConn", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "-", "1", ",", "err", "\n", "}", "\n\n", "defer", "c", ".", "returnConn", "(", "pconn", ")", "\n\n", "if", "!", "pconn", ".", "hasFeature", "(", "\"", "\"", ")", "{", "pconn", ".", "debug", "(", "\"", "\"", ")", "\n", "return", "-", "1", ",", "nil", "\n", "}", "\n\n", "if", "err", "=", "pconn", ".", "setType", "(", "\"", "\"", ")", ";", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n\n", "code", ",", "msg", ",", "err", ":=", "pconn", ".", "sendCommand", "(", "\"", "\"", ",", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "-", "1", ",", "err", "\n", "}", "\n\n", "if", "code", "!=", "replyFileStatus", "{", "pconn", ".", "debug", "(", "\"", "\"", ",", "code", ",", "msg", ")", "\n", "return", "-", "1", ",", "nil", "\n", "}", "\n\n", "size", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "msg", ",", "10", ",", "64", ")", "\n", "if", "err", "!=", "nil", "{", "pconn", ".", "debug", "(", "`failed parsing SIZE response \"%s\": %s`", ",", "msg", ",", "err", ")", "\n", "return", "-", "1", ",", "nil", "\n", "}", "\n\n", "return", "size", ",", "nil", "\n", "}" ]
// Fetch SIZE of file. Returns error only on underlying connection error. // If the server doesn't support size, it returns -1 and no error.
[ "Fetch", "SIZE", "of", "file", ".", "Returns", "error", "only", "on", "underlying", "connection", "error", ".", "If", "the", "server", "doesn", "t", "support", "size", "it", "returns", "-", "1", "and", "no", "error", "." ]
012609e90524f0bfde77100facdc47f807794c27
https://github.com/secsy/goftp/blob/012609e90524f0bfde77100facdc47f807794c27/transfer.go#L224-L258
145,971
secsy/goftp
client.go
newClient
func newClient(config Config, hosts []string) *Client { if config.ConnectionsPerHost <= 0 { config.ConnectionsPerHost = 5 } if config.Timeout <= 0 { config.Timeout = 5 * time.Second } if config.User == "" { config.User = "anonymous" } if config.Password == "" { config.Password = "anonymous" } if config.ServerLocation == nil { config.ServerLocation = time.UTC } if config.ActiveListenAddr == "" { config.ActiveListenAddr = ":0" } return &Client{ config: config, freeConnCh: make(chan *persistentConn, len(hosts)*config.ConnectionsPerHost), t0: time.Now(), hosts: hosts, allCons: make(map[int]*persistentConn), numConnsPerHost: make(map[string]int), } }
go
func newClient(config Config, hosts []string) *Client { if config.ConnectionsPerHost <= 0 { config.ConnectionsPerHost = 5 } if config.Timeout <= 0 { config.Timeout = 5 * time.Second } if config.User == "" { config.User = "anonymous" } if config.Password == "" { config.Password = "anonymous" } if config.ServerLocation == nil { config.ServerLocation = time.UTC } if config.ActiveListenAddr == "" { config.ActiveListenAddr = ":0" } return &Client{ config: config, freeConnCh: make(chan *persistentConn, len(hosts)*config.ConnectionsPerHost), t0: time.Now(), hosts: hosts, allCons: make(map[int]*persistentConn), numConnsPerHost: make(map[string]int), } }
[ "func", "newClient", "(", "config", "Config", ",", "hosts", "[", "]", "string", ")", "*", "Client", "{", "if", "config", ".", "ConnectionsPerHost", "<=", "0", "{", "config", ".", "ConnectionsPerHost", "=", "5", "\n", "}", "\n\n", "if", "config", ".", "Timeout", "<=", "0", "{", "config", ".", "Timeout", "=", "5", "*", "time", ".", "Second", "\n", "}", "\n\n", "if", "config", ".", "User", "==", "\"", "\"", "{", "config", ".", "User", "=", "\"", "\"", "\n", "}", "\n\n", "if", "config", ".", "Password", "==", "\"", "\"", "{", "config", ".", "Password", "=", "\"", "\"", "\n", "}", "\n\n", "if", "config", ".", "ServerLocation", "==", "nil", "{", "config", ".", "ServerLocation", "=", "time", ".", "UTC", "\n", "}", "\n\n", "if", "config", ".", "ActiveListenAddr", "==", "\"", "\"", "{", "config", ".", "ActiveListenAddr", "=", "\"", "\"", "\n", "}", "\n\n", "return", "&", "Client", "{", "config", ":", "config", ",", "freeConnCh", ":", "make", "(", "chan", "*", "persistentConn", ",", "len", "(", "hosts", ")", "*", "config", ".", "ConnectionsPerHost", ")", ",", "t0", ":", "time", ".", "Now", "(", ")", ",", "hosts", ":", "hosts", ",", "allCons", ":", "make", "(", "map", "[", "int", "]", "*", "persistentConn", ")", ",", "numConnsPerHost", ":", "make", "(", "map", "[", "string", "]", "int", ")", ",", "}", "\n", "}" ]
// Construct and return a new client Conn, setting default config // values as necessary.
[ "Construct", "and", "return", "a", "new", "client", "Conn", "setting", "default", "config", "values", "as", "necessary", "." ]
012609e90524f0bfde77100facdc47f807794c27
https://github.com/secsy/goftp/blob/012609e90524f0bfde77100facdc47f807794c27/client.go#L175-L209
145,972
secsy/goftp
client.go
Close
func (c *Client) Close() error { c.mu.Lock() if c.closed { c.mu.Unlock() return ftpError{err: errors.New("already closed")} } c.closed = true var conns []*persistentConn for _, conn := range c.allCons { conns = append(conns, conn) } c.mu.Unlock() for _, pconn := range conns { c.removeConn(pconn) } return nil }
go
func (c *Client) Close() error { c.mu.Lock() if c.closed { c.mu.Unlock() return ftpError{err: errors.New("already closed")} } c.closed = true var conns []*persistentConn for _, conn := range c.allCons { conns = append(conns, conn) } c.mu.Unlock() for _, pconn := range conns { c.removeConn(pconn) } return nil }
[ "func", "(", "c", "*", "Client", ")", "Close", "(", ")", "error", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "if", "c", ".", "closed", "{", "c", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "ftpError", "{", "err", ":", "errors", ".", "New", "(", "\"", "\"", ")", "}", "\n", "}", "\n", "c", ".", "closed", "=", "true", "\n\n", "var", "conns", "[", "]", "*", "persistentConn", "\n", "for", "_", ",", "conn", ":=", "range", "c", ".", "allCons", "{", "conns", "=", "append", "(", "conns", ",", "conn", ")", "\n", "}", "\n", "c", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "for", "_", ",", "pconn", ":=", "range", "conns", "{", "c", ".", "removeConn", "(", "pconn", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Close closes all open server connections. Currently this does not attempt // to do any kind of polite FTP connection termination. It will interrupt // all transfers in progress.
[ "Close", "closes", "all", "open", "server", "connections", ".", "Currently", "this", "does", "not", "attempt", "to", "do", "any", "kind", "of", "polite", "FTP", "connection", "termination", ".", "It", "will", "interrupt", "all", "transfers", "in", "progress", "." ]
012609e90524f0bfde77100facdc47f807794c27
https://github.com/secsy/goftp/blob/012609e90524f0bfde77100facdc47f807794c27/client.go#L214-L233
145,973
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
145,974
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
145,975
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
145,976
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
145,977
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
145,978
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
145,979
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
145,980
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
145,981
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
145,982
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
145,983
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
145,984
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
145,985
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
145,986
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
145,987
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
145,988
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
145,989
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
145,990
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
145,991
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
145,992
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
145,993
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
145,994
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
145,995
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
145,996
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
145,997
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
145,998
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
145,999
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