id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1 value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
15,400 | yvasiyarov/gorelic | agent.go | initTimer | func (agent *Agent) initTimer() {
if agent.HTTPTimer == nil {
agent.HTTPTimer = metrics.NewTimer()
}
} | go | func (agent *Agent) initTimer() {
if agent.HTTPTimer == nil {
agent.HTTPTimer = metrics.NewTimer()
}
} | [
"func",
"(",
"agent",
"*",
"Agent",
")",
"initTimer",
"(",
")",
"{",
"if",
"agent",
".",
"HTTPTimer",
"==",
"nil",
"{",
"agent",
".",
"HTTPTimer",
"=",
"metrics",
".",
"NewTimer",
"(",
")",
"\n",
"}",
"\n",
"}"
] | //Initialize global metrics.Timer object, used to collect HTTP metrics | [
"Initialize",
"global",
"metrics",
".",
"Timer",
"object",
"used",
"to",
"collect",
"HTTP",
"metrics"
] | 635ca6035f2355e29fc558effa613d0d5867aac8 | https://github.com/yvasiyarov/gorelic/blob/635ca6035f2355e29fc558effa613d0d5867aac8/agent.go#L181-L185 |
15,401 | yvasiyarov/gorelic | agent.go | initStatusCounters | func (agent *Agent) initStatusCounters() {
httpStatuses := []int{
http.StatusContinue, http.StatusSwitchingProtocols,
http.StatusOK, http.StatusCreated, http.StatusAccepted, http.StatusNonAuthoritativeInfo,
http.StatusNoContent, http.StatusResetContent, http.StatusPartialContent,
http.StatusMultipleChoices, http.StatusMovedPermanently, http.StatusFound, http.StatusSeeOther,
http.StatusNotModified, http.StatusUseProxy, http.StatusTemporaryRedirect,
http.StatusBadRequest, http.StatusUnauthorized, http.StatusPaymentRequired, http.StatusForbidden,
http.StatusNotFound, http.StatusMethodNotAllowed, http.StatusNotAcceptable, http.StatusProxyAuthRequired,
http.StatusRequestTimeout, http.StatusConflict, http.StatusGone, http.StatusLengthRequired,
http.StatusPreconditionFailed, http.StatusRequestEntityTooLarge, http.StatusRequestURITooLong, http.StatusUnsupportedMediaType,
http.StatusRequestedRangeNotSatisfiable, http.StatusExpectationFailed, http.StatusTeapot,
http.StatusInternalServerError, http.StatusNotImplemented, http.StatusBadGateway,
http.StatusServiceUnavailable, http.StatusGatewayTimeout, http.StatusHTTPVersionNotSupported,
}
agent.HTTPStatusCounters = make(map[int]metrics.Counter, len(httpStatuses))
for _, statusCode := range httpStatuses {
agent.HTTPStatusCounters[statusCode] = metrics.NewCounter()
}
} | go | func (agent *Agent) initStatusCounters() {
httpStatuses := []int{
http.StatusContinue, http.StatusSwitchingProtocols,
http.StatusOK, http.StatusCreated, http.StatusAccepted, http.StatusNonAuthoritativeInfo,
http.StatusNoContent, http.StatusResetContent, http.StatusPartialContent,
http.StatusMultipleChoices, http.StatusMovedPermanently, http.StatusFound, http.StatusSeeOther,
http.StatusNotModified, http.StatusUseProxy, http.StatusTemporaryRedirect,
http.StatusBadRequest, http.StatusUnauthorized, http.StatusPaymentRequired, http.StatusForbidden,
http.StatusNotFound, http.StatusMethodNotAllowed, http.StatusNotAcceptable, http.StatusProxyAuthRequired,
http.StatusRequestTimeout, http.StatusConflict, http.StatusGone, http.StatusLengthRequired,
http.StatusPreconditionFailed, http.StatusRequestEntityTooLarge, http.StatusRequestURITooLong, http.StatusUnsupportedMediaType,
http.StatusRequestedRangeNotSatisfiable, http.StatusExpectationFailed, http.StatusTeapot,
http.StatusInternalServerError, http.StatusNotImplemented, http.StatusBadGateway,
http.StatusServiceUnavailable, http.StatusGatewayTimeout, http.StatusHTTPVersionNotSupported,
}
agent.HTTPStatusCounters = make(map[int]metrics.Counter, len(httpStatuses))
for _, statusCode := range httpStatuses {
agent.HTTPStatusCounters[statusCode] = metrics.NewCounter()
}
} | [
"func",
"(",
"agent",
"*",
"Agent",
")",
"initStatusCounters",
"(",
")",
"{",
"httpStatuses",
":=",
"[",
"]",
"int",
"{",
"http",
".",
"StatusContinue",
",",
"http",
".",
"StatusSwitchingProtocols",
",",
"http",
".",
"StatusOK",
",",
"http",
".",
"StatusCr... | //Initialize metrics.Counters objects, used to collect HTTP statuses | [
"Initialize",
"metrics",
".",
"Counters",
"objects",
"used",
"to",
"collect",
"HTTP",
"statuses"
] | 635ca6035f2355e29fc558effa613d0d5867aac8 | https://github.com/yvasiyarov/gorelic/blob/635ca6035f2355e29fc558effa613d0d5867aac8/agent.go#L188-L212 |
15,402 | yvasiyarov/gorelic | agent.go | debug | func (agent *Agent) debug(msg string) {
if agent.Verbose {
log.Println(msg)
}
} | go | func (agent *Agent) debug(msg string) {
if agent.Verbose {
log.Println(msg)
}
} | [
"func",
"(",
"agent",
"*",
"Agent",
")",
"debug",
"(",
"msg",
"string",
")",
"{",
"if",
"agent",
".",
"Verbose",
"{",
"log",
".",
"Println",
"(",
"msg",
")",
"\n",
"}",
"\n",
"}"
] | //Print debug messages | [
"Print",
"debug",
"messages"
] | 635ca6035f2355e29fc558effa613d0d5867aac8 | https://github.com/yvasiyarov/gorelic/blob/635ca6035f2355e29fc558effa613d0d5867aac8/agent.go#L215-L219 |
15,403 | lestrrat-go/backoff | option.go | WithMaxInterval | func WithMaxInterval(v time.Duration) Option {
return &option{
name: optkeyMaxInterval,
value: float64(v),
}
} | go | func WithMaxInterval(v time.Duration) Option {
return &option{
name: optkeyMaxInterval,
value: float64(v),
}
} | [
"func",
"WithMaxInterval",
"(",
"v",
"time",
".",
"Duration",
")",
"Option",
"{",
"return",
"&",
"option",
"{",
"name",
":",
"optkeyMaxInterval",
",",
"value",
":",
"float64",
"(",
"v",
")",
",",
"}",
"\n",
"}"
] | // WithMaxInterval specifies the maximum interval between retries, and is
// currently only applicable to exponential backoffs.
//
// By default this is capped at 2 minutes. If you would like to change this
// value, you must explicitly specify it through this option.
//
// If a value of 0 is specified, then there is no limit, and the backoff
// interval will keep increasing. | [
"WithMaxInterval",
"specifies",
"the",
"maximum",
"interval",
"between",
"retries",
"and",
"is",
"currently",
"only",
"applicable",
"to",
"exponential",
"backoffs",
".",
"By",
"default",
"this",
"is",
"capped",
"at",
"2",
"minutes",
".",
"If",
"you",
"would",
... | 0bc2a4274cd0f8baa49f2d598df5ef0cc3069c80 | https://github.com/lestrrat-go/backoff/blob/0bc2a4274cd0f8baa49f2d598df5ef0cc3069c80/option.go#L42-L47 |
15,404 | lestrrat-go/backoff | option.go | WithMaxElapsedTime | func WithMaxElapsedTime(v time.Duration) Option{
return &option{
name: optkeyMaxElapsedTime,
value: v,
}
} | go | func WithMaxElapsedTime(v time.Duration) Option{
return &option{
name: optkeyMaxElapsedTime,
value: v,
}
} | [
"func",
"WithMaxElapsedTime",
"(",
"v",
"time",
".",
"Duration",
")",
"Option",
"{",
"return",
"&",
"option",
"{",
"name",
":",
"optkeyMaxElapsedTime",
",",
"value",
":",
"v",
",",
"}",
"\n",
"}"
] | // WithMaxElapsedTime specifies the maximum amount of accumulative time that
// the backoff is allowed to wait before it is considered failed. | [
"WithMaxElapsedTime",
"specifies",
"the",
"maximum",
"amount",
"of",
"accumulative",
"time",
"that",
"the",
"backoff",
"is",
"allowed",
"to",
"wait",
"before",
"it",
"is",
"considered",
"failed",
"."
] | 0bc2a4274cd0f8baa49f2d598df5ef0cc3069c80 | https://github.com/lestrrat-go/backoff/blob/0bc2a4274cd0f8baa49f2d598df5ef0cc3069c80/option.go#L63-L68 |
15,405 | lestrrat-go/backoff | backoff.go | IsPermanentError | func IsPermanentError(err error) bool {
if err == nil {
return false
}
if perr, ok := err.(PermanentError); ok {
return perr.IsPermanent()
}
if cerr := errors.Cause(err); cerr != err {
return IsPermanentError(cerr)
}
return false
} | go | func IsPermanentError(err error) bool {
if err == nil {
return false
}
if perr, ok := err.(PermanentError); ok {
return perr.IsPermanent()
}
if cerr := errors.Cause(err); cerr != err {
return IsPermanentError(cerr)
}
return false
} | [
"func",
"IsPermanentError",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"perr",
",",
"ok",
":=",
"err",
".",
"(",
"PermanentError",
")",
";",
"ok",
"{",
"return",
"perr",
".",
"IsP... | // IsPermanentError returns true if the given error is a permanent error. Permanent
// errors are those that implements the `PermanentError` interface and returns
// `true` for the `IsPermanent` method. | [
"IsPermanentError",
"returns",
"true",
"if",
"the",
"given",
"error",
"is",
"a",
"permanent",
"error",
".",
"Permanent",
"errors",
"are",
"those",
"that",
"implements",
"the",
"PermanentError",
"interface",
"and",
"returns",
"true",
"for",
"the",
"IsPermanent",
... | 0bc2a4274cd0f8baa49f2d598df5ef0cc3069c80 | https://github.com/lestrrat-go/backoff/blob/0bc2a4274cd0f8baa49f2d598df5ef0cc3069c80/backoff.go#L43-L54 |
15,406 | lestrrat-go/backoff | backoff.go | Continue | func Continue(b Backoff) bool {
select {
case <-b.Done():
return false
case <-b.Next():
return true
}
} | go | func Continue(b Backoff) bool {
select {
case <-b.Done():
return false
case <-b.Next():
return true
}
} | [
"func",
"Continue",
"(",
"b",
"Backoff",
")",
"bool",
"{",
"select",
"{",
"case",
"<-",
"b",
".",
"Done",
"(",
")",
":",
"return",
"false",
"\n",
"case",
"<-",
"b",
".",
"Next",
"(",
")",
":",
"return",
"true",
"\n",
"}",
"\n",
"}"
] | // Continue is a convenience wrapper around the | [
"Continue",
"is",
"a",
"convenience",
"wrapper",
"around",
"the"
] | 0bc2a4274cd0f8baa49f2d598df5ef0cc3069c80 | https://github.com/lestrrat-go/backoff/blob/0bc2a4274cd0f8baa49f2d598df5ef0cc3069c80/backoff.go#L57-L64 |
15,407 | lestrrat-go/backoff | backoff.go | Retry | func Retry(ctx context.Context, p Policy, e Executer) error {
b, cancel := p.Start(ctx)
defer cancel()
for Continue(b) {
err := e.Execute(ctx)
if err == nil {
return nil
}
if IsPermanentError(err) {
return errors.Wrap(err, `permanent error`)
}
}
return errors.New(`retry attempts failed`)
} | go | func Retry(ctx context.Context, p Policy, e Executer) error {
b, cancel := p.Start(ctx)
defer cancel()
for Continue(b) {
err := e.Execute(ctx)
if err == nil {
return nil
}
if IsPermanentError(err) {
return errors.Wrap(err, `permanent error`)
}
}
return errors.New(`retry attempts failed`)
} | [
"func",
"Retry",
"(",
"ctx",
"context",
".",
"Context",
",",
"p",
"Policy",
",",
"e",
"Executer",
")",
"error",
"{",
"b",
",",
"cancel",
":=",
"p",
".",
"Start",
"(",
"ctx",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n\n",
"for",
"Continue",
"(",
... | // Retry is a convenience wrapper around the backoff algorithm. If your target
// operation can be nicely enclosed in the `Executer` interface, this will
// remove your need to write much of the boilerplate. | [
"Retry",
"is",
"a",
"convenience",
"wrapper",
"around",
"the",
"backoff",
"algorithm",
".",
"If",
"your",
"target",
"operation",
"can",
"be",
"nicely",
"enclosed",
"in",
"the",
"Executer",
"interface",
"this",
"will",
"remove",
"your",
"need",
"to",
"write",
... | 0bc2a4274cd0f8baa49f2d598df5ef0cc3069c80 | https://github.com/lestrrat-go/backoff/blob/0bc2a4274cd0f8baa49f2d598df5ef0cc3069c80/backoff.go#L69-L84 |
15,408 | exoscale/egoscale | runstatus_event.go | UpdateRunstatusIncident | func (client *Client) UpdateRunstatusIncident(ctx context.Context, incident RunstatusIncident, event RunstatusEvent) error {
if incident.EventsURL == "" {
return fmt.Errorf("empty Events URL for %#v", incident)
}
_, err := client.runstatusRequest(ctx, incident.EventsURL, event, "POST")
return err
} | go | func (client *Client) UpdateRunstatusIncident(ctx context.Context, incident RunstatusIncident, event RunstatusEvent) error {
if incident.EventsURL == "" {
return fmt.Errorf("empty Events URL for %#v", incident)
}
_, err := client.runstatusRequest(ctx, incident.EventsURL, event, "POST")
return err
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"UpdateRunstatusIncident",
"(",
"ctx",
"context",
".",
"Context",
",",
"incident",
"RunstatusIncident",
",",
"event",
"RunstatusEvent",
")",
"error",
"{",
"if",
"incident",
".",
"EventsURL",
"==",
"\"",
"\"",
"{",
"... | // UpdateRunstatusIncident create runstatus incident event
// Events can be updates or final message with status completed. | [
"UpdateRunstatusIncident",
"create",
"runstatus",
"incident",
"event",
"Events",
"can",
"be",
"updates",
"or",
"final",
"message",
"with",
"status",
"completed",
"."
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_event.go#L19-L26 |
15,409 | exoscale/egoscale | runstatus_event.go | UpdateRunstatusMaintenance | func (client *Client) UpdateRunstatusMaintenance(ctx context.Context, maintenance RunstatusMaintenance, event RunstatusEvent) error {
if maintenance.EventsURL == "" {
return fmt.Errorf("empty Events URL for %#v", maintenance)
}
_, err := client.runstatusRequest(ctx, maintenance.EventsURL, event, "POST")
return err
} | go | func (client *Client) UpdateRunstatusMaintenance(ctx context.Context, maintenance RunstatusMaintenance, event RunstatusEvent) error {
if maintenance.EventsURL == "" {
return fmt.Errorf("empty Events URL for %#v", maintenance)
}
_, err := client.runstatusRequest(ctx, maintenance.EventsURL, event, "POST")
return err
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"UpdateRunstatusMaintenance",
"(",
"ctx",
"context",
".",
"Context",
",",
"maintenance",
"RunstatusMaintenance",
",",
"event",
"RunstatusEvent",
")",
"error",
"{",
"if",
"maintenance",
".",
"EventsURL",
"==",
"\"",
"\""... | // UpdateRunstatusMaintenance adds a event to a maintenance.
// Events can be updates or final message with status completed. | [
"UpdateRunstatusMaintenance",
"adds",
"a",
"event",
"to",
"a",
"maintenance",
".",
"Events",
"can",
"be",
"updates",
"or",
"final",
"message",
"with",
"status",
"completed",
"."
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_event.go#L30-L37 |
15,410 | exoscale/egoscale | events.go | ListRequest | func (event Event) ListRequest() (ListCommand, error) {
req := &ListEvents{
ID: event.ID,
Level: event.Level,
Type: event.Type,
}
return req, nil
} | go | func (event Event) ListRequest() (ListCommand, error) {
req := &ListEvents{
ID: event.ID,
Level: event.Level,
Type: event.Type,
}
return req, nil
} | [
"func",
"(",
"event",
"Event",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"req",
":=",
"&",
"ListEvents",
"{",
"ID",
":",
"event",
".",
"ID",
",",
"Level",
":",
"event",
".",
"Level",
",",
"Type",
":",
"event",
".",
... | // ListRequest builds the ListEvents request | [
"ListRequest",
"builds",
"the",
"ListEvents",
"request"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/events.go#L17-L25 |
15,411 | exoscale/egoscale | volumes.go | ListRequest | func (vol Volume) ListRequest() (ListCommand, error) {
req := &ListVolumes{
Name: vol.Name,
Type: vol.Type,
VirtualMachineID: vol.VirtualMachineID,
ZoneID: vol.ZoneID,
}
return req, nil
} | go | func (vol Volume) ListRequest() (ListCommand, error) {
req := &ListVolumes{
Name: vol.Name,
Type: vol.Type,
VirtualMachineID: vol.VirtualMachineID,
ZoneID: vol.ZoneID,
}
return req, nil
} | [
"func",
"(",
"vol",
"Volume",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"req",
":=",
"&",
"ListVolumes",
"{",
"Name",
":",
"vol",
".",
"Name",
",",
"Type",
":",
"vol",
".",
"Type",
",",
"VirtualMachineID",
":",
"vol",
... | // ListRequest builds the ListVolumes request | [
"ListRequest",
"builds",
"the",
"ListVolumes",
"request"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/volumes.go#L63-L72 |
15,412 | exoscale/egoscale | templates.go | ListRequest | func (template Template) ListRequest() (ListCommand, error) {
req := &ListTemplates{
ID: template.ID,
Name: template.Name,
ZoneID: template.ZoneID,
}
if template.IsFeatured {
req.TemplateFilter = "featured"
}
if template.Removed != "" {
*req.ShowRemoved = true
}
for i := range template.Tags {
req.Tags = append(req.Tags, template.Tags[i])
}
return req, nil
} | go | func (template Template) ListRequest() (ListCommand, error) {
req := &ListTemplates{
ID: template.ID,
Name: template.Name,
ZoneID: template.ZoneID,
}
if template.IsFeatured {
req.TemplateFilter = "featured"
}
if template.Removed != "" {
*req.ShowRemoved = true
}
for i := range template.Tags {
req.Tags = append(req.Tags, template.Tags[i])
}
return req, nil
} | [
"func",
"(",
"template",
"Template",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"req",
":=",
"&",
"ListTemplates",
"{",
"ID",
":",
"template",
".",
"ID",
",",
"Name",
":",
"template",
".",
"Name",
",",
"ZoneID",
":",
"t... | // ListRequest builds the ListTemplates request | [
"ListRequest",
"builds",
"the",
"ListTemplates",
"request"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/templates.go#L49-L67 |
15,413 | exoscale/egoscale | templates.go | ListRequest | func (osCat OSCategory) ListRequest() (ListCommand, error) {
req := &ListOSCategories{
Name: osCat.Name,
ID: osCat.ID,
}
return req, nil
} | go | func (osCat OSCategory) ListRequest() (ListCommand, error) {
req := &ListOSCategories{
Name: osCat.Name,
ID: osCat.ID,
}
return req, nil
} | [
"func",
"(",
"osCat",
"OSCategory",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"req",
":=",
"&",
"ListOSCategories",
"{",
"Name",
":",
"osCat",
".",
"Name",
",",
"ID",
":",
"osCat",
".",
"ID",
",",
"}",
"\n\n",
"return"... | // ListRequest builds the ListOSCategories request | [
"ListRequest",
"builds",
"the",
"ListOSCategories",
"request"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/templates.go#L98-L105 |
15,414 | exoscale/egoscale | uuid.go | DeepCopy | func (u *UUID) DeepCopy() *UUID {
if u == nil {
return nil
}
out := [uuid.Size]byte{}
copy(out[:], u.Bytes())
return &UUID{
(uuid.UUID)(out),
}
} | go | func (u *UUID) DeepCopy() *UUID {
if u == nil {
return nil
}
out := [uuid.Size]byte{}
copy(out[:], u.Bytes())
return &UUID{
(uuid.UUID)(out),
}
} | [
"func",
"(",
"u",
"*",
"UUID",
")",
"DeepCopy",
"(",
")",
"*",
"UUID",
"{",
"if",
"u",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"out",
":=",
"[",
"uuid",
".",
"Size",
"]",
"byte",
"{",
"}",
"\n",
"copy",
"(",
"out",
"[",
":",
"... | // DeepCopy create a true copy of the receiver. | [
"DeepCopy",
"create",
"a",
"true",
"copy",
"of",
"the",
"receiver",
"."
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/uuid.go#L16-L27 |
15,415 | exoscale/egoscale | uuid.go | DeepCopyInto | func (u *UUID) DeepCopyInto(out *UUID) {
o := [uuid.Size]byte{}
copy(o[:], u.Bytes())
out.UUID = (uuid.UUID)(o)
} | go | func (u *UUID) DeepCopyInto(out *UUID) {
o := [uuid.Size]byte{}
copy(o[:], u.Bytes())
out.UUID = (uuid.UUID)(o)
} | [
"func",
"(",
"u",
"*",
"UUID",
")",
"DeepCopyInto",
"(",
"out",
"*",
"UUID",
")",
"{",
"o",
":=",
"[",
"uuid",
".",
"Size",
"]",
"byte",
"{",
"}",
"\n",
"copy",
"(",
"o",
"[",
":",
"]",
",",
"u",
".",
"Bytes",
"(",
")",
")",
"\n\n",
"out",
... | // DeepCopyInto copies the receiver into out.
//
// In must be non nil. | [
"DeepCopyInto",
"copies",
"the",
"receiver",
"into",
"out",
".",
"In",
"must",
"be",
"non",
"nil",
"."
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/uuid.go#L32-L37 |
15,416 | exoscale/egoscale | uuid.go | UnmarshalJSON | func (u *UUID) UnmarshalJSON(b []byte) error {
var s string
if err := json.Unmarshal(b, &s); err != nil {
return err
}
new, err := ParseUUID(s)
if err == nil {
u.UUID = new.UUID
}
return err
} | go | func (u *UUID) UnmarshalJSON(b []byte) error {
var s string
if err := json.Unmarshal(b, &s); err != nil {
return err
}
new, err := ParseUUID(s)
if err == nil {
u.UUID = new.UUID
}
return err
} | [
"func",
"(",
"u",
"*",
"UUID",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"s",
"string",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"b",
",",
"&",
"s",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
... | // UnmarshalJSON unmarshals the raw JSON into the UUID. | [
"UnmarshalJSON",
"unmarshals",
"the",
"raw",
"JSON",
"into",
"the",
"UUID",
"."
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/uuid.go#L45-L56 |
15,417 | exoscale/egoscale | uuid.go | ParseUUID | func ParseUUID(s string) (*UUID, error) {
u, err := uuid.FromString(s)
if err != nil {
return nil, err
}
return &UUID{u}, nil
} | go | func ParseUUID(s string) (*UUID, error) {
u, err := uuid.FromString(s)
if err != nil {
return nil, err
}
return &UUID{u}, nil
} | [
"func",
"ParseUUID",
"(",
"s",
"string",
")",
"(",
"*",
"UUID",
",",
"error",
")",
"{",
"u",
",",
"err",
":=",
"uuid",
".",
"FromString",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return"... | // ParseUUID parses a string into a UUID. | [
"ParseUUID",
"parses",
"a",
"string",
"into",
"a",
"UUID",
"."
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/uuid.go#L64-L70 |
15,418 | exoscale/egoscale | uuid.go | MustParseUUID | func MustParseUUID(s string) *UUID {
u, e := ParseUUID(s)
if e != nil {
panic(e)
}
return u
} | go | func MustParseUUID(s string) *UUID {
u, e := ParseUUID(s)
if e != nil {
panic(e)
}
return u
} | [
"func",
"MustParseUUID",
"(",
"s",
"string",
")",
"*",
"UUID",
"{",
"u",
",",
"e",
":=",
"ParseUUID",
"(",
"s",
")",
"\n",
"if",
"e",
"!=",
"nil",
"{",
"panic",
"(",
"e",
")",
"\n",
"}",
"\n",
"return",
"u",
"\n",
"}"
] | // MustParseUUID acts like ParseUUID but panic in case of a failure. | [
"MustParseUUID",
"acts",
"like",
"ParseUUID",
"but",
"panic",
"in",
"case",
"of",
"a",
"failure",
"."
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/uuid.go#L73-L79 |
15,419 | exoscale/egoscale | runstatus_service.go | Match | func (service RunstatusService) Match(other RunstatusService) bool {
if other.Name != "" && service.Name == other.Name {
return true
}
if other.ID > 0 && service.ID == other.ID {
return true
}
return false
} | go | func (service RunstatusService) Match(other RunstatusService) bool {
if other.Name != "" && service.Name == other.Name {
return true
}
if other.ID > 0 && service.ID == other.ID {
return true
}
return false
} | [
"func",
"(",
"service",
"RunstatusService",
")",
"Match",
"(",
"other",
"RunstatusService",
")",
"bool",
"{",
"if",
"other",
".",
"Name",
"!=",
"\"",
"\"",
"&&",
"service",
".",
"Name",
"==",
"other",
".",
"Name",
"{",
"return",
"true",
"\n",
"}",
"\n\... | // Match returns true if the other service has got similarities with itself | [
"Match",
"returns",
"true",
"if",
"the",
"other",
"service",
"has",
"got",
"similarities",
"with",
"itself"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_service.go#L47-L57 |
15,420 | exoscale/egoscale | runstatus_service.go | DeleteRunstatusService | func (client *Client) DeleteRunstatusService(ctx context.Context, service RunstatusService) error {
if service.URL == "" {
return fmt.Errorf("empty URL for %#v", service)
}
_, err := client.runstatusRequest(ctx, service.URL, nil, "DELETE")
return err
} | go | func (client *Client) DeleteRunstatusService(ctx context.Context, service RunstatusService) error {
if service.URL == "" {
return fmt.Errorf("empty URL for %#v", service)
}
_, err := client.runstatusRequest(ctx, service.URL, nil, "DELETE")
return err
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"DeleteRunstatusService",
"(",
"ctx",
"context",
".",
"Context",
",",
"service",
"RunstatusService",
")",
"error",
"{",
"if",
"service",
".",
"URL",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\... | // DeleteRunstatusService delete runstatus service | [
"DeleteRunstatusService",
"delete",
"runstatus",
"service"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_service.go#L67-L74 |
15,421 | exoscale/egoscale | runstatus_service.go | CreateRunstatusService | func (client *Client) CreateRunstatusService(ctx context.Context, service RunstatusService) (*RunstatusService, error) {
if service.PageURL == "" {
return nil, fmt.Errorf("empty Page URL for %#v", service)
}
page, err := client.GetRunstatusPage(ctx, RunstatusPage{URL: service.PageURL})
if err != nil {
return nil, err
}
resp, err := client.runstatusRequest(ctx, page.ServicesURL, service, "POST")
if err != nil {
return nil, err
}
s := &RunstatusService{}
if err := json.Unmarshal(resp, s); err != nil {
return nil, err
}
return s, nil
} | go | func (client *Client) CreateRunstatusService(ctx context.Context, service RunstatusService) (*RunstatusService, error) {
if service.PageURL == "" {
return nil, fmt.Errorf("empty Page URL for %#v", service)
}
page, err := client.GetRunstatusPage(ctx, RunstatusPage{URL: service.PageURL})
if err != nil {
return nil, err
}
resp, err := client.runstatusRequest(ctx, page.ServicesURL, service, "POST")
if err != nil {
return nil, err
}
s := &RunstatusService{}
if err := json.Unmarshal(resp, s); err != nil {
return nil, err
}
return s, nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"CreateRunstatusService",
"(",
"ctx",
"context",
".",
"Context",
",",
"service",
"RunstatusService",
")",
"(",
"*",
"RunstatusService",
",",
"error",
")",
"{",
"if",
"service",
".",
"PageURL",
"==",
"\"",
"\"",
"{... | // CreateRunstatusService create runstatus service | [
"CreateRunstatusService",
"create",
"runstatus",
"service"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_service.go#L77-L98 |
15,422 | exoscale/egoscale | runstatus_service.go | GetRunstatusService | func (client *Client) GetRunstatusService(ctx context.Context, service RunstatusService) (*RunstatusService, error) {
if service.URL != "" {
return client.getRunstatusService(ctx, service.URL)
}
if service.PageURL == "" {
return nil, fmt.Errorf("empty Page URL in %#v", service)
}
page, err := client.getRunstatusPage(ctx, service.PageURL)
if err != nil {
return nil, err
}
for i := range page.Services {
s := &page.Services[i]
if s.Match(service) {
if err := s.FakeID(); err != nil {
log.Printf("bad fake ID for %#v, %s", s, err)
}
return s, nil
}
}
return nil, fmt.Errorf("%#v not found", service)
} | go | func (client *Client) GetRunstatusService(ctx context.Context, service RunstatusService) (*RunstatusService, error) {
if service.URL != "" {
return client.getRunstatusService(ctx, service.URL)
}
if service.PageURL == "" {
return nil, fmt.Errorf("empty Page URL in %#v", service)
}
page, err := client.getRunstatusPage(ctx, service.PageURL)
if err != nil {
return nil, err
}
for i := range page.Services {
s := &page.Services[i]
if s.Match(service) {
if err := s.FakeID(); err != nil {
log.Printf("bad fake ID for %#v, %s", s, err)
}
return s, nil
}
}
return nil, fmt.Errorf("%#v not found", service)
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"GetRunstatusService",
"(",
"ctx",
"context",
".",
"Context",
",",
"service",
"RunstatusService",
")",
"(",
"*",
"RunstatusService",
",",
"error",
")",
"{",
"if",
"service",
".",
"URL",
"!=",
"\"",
"\"",
"{",
"r... | // GetRunstatusService displays service detail. | [
"GetRunstatusService",
"displays",
"service",
"detail",
"."
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_service.go#L101-L126 |
15,423 | exoscale/egoscale | runstatus_service.go | ListRunstatusServices | func (client *Client) ListRunstatusServices(ctx context.Context, page RunstatusPage) ([]RunstatusService, error) {
if page.ServicesURL == "" {
return nil, fmt.Errorf("empty Services URL for %#v", page)
}
results := make([]RunstatusService, 0)
var err error
client.PaginateRunstatusServices(ctx, page, func(service *RunstatusService, e error) bool {
if e != nil {
err = e
return false
}
results = append(results, *service)
return true
})
return results, err
} | go | func (client *Client) ListRunstatusServices(ctx context.Context, page RunstatusPage) ([]RunstatusService, error) {
if page.ServicesURL == "" {
return nil, fmt.Errorf("empty Services URL for %#v", page)
}
results := make([]RunstatusService, 0)
var err error
client.PaginateRunstatusServices(ctx, page, func(service *RunstatusService, e error) bool {
if e != nil {
err = e
return false
}
results = append(results, *service)
return true
})
return results, err
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"ListRunstatusServices",
"(",
"ctx",
"context",
".",
"Context",
",",
"page",
"RunstatusPage",
")",
"(",
"[",
"]",
"RunstatusService",
",",
"error",
")",
"{",
"if",
"page",
".",
"ServicesURL",
"==",
"\"",
"\"",
"... | // ListRunstatusServices displays the list of services. | [
"ListRunstatusServices",
"displays",
"the",
"list",
"of",
"services",
"."
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_service.go#L147-L166 |
15,424 | exoscale/egoscale | runstatus_service.go | PaginateRunstatusServices | func (client *Client) PaginateRunstatusServices(ctx context.Context, page RunstatusPage, callback func(*RunstatusService, error) bool) { // nolint: dupl
if page.ServicesURL == "" {
callback(nil, fmt.Errorf("empty Services URL for %#v", page))
return
}
servicesURL := page.ServicesURL
for servicesURL != "" {
resp, err := client.runstatusRequest(ctx, servicesURL, nil, "GET")
if err != nil {
callback(nil, err)
return
}
var ss *RunstatusServiceList
if err := json.Unmarshal(resp, &ss); err != nil {
callback(nil, err)
return
}
for i := range ss.Services {
if err := ss.Services[i].FakeID(); err != nil {
log.Printf("bad fake ID for %#v, %s", ss.Services[i], err)
}
if cont := callback(&ss.Services[i], nil); !cont {
return
}
}
servicesURL = ss.Next
}
} | go | func (client *Client) PaginateRunstatusServices(ctx context.Context, page RunstatusPage, callback func(*RunstatusService, error) bool) { // nolint: dupl
if page.ServicesURL == "" {
callback(nil, fmt.Errorf("empty Services URL for %#v", page))
return
}
servicesURL := page.ServicesURL
for servicesURL != "" {
resp, err := client.runstatusRequest(ctx, servicesURL, nil, "GET")
if err != nil {
callback(nil, err)
return
}
var ss *RunstatusServiceList
if err := json.Unmarshal(resp, &ss); err != nil {
callback(nil, err)
return
}
for i := range ss.Services {
if err := ss.Services[i].FakeID(); err != nil {
log.Printf("bad fake ID for %#v, %s", ss.Services[i], err)
}
if cont := callback(&ss.Services[i], nil); !cont {
return
}
}
servicesURL = ss.Next
}
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"PaginateRunstatusServices",
"(",
"ctx",
"context",
".",
"Context",
",",
"page",
"RunstatusPage",
",",
"callback",
"func",
"(",
"*",
"RunstatusService",
",",
"error",
")",
"bool",
")",
"{",
"// nolint: dupl",
"if",
... | // PaginateRunstatusServices paginates Services | [
"PaginateRunstatusServices",
"paginates",
"Services"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_service.go#L169-L201 |
15,425 | exoscale/egoscale | dns.go | CreateDomain | func (client *Client) CreateDomain(ctx context.Context, name string) (*DNSDomain, error) {
m, err := json.Marshal(DNSDomainResponse{
Domain: &DNSDomain{
Name: name,
},
})
if err != nil {
return nil, err
}
resp, err := client.dnsRequest(ctx, "/v1/domains", nil, string(m), "POST")
if err != nil {
return nil, err
}
var d *DNSDomainResponse
if err := json.Unmarshal(resp, &d); err != nil {
return nil, err
}
return d.Domain, nil
} | go | func (client *Client) CreateDomain(ctx context.Context, name string) (*DNSDomain, error) {
m, err := json.Marshal(DNSDomainResponse{
Domain: &DNSDomain{
Name: name,
},
})
if err != nil {
return nil, err
}
resp, err := client.dnsRequest(ctx, "/v1/domains", nil, string(m), "POST")
if err != nil {
return nil, err
}
var d *DNSDomainResponse
if err := json.Unmarshal(resp, &d); err != nil {
return nil, err
}
return d.Domain, nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"CreateDomain",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"*",
"DNSDomain",
",",
"error",
")",
"{",
"m",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"DNSDomainResponse",
"{",
... | // CreateDomain creates a DNS domain | [
"CreateDomain",
"creates",
"a",
"DNS",
"domain"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/dns.go#L129-L150 |
15,426 | exoscale/egoscale | dns.go | GetDomain | func (client *Client) GetDomain(ctx context.Context, name string) (*DNSDomain, error) {
resp, err := client.dnsRequest(ctx, "/v1/domains/"+name, nil, "", "GET")
if err != nil {
return nil, err
}
var d *DNSDomainResponse
if err := json.Unmarshal(resp, &d); err != nil {
return nil, err
}
return d.Domain, nil
} | go | func (client *Client) GetDomain(ctx context.Context, name string) (*DNSDomain, error) {
resp, err := client.dnsRequest(ctx, "/v1/domains/"+name, nil, "", "GET")
if err != nil {
return nil, err
}
var d *DNSDomainResponse
if err := json.Unmarshal(resp, &d); err != nil {
return nil, err
}
return d.Domain, nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"GetDomain",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"*",
"DNSDomain",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"client",
".",
"dnsRequest",
"(",
"ctx",
",",
"\"",
... | // GetDomain gets a DNS domain | [
"GetDomain",
"gets",
"a",
"DNS",
"domain"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/dns.go#L153-L165 |
15,427 | exoscale/egoscale | dns.go | GetDomains | func (client *Client) GetDomains(ctx context.Context) ([]DNSDomain, error) {
resp, err := client.dnsRequest(ctx, "/v1/domains", nil, "", "GET")
if err != nil {
return nil, err
}
var d []DNSDomainResponse
if err := json.Unmarshal(resp, &d); err != nil {
return nil, err
}
domains := make([]DNSDomain, len(d))
for i := range d {
domains[i] = *d[i].Domain
}
return domains, nil
} | go | func (client *Client) GetDomains(ctx context.Context) ([]DNSDomain, error) {
resp, err := client.dnsRequest(ctx, "/v1/domains", nil, "", "GET")
if err != nil {
return nil, err
}
var d []DNSDomainResponse
if err := json.Unmarshal(resp, &d); err != nil {
return nil, err
}
domains := make([]DNSDomain, len(d))
for i := range d {
domains[i] = *d[i].Domain
}
return domains, nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"GetDomains",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"DNSDomain",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"client",
".",
"dnsRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"nil",... | // GetDomains gets DNS domains | [
"GetDomains",
"gets",
"DNS",
"domains"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/dns.go#L168-L184 |
15,428 | exoscale/egoscale | dns.go | DeleteDomain | func (client *Client) DeleteDomain(ctx context.Context, name string) error {
_, err := client.dnsRequest(ctx, "/v1/domains/"+name, nil, "", "DELETE")
return err
} | go | func (client *Client) DeleteDomain(ctx context.Context, name string) error {
_, err := client.dnsRequest(ctx, "/v1/domains/"+name, nil, "", "DELETE")
return err
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"DeleteDomain",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"client",
".",
"dnsRequest",
"(",
"ctx",
",",
"\"",
"\"",
"+",
"name",
",",
"nil",
",... | // DeleteDomain delets a DNS domain | [
"DeleteDomain",
"delets",
"a",
"DNS",
"domain"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/dns.go#L187-L190 |
15,429 | exoscale/egoscale | dns.go | GetRecord | func (client *Client) GetRecord(ctx context.Context, domain string, recordID int64) (*DNSRecord, error) {
id := strconv.FormatInt(recordID, 10)
resp, err := client.dnsRequest(ctx, "/v1/domains/"+domain+"/records/"+id, nil, "", "GET")
if err != nil {
return nil, err
}
var r DNSRecordResponse
if err = json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &(r.Record), nil
} | go | func (client *Client) GetRecord(ctx context.Context, domain string, recordID int64) (*DNSRecord, error) {
id := strconv.FormatInt(recordID, 10)
resp, err := client.dnsRequest(ctx, "/v1/domains/"+domain+"/records/"+id, nil, "", "GET")
if err != nil {
return nil, err
}
var r DNSRecordResponse
if err = json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &(r.Record), nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"GetRecord",
"(",
"ctx",
"context",
".",
"Context",
",",
"domain",
"string",
",",
"recordID",
"int64",
")",
"(",
"*",
"DNSRecord",
",",
"error",
")",
"{",
"id",
":=",
"strconv",
".",
"FormatInt",
"(",
"recordI... | // GetRecord returns a DNS record | [
"GetRecord",
"returns",
"a",
"DNS",
"record"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/dns.go#L193-L206 |
15,430 | exoscale/egoscale | dns.go | GetRecords | func (client *Client) GetRecords(ctx context.Context, domain string) ([]DNSRecord, error) {
resp, err := client.dnsRequest(ctx, "/v1/domains/"+domain+"/records", nil, "", "GET")
if err != nil {
return nil, err
}
var r []DNSRecordResponse
if err = json.Unmarshal(resp, &r); err != nil {
return nil, err
}
records := make([]DNSRecord, 0, len(r))
for _, rec := range r {
records = append(records, rec.Record)
}
return records, nil
} | go | func (client *Client) GetRecords(ctx context.Context, domain string) ([]DNSRecord, error) {
resp, err := client.dnsRequest(ctx, "/v1/domains/"+domain+"/records", nil, "", "GET")
if err != nil {
return nil, err
}
var r []DNSRecordResponse
if err = json.Unmarshal(resp, &r); err != nil {
return nil, err
}
records := make([]DNSRecord, 0, len(r))
for _, rec := range r {
records = append(records, rec.Record)
}
return records, nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"GetRecords",
"(",
"ctx",
"context",
".",
"Context",
",",
"domain",
"string",
")",
"(",
"[",
"]",
"DNSRecord",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"client",
".",
"dnsRequest",
"(",
"ctx",
",",
... | // GetRecords returns the DNS records | [
"GetRecords",
"returns",
"the",
"DNS",
"records"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/dns.go#L209-L226 |
15,431 | exoscale/egoscale | dns.go | CreateRecord | func (client *Client) CreateRecord(ctx context.Context, name string, rec DNSRecord) (*DNSRecord, error) {
body, err := json.Marshal(DNSRecordResponse{
Record: rec,
})
if err != nil {
return nil, err
}
resp, err := client.dnsRequest(ctx, "/v1/domains/"+name+"/records", nil, string(body), "POST")
if err != nil {
return nil, err
}
var r DNSRecordResponse
if err = json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &(r.Record), nil
} | go | func (client *Client) CreateRecord(ctx context.Context, name string, rec DNSRecord) (*DNSRecord, error) {
body, err := json.Marshal(DNSRecordResponse{
Record: rec,
})
if err != nil {
return nil, err
}
resp, err := client.dnsRequest(ctx, "/v1/domains/"+name+"/records", nil, string(body), "POST")
if err != nil {
return nil, err
}
var r DNSRecordResponse
if err = json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &(r.Record), nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"CreateRecord",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"rec",
"DNSRecord",
")",
"(",
"*",
"DNSRecord",
",",
"error",
")",
"{",
"body",
",",
"err",
":=",
"json",
".",
"Marshal",
"(... | // CreateRecord creates a DNS record | [
"CreateRecord",
"creates",
"a",
"DNS",
"record"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/dns.go#L258-L277 |
15,432 | exoscale/egoscale | dns.go | UpdateRecord | func (client *Client) UpdateRecord(ctx context.Context, name string, rec UpdateDNSRecord) (*DNSRecord, error) {
body, err := json.Marshal(UpdateDNSRecordResponse{
Record: rec,
})
if err != nil {
return nil, err
}
id := strconv.FormatInt(rec.ID, 10)
resp, err := client.dnsRequest(ctx, "/v1/domains/"+name+"/records/"+id, nil, string(body), "PUT")
if err != nil {
return nil, err
}
var r DNSRecordResponse
if err = json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &(r.Record), nil
} | go | func (client *Client) UpdateRecord(ctx context.Context, name string, rec UpdateDNSRecord) (*DNSRecord, error) {
body, err := json.Marshal(UpdateDNSRecordResponse{
Record: rec,
})
if err != nil {
return nil, err
}
id := strconv.FormatInt(rec.ID, 10)
resp, err := client.dnsRequest(ctx, "/v1/domains/"+name+"/records/"+id, nil, string(body), "PUT")
if err != nil {
return nil, err
}
var r DNSRecordResponse
if err = json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &(r.Record), nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"UpdateRecord",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"rec",
"UpdateDNSRecord",
")",
"(",
"*",
"DNSRecord",
",",
"error",
")",
"{",
"body",
",",
"err",
":=",
"json",
".",
"Marshal"... | // UpdateRecord updates a DNS record | [
"UpdateRecord",
"updates",
"a",
"DNS",
"record"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/dns.go#L280-L300 |
15,433 | exoscale/egoscale | dns.go | DeleteRecord | func (client *Client) DeleteRecord(ctx context.Context, name string, recordID int64) error {
id := strconv.FormatInt(recordID, 10)
_, err := client.dnsRequest(ctx, "/v1/domains/"+name+"/records/"+id, nil, "", "DELETE")
return err
} | go | func (client *Client) DeleteRecord(ctx context.Context, name string, recordID int64) error {
id := strconv.FormatInt(recordID, 10)
_, err := client.dnsRequest(ctx, "/v1/domains/"+name+"/records/"+id, nil, "", "DELETE")
return err
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"DeleteRecord",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"recordID",
"int64",
")",
"error",
"{",
"id",
":=",
"strconv",
".",
"FormatInt",
"(",
"recordID",
",",
"10",
")",
"\n",
"_",
... | // DeleteRecord deletes a record | [
"DeleteRecord",
"deletes",
"a",
"record"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/dns.go#L303-L308 |
15,434 | exoscale/egoscale | cidr.go | MarshalJSON | func (cidr CIDR) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("%q", cidr)), nil
} | go | func (cidr CIDR) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("%q", cidr)), nil
} | [
"func",
"(",
"cidr",
"CIDR",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"cidr",
")",
")",
",",
"nil",
"\n",
"}"
] | // MarshalJSON converts the CIDR to a string representation | [
"MarshalJSON",
"converts",
"the",
"CIDR",
"to",
"a",
"string",
"representation"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/cidr.go#L31-L33 |
15,435 | exoscale/egoscale | cidr.go | ParseCIDR | func ParseCIDR(s string) (*CIDR, error) {
_, net, err := net.ParseCIDR(s)
if err != nil {
return nil, err
}
return &CIDR{*net}, nil
} | go | func ParseCIDR(s string) (*CIDR, error) {
_, net, err := net.ParseCIDR(s)
if err != nil {
return nil, err
}
return &CIDR{*net}, nil
} | [
"func",
"ParseCIDR",
"(",
"s",
"string",
")",
"(",
"*",
"CIDR",
",",
"error",
")",
"{",
"_",
",",
"net",
",",
"err",
":=",
"net",
".",
"ParseCIDR",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\... | // ParseCIDR parses a CIDR from a string | [
"ParseCIDR",
"parses",
"a",
"CIDR",
"from",
"a",
"string"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/cidr.go#L41-L47 |
15,436 | exoscale/egoscale | cidr.go | MustParseCIDR | func MustParseCIDR(s string) *CIDR {
cidr, err := ParseCIDR(s)
if err != nil {
panic(err)
}
return cidr
} | go | func MustParseCIDR(s string) *CIDR {
cidr, err := ParseCIDR(s)
if err != nil {
panic(err)
}
return cidr
} | [
"func",
"MustParseCIDR",
"(",
"s",
"string",
")",
"*",
"CIDR",
"{",
"cidr",
",",
"err",
":=",
"ParseCIDR",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"cidr",
"\n",
"}"
] | // MustParseCIDR forces parseCIDR or panics | [
"MustParseCIDR",
"forces",
"parseCIDR",
"or",
"panics"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/cidr.go#L50-L57 |
15,437 | exoscale/egoscale | cidr.go | Equal | func (cidr CIDR) Equal(c CIDR) bool {
return (cidr.IPNet.IP.Equal(c.IPNet.IP) && bytes.Equal(cidr.IPNet.Mask, c.IPNet.Mask))
} | go | func (cidr CIDR) Equal(c CIDR) bool {
return (cidr.IPNet.IP.Equal(c.IPNet.IP) && bytes.Equal(cidr.IPNet.Mask, c.IPNet.Mask))
} | [
"func",
"(",
"cidr",
"CIDR",
")",
"Equal",
"(",
"c",
"CIDR",
")",
"bool",
"{",
"return",
"(",
"cidr",
".",
"IPNet",
".",
"IP",
".",
"Equal",
"(",
"c",
".",
"IPNet",
".",
"IP",
")",
"&&",
"bytes",
".",
"Equal",
"(",
"cidr",
".",
"IPNet",
".",
... | // Equal compare two CIDR | [
"Equal",
"compare",
"two",
"CIDR"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/cidr.go#L60-L62 |
15,438 | exoscale/egoscale | networks.go | ListRequest | func (network Network) ListRequest() (ListCommand, error) {
//TODO add tags support
req := &ListNetworks{
ID: network.ID,
Keyword: network.Name, // this is a hack as listNetworks doesn't support to search by name.
PhysicalNetworkID: network.PhysicalNetworkID,
TrafficType: network.TrafficType,
Type: network.Type,
ZoneID: network.ZoneID,
}
if network.CanUseForDeploy {
req.CanUseForDeploy = &network.CanUseForDeploy
}
if network.RestartRequired {
req.RestartRequired = &network.RestartRequired
}
return req, nil
} | go | func (network Network) ListRequest() (ListCommand, error) {
//TODO add tags support
req := &ListNetworks{
ID: network.ID,
Keyword: network.Name, // this is a hack as listNetworks doesn't support to search by name.
PhysicalNetworkID: network.PhysicalNetworkID,
TrafficType: network.TrafficType,
Type: network.Type,
ZoneID: network.ZoneID,
}
if network.CanUseForDeploy {
req.CanUseForDeploy = &network.CanUseForDeploy
}
if network.RestartRequired {
req.RestartRequired = &network.RestartRequired
}
return req, nil
} | [
"func",
"(",
"network",
"Network",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"//TODO add tags support",
"req",
":=",
"&",
"ListNetworks",
"{",
"ID",
":",
"network",
".",
"ID",
",",
"Keyword",
":",
"network",
".",
"Name",
"... | // ListRequest builds the ListNetworks request | [
"ListRequest",
"builds",
"the",
"ListNetworks",
"request"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/networks.go#L58-L77 |
15,439 | exoscale/egoscale | request.go | Error | func (e ErrorResponse) Error() string {
return fmt.Sprintf("API error %s %d (%s %d): %s", e.ErrorCode, e.ErrorCode, e.CSErrorCode, e.CSErrorCode, e.ErrorText)
} | go | func (e ErrorResponse) Error() string {
return fmt.Sprintf("API error %s %d (%s %d): %s", e.ErrorCode, e.ErrorCode, e.CSErrorCode, e.CSErrorCode, e.ErrorText)
} | [
"func",
"(",
"e",
"ErrorResponse",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"ErrorCode",
",",
"e",
".",
"ErrorCode",
",",
"e",
".",
"CSErrorCode",
",",
"e",
".",
"CSErrorCode",
",",
"e"... | // Error formats a CloudStack error into a standard error | [
"Error",
"formats",
"a",
"CloudStack",
"error",
"into",
"a",
"standard",
"error"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/request.go#L22-L24 |
15,440 | exoscale/egoscale | request.go | Error | func (e BooleanResponse) Error() error {
if !e.Success {
return fmt.Errorf("API error: %s", e.DisplayText)
}
return nil
} | go | func (e BooleanResponse) Error() error {
if !e.Success {
return fmt.Errorf("API error: %s", e.DisplayText)
}
return nil
} | [
"func",
"(",
"e",
"BooleanResponse",
")",
"Error",
"(",
")",
"error",
"{",
"if",
"!",
"e",
".",
"Success",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"e",
".",
"DisplayText",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Error formats a CloudStack job response into a standard error | [
"Error",
"formats",
"a",
"CloudStack",
"job",
"response",
"into",
"a",
"standard",
"error"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/request.go#L27-L33 |
15,441 | exoscale/egoscale | request.go | asyncRequest | func (client *Client) asyncRequest(ctx context.Context, asyncCommand AsyncCommand) (interface{}, error) {
var err error
resp := asyncCommand.AsyncResponse()
client.AsyncRequestWithContext(
ctx,
asyncCommand,
func(j *AsyncJobResult, e error) bool {
if e != nil {
err = e
return false
}
if j.JobStatus != Pending {
if r := j.Result(resp); r != nil {
err = r
}
return false
}
return true
},
)
return resp, err
} | go | func (client *Client) asyncRequest(ctx context.Context, asyncCommand AsyncCommand) (interface{}, error) {
var err error
resp := asyncCommand.AsyncResponse()
client.AsyncRequestWithContext(
ctx,
asyncCommand,
func(j *AsyncJobResult, e error) bool {
if e != nil {
err = e
return false
}
if j.JobStatus != Pending {
if r := j.Result(resp); r != nil {
err = r
}
return false
}
return true
},
)
return resp, err
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"asyncRequest",
"(",
"ctx",
"context",
".",
"Context",
",",
"asyncCommand",
"AsyncCommand",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"resp",
":=",
"asyncCommand",
"... | // asyncRequest perform an asynchronous job with a context | [
"asyncRequest",
"perform",
"an",
"asynchronous",
"job",
"with",
"a",
"context"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/request.go#L114-L136 |
15,442 | exoscale/egoscale | request.go | SyncRequestWithContext | func (client *Client) SyncRequestWithContext(ctx context.Context, command Command) (interface{}, error) {
body, err := client.request(ctx, command)
if err != nil {
return nil, err
}
response := command.Response()
b, ok := response.(*BooleanResponse)
if ok {
m := make(map[string]interface{})
if errUnmarshal := json.Unmarshal(body, &m); errUnmarshal != nil {
return nil, errUnmarshal
}
b.DisplayText, _ = m["displaytext"].(string)
if success, okSuccess := m["success"].(string); okSuccess {
b.Success = success == "true"
}
if success, okSuccess := m["success"].(bool); okSuccess {
b.Success = success
}
return b, nil
}
if err := json.Unmarshal(body, response); err != nil {
errResponse := new(ErrorResponse)
if e := json.Unmarshal(body, errResponse); e == nil && errResponse.ErrorCode > 0 {
return errResponse, nil
}
return nil, err
}
return response, nil
} | go | func (client *Client) SyncRequestWithContext(ctx context.Context, command Command) (interface{}, error) {
body, err := client.request(ctx, command)
if err != nil {
return nil, err
}
response := command.Response()
b, ok := response.(*BooleanResponse)
if ok {
m := make(map[string]interface{})
if errUnmarshal := json.Unmarshal(body, &m); errUnmarshal != nil {
return nil, errUnmarshal
}
b.DisplayText, _ = m["displaytext"].(string)
if success, okSuccess := m["success"].(string); okSuccess {
b.Success = success == "true"
}
if success, okSuccess := m["success"].(bool); okSuccess {
b.Success = success
}
return b, nil
}
if err := json.Unmarshal(body, response); err != nil {
errResponse := new(ErrorResponse)
if e := json.Unmarshal(body, errResponse); e == nil && errResponse.ErrorCode > 0 {
return errResponse, nil
}
return nil, err
}
return response, nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"SyncRequestWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"command",
"Command",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"body",
",",
"err",
":=",
"client",
".",
"request",
"(",
"ct... | // SyncRequestWithContext performs a sync request with a context | [
"SyncRequestWithContext",
"performs",
"a",
"sync",
"request",
"with",
"a",
"context"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/request.go#L139-L175 |
15,443 | exoscale/egoscale | request.go | BooleanRequest | func (client *Client) BooleanRequest(command Command) error {
resp, err := client.Request(command)
if err != nil {
return err
}
if b, ok := resp.(*BooleanResponse); ok {
return b.Error()
}
panic(fmt.Errorf("command %q is not a proper boolean response. %#v", client.APIName(command), resp))
} | go | func (client *Client) BooleanRequest(command Command) error {
resp, err := client.Request(command)
if err != nil {
return err
}
if b, ok := resp.(*BooleanResponse); ok {
return b.Error()
}
panic(fmt.Errorf("command %q is not a proper boolean response. %#v", client.APIName(command), resp))
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"BooleanRequest",
"(",
"command",
"Command",
")",
"error",
"{",
"resp",
",",
"err",
":=",
"client",
".",
"Request",
"(",
"command",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n... | // BooleanRequest performs the given boolean command | [
"BooleanRequest",
"performs",
"the",
"given",
"boolean",
"command"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/request.go#L178-L189 |
15,444 | exoscale/egoscale | request.go | BooleanRequestWithContext | func (client *Client) BooleanRequestWithContext(ctx context.Context, command Command) error {
resp, err := client.RequestWithContext(ctx, command)
if err != nil {
return err
}
if b, ok := resp.(*BooleanResponse); ok {
return b.Error()
}
panic(fmt.Errorf("command %q is not a proper boolean response. %#v", client.APIName(command), resp))
} | go | func (client *Client) BooleanRequestWithContext(ctx context.Context, command Command) error {
resp, err := client.RequestWithContext(ctx, command)
if err != nil {
return err
}
if b, ok := resp.(*BooleanResponse); ok {
return b.Error()
}
panic(fmt.Errorf("command %q is not a proper boolean response. %#v", client.APIName(command), resp))
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"BooleanRequestWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"command",
"Command",
")",
"error",
"{",
"resp",
",",
"err",
":=",
"client",
".",
"RequestWithContext",
"(",
"ctx",
",",
"command",
")",
"\n... | // BooleanRequestWithContext performs the given boolean command | [
"BooleanRequestWithContext",
"performs",
"the",
"given",
"boolean",
"command"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/request.go#L192-L203 |
15,445 | exoscale/egoscale | request.go | Request | func (client *Client) Request(command Command) (interface{}, error) {
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
defer cancel()
return client.RequestWithContext(ctx, command)
} | go | func (client *Client) Request(command Command) (interface{}, error) {
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
defer cancel()
return client.RequestWithContext(ctx, command)
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"Request",
"(",
"command",
"Command",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"cl... | // Request performs the given command | [
"Request",
"performs",
"the",
"given",
"command"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/request.go#L206-L211 |
15,446 | exoscale/egoscale | request.go | RequestWithContext | func (client *Client) RequestWithContext(ctx context.Context, command Command) (interface{}, error) {
switch c := command.(type) {
case AsyncCommand:
return client.asyncRequest(ctx, c)
default:
return client.SyncRequestWithContext(ctx, command)
}
} | go | func (client *Client) RequestWithContext(ctx context.Context, command Command) (interface{}, error) {
switch c := command.(type) {
case AsyncCommand:
return client.asyncRequest(ctx, c)
default:
return client.SyncRequestWithContext(ctx, command)
}
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"RequestWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"command",
"Command",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"switch",
"c",
":=",
"command",
".",
"(",
"type",
")",
"{",
"c... | // RequestWithContext preforms a command with a context | [
"RequestWithContext",
"preforms",
"a",
"command",
"with",
"a",
"context"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/request.go#L214-L221 |
15,447 | exoscale/egoscale | request.go | SyncRequest | func (client *Client) SyncRequest(command Command) (interface{}, error) {
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
defer cancel()
return client.SyncRequestWithContext(ctx, command)
} | go | func (client *Client) SyncRequest(command Command) (interface{}, error) {
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
defer cancel()
return client.SyncRequestWithContext(ctx, command)
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"SyncRequest",
"(",
"command",
"Command",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
... | // SyncRequest performs the command as is | [
"SyncRequest",
"performs",
"the",
"command",
"as",
"is"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/request.go#L224-L229 |
15,448 | exoscale/egoscale | request.go | AsyncRequest | func (client *Client) AsyncRequest(asyncCommand AsyncCommand, callback WaitAsyncJobResultFunc) {
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
defer cancel()
client.AsyncRequestWithContext(ctx, asyncCommand, callback)
} | go | func (client *Client) AsyncRequest(asyncCommand AsyncCommand, callback WaitAsyncJobResultFunc) {
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
defer cancel()
client.AsyncRequestWithContext(ctx, asyncCommand, callback)
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"AsyncRequest",
"(",
"asyncCommand",
"AsyncCommand",
",",
"callback",
"WaitAsyncJobResultFunc",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
... | // AsyncRequest performs the given command | [
"AsyncRequest",
"performs",
"the",
"given",
"command"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/request.go#L232-L237 |
15,449 | exoscale/egoscale | request.go | AsyncRequestWithContext | func (client *Client) AsyncRequestWithContext(ctx context.Context, asyncCommand AsyncCommand, callback WaitAsyncJobResultFunc) {
result, err := client.SyncRequestWithContext(ctx, asyncCommand)
if err != nil {
if !callback(nil, err) {
return
}
}
jobResult, ok := result.(*AsyncJobResult)
if !ok {
callback(nil, fmt.Errorf("wrong type, AsyncJobResult was expected instead of %T", result))
}
// Successful response
if jobResult.JobID == nil || jobResult.JobStatus != Pending {
callback(jobResult, nil)
// without a JobID, the next requests will only fail
return
}
for iteration := 0; ; iteration++ {
time.Sleep(client.RetryStrategy(int64(iteration)))
req := &QueryAsyncJobResult{JobID: jobResult.JobID}
resp, err := client.SyncRequestWithContext(ctx, req)
if err != nil && !callback(nil, err) {
return
}
result, ok := resp.(*AsyncJobResult)
if !ok {
if !callback(nil, fmt.Errorf("wrong type. AsyncJobResult expected, got %T", resp)) {
return
}
}
if !callback(result, nil) {
return
}
}
} | go | func (client *Client) AsyncRequestWithContext(ctx context.Context, asyncCommand AsyncCommand, callback WaitAsyncJobResultFunc) {
result, err := client.SyncRequestWithContext(ctx, asyncCommand)
if err != nil {
if !callback(nil, err) {
return
}
}
jobResult, ok := result.(*AsyncJobResult)
if !ok {
callback(nil, fmt.Errorf("wrong type, AsyncJobResult was expected instead of %T", result))
}
// Successful response
if jobResult.JobID == nil || jobResult.JobStatus != Pending {
callback(jobResult, nil)
// without a JobID, the next requests will only fail
return
}
for iteration := 0; ; iteration++ {
time.Sleep(client.RetryStrategy(int64(iteration)))
req := &QueryAsyncJobResult{JobID: jobResult.JobID}
resp, err := client.SyncRequestWithContext(ctx, req)
if err != nil && !callback(nil, err) {
return
}
result, ok := resp.(*AsyncJobResult)
if !ok {
if !callback(nil, fmt.Errorf("wrong type. AsyncJobResult expected, got %T", resp)) {
return
}
}
if !callback(result, nil) {
return
}
}
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"AsyncRequestWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"asyncCommand",
"AsyncCommand",
",",
"callback",
"WaitAsyncJobResultFunc",
")",
"{",
"result",
",",
"err",
":=",
"client",
".",
"SyncRequestWithContex... | // AsyncRequestWithContext preforms a request with a context | [
"AsyncRequestWithContext",
"preforms",
"a",
"request",
"with",
"a",
"context"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/request.go#L240-L280 |
15,450 | exoscale/egoscale | request.go | Payload | func (client *Client) Payload(command Command) (url.Values, error) {
params, err := prepareValues("", command)
if err != nil {
return nil, err
}
if hookReq, ok := command.(onBeforeHook); ok {
if err := hookReq.onBeforeSend(params); err != nil {
return params, err
}
}
params.Set("apikey", client.APIKey)
params.Set("command", client.APIName(command))
params.Set("response", "json")
if params.Get("expires") == "" && client.Expiration >= 0 {
params.Set("signatureversion", "3")
params.Set("expires", time.Now().Add(client.Expiration).Local().Format("2006-01-02T15:04:05-0700"))
}
return params, nil
} | go | func (client *Client) Payload(command Command) (url.Values, error) {
params, err := prepareValues("", command)
if err != nil {
return nil, err
}
if hookReq, ok := command.(onBeforeHook); ok {
if err := hookReq.onBeforeSend(params); err != nil {
return params, err
}
}
params.Set("apikey", client.APIKey)
params.Set("command", client.APIName(command))
params.Set("response", "json")
if params.Get("expires") == "" && client.Expiration >= 0 {
params.Set("signatureversion", "3")
params.Set("expires", time.Now().Add(client.Expiration).Local().Format("2006-01-02T15:04:05-0700"))
}
return params, nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"Payload",
"(",
"command",
"Command",
")",
"(",
"url",
".",
"Values",
",",
"error",
")",
"{",
"params",
",",
"err",
":=",
"prepareValues",
"(",
"\"",
"\"",
",",
"command",
")",
"\n",
"if",
"err",
"!=",
"ni... | // Payload builds the HTTP request params from the given command | [
"Payload",
"builds",
"the",
"HTTP",
"request",
"params",
"from",
"the",
"given",
"command"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/request.go#L283-L303 |
15,451 | exoscale/egoscale | request.go | Sign | func (client *Client) Sign(params url.Values) (string, error) {
query := encodeValues(params)
query = strings.ToLower(query)
mac := hmac.New(sha1.New, []byte(client.apiSecret))
_, err := mac.Write([]byte(query))
if err != nil {
return "", err
}
signature := base64.StdEncoding.EncodeToString(mac.Sum(nil))
return signature, nil
} | go | func (client *Client) Sign(params url.Values) (string, error) {
query := encodeValues(params)
query = strings.ToLower(query)
mac := hmac.New(sha1.New, []byte(client.apiSecret))
_, err := mac.Write([]byte(query))
if err != nil {
return "", err
}
signature := base64.StdEncoding.EncodeToString(mac.Sum(nil))
return signature, nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"Sign",
"(",
"params",
"url",
".",
"Values",
")",
"(",
"string",
",",
"error",
")",
"{",
"query",
":=",
"encodeValues",
"(",
"params",
")",
"\n",
"query",
"=",
"strings",
".",
"ToLower",
"(",
"query",
")",
... | // Sign signs the HTTP request and returns the signature as as base64 encoding | [
"Sign",
"signs",
"the",
"HTTP",
"request",
"and",
"returns",
"the",
"signature",
"as",
"as",
"base64",
"encoding"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/request.go#L306-L317 |
15,452 | exoscale/egoscale | request.go | request | func (client *Client) request(ctx context.Context, command Command) (json.RawMessage, error) {
params, err := client.Payload(command)
if err != nil {
return nil, err
}
signature, err := client.Sign(params)
if err != nil {
return nil, err
}
params.Add("signature", signature)
method := "GET"
query := params.Encode()
url := fmt.Sprintf("%s?%s", client.Endpoint, query)
var body io.Reader
// respect Internet Explorer limit of 2048
if len(url) > 2048 {
url = client.Endpoint
method = "POST"
body = strings.NewReader(query)
}
request, err := http.NewRequest(method, url, body)
if err != nil {
return nil, err
}
request = request.WithContext(ctx)
request.Header.Add("User-Agent", fmt.Sprintf("exoscale/egoscale (%v)", Version))
if method == "POST" {
request.Header.Add("Content-Type", "application/x-www-form-urlencoded")
request.Header.Add("Content-Length", strconv.Itoa(len(query)))
}
resp, err := client.HTTPClient.Do(request)
if err != nil {
return nil, err
}
defer resp.Body.Close() // nolint: errcheck
contentType := resp.Header.Get("content-type")
if !strings.Contains(contentType, "application/json") {
return nil, fmt.Errorf(`body content-type response expected "application/json", got %q`, contentType)
}
text, err := client.parseResponse(resp, client.APIName(command))
if err != nil {
return nil, err
}
return text, nil
} | go | func (client *Client) request(ctx context.Context, command Command) (json.RawMessage, error) {
params, err := client.Payload(command)
if err != nil {
return nil, err
}
signature, err := client.Sign(params)
if err != nil {
return nil, err
}
params.Add("signature", signature)
method := "GET"
query := params.Encode()
url := fmt.Sprintf("%s?%s", client.Endpoint, query)
var body io.Reader
// respect Internet Explorer limit of 2048
if len(url) > 2048 {
url = client.Endpoint
method = "POST"
body = strings.NewReader(query)
}
request, err := http.NewRequest(method, url, body)
if err != nil {
return nil, err
}
request = request.WithContext(ctx)
request.Header.Add("User-Agent", fmt.Sprintf("exoscale/egoscale (%v)", Version))
if method == "POST" {
request.Header.Add("Content-Type", "application/x-www-form-urlencoded")
request.Header.Add("Content-Length", strconv.Itoa(len(query)))
}
resp, err := client.HTTPClient.Do(request)
if err != nil {
return nil, err
}
defer resp.Body.Close() // nolint: errcheck
contentType := resp.Header.Get("content-type")
if !strings.Contains(contentType, "application/json") {
return nil, fmt.Errorf(`body content-type response expected "application/json", got %q`, contentType)
}
text, err := client.parseResponse(resp, client.APIName(command))
if err != nil {
return nil, err
}
return text, nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"request",
"(",
"ctx",
"context",
".",
"Context",
",",
"command",
"Command",
")",
"(",
"json",
".",
"RawMessage",
",",
"error",
")",
"{",
"params",
",",
"err",
":=",
"client",
".",
"Payload",
"(",
"command",
... | // request makes a Request while being close to the metal | [
"request",
"makes",
"a",
"Request",
"while",
"being",
"close",
"to",
"the",
"metal"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/request.go#L320-L373 |
15,453 | exoscale/egoscale | async_jobs.go | Error | func (a AsyncJobResult) Error() error {
r := new(ErrorResponse)
if e := json.Unmarshal(*a.JobResult, r); e != nil {
return e
}
return r
} | go | func (a AsyncJobResult) Error() error {
r := new(ErrorResponse)
if e := json.Unmarshal(*a.JobResult, r); e != nil {
return e
}
return r
} | [
"func",
"(",
"a",
"AsyncJobResult",
")",
"Error",
"(",
")",
"error",
"{",
"r",
":=",
"new",
"(",
"ErrorResponse",
")",
"\n",
"if",
"e",
":=",
"json",
".",
"Unmarshal",
"(",
"*",
"a",
".",
"JobResult",
",",
"r",
")",
";",
"e",
"!=",
"nil",
"{",
... | // Error builds an error message from the result | [
"Error",
"builds",
"an",
"error",
"message",
"from",
"the",
"result"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/async_jobs.go#L34-L40 |
15,454 | exoscale/egoscale | async_jobs.go | Result | func (a AsyncJobResult) Result(i interface{}) error {
if a.JobStatus == Failure {
return a.Error()
}
if a.JobStatus == Success {
m := map[string]json.RawMessage{}
err := json.Unmarshal(*(a.JobResult), &m)
if err == nil {
if len(m) >= 1 {
if _, ok := m["success"]; ok {
return json.Unmarshal(*(a.JobResult), i)
}
// otherwise, pick the first key
for k := range m {
return json.Unmarshal(m[k], i)
}
}
return errors.New("empty response")
}
}
return nil
} | go | func (a AsyncJobResult) Result(i interface{}) error {
if a.JobStatus == Failure {
return a.Error()
}
if a.JobStatus == Success {
m := map[string]json.RawMessage{}
err := json.Unmarshal(*(a.JobResult), &m)
if err == nil {
if len(m) >= 1 {
if _, ok := m["success"]; ok {
return json.Unmarshal(*(a.JobResult), i)
}
// otherwise, pick the first key
for k := range m {
return json.Unmarshal(m[k], i)
}
}
return errors.New("empty response")
}
}
return nil
} | [
"func",
"(",
"a",
"AsyncJobResult",
")",
"Result",
"(",
"i",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"a",
".",
"JobStatus",
"==",
"Failure",
"{",
"return",
"a",
".",
"Error",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"a",
".",
"JobStatus",
"==",
... | // Result unmarshals the result of an AsyncJobResult into the given interface | [
"Result",
"unmarshals",
"the",
"result",
"of",
"an",
"AsyncJobResult",
"into",
"the",
"given",
"interface"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/async_jobs.go#L71-L96 |
15,455 | exoscale/egoscale | runstatus_incident.go | Match | func (incident RunstatusIncident) Match(other RunstatusIncident) bool {
if other.Title != "" && incident.Title == other.Title {
return true
}
if other.ID > 0 && incident.ID == other.ID {
return true
}
return false
} | go | func (incident RunstatusIncident) Match(other RunstatusIncident) bool {
if other.Title != "" && incident.Title == other.Title {
return true
}
if other.ID > 0 && incident.ID == other.ID {
return true
}
return false
} | [
"func",
"(",
"incident",
"RunstatusIncident",
")",
"Match",
"(",
"other",
"RunstatusIncident",
")",
"bool",
"{",
"if",
"other",
".",
"Title",
"!=",
"\"",
"\"",
"&&",
"incident",
".",
"Title",
"==",
"other",
".",
"Title",
"{",
"return",
"true",
"\n",
"}",... | // Match returns true if the other incident has got similarities with itself | [
"Match",
"returns",
"true",
"if",
"the",
"other",
"incident",
"has",
"got",
"similarities",
"with",
"itself"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_incident.go#L29-L39 |
15,456 | exoscale/egoscale | runstatus_incident.go | GetRunstatusIncident | func (client *Client) GetRunstatusIncident(ctx context.Context, incident RunstatusIncident) (*RunstatusIncident, error) {
if incident.URL != "" {
return client.getRunstatusIncident(ctx, incident.URL)
}
if incident.PageURL == "" {
return nil, fmt.Errorf("empty Page URL for %#v", incident)
}
page, err := client.getRunstatusPage(ctx, incident.PageURL)
if err != nil {
return nil, err
}
for i := range page.Incidents {
j := &page.Incidents[i]
if j.Match(incident) {
return j, nil
}
}
return nil, fmt.Errorf("%#v not found", incident)
} | go | func (client *Client) GetRunstatusIncident(ctx context.Context, incident RunstatusIncident) (*RunstatusIncident, error) {
if incident.URL != "" {
return client.getRunstatusIncident(ctx, incident.URL)
}
if incident.PageURL == "" {
return nil, fmt.Errorf("empty Page URL for %#v", incident)
}
page, err := client.getRunstatusPage(ctx, incident.PageURL)
if err != nil {
return nil, err
}
for i := range page.Incidents {
j := &page.Incidents[i]
if j.Match(incident) {
return j, nil
}
}
return nil, fmt.Errorf("%#v not found", incident)
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"GetRunstatusIncident",
"(",
"ctx",
"context",
".",
"Context",
",",
"incident",
"RunstatusIncident",
")",
"(",
"*",
"RunstatusIncident",
",",
"error",
")",
"{",
"if",
"incident",
".",
"URL",
"!=",
"\"",
"\"",
"{",... | // GetRunstatusIncident retrieves the details of a specific incident. | [
"GetRunstatusIncident",
"retrieves",
"the",
"details",
"of",
"a",
"specific",
"incident",
"."
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_incident.go#L49-L71 |
15,457 | exoscale/egoscale | runstatus_incident.go | ListRunstatusIncidents | func (client *Client) ListRunstatusIncidents(ctx context.Context, page RunstatusPage) ([]RunstatusIncident, error) {
if page.IncidentsURL == "" {
return nil, fmt.Errorf("empty Incidents URL for %#v", page)
}
results := make([]RunstatusIncident, 0)
var err error
client.PaginateRunstatusIncidents(ctx, page, func(incident *RunstatusIncident, e error) bool {
if e != nil {
err = e
return false
}
results = append(results, *incident)
return true
})
return results, err
} | go | func (client *Client) ListRunstatusIncidents(ctx context.Context, page RunstatusPage) ([]RunstatusIncident, error) {
if page.IncidentsURL == "" {
return nil, fmt.Errorf("empty Incidents URL for %#v", page)
}
results := make([]RunstatusIncident, 0)
var err error
client.PaginateRunstatusIncidents(ctx, page, func(incident *RunstatusIncident, e error) bool {
if e != nil {
err = e
return false
}
results = append(results, *incident)
return true
})
return results, err
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"ListRunstatusIncidents",
"(",
"ctx",
"context",
".",
"Context",
",",
"page",
"RunstatusPage",
")",
"(",
"[",
"]",
"RunstatusIncident",
",",
"error",
")",
"{",
"if",
"page",
".",
"IncidentsURL",
"==",
"\"",
"\"",
... | // ListRunstatusIncidents lists the incidents for a specific page. | [
"ListRunstatusIncidents",
"lists",
"the",
"incidents",
"for",
"a",
"specific",
"page",
"."
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_incident.go#L87-L106 |
15,458 | exoscale/egoscale | runstatus_incident.go | PaginateRunstatusIncidents | func (client *Client) PaginateRunstatusIncidents(ctx context.Context, page RunstatusPage, callback func(*RunstatusIncident, error) bool) {
if page.IncidentsURL == "" {
callback(nil, fmt.Errorf("empty Incidents URL for %#v", page))
return
}
incidentsURL := page.IncidentsURL
for incidentsURL != "" {
resp, err := client.runstatusRequest(ctx, incidentsURL, nil, "GET")
if err != nil {
callback(nil, err)
return
}
var is *RunstatusIncidentList
if err := json.Unmarshal(resp, &is); err != nil {
callback(nil, err)
return
}
for i := range is.Incidents {
if cont := callback(&is.Incidents[i], nil); !cont {
return
}
}
incidentsURL = is.Next
}
} | go | func (client *Client) PaginateRunstatusIncidents(ctx context.Context, page RunstatusPage, callback func(*RunstatusIncident, error) bool) {
if page.IncidentsURL == "" {
callback(nil, fmt.Errorf("empty Incidents URL for %#v", page))
return
}
incidentsURL := page.IncidentsURL
for incidentsURL != "" {
resp, err := client.runstatusRequest(ctx, incidentsURL, nil, "GET")
if err != nil {
callback(nil, err)
return
}
var is *RunstatusIncidentList
if err := json.Unmarshal(resp, &is); err != nil {
callback(nil, err)
return
}
for i := range is.Incidents {
if cont := callback(&is.Incidents[i], nil); !cont {
return
}
}
incidentsURL = is.Next
}
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"PaginateRunstatusIncidents",
"(",
"ctx",
"context",
".",
"Context",
",",
"page",
"RunstatusPage",
",",
"callback",
"func",
"(",
"*",
"RunstatusIncident",
",",
"error",
")",
"bool",
")",
"{",
"if",
"page",
".",
"I... | // PaginateRunstatusIncidents paginate Incidents | [
"PaginateRunstatusIncidents",
"paginate",
"Incidents"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_incident.go#L109-L137 |
15,459 | exoscale/egoscale | runstatus_incident.go | CreateRunstatusIncident | func (client *Client) CreateRunstatusIncident(ctx context.Context, incident RunstatusIncident) (*RunstatusIncident, error) {
if incident.PageURL == "" {
return nil, fmt.Errorf("empty Page URL for %#v", incident)
}
page, err := client.getRunstatusPage(ctx, incident.PageURL)
if err != nil {
return nil, err
}
if page.IncidentsURL == "" {
return nil, fmt.Errorf("empty Incidents URL for %#v", page)
}
resp, err := client.runstatusRequest(ctx, page.IncidentsURL, incident, "POST")
if err != nil {
return nil, err
}
i := &RunstatusIncident{}
if err := json.Unmarshal(resp, &i); err != nil {
return nil, err
}
return i, nil
} | go | func (client *Client) CreateRunstatusIncident(ctx context.Context, incident RunstatusIncident) (*RunstatusIncident, error) {
if incident.PageURL == "" {
return nil, fmt.Errorf("empty Page URL for %#v", incident)
}
page, err := client.getRunstatusPage(ctx, incident.PageURL)
if err != nil {
return nil, err
}
if page.IncidentsURL == "" {
return nil, fmt.Errorf("empty Incidents URL for %#v", page)
}
resp, err := client.runstatusRequest(ctx, page.IncidentsURL, incident, "POST")
if err != nil {
return nil, err
}
i := &RunstatusIncident{}
if err := json.Unmarshal(resp, &i); err != nil {
return nil, err
}
return i, nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"CreateRunstatusIncident",
"(",
"ctx",
"context",
".",
"Context",
",",
"incident",
"RunstatusIncident",
")",
"(",
"*",
"RunstatusIncident",
",",
"error",
")",
"{",
"if",
"incident",
".",
"PageURL",
"==",
"\"",
"\"",... | // CreateRunstatusIncident create runstatus incident | [
"CreateRunstatusIncident",
"create",
"runstatus",
"incident"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_incident.go#L140-L165 |
15,460 | exoscale/egoscale | runstatus_incident.go | DeleteRunstatusIncident | func (client *Client) DeleteRunstatusIncident(ctx context.Context, incident RunstatusIncident) error {
if incident.URL == "" {
return fmt.Errorf("empty URL for %#v", incident)
}
_, err := client.runstatusRequest(ctx, incident.URL, nil, "DELETE")
return err
} | go | func (client *Client) DeleteRunstatusIncident(ctx context.Context, incident RunstatusIncident) error {
if incident.URL == "" {
return fmt.Errorf("empty URL for %#v", incident)
}
_, err := client.runstatusRequest(ctx, incident.URL, nil, "DELETE")
return err
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"DeleteRunstatusIncident",
"(",
"ctx",
"context",
".",
"Context",
",",
"incident",
"RunstatusIncident",
")",
"error",
"{",
"if",
"incident",
".",
"URL",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
... | // DeleteRunstatusIncident delete runstatus incident | [
"DeleteRunstatusIncident",
"delete",
"runstatus",
"incident"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_incident.go#L168-L175 |
15,461 | exoscale/egoscale | snapshots.go | ListRequest | func (ss Snapshot) ListRequest() (ListCommand, error) {
// Restricted cannot be applied here because it really has three states
req := &ListSnapshots{
ID: ss.ID,
Name: ss.Name,
VolumeID: ss.VolumeID,
SnapshotType: ss.SnapshotType,
ZoneID: ss.ZoneID,
// TODO: tags
}
return req, nil
} | go | func (ss Snapshot) ListRequest() (ListCommand, error) {
// Restricted cannot be applied here because it really has three states
req := &ListSnapshots{
ID: ss.ID,
Name: ss.Name,
VolumeID: ss.VolumeID,
SnapshotType: ss.SnapshotType,
ZoneID: ss.ZoneID,
// TODO: tags
}
return req, nil
} | [
"func",
"(",
"ss",
"Snapshot",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"// Restricted cannot be applied here because it really has three states",
"req",
":=",
"&",
"ListSnapshots",
"{",
"ID",
":",
"ss",
".",
"ID",
",",
"Name",
"... | // ListRequest builds the ListSnapshot request | [
"ListRequest",
"builds",
"the",
"ListSnapshot",
"request"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/snapshots.go#L72-L84 |
15,462 | exoscale/egoscale | ssh_keypairs.go | Delete | func (ssh SSHKeyPair) Delete(ctx context.Context, client *Client) error {
if ssh.Name == "" {
return fmt.Errorf("an SSH Key Pair may only be deleted using Name")
}
return client.BooleanRequestWithContext(ctx, &DeleteSSHKeyPair{
Name: ssh.Name,
})
} | go | func (ssh SSHKeyPair) Delete(ctx context.Context, client *Client) error {
if ssh.Name == "" {
return fmt.Errorf("an SSH Key Pair may only be deleted using Name")
}
return client.BooleanRequestWithContext(ctx, &DeleteSSHKeyPair{
Name: ssh.Name,
})
} | [
"func",
"(",
"ssh",
"SSHKeyPair",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"*",
"Client",
")",
"error",
"{",
"if",
"ssh",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
... | // Delete removes the given SSH key, by Name | [
"Delete",
"removes",
"the",
"given",
"SSH",
"key",
"by",
"Name"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/ssh_keypairs.go#L18-L26 |
15,463 | exoscale/egoscale | ssh_keypairs.go | ListRequest | func (ssh SSHKeyPair) ListRequest() (ListCommand, error) {
req := &ListSSHKeyPairs{
Fingerprint: ssh.Fingerprint,
Name: ssh.Name,
}
return req, nil
} | go | func (ssh SSHKeyPair) ListRequest() (ListCommand, error) {
req := &ListSSHKeyPairs{
Fingerprint: ssh.Fingerprint,
Name: ssh.Name,
}
return req, nil
} | [
"func",
"(",
"ssh",
"SSHKeyPair",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"req",
":=",
"&",
"ListSSHKeyPairs",
"{",
"Fingerprint",
":",
"ssh",
".",
"Fingerprint",
",",
"Name",
":",
"ssh",
".",
"Name",
",",
"}",
"\n\n",... | // ListRequest builds the ListSSHKeyPairs request | [
"ListRequest",
"builds",
"the",
"ListSSHKeyPairs",
"request"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/ssh_keypairs.go#L29-L36 |
15,464 | exoscale/egoscale | security_groups.go | Delete | func (sg SecurityGroup) Delete(ctx context.Context, client *Client) error {
if sg.ID == nil && sg.Name == "" {
return fmt.Errorf("a SecurityGroup may only be deleted using ID or Name")
}
req := &DeleteSecurityGroup{}
if sg.ID != nil {
req.ID = sg.ID
} else {
req.Name = sg.Name
}
return client.BooleanRequestWithContext(ctx, req)
} | go | func (sg SecurityGroup) Delete(ctx context.Context, client *Client) error {
if sg.ID == nil && sg.Name == "" {
return fmt.Errorf("a SecurityGroup may only be deleted using ID or Name")
}
req := &DeleteSecurityGroup{}
if sg.ID != nil {
req.ID = sg.ID
} else {
req.Name = sg.Name
}
return client.BooleanRequestWithContext(ctx, req)
} | [
"func",
"(",
"sg",
"SecurityGroup",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"*",
"Client",
")",
"error",
"{",
"if",
"sg",
".",
"ID",
"==",
"nil",
"&&",
"sg",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"... | // Delete deletes the given Security Group | [
"Delete",
"deletes",
"the",
"given",
"Security",
"Group"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/security_groups.go#L39-L53 |
15,465 | exoscale/egoscale | security_groups.go | RuleByID | func (sg SecurityGroup) RuleByID(ruleID UUID) (*IngressRule, *EgressRule) {
for i, in := range sg.IngressRule {
if in.RuleID.Equal(ruleID) {
return &sg.IngressRule[i], nil
}
}
for i, out := range sg.EgressRule {
if out.RuleID.Equal(ruleID) {
return nil, &sg.EgressRule[i]
}
}
return nil, nil
} | go | func (sg SecurityGroup) RuleByID(ruleID UUID) (*IngressRule, *EgressRule) {
for i, in := range sg.IngressRule {
if in.RuleID.Equal(ruleID) {
return &sg.IngressRule[i], nil
}
}
for i, out := range sg.EgressRule {
if out.RuleID.Equal(ruleID) {
return nil, &sg.EgressRule[i]
}
}
return nil, nil
} | [
"func",
"(",
"sg",
"SecurityGroup",
")",
"RuleByID",
"(",
"ruleID",
"UUID",
")",
"(",
"*",
"IngressRule",
",",
"*",
"EgressRule",
")",
"{",
"for",
"i",
",",
"in",
":=",
"range",
"sg",
".",
"IngressRule",
"{",
"if",
"in",
".",
"RuleID",
".",
"Equal",
... | // RuleByID returns IngressRule or EgressRule by a rule ID | [
"RuleByID",
"returns",
"IngressRule",
"or",
"EgressRule",
"by",
"a",
"rule",
"ID"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/security_groups.go#L56-L70 |
15,466 | exoscale/egoscale | users.go | ListRequest | func (user User) ListRequest() (ListCommand, error) {
req := &ListUsers{
ID: user.ID,
UserName: user.UserName,
}
return req, nil
} | go | func (user User) ListRequest() (ListCommand, error) {
req := &ListUsers{
ID: user.ID,
UserName: user.UserName,
}
return req, nil
} | [
"func",
"(",
"user",
"User",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"req",
":=",
"&",
"ListUsers",
"{",
"ID",
":",
"user",
".",
"ID",
",",
"UserName",
":",
"user",
".",
"UserName",
",",
"}",
"\n\n",
"return",
"req... | // ListRequest builds the ListUsers request | [
"ListRequest",
"builds",
"the",
"ListUsers",
"request"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/users.go#L24-L31 |
15,467 | exoscale/egoscale | network_offerings.go | ListRequest | func (no NetworkOffering) ListRequest() (ListCommand, error) {
req := &ListNetworkOfferings{
Availability: no.Availability,
ID: no.ID,
Name: no.Name,
State: no.State,
TrafficType: no.TrafficType,
}
return req, nil
} | go | func (no NetworkOffering) ListRequest() (ListCommand, error) {
req := &ListNetworkOfferings{
Availability: no.Availability,
ID: no.ID,
Name: no.Name,
State: no.State,
TrafficType: no.TrafficType,
}
return req, nil
} | [
"func",
"(",
"no",
"NetworkOffering",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"req",
":=",
"&",
"ListNetworkOfferings",
"{",
"Availability",
":",
"no",
".",
"Availability",
",",
"ID",
":",
"no",
".",
"ID",
",",
"Name",
... | // ListRequest builds the ListNetworkOfferings request
//
// This doesn't take into account the IsDefault flag as the default value is true. | [
"ListRequest",
"builds",
"the",
"ListNetworkOfferings",
"request",
"This",
"doesn",
"t",
"take",
"into",
"account",
"the",
"IsDefault",
"flag",
"as",
"the",
"default",
"value",
"is",
"true",
"."
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/network_offerings.go#L31-L41 |
15,468 | exoscale/egoscale | addresses.go | ListRequest | func (ipaddress IPAddress) ListRequest() (ListCommand, error) {
req := &ListPublicIPAddresses{
AssociatedNetworkID: ipaddress.AssociatedNetworkID,
ID: ipaddress.ID,
IPAddress: ipaddress.IPAddress,
PhysicalNetworkID: ipaddress.PhysicalNetworkID,
VlanID: ipaddress.VlanID,
ZoneID: ipaddress.ZoneID,
}
if ipaddress.IsElastic {
req.IsElastic = &ipaddress.IsElastic
}
if ipaddress.IsSourceNat {
req.IsSourceNat = &ipaddress.IsSourceNat
}
if ipaddress.ForVirtualNetwork {
req.ForVirtualNetwork = &ipaddress.ForVirtualNetwork
}
return req, nil
} | go | func (ipaddress IPAddress) ListRequest() (ListCommand, error) {
req := &ListPublicIPAddresses{
AssociatedNetworkID: ipaddress.AssociatedNetworkID,
ID: ipaddress.ID,
IPAddress: ipaddress.IPAddress,
PhysicalNetworkID: ipaddress.PhysicalNetworkID,
VlanID: ipaddress.VlanID,
ZoneID: ipaddress.ZoneID,
}
if ipaddress.IsElastic {
req.IsElastic = &ipaddress.IsElastic
}
if ipaddress.IsSourceNat {
req.IsSourceNat = &ipaddress.IsSourceNat
}
if ipaddress.ForVirtualNetwork {
req.ForVirtualNetwork = &ipaddress.ForVirtualNetwork
}
return req, nil
} | [
"func",
"(",
"ipaddress",
"IPAddress",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"req",
":=",
"&",
"ListPublicIPAddresses",
"{",
"AssociatedNetworkID",
":",
"ipaddress",
".",
"AssociatedNetworkID",
",",
"ID",
":",
"ipaddress",
"... | // ListRequest builds the ListAdresses request | [
"ListRequest",
"builds",
"the",
"ListAdresses",
"request"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/addresses.go#L57-L77 |
15,469 | exoscale/egoscale | addresses.go | Delete | func (ipaddress IPAddress) Delete(ctx context.Context, client *Client) error {
if ipaddress.ID == nil {
return fmt.Errorf("an IPAddress may only be deleted using ID")
}
return client.BooleanRequestWithContext(ctx, &DisassociateIPAddress{
ID: ipaddress.ID,
})
} | go | func (ipaddress IPAddress) Delete(ctx context.Context, client *Client) error {
if ipaddress.ID == nil {
return fmt.Errorf("an IPAddress may only be deleted using ID")
}
return client.BooleanRequestWithContext(ctx, &DisassociateIPAddress{
ID: ipaddress.ID,
})
} | [
"func",
"(",
"ipaddress",
"IPAddress",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"*",
"Client",
")",
"error",
"{",
"if",
"ipaddress",
".",
"ID",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
... | // Delete removes the resource | [
"Delete",
"removes",
"the",
"resource"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/addresses.go#L80-L88 |
15,470 | exoscale/egoscale | serialization.go | info | func info(command interface{}) (*CommandInfo, error) {
typeof := reflect.TypeOf(command)
// Going up the pointer chain to find the underlying struct
for typeof.Kind() == reflect.Ptr {
typeof = typeof.Elem()
}
field, ok := typeof.FieldByName("_")
if !ok {
return nil, fmt.Errorf(`missing meta ("_") field in %#v`, command)
}
name, nameOk := field.Tag.Lookup("name")
description, _ := field.Tag.Lookup("description")
if !nameOk {
return nil, fmt.Errorf(`missing "name" key in the tag string of %#v`, command)
}
info := &CommandInfo{
Name: name,
Description: description,
}
return info, nil
} | go | func info(command interface{}) (*CommandInfo, error) {
typeof := reflect.TypeOf(command)
// Going up the pointer chain to find the underlying struct
for typeof.Kind() == reflect.Ptr {
typeof = typeof.Elem()
}
field, ok := typeof.FieldByName("_")
if !ok {
return nil, fmt.Errorf(`missing meta ("_") field in %#v`, command)
}
name, nameOk := field.Tag.Lookup("name")
description, _ := field.Tag.Lookup("description")
if !nameOk {
return nil, fmt.Errorf(`missing "name" key in the tag string of %#v`, command)
}
info := &CommandInfo{
Name: name,
Description: description,
}
return info, nil
} | [
"func",
"info",
"(",
"command",
"interface",
"{",
"}",
")",
"(",
"*",
"CommandInfo",
",",
"error",
")",
"{",
"typeof",
":=",
"reflect",
".",
"TypeOf",
"(",
"command",
")",
"\n\n",
"// Going up the pointer chain to find the underlying struct",
"for",
"typeof",
".... | // info returns the meta info of a command
//
// command is not a Command so it's easier to Test | [
"info",
"returns",
"the",
"meta",
"info",
"of",
"a",
"command",
"command",
"is",
"not",
"a",
"Command",
"so",
"it",
"s",
"easier",
"to",
"Test"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/serialization.go#L26-L52 |
15,471 | exoscale/egoscale | runstatus_page.go | Match | func (page RunstatusPage) Match(other RunstatusPage) bool {
if other.Subdomain != "" && page.Subdomain == other.Subdomain {
return true
}
if other.ID > 0 && page.ID == other.ID {
return true
}
return false
} | go | func (page RunstatusPage) Match(other RunstatusPage) bool {
if other.Subdomain != "" && page.Subdomain == other.Subdomain {
return true
}
if other.ID > 0 && page.ID == other.ID {
return true
}
return false
} | [
"func",
"(",
"page",
"RunstatusPage",
")",
"Match",
"(",
"other",
"RunstatusPage",
")",
"bool",
"{",
"if",
"other",
".",
"Subdomain",
"!=",
"\"",
"\"",
"&&",
"page",
".",
"Subdomain",
"==",
"other",
".",
"Subdomain",
"{",
"return",
"true",
"\n",
"}",
"... | // Match returns true if the other page has got similarities with itself | [
"Match",
"returns",
"true",
"if",
"the",
"other",
"page",
"has",
"got",
"similarities",
"with",
"itself"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_page.go#L42-L52 |
15,472 | exoscale/egoscale | runstatus_page.go | CreateRunstatusPage | func (client *Client) CreateRunstatusPage(ctx context.Context, page RunstatusPage) (*RunstatusPage, error) {
resp, err := client.runstatusRequest(ctx, client.Endpoint+runstatusPagesURL, page, "POST")
if err != nil {
return nil, err
}
var p *RunstatusPage
if err := json.Unmarshal(resp, &p); err != nil {
return nil, err
}
return p, nil
} | go | func (client *Client) CreateRunstatusPage(ctx context.Context, page RunstatusPage) (*RunstatusPage, error) {
resp, err := client.runstatusRequest(ctx, client.Endpoint+runstatusPagesURL, page, "POST")
if err != nil {
return nil, err
}
var p *RunstatusPage
if err := json.Unmarshal(resp, &p); err != nil {
return nil, err
}
return p, nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"CreateRunstatusPage",
"(",
"ctx",
"context",
".",
"Context",
",",
"page",
"RunstatusPage",
")",
"(",
"*",
"RunstatusPage",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"client",
".",
"runstatusRequest",
"(",... | // CreateRunstatusPage create runstatus page | [
"CreateRunstatusPage",
"create",
"runstatus",
"page"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_page.go#L62-L74 |
15,473 | exoscale/egoscale | runstatus_page.go | DeleteRunstatusPage | func (client *Client) DeleteRunstatusPage(ctx context.Context, page RunstatusPage) error {
if page.URL == "" {
return fmt.Errorf("empty URL for %#v", page)
}
_, err := client.runstatusRequest(ctx, page.URL, nil, "DELETE")
return err
} | go | func (client *Client) DeleteRunstatusPage(ctx context.Context, page RunstatusPage) error {
if page.URL == "" {
return fmt.Errorf("empty URL for %#v", page)
}
_, err := client.runstatusRequest(ctx, page.URL, nil, "DELETE")
return err
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"DeleteRunstatusPage",
"(",
"ctx",
"context",
".",
"Context",
",",
"page",
"RunstatusPage",
")",
"error",
"{",
"if",
"page",
".",
"URL",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
... | // DeleteRunstatusPage delete runstatus page | [
"DeleteRunstatusPage",
"delete",
"runstatus",
"page"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_page.go#L77-L83 |
15,474 | exoscale/egoscale | runstatus_page.go | GetRunstatusPage | func (client *Client) GetRunstatusPage(ctx context.Context, page RunstatusPage) (*RunstatusPage, error) {
if page.URL != "" {
return client.getRunstatusPage(ctx, page.URL)
}
ps, err := client.ListRunstatusPages(ctx)
if err != nil {
return nil, err
}
for i := range ps {
if ps[i].Match(page) {
return client.getRunstatusPage(ctx, ps[i].URL)
}
}
return nil, fmt.Errorf("%#v not found", page)
} | go | func (client *Client) GetRunstatusPage(ctx context.Context, page RunstatusPage) (*RunstatusPage, error) {
if page.URL != "" {
return client.getRunstatusPage(ctx, page.URL)
}
ps, err := client.ListRunstatusPages(ctx)
if err != nil {
return nil, err
}
for i := range ps {
if ps[i].Match(page) {
return client.getRunstatusPage(ctx, ps[i].URL)
}
}
return nil, fmt.Errorf("%#v not found", page)
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"GetRunstatusPage",
"(",
"ctx",
"context",
".",
"Context",
",",
"page",
"RunstatusPage",
")",
"(",
"*",
"RunstatusPage",
",",
"error",
")",
"{",
"if",
"page",
".",
"URL",
"!=",
"\"",
"\"",
"{",
"return",
"clie... | // GetRunstatusPage fetches the runstatus page | [
"GetRunstatusPage",
"fetches",
"the",
"runstatus",
"page"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_page.go#L86-L103 |
15,475 | exoscale/egoscale | runstatus_page.go | ListRunstatusPages | func (client *Client) ListRunstatusPages(ctx context.Context) ([]RunstatusPage, error) {
resp, err := client.runstatusRequest(ctx, client.Endpoint+runstatusPagesURL, nil, "GET")
if err != nil {
return nil, err
}
var p *RunstatusPageList
if err := json.Unmarshal(resp, &p); err != nil {
return nil, err
}
return p.Pages, nil
} | go | func (client *Client) ListRunstatusPages(ctx context.Context) ([]RunstatusPage, error) {
resp, err := client.runstatusRequest(ctx, client.Endpoint+runstatusPagesURL, nil, "GET")
if err != nil {
return nil, err
}
var p *RunstatusPageList
if err := json.Unmarshal(resp, &p); err != nil {
return nil, err
}
return p.Pages, nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"ListRunstatusPages",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"RunstatusPage",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"client",
".",
"runstatusRequest",
"(",
"ctx",
",",
"client",
... | // ListRunstatusPages list all the runstatus pages | [
"ListRunstatusPages",
"list",
"all",
"the",
"runstatus",
"pages"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_page.go#L132-L144 |
15,476 | exoscale/egoscale | runstatus_page.go | PaginateRunstatusPages | func (client *Client) PaginateRunstatusPages(ctx context.Context, callback func(pages []RunstatusPage, e error) bool) {
pageURL := client.Endpoint + runstatusPagesURL
for pageURL != "" {
resp, err := client.runstatusRequest(ctx, pageURL, nil, "GET")
if err != nil {
callback(nil, err)
return
}
var p *RunstatusPageList
if err := json.Unmarshal(resp, &p); err != nil {
callback(nil, err)
return
}
if ok := callback(p.Pages, nil); ok {
return
}
pageURL = p.Next
}
} | go | func (client *Client) PaginateRunstatusPages(ctx context.Context, callback func(pages []RunstatusPage, e error) bool) {
pageURL := client.Endpoint + runstatusPagesURL
for pageURL != "" {
resp, err := client.runstatusRequest(ctx, pageURL, nil, "GET")
if err != nil {
callback(nil, err)
return
}
var p *RunstatusPageList
if err := json.Unmarshal(resp, &p); err != nil {
callback(nil, err)
return
}
if ok := callback(p.Pages, nil); ok {
return
}
pageURL = p.Next
}
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"PaginateRunstatusPages",
"(",
"ctx",
"context",
".",
"Context",
",",
"callback",
"func",
"(",
"pages",
"[",
"]",
"RunstatusPage",
",",
"e",
"error",
")",
"bool",
")",
"{",
"pageURL",
":=",
"client",
".",
"Endpo... | //PaginateRunstatusPages paginate on runstatus pages | [
"PaginateRunstatusPages",
"paginate",
"on",
"runstatus",
"pages"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_page.go#L147-L168 |
15,477 | exoscale/egoscale | instance_groups.go | ListRequest | func (ig InstanceGroup) ListRequest() (ListCommand, error) {
req := &ListInstanceGroups{
ID: ig.ID,
Name: ig.Name,
}
return req, nil
} | go | func (ig InstanceGroup) ListRequest() (ListCommand, error) {
req := &ListInstanceGroups{
ID: ig.ID,
Name: ig.Name,
}
return req, nil
} | [
"func",
"(",
"ig",
"InstanceGroup",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"req",
":=",
"&",
"ListInstanceGroups",
"{",
"ID",
":",
"ig",
".",
"ID",
",",
"Name",
":",
"ig",
".",
"Name",
",",
"}",
"\n\n",
"return",
... | // ListRequest builds the ListInstanceGroups request | [
"ListRequest",
"builds",
"the",
"ListInstanceGroups",
"request"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/instance_groups.go#L12-L19 |
15,478 | exoscale/egoscale | resource_limits.go | ListRequest | func (limit ResourceLimit) ListRequest() (ListCommand, error) {
req := &ListResourceLimits{
ResourceType: limit.ResourceType,
ResourceTypeName: limit.ResourceTypeName,
}
return req, nil
} | go | func (limit ResourceLimit) ListRequest() (ListCommand, error) {
req := &ListResourceLimits{
ResourceType: limit.ResourceType,
ResourceTypeName: limit.ResourceTypeName,
}
return req, nil
} | [
"func",
"(",
"limit",
"ResourceLimit",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"req",
":=",
"&",
"ListResourceLimits",
"{",
"ResourceType",
":",
"limit",
".",
"ResourceType",
",",
"ResourceTypeName",
":",
"limit",
".",
"Reso... | // ListRequest builds the ListResourceLimits request | [
"ListRequest",
"builds",
"the",
"ListResourceLimits",
"request"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/resource_limits.go#L73-L80 |
15,479 | exoscale/egoscale | resource_metadata.go | ListRequest | func (detail ResourceDetail) ListRequest() (ListCommand, error) {
if detail.ResourceType == "" {
return nil, fmt.Errorf("the resourcetype parameter is required")
}
req := &ListResourceDetails{
ResourceType: detail.ResourceType,
ResourceID: detail.ResourceID,
}
return req, nil
} | go | func (detail ResourceDetail) ListRequest() (ListCommand, error) {
if detail.ResourceType == "" {
return nil, fmt.Errorf("the resourcetype parameter is required")
}
req := &ListResourceDetails{
ResourceType: detail.ResourceType,
ResourceID: detail.ResourceID,
}
return req, nil
} | [
"func",
"(",
"detail",
"ResourceDetail",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"if",
"detail",
".",
"ResourceType",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}"... | // ListRequest builds the ListResourceDetails request | [
"ListRequest",
"builds",
"the",
"ListResourceDetails",
"request"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/resource_metadata.go#L9-L20 |
15,480 | exoscale/egoscale | client.go | Get | func (client *Client) Get(ls Listable) (interface{}, error) {
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
defer cancel()
return client.GetWithContext(ctx, ls)
} | go | func (client *Client) Get(ls Listable) (interface{}, error) {
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
defer cancel()
return client.GetWithContext(ctx, ls)
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"Get",
"(",
"ls",
"Listable",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"client",
... | // Get populates the given resource or fails | [
"Get",
"populates",
"the",
"given",
"resource",
"or",
"fails"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L99-L104 |
15,481 | exoscale/egoscale | client.go | GetWithContext | func (client *Client) GetWithContext(ctx context.Context, ls Listable) (interface{}, error) {
gs, err := client.ListWithContext(ctx, ls)
if err != nil {
return nil, err
}
count := len(gs)
if count != 1 {
req, err := ls.ListRequest()
if err != nil {
return nil, err
}
params, err := client.Payload(req)
if err != nil {
return nil, err
}
// removing sensitive/useless informations
params.Del("expires")
params.Del("response")
params.Del("signature")
params.Del("signatureversion")
// formatting the query string nicely
payload := params.Encode()
payload = strings.Replace(payload, "&", ", ", -1)
if count == 0 {
return nil, &ErrorResponse{
CSErrorCode: ServerAPIException,
ErrorCode: ParamError,
ErrorText: fmt.Sprintf("not found, query: %s", payload),
}
}
return nil, fmt.Errorf("more than one element found: %s", payload)
}
return gs[0], nil
} | go | func (client *Client) GetWithContext(ctx context.Context, ls Listable) (interface{}, error) {
gs, err := client.ListWithContext(ctx, ls)
if err != nil {
return nil, err
}
count := len(gs)
if count != 1 {
req, err := ls.ListRequest()
if err != nil {
return nil, err
}
params, err := client.Payload(req)
if err != nil {
return nil, err
}
// removing sensitive/useless informations
params.Del("expires")
params.Del("response")
params.Del("signature")
params.Del("signatureversion")
// formatting the query string nicely
payload := params.Encode()
payload = strings.Replace(payload, "&", ", ", -1)
if count == 0 {
return nil, &ErrorResponse{
CSErrorCode: ServerAPIException,
ErrorCode: ParamError,
ErrorText: fmt.Sprintf("not found, query: %s", payload),
}
}
return nil, fmt.Errorf("more than one element found: %s", payload)
}
return gs[0], nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"GetWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"ls",
"Listable",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"gs",
",",
"err",
":=",
"client",
".",
"ListWithContext",
"(",
"ctx",
... | // GetWithContext populates the given resource or fails | [
"GetWithContext",
"populates",
"the",
"given",
"resource",
"or",
"fails"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L107-L145 |
15,482 | exoscale/egoscale | client.go | Delete | func (client *Client) Delete(g Deletable) error {
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
defer cancel()
return client.DeleteWithContext(ctx, g)
} | go | func (client *Client) Delete(g Deletable) error {
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
defer cancel()
return client.DeleteWithContext(ctx, g)
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"Delete",
"(",
"g",
"Deletable",
")",
"error",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"client",
".",
"Timeout",
")",
"\n",
"defer",
... | // Delete removes the given resource of fails | [
"Delete",
"removes",
"the",
"given",
"resource",
"of",
"fails"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L148-L153 |
15,483 | exoscale/egoscale | client.go | DeleteWithContext | func (client *Client) DeleteWithContext(ctx context.Context, g Deletable) error {
return g.Delete(ctx, client)
} | go | func (client *Client) DeleteWithContext(ctx context.Context, g Deletable) error {
return g.Delete(ctx, client)
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"DeleteWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"g",
"Deletable",
")",
"error",
"{",
"return",
"g",
".",
"Delete",
"(",
"ctx",
",",
"client",
")",
"\n",
"}"
] | // DeleteWithContext removes the given resource of fails | [
"DeleteWithContext",
"removes",
"the",
"given",
"resource",
"of",
"fails"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L156-L158 |
15,484 | exoscale/egoscale | client.go | Paginate | func (client *Client) Paginate(g Listable, callback IterateItemFunc) {
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
defer cancel()
client.PaginateWithContext(ctx, g, callback)
} | go | func (client *Client) Paginate(g Listable, callback IterateItemFunc) {
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
defer cancel()
client.PaginateWithContext(ctx, g, callback)
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"Paginate",
"(",
"g",
"Listable",
",",
"callback",
"IterateItemFunc",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"client",
".",
"Timeou... | // Paginate runs the ListCommand and paginates | [
"Paginate",
"runs",
"the",
"ListCommand",
"and",
"paginates"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L257-L262 |
15,485 | exoscale/egoscale | client.go | PaginateWithContext | func (client *Client) PaginateWithContext(ctx context.Context, g Listable, callback IterateItemFunc) {
req, err := g.ListRequest()
if err != nil {
callback(nil, err)
return
}
pageSize := client.PageSize
page := 1
for {
req.SetPage(page)
req.SetPageSize(pageSize)
resp, err := client.RequestWithContext(ctx, req)
if err != nil {
// in case of 431, the response is knowingly empty
if errResponse, ok := err.(*ErrorResponse); ok && page == 1 && errResponse.ErrorCode == ParamError {
break
}
callback(nil, err)
break
}
size := 0
didErr := false
req.Each(resp, func(element interface{}, err error) bool {
// If the context was cancelled, kill it in flight
if e := ctx.Err(); e != nil {
element = nil
err = e
}
if callback(element, err) {
size++
return true
}
didErr = true
return false
})
if size < pageSize || didErr {
break
}
page++
}
} | go | func (client *Client) PaginateWithContext(ctx context.Context, g Listable, callback IterateItemFunc) {
req, err := g.ListRequest()
if err != nil {
callback(nil, err)
return
}
pageSize := client.PageSize
page := 1
for {
req.SetPage(page)
req.SetPageSize(pageSize)
resp, err := client.RequestWithContext(ctx, req)
if err != nil {
// in case of 431, the response is knowingly empty
if errResponse, ok := err.(*ErrorResponse); ok && page == 1 && errResponse.ErrorCode == ParamError {
break
}
callback(nil, err)
break
}
size := 0
didErr := false
req.Each(resp, func(element interface{}, err error) bool {
// If the context was cancelled, kill it in flight
if e := ctx.Err(); e != nil {
element = nil
err = e
}
if callback(element, err) {
size++
return true
}
didErr = true
return false
})
if size < pageSize || didErr {
break
}
page++
}
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"PaginateWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"g",
"Listable",
",",
"callback",
"IterateItemFunc",
")",
"{",
"req",
",",
"err",
":=",
"g",
".",
"ListRequest",
"(",
")",
"\n",
"if",
"err",
... | // PaginateWithContext runs the ListCommand as long as the ctx is valid | [
"PaginateWithContext",
"runs",
"the",
"ListCommand",
"as",
"long",
"as",
"the",
"ctx",
"is",
"valid"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L265-L314 |
15,486 | exoscale/egoscale | client.go | APIName | func (client *Client) APIName(command Command) string {
// This is due to a limitation of Go<=1.7
_, ok := command.(*AuthorizeSecurityGroupEgress)
_, okPtr := command.(AuthorizeSecurityGroupEgress)
if ok || okPtr {
return "authorizeSecurityGroupEgress"
}
info, err := info(command)
if err != nil {
panic(err)
}
return info.Name
} | go | func (client *Client) APIName(command Command) string {
// This is due to a limitation of Go<=1.7
_, ok := command.(*AuthorizeSecurityGroupEgress)
_, okPtr := command.(AuthorizeSecurityGroupEgress)
if ok || okPtr {
return "authorizeSecurityGroupEgress"
}
info, err := info(command)
if err != nil {
panic(err)
}
return info.Name
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"APIName",
"(",
"command",
"Command",
")",
"string",
"{",
"// This is due to a limitation of Go<=1.7",
"_",
",",
"ok",
":=",
"command",
".",
"(",
"*",
"AuthorizeSecurityGroupEgress",
")",
"\n",
"_",
",",
"okPtr",
":="... | // APIName returns the name of the given command | [
"APIName",
"returns",
"the",
"name",
"of",
"the",
"given",
"command"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L317-L330 |
15,487 | exoscale/egoscale | client.go | APIDescription | func (client *Client) APIDescription(command Command) string {
info, err := info(command)
if err != nil {
return "*missing description*"
}
return info.Description
} | go | func (client *Client) APIDescription(command Command) string {
info, err := info(command)
if err != nil {
return "*missing description*"
}
return info.Description
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"APIDescription",
"(",
"command",
"Command",
")",
"string",
"{",
"info",
",",
"err",
":=",
"info",
"(",
"command",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
... | // APIDescription returns the description of the given command | [
"APIDescription",
"returns",
"the",
"description",
"of",
"the",
"given",
"command"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L333-L339 |
15,488 | exoscale/egoscale | client.go | Response | func (client *Client) Response(command Command) interface{} {
switch c := command.(type) {
case AsyncCommand:
return c.AsyncResponse()
default:
return command.Response()
}
} | go | func (client *Client) Response(command Command) interface{} {
switch c := command.(type) {
case AsyncCommand:
return c.AsyncResponse()
default:
return command.Response()
}
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"Response",
"(",
"command",
"Command",
")",
"interface",
"{",
"}",
"{",
"switch",
"c",
":=",
"command",
".",
"(",
"type",
")",
"{",
"case",
"AsyncCommand",
":",
"return",
"c",
".",
"AsyncResponse",
"(",
")",
... | // Response returns the response structure of the given command | [
"Response",
"returns",
"the",
"response",
"structure",
"of",
"the",
"given",
"command"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L342-L349 |
15,489 | exoscale/egoscale | client.go | TraceOn | func (client *Client) TraceOn() {
if _, ok := client.HTTPClient.Transport.(*traceTransport); !ok {
client.HTTPClient.Transport = &traceTransport{
transport: client.HTTPClient.Transport,
logger: client.Logger,
}
}
} | go | func (client *Client) TraceOn() {
if _, ok := client.HTTPClient.Transport.(*traceTransport); !ok {
client.HTTPClient.Transport = &traceTransport{
transport: client.HTTPClient.Transport,
logger: client.Logger,
}
}
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"TraceOn",
"(",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"client",
".",
"HTTPClient",
".",
"Transport",
".",
"(",
"*",
"traceTransport",
")",
";",
"!",
"ok",
"{",
"client",
".",
"HTTPClient",
".",
"Transport",
... | // TraceOn activates the HTTP tracer | [
"TraceOn",
"activates",
"the",
"HTTP",
"tracer"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L352-L359 |
15,490 | exoscale/egoscale | client.go | TraceOff | func (client *Client) TraceOff() {
if rt, ok := client.HTTPClient.Transport.(*traceTransport); ok {
client.HTTPClient.Transport = rt.transport
}
} | go | func (client *Client) TraceOff() {
if rt, ok := client.HTTPClient.Transport.(*traceTransport); ok {
client.HTTPClient.Transport = rt.transport
}
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"TraceOff",
"(",
")",
"{",
"if",
"rt",
",",
"ok",
":=",
"client",
".",
"HTTPClient",
".",
"Transport",
".",
"(",
"*",
"traceTransport",
")",
";",
"ok",
"{",
"client",
".",
"HTTPClient",
".",
"Transport",
"="... | // TraceOff deactivates the HTTP tracer | [
"TraceOff",
"deactivates",
"the",
"HTTP",
"tracer"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L362-L366 |
15,491 | exoscale/egoscale | client.go | RoundTrip | func (t *traceTransport) RoundTrip(req *http.Request) (*http.Response, error) {
if dump, err := httputil.DumpRequest(req, true); err == nil {
t.logger.Printf("%s", dump)
}
resp, err := t.transport.RoundTrip(req)
if err != nil {
return nil, err
}
if dump, err := httputil.DumpResponse(resp, true); err == nil {
t.logger.Printf("%s", dump)
}
return resp, nil
} | go | func (t *traceTransport) RoundTrip(req *http.Request) (*http.Response, error) {
if dump, err := httputil.DumpRequest(req, true); err == nil {
t.logger.Printf("%s", dump)
}
resp, err := t.transport.RoundTrip(req)
if err != nil {
return nil, err
}
if dump, err := httputil.DumpResponse(resp, true); err == nil {
t.logger.Printf("%s", dump)
}
return resp, nil
} | [
"func",
"(",
"t",
"*",
"traceTransport",
")",
"RoundTrip",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"if",
"dump",
",",
"err",
":=",
"httputil",
".",
"DumpRequest",
"(",
"req",
",",
"tr... | // RoundTrip executes a single HTTP transaction | [
"RoundTrip",
"executes",
"a",
"single",
"HTTP",
"transaction"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L375-L390 |
15,492 | exoscale/egoscale | client.go | MonotonicRetryStrategyFunc | func MonotonicRetryStrategyFunc(seconds int) RetryStrategyFunc {
return func(iteration int64) time.Duration {
return time.Duration(seconds) * time.Second
}
} | go | func MonotonicRetryStrategyFunc(seconds int) RetryStrategyFunc {
return func(iteration int64) time.Duration {
return time.Duration(seconds) * time.Second
}
} | [
"func",
"MonotonicRetryStrategyFunc",
"(",
"seconds",
"int",
")",
"RetryStrategyFunc",
"{",
"return",
"func",
"(",
"iteration",
"int64",
")",
"time",
".",
"Duration",
"{",
"return",
"time",
".",
"Duration",
"(",
"seconds",
")",
"*",
"time",
".",
"Second",
"\... | // MonotonicRetryStrategyFunc returns a function that waits for n seconds for each iteration | [
"MonotonicRetryStrategyFunc",
"returns",
"a",
"function",
"that",
"waits",
"for",
"n",
"seconds",
"for",
"each",
"iteration"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L393-L397 |
15,493 | exoscale/egoscale | client.go | FibonacciRetryStrategy | func FibonacciRetryStrategy(iteration int64) time.Duration {
var a, b, i, tmp int64
a = 0
b = 1
for i = 0; i < iteration; i++ {
tmp = a + b
a = b
b = tmp
}
return time.Duration(a) * time.Second
} | go | func FibonacciRetryStrategy(iteration int64) time.Duration {
var a, b, i, tmp int64
a = 0
b = 1
for i = 0; i < iteration; i++ {
tmp = a + b
a = b
b = tmp
}
return time.Duration(a) * time.Second
} | [
"func",
"FibonacciRetryStrategy",
"(",
"iteration",
"int64",
")",
"time",
".",
"Duration",
"{",
"var",
"a",
",",
"b",
",",
"i",
",",
"tmp",
"int64",
"\n",
"a",
"=",
"0",
"\n",
"b",
"=",
"1",
"\n",
"for",
"i",
"=",
"0",
";",
"i",
"<",
"iteration",... | // FibonacciRetryStrategy waits for an increasing amount of time following the Fibonacci sequence | [
"FibonacciRetryStrategy",
"waits",
"for",
"an",
"increasing",
"amount",
"of",
"time",
"following",
"the",
"Fibonacci",
"sequence"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L400-L410 |
15,494 | exoscale/egoscale | virtual_machines.go | Delete | func (vm VirtualMachine) Delete(ctx context.Context, client *Client) error {
_, err := client.RequestWithContext(ctx, &DestroyVirtualMachine{
ID: vm.ID,
})
return err
} | go | func (vm VirtualMachine) Delete(ctx context.Context, client *Client) error {
_, err := client.RequestWithContext(ctx, &DestroyVirtualMachine{
ID: vm.ID,
})
return err
} | [
"func",
"(",
"vm",
"VirtualMachine",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"*",
"Client",
")",
"error",
"{",
"_",
",",
"err",
":=",
"client",
".",
"RequestWithContext",
"(",
"ctx",
",",
"&",
"DestroyVirtualMachine",
"{",
"I... | // Delete destroys the VM | [
"Delete",
"destroys",
"the",
"VM"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/virtual_machines.go#L112-L118 |
15,495 | exoscale/egoscale | virtual_machines.go | ListRequest | func (vm VirtualMachine) ListRequest() (ListCommand, error) {
// XXX: AffinityGroupID, SecurityGroupID
req := &ListVirtualMachines{
GroupID: vm.GroupID,
ID: vm.ID,
Name: vm.Name,
State: vm.State,
TemplateID: vm.TemplateID,
ZoneID: vm.ZoneID,
}
nic := vm.DefaultNic()
if nic != nil {
req.IPAddress = nic.IPAddress
}
for i := range vm.Tags {
req.Tags = append(req.Tags, vm.Tags[i])
}
return req, nil
} | go | func (vm VirtualMachine) ListRequest() (ListCommand, error) {
// XXX: AffinityGroupID, SecurityGroupID
req := &ListVirtualMachines{
GroupID: vm.GroupID,
ID: vm.ID,
Name: vm.Name,
State: vm.State,
TemplateID: vm.TemplateID,
ZoneID: vm.ZoneID,
}
nic := vm.DefaultNic()
if nic != nil {
req.IPAddress = nic.IPAddress
}
for i := range vm.Tags {
req.Tags = append(req.Tags, vm.Tags[i])
}
return req, nil
} | [
"func",
"(",
"vm",
"VirtualMachine",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"// XXX: AffinityGroupID, SecurityGroupID",
"req",
":=",
"&",
"ListVirtualMachines",
"{",
"GroupID",
":",
"vm",
".",
"GroupID",
",",
"ID",
":",
"vm",... | // ListRequest builds the ListVirtualMachines request | [
"ListRequest",
"builds",
"the",
"ListVirtualMachines",
"request"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/virtual_machines.go#L121-L143 |
15,496 | exoscale/egoscale | virtual_machines.go | DefaultNic | func (vm VirtualMachine) DefaultNic() *Nic {
for i, nic := range vm.Nic {
if nic.IsDefault {
return &vm.Nic[i]
}
}
return nil
} | go | func (vm VirtualMachine) DefaultNic() *Nic {
for i, nic := range vm.Nic {
if nic.IsDefault {
return &vm.Nic[i]
}
}
return nil
} | [
"func",
"(",
"vm",
"VirtualMachine",
")",
"DefaultNic",
"(",
")",
"*",
"Nic",
"{",
"for",
"i",
",",
"nic",
":=",
"range",
"vm",
".",
"Nic",
"{",
"if",
"nic",
".",
"IsDefault",
"{",
"return",
"&",
"vm",
".",
"Nic",
"[",
"i",
"]",
"\n",
"}",
"\n"... | // DefaultNic returns the default nic | [
"DefaultNic",
"returns",
"the",
"default",
"nic"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/virtual_machines.go#L146-L154 |
15,497 | exoscale/egoscale | virtual_machines.go | IP | func (vm VirtualMachine) IP() *net.IP {
nic := vm.DefaultNic()
if nic != nil {
ip := nic.IPAddress
return &ip
}
return nil
} | go | func (vm VirtualMachine) IP() *net.IP {
nic := vm.DefaultNic()
if nic != nil {
ip := nic.IPAddress
return &ip
}
return nil
} | [
"func",
"(",
"vm",
"VirtualMachine",
")",
"IP",
"(",
")",
"*",
"net",
".",
"IP",
"{",
"nic",
":=",
"vm",
".",
"DefaultNic",
"(",
")",
"\n",
"if",
"nic",
"!=",
"nil",
"{",
"ip",
":=",
"nic",
".",
"IPAddress",
"\n",
"return",
"&",
"ip",
"\n",
"}"... | // IP returns the default nic IP address | [
"IP",
"returns",
"the",
"default",
"nic",
"IP",
"address"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/virtual_machines.go#L157-L165 |
15,498 | exoscale/egoscale | virtual_machines.go | NicsByType | func (vm VirtualMachine) NicsByType(nicType string) []Nic {
nics := make([]Nic, 0)
for _, nic := range vm.Nic {
if nic.Type == nicType {
// XXX The API forgets to specify it
n := nic
n.VirtualMachineID = vm.ID
nics = append(nics, n)
}
}
return nics
} | go | func (vm VirtualMachine) NicsByType(nicType string) []Nic {
nics := make([]Nic, 0)
for _, nic := range vm.Nic {
if nic.Type == nicType {
// XXX The API forgets to specify it
n := nic
n.VirtualMachineID = vm.ID
nics = append(nics, n)
}
}
return nics
} | [
"func",
"(",
"vm",
"VirtualMachine",
")",
"NicsByType",
"(",
"nicType",
"string",
")",
"[",
"]",
"Nic",
"{",
"nics",
":=",
"make",
"(",
"[",
"]",
"Nic",
",",
"0",
")",
"\n",
"for",
"_",
",",
"nic",
":=",
"range",
"vm",
".",
"Nic",
"{",
"if",
"n... | // NicsByType returns the corresponding interfaces base on the given type | [
"NicsByType",
"returns",
"the",
"corresponding",
"interfaces",
"base",
"on",
"the",
"given",
"type"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/virtual_machines.go#L168-L179 |
15,499 | exoscale/egoscale | virtual_machines.go | NicByNetworkID | func (vm VirtualMachine) NicByNetworkID(networkID UUID) *Nic {
for _, nic := range vm.Nic {
if nic.NetworkID.Equal(networkID) {
n := nic
n.VirtualMachineID = vm.ID
return &n
}
}
return nil
} | go | func (vm VirtualMachine) NicByNetworkID(networkID UUID) *Nic {
for _, nic := range vm.Nic {
if nic.NetworkID.Equal(networkID) {
n := nic
n.VirtualMachineID = vm.ID
return &n
}
}
return nil
} | [
"func",
"(",
"vm",
"VirtualMachine",
")",
"NicByNetworkID",
"(",
"networkID",
"UUID",
")",
"*",
"Nic",
"{",
"for",
"_",
",",
"nic",
":=",
"range",
"vm",
".",
"Nic",
"{",
"if",
"nic",
".",
"NetworkID",
".",
"Equal",
"(",
"networkID",
")",
"{",
"n",
... | // NicByNetworkID returns the corresponding interface based on the given NetworkID
//
// A VM cannot be connected twice to a same network. | [
"NicByNetworkID",
"returns",
"the",
"corresponding",
"interface",
"based",
"on",
"the",
"given",
"NetworkID",
"A",
"VM",
"cannot",
"be",
"connected",
"twice",
"to",
"a",
"same",
"network",
"."
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/virtual_machines.go#L184-L193 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.