1
0
mirror of https://github.com/rancher/cli.git synced 2026-02-05 09:48:36 +01:00

Remove ununsed files and dependencies

This commit is contained in:
Dan Ramich
2018-03-22 13:58:40 -07:00
committed by Craig Jellick
parent b7f978e728
commit d2dbfa3314
454 changed files with 78222 additions and 43910 deletions

View File

@@ -7,17 +7,14 @@ import (
"encoding/pem"
"io"
"io/ioutil"
"math/rand"
"os"
"os/exec"
"strings"
"syscall"
"text/template"
"time"
"unicode"
"github.com/docker/docker/pkg/namesgenerator"
"github.com/fatih/color"
"github.com/ghodss/yaml"
"github.com/pkg/errors"
"github.com/rancher/cli/cliclient"
@@ -28,7 +25,6 @@ import (
var (
errNoURL = errors.New("RANCHER_URL environment or --Url is not set, run `login`")
colors = []color.Attribute{color.FgGreen, color.FgBlue, color.FgCyan, color.FgMagenta, color.FgRed, color.FgWhite, color.FgYellow}
)
func loadAndVerifyCert(path string) (string, error) {
@@ -170,13 +166,6 @@ func processExitCode(err error) error {
return err
}
func getRandomColor() color.Attribute {
s1 := rand.NewSource(time.Now().UnixNano())
r1 := rand.New(s1)
index := r1.Intn(8)
return colors[index]
}
func SplitOnColon(s string) []string {
return strings.Split(s, ":")
}

View File

@@ -1,23 +0,0 @@
package cmd
import (
"errors"
"fmt"
"strings"
"github.com/rancher/go-rancher/v3"
)
func pickAction(resource *client.Resource, actions ...string) (string, error) {
for _, action := range actions {
if _, ok := resource.Actions[action]; ok {
return action, nil
}
}
msg := fmt.Sprintf("%s not currently available on %s %s", strings.Join(actions, "/"), resource.Type, resource.Id)
return "", errors.New(replaceTypeNames(msg))
}
func replaceTypeNames(msg string) string {
return strings.Replace(msg, "project", "environment", -1)
}

View File

@@ -1,206 +0,0 @@
package cmd
import (
"fmt"
"strings"
"time"
"github.com/rancher/cli/cliclient"
"github.com/rancher/cli/monitor"
"github.com/rancher/rancher-compose-executor/project/options"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
var (
waitTypes = []string{"service", "container", "host", "stack", "machine", "projectTemplate"}
)
func WaitCommand() cli.Command {
return cli.Command{
Name: "wait",
Usage: "Wait for resources " + strings.Join(waitTypes, ", "),
ArgsUsage: "[ID NAME...]",
Action: waitForResources,
Flags: []cli.Flag{},
}
}
func WaitFor(ctx *cli.Context, resource string) error {
w, err := NewWaiter(ctx)
if err != nil {
return err
}
w.Add(resource)
return w.Wait()
}
func waitForResources(ctx *cli.Context) error {
ctx.GlobalSet("wait", "true")
w, err := NewWaiter(ctx)
if err != nil {
return err
}
for _, r := range ctx.Args() {
w.Add(r)
}
return w.Wait()
}
func NewWaiter(ctx *cli.Context) (*Waiter, error) {
client, err := GetClient(ctx)
if err != nil {
return nil, err
}
waitState := ctx.GlobalString("wait-state")
if waitState == "" {
waitState = "active"
}
return &Waiter{
enabled: ctx.GlobalBool("wait"),
timeout: ctx.GlobalInt("wait-timeout"),
state: waitState,
client: client,
}, nil
}
type Waiter struct {
enabled bool
timeout int
state string
resources []string
client *cliclient.MasterClient
monitor *monitor.Monitor
}
type ResourceID string
func NewResourceID(resourceType, id string) ResourceID {
return ResourceID(fmt.Sprintf("%s:%s", resourceType, id))
}
func (r ResourceID) ID() string {
str := string(r)
return str[strings.Index(str, ":")+1:]
}
func (r ResourceID) Type() string {
str := string(r)
return str[:strings.Index(str, ":")]
}
func (w *Waiter) Add(resources ...string) options.Waiter {
for _, resource := range resources {
fmt.Println(resource)
w.resources = append(w.resources, resource)
}
return w
}
func (w *Waiter) done(resourceType, id string) (bool, error) {
data := map[string]interface{}{}
ok, err := w.monitor.Get(resourceType, id, &data)
if err != nil {
return ok, err
}
if ok {
return w.checkDone(resourceType, id, data)
}
// FIXME Add this back?
//if err := w.client.ById(resourceType, id, &data); err != nil {
// return false, err
//}
return w.checkDone(resourceType, id, data)
}
func (w *Waiter) checkDone(resourceType, id string, data map[string]interface{}) (bool, error) {
transitioning := fmt.Sprint(data["transitioning"])
logrus.Debugf("%s:%s transitioning=%s state=%v, healthState=%v waitState=%s", resourceType, id, transitioning,
data["state"], data["healthState"], w.state)
switch transitioning {
case "yes":
return false, nil
case "error":
return false, fmt.Errorf("%s:%s failed: %s", resourceType, id, data["transitioningMessage"])
}
if w.state == "" {
return true, nil
}
return (data["state"] == w.state || data["healthState"] == w.state), nil
}
func (w *Waiter) Wait() error {
if !w.enabled {
return nil
}
watching := map[ResourceID]bool{}
w.monitor = monitor.New(w.client)
sub := w.monitor.Subscribe()
//go func() { logrus.Fatal(w.monitor.Start()) }()
//for _, resource := range w.resources {
// r, err := Lookup(w.client, resource, waitTypes...)
// if err != nil {
// return err
// }
//
// ok, err := w.done(r.Type, r.ID)
// if err != nil {
// return err
// }
// if !ok {
// watching[NewResourceID(r.Type, r.ID)] = true
// }
//}
timeout := time.After(time.Duration(w.timeout) * time.Second)
every := time.Tick(10 * time.Second)
for len(watching) > 0 {
var event *monitor.Event
select {
case event = <-sub.C:
case <-timeout:
return fmt.Errorf("Timeout")
case <-every:
for resource := range watching {
ok, err := w.done(resource.Type(), resource.ID())
if err != nil {
return err
}
if ok {
delete(watching, resource)
}
}
continue
}
resource := NewResourceID(event.ResourceType, event.ResourceID)
if !watching[resource] {
continue
}
done, err := w.done(event.ResourceType, event.ResourceID)
if err != nil {
return err
}
if done {
delete(watching, resource)
}
}
return nil
}

View File

@@ -1,151 +0,0 @@
package monitor
import (
"encoding/json"
"fmt"
"net/url"
"sync"
"github.com/gorilla/websocket"
"github.com/pkg/errors"
"github.com/rancher/go-rancher/v3"
"github.com/sirupsen/logrus"
)
type UpWatcher struct {
sync.Mutex
c *client.RancherClient
subCounter int
subscriptions map[int]*Subscription
}
func (m *UpWatcher) Subscribe() *Subscription {
m.Lock()
defer m.Unlock()
m.subCounter++
sub := &Subscription{
id: m.subCounter,
C: make(chan *Event, 1024),
}
m.subscriptions[sub.id] = sub
return sub
}
func (m *UpWatcher) Unsubscribe(sub *Subscription) {
m.Lock()
defer m.Unlock()
close(sub.C)
delete(m.subscriptions, sub.id)
}
func NewUpWatcher(c *client.RancherClient) *UpWatcher {
return &UpWatcher{
c: c,
subscriptions: map[int]*Subscription{},
}
}
func (m *UpWatcher) Start(stackID string) error {
schema, ok := m.c.GetSchemas().CheckSchema("subscribe")
if !ok {
return fmt.Errorf("Not authorized to subscribe")
}
urlString := schema.Links["collection"]
u, err := url.Parse(urlString)
if err != nil {
return err
}
switch u.Scheme {
case "http":
u.Scheme = "ws"
case "https":
u.Scheme = "wss"
}
q := u.Query()
q.Add("eventNames", "resource.change")
q.Add("eventNames", "service.kubernetes.change")
u.RawQuery = q.Encode()
conn, resp, err := m.c.Websocket(u.String(), nil)
if err != nil {
return err
}
if resp.StatusCode != 101 {
return fmt.Errorf("Bad status code: %d %s", resp.StatusCode, resp.Status)
}
logrus.Debugf("Connected to: %s", u.String())
return m.watch(conn, stackID)
}
func (m *UpWatcher) watch(conn *websocket.Conn, stackID string) error {
serviceIds := map[string]struct{}{}
for {
v := Event{}
_, r, err := conn.NextReader()
if err != nil {
return err
}
if err := json.NewDecoder(r).Decode(&v); err != nil {
logrus.Errorf("Failed to parse json in message")
continue
}
logrus.Debugf("Event: %s %s %s", v.Name, v.ResourceType, v.ResourceID)
if v.ResourceType == "stack" {
stackData := &client.Stack{}
if err := unmarshalling(v.Data["resource"], stackData); err != nil {
logrus.Errorf("failed to unmarshalling err: %v", err)
continue
}
if stackData.Id == stackID {
stackID = stackData.Id
for _, serviceID := range stackData.ServiceIds {
serviceIds[serviceID] = struct{}{}
}
switch stackData.Transitioning {
case "error":
return errors.Errorf("Failed to launch stack %s. Error message: %s", stackID, stackData.TransitioningMessage)
}
}
} else if v.ResourceType == "serviceLog" {
serviceLogData := &client.ServiceLog{}
if err := unmarshalling(v.Data["resource"], serviceLogData); err != nil {
logrus.Errorf("failed to unmarshalling err: %v", err)
continue
}
if service, err := m.c.Service.ById(serviceLogData.ServiceId); err == nil {
if service.StackId == stackID {
msg := fmt.Sprintf("%s ServiceLog: %s", serviceLogData.Created, serviceLogData.Description)
switch serviceLogData.Level {
case "info":
logrus.Infof(msg)
case "error":
logrus.Error(err)
return err
}
}
}
}
}
}
func unmarshalling(data interface{}, v interface{}) error {
raw, err := json.Marshal(data)
if err != nil {
return errors.Wrapf(err, "failed to marshall object. Body: %v", data)
}
if err := json.Unmarshal(raw, &v); err != nil {
return errors.Wrapf(err, "failed to unmarshall object. Body: %v", string(raw))
}
return nil
}

View File

@@ -1,39 +1,15 @@
github.com/docker/distribution 77b9d2997abcded79a5314970fe69a44c93c25fb
github.com/docker/docker 8658748ef716e43a5f6d834825d818012ed6e2c4
github.com/docker/go-connections 988efe982fdecb46f01d53465878ff1f2ff411ce
github.com/docker/go-units f2d77a61e3c169b43402a0a1e84f06daf29b8190
github.com/docker/libcompose 6d5e31da6e294b6d2922434a68e19538038f4243 https://github.com/rancher/libcompose
github.com/gorilla/websocket 1551221275a7bd42978745a376b2531f791d88f3
github.com/mitchellh/mapstructure ca63d7c062ee3c9f34db231e352b60012b4fd0c1
github.com/opencontainers/runc cc29e3dded8e27ba8f65738f40d251c885030a28
github.com/patrickmn/go-cache 1881a9bccb818787f68c52bfba648c6cf34c34fa
github.com/pkg/errors 1d2e60385a13aaa66134984235061c2f9302520e
github.com/urfave/cli v1.18.0
golang.org/x/crypto 4d48e5fa3d62b5e6e71260571bf76c767198ca02
golang.org/x/net 2beffdc2e92c8a3027590f898fe88f69af48a3f8 https://github.com/tonistiigi/net.git
golang.org/x/sys eb2c74142fd19a79b3f237334c7384d5167b1b46
github.com/fatih/color 67c513e5729f918f5e69786686770c27141a4490
github.com/mattn/go-colorable ad5389df28cdac544c99bd7b9161a0b5b6ca9d1b
github.com/mattn/go-isatty fc9e8d8ef48496124e79ae0df75490096eccf6fe
gopkg.in/check.v1 4f90aeace3a26ad7021961c297b22c42160c7b25
github.com/c-bata/go-prompt f329ebd2409de559ba256325b8a18b13a145b5d5
github.com/mattn/go-tty 061c12e2dc3ef933c21c2249823e6f42e6935c40
github.com/docker/docker 8658748ef716e43a5f6d834825d818012ed6e2c4
github.com/ghodss/yaml 0ca9ea5df5451ffdf184b4428c902747c2c11cd7
github.com/pkg/errors 1d2e60385a13aaa66134984235061c2f9302520e
github.com/pkg/term b1f72af2d63057363398bec5873d16a98b453312
github.com/Masterminds/sprig c974324bb59b465f00b128a055656d44f60e4ffc
github.com/fatih/structs dc3312cb1a4513a366c4c9e622ad55c32df12ed3
github.com/flynn/go-shlex 3f9db97f856818214da2e1057f8ad84803971cff
gopkg.in/yaml.v2 eb3733d160e74a9c7e442f435eb3bea458e1d19f
github.com/aokoli/goutils 9c37978a95bd5c709a15883b6242714ea6709e64
github.com/satori/go.uuid 5bf94b69c6b68ee1b541973bb8e1144db23a194b
github.com/xeipuuv/gojsonpointer e0fe6f68307607d540ed8eac07a342c33fa1b54a
github.com/xeipuuv/gojsonreference e02fc20de94c78484cd5ffb007f8af96be030a45
github.com/xeipuuv/gojsonschema ac452913faa25c08bb78810d3e6f88b8a39f8f25
github.com/patrickmn/go-cache 1881a9bccb818787f68c52bfba648c6cf34c34fa
github.com/sirupsen/logrus d682213848ed68c0a260ca37d6dd5ace8423f5ba
github.com/urfave/cli v1.18.0
gopkg.in/check.v1 4f90aeace3a26ad7021961c297b22c42160c7b25
k8s.io/kubernetes v1.8.6-rancher1 https://github.com/ibuildthecloud/kubernetes.git transitive=true,staging=true
bitbucket.org/ww/goautoneg a547fc61f48d567d5b4ec6f8aee5573d8efce11d https://github.com/rancher/goautoneg.git
github.com/ghodss/yaml 0ca9ea5df5451ffdf184b4428c902747c2c11cd7
github.com/rancher/go-rancher ed07de9d7bd081a1d00bbaff03ade572082584d1
github.com/rancher/norman ad73d371721bf32faf7a45e02ff9c30af5f8438a
github.com/rancher/types eab18ee4b917a7150742bca8e03635b47eb3813e
github.com/rancher/rancher-compose-executor v0.14.18

View File

@@ -1,5 +0,0 @@
language: go
go:
- 1.8.x
- tip

View File

@@ -1,20 +0,0 @@
The MIT License (MIT)
Copyright (c) 2013 Fatih Arslan
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,177 +0,0 @@
# Color [![GoDoc](https://godoc.org/github.com/fatih/color?status.svg)](https://godoc.org/github.com/fatih/color) [![Build Status](https://img.shields.io/travis/fatih/color.svg?style=flat-square)](https://travis-ci.org/fatih/color)
Color lets you use colorized outputs in terms of [ANSI Escape
Codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors) in Go (Golang). It
has support for Windows too! The API can be used in several ways, pick one that
suits you.
![Color](https://i.imgur.com/c1JI0lA.png)
## Install
```bash
go get github.com/fatih/color
```
Note that the `vendor` folder is here for stability. Remove the folder if you
already have the dependencies in your GOPATH.
## Examples
### Standard colors
```go
// Print with default helper functions
color.Cyan("Prints text in cyan.")
// A newline will be appended automatically
color.Blue("Prints %s in blue.", "text")
// These are using the default foreground colors
color.Red("We have red")
color.Magenta("And many others ..")
```
### Mix and reuse colors
```go
// Create a new color object
c := color.New(color.FgCyan).Add(color.Underline)
c.Println("Prints cyan text with an underline.")
// Or just add them to New()
d := color.New(color.FgCyan, color.Bold)
d.Printf("This prints bold cyan %s\n", "too!.")
// Mix up foreground and background colors, create new mixes!
red := color.New(color.FgRed)
boldRed := red.Add(color.Bold)
boldRed.Println("This will print text in bold red.")
whiteBackground := red.Add(color.BgWhite)
whiteBackground.Println("Red text with white background.")
```
### Use your own output (io.Writer)
```go
// Use your own io.Writer output
color.New(color.FgBlue).Fprintln(myWriter, "blue color!")
blue := color.New(color.FgBlue)
blue.Fprint(writer, "This will print text in blue.")
```
### Custom print functions (PrintFunc)
```go
// Create a custom print function for convenience
red := color.New(color.FgRed).PrintfFunc()
red("Warning")
red("Error: %s", err)
// Mix up multiple attributes
notice := color.New(color.Bold, color.FgGreen).PrintlnFunc()
notice("Don't forget this...")
```
### Custom fprint functions (FprintFunc)
```go
blue := color.New(FgBlue).FprintfFunc()
blue(myWriter, "important notice: %s", stars)
// Mix up with multiple attributes
success := color.New(color.Bold, color.FgGreen).FprintlnFunc()
success(myWriter, "Don't forget this...")
```
### Insert into noncolor strings (SprintFunc)
```go
// Create SprintXxx functions to mix strings with other non-colorized strings:
yellow := color.New(color.FgYellow).SprintFunc()
red := color.New(color.FgRed).SprintFunc()
fmt.Printf("This is a %s and this is %s.\n", yellow("warning"), red("error"))
info := color.New(color.FgWhite, color.BgGreen).SprintFunc()
fmt.Printf("This %s rocks!\n", info("package"))
// Use helper functions
fmt.Println("This", color.RedString("warning"), "should be not neglected.")
fmt.Printf("%v %v\n", color.GreenString("Info:"), "an important message.")
// Windows supported too! Just don't forget to change the output to color.Output
fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))
```
### Plug into existing code
```go
// Use handy standard colors
color.Set(color.FgYellow)
fmt.Println("Existing text will now be in yellow")
fmt.Printf("This one %s\n", "too")
color.Unset() // Don't forget to unset
// You can mix up parameters
color.Set(color.FgMagenta, color.Bold)
defer color.Unset() // Use it in your function
fmt.Println("All text will now be bold magenta.")
```
### Disable color
There might be a case where you want to disable color output (for example to
pipe the standard output of your app to somewhere else). `Color` has support to
disable colors both globally and for single color definition. For example
suppose you have a CLI app and a `--no-color` bool flag. You can easily disable
the color output with:
```go
var flagNoColor = flag.Bool("no-color", false, "Disable color output")
if *flagNoColor {
color.NoColor = true // disables colorized output
}
```
It also has support for single color definitions (local). You can
disable/enable color output on the fly:
```go
c := color.New(color.FgCyan)
c.Println("Prints cyan text")
c.DisableColor()
c.Println("This is printed without any color")
c.EnableColor()
c.Println("This prints again cyan...")
```
## Todo
* Save/Return previous values
* Evaluate fmt.Formatter interface
## Credits
* [Fatih Arslan](https://github.com/fatih)
* Windows support via @mattn: [colorable](https://github.com/mattn/go-colorable)
## License
The MIT License (MIT) - see [`LICENSE.md`](https://github.com/fatih/color/blob/master/LICENSE.md) for more details

View File

@@ -1,600 +0,0 @@
package color
import (
"fmt"
"io"
"os"
"strconv"
"strings"
"sync"
"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
)
var (
// NoColor defines if the output is colorized or not. It's dynamically set to
// false or true based on the stdout's file descriptor referring to a terminal
// or not. This is a global option and affects all colors. For more control
// over each color block use the methods DisableColor() individually.
NoColor = os.Getenv("TERM") == "dumb" ||
(!isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd()))
// Output defines the standard output of the print functions. By default
// os.Stdout is used.
Output = colorable.NewColorableStdout()
// colorsCache is used to reduce the count of created Color objects and
// allows to reuse already created objects with required Attribute.
colorsCache = make(map[Attribute]*Color)
colorsCacheMu sync.Mutex // protects colorsCache
)
// Color defines a custom color object which is defined by SGR parameters.
type Color struct {
params []Attribute
noColor *bool
}
// Attribute defines a single SGR Code
type Attribute int
const escape = "\x1b"
// Base attributes
const (
Reset Attribute = iota
Bold
Faint
Italic
Underline
BlinkSlow
BlinkRapid
ReverseVideo
Concealed
CrossedOut
)
// Foreground text colors
const (
FgBlack Attribute = iota + 30
FgRed
FgGreen
FgYellow
FgBlue
FgMagenta
FgCyan
FgWhite
)
// Foreground Hi-Intensity text colors
const (
FgHiBlack Attribute = iota + 90
FgHiRed
FgHiGreen
FgHiYellow
FgHiBlue
FgHiMagenta
FgHiCyan
FgHiWhite
)
// Background text colors
const (
BgBlack Attribute = iota + 40
BgRed
BgGreen
BgYellow
BgBlue
BgMagenta
BgCyan
BgWhite
)
// Background Hi-Intensity text colors
const (
BgHiBlack Attribute = iota + 100
BgHiRed
BgHiGreen
BgHiYellow
BgHiBlue
BgHiMagenta
BgHiCyan
BgHiWhite
)
// New returns a newly created color object.
func New(value ...Attribute) *Color {
c := &Color{params: make([]Attribute, 0)}
c.Add(value...)
return c
}
// Set sets the given parameters immediately. It will change the color of
// output with the given SGR parameters until color.Unset() is called.
func Set(p ...Attribute) *Color {
c := New(p...)
c.Set()
return c
}
// Unset resets all escape attributes and clears the output. Usually should
// be called after Set().
func Unset() {
if NoColor {
return
}
fmt.Fprintf(Output, "%s[%dm", escape, Reset)
}
// Set sets the SGR sequence.
func (c *Color) Set() *Color {
if c.isNoColorSet() {
return c
}
fmt.Fprintf(Output, c.format())
return c
}
func (c *Color) unset() {
if c.isNoColorSet() {
return
}
Unset()
}
func (c *Color) setWriter(w io.Writer) *Color {
if c.isNoColorSet() {
return c
}
fmt.Fprintf(w, c.format())
return c
}
func (c *Color) unsetWriter(w io.Writer) {
if c.isNoColorSet() {
return
}
if NoColor {
return
}
fmt.Fprintf(w, "%s[%dm", escape, Reset)
}
// Add is used to chain SGR parameters. Use as many as parameters to combine
// and create custom color objects. Example: Add(color.FgRed, color.Underline).
func (c *Color) Add(value ...Attribute) *Color {
c.params = append(c.params, value...)
return c
}
func (c *Color) prepend(value Attribute) {
c.params = append(c.params, 0)
copy(c.params[1:], c.params[0:])
c.params[0] = value
}
// Fprint formats using the default formats for its operands and writes to w.
// Spaces are added between operands when neither is a string.
// It returns the number of bytes written and any write error encountered.
// On Windows, users should wrap w with colorable.NewColorable() if w is of
// type *os.File.
func (c *Color) Fprint(w io.Writer, a ...interface{}) (n int, err error) {
c.setWriter(w)
defer c.unsetWriter(w)
return fmt.Fprint(w, a...)
}
// Print formats using the default formats for its operands and writes to
// standard output. Spaces are added between operands when neither is a
// string. It returns the number of bytes written and any write error
// encountered. This is the standard fmt.Print() method wrapped with the given
// color.
func (c *Color) Print(a ...interface{}) (n int, err error) {
c.Set()
defer c.unset()
return fmt.Fprint(Output, a...)
}
// Fprintf formats according to a format specifier and writes to w.
// It returns the number of bytes written and any write error encountered.
// On Windows, users should wrap w with colorable.NewColorable() if w is of
// type *os.File.
func (c *Color) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
c.setWriter(w)
defer c.unsetWriter(w)
return fmt.Fprintf(w, format, a...)
}
// Printf formats according to a format specifier and writes to standard output.
// It returns the number of bytes written and any write error encountered.
// This is the standard fmt.Printf() method wrapped with the given color.
func (c *Color) Printf(format string, a ...interface{}) (n int, err error) {
c.Set()
defer c.unset()
return fmt.Fprintf(Output, format, a...)
}
// Fprintln formats using the default formats for its operands and writes to w.
// Spaces are always added between operands and a newline is appended.
// On Windows, users should wrap w with colorable.NewColorable() if w is of
// type *os.File.
func (c *Color) Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
c.setWriter(w)
defer c.unsetWriter(w)
return fmt.Fprintln(w, a...)
}
// Println formats using the default formats for its operands and writes to
// standard output. Spaces are always added between operands and a newline is
// appended. It returns the number of bytes written and any write error
// encountered. This is the standard fmt.Print() method wrapped with the given
// color.
func (c *Color) Println(a ...interface{}) (n int, err error) {
c.Set()
defer c.unset()
return fmt.Fprintln(Output, a...)
}
// Sprint is just like Print, but returns a string instead of printing it.
func (c *Color) Sprint(a ...interface{}) string {
return c.wrap(fmt.Sprint(a...))
}
// Sprintln is just like Println, but returns a string instead of printing it.
func (c *Color) Sprintln(a ...interface{}) string {
return c.wrap(fmt.Sprintln(a...))
}
// Sprintf is just like Printf, but returns a string instead of printing it.
func (c *Color) Sprintf(format string, a ...interface{}) string {
return c.wrap(fmt.Sprintf(format, a...))
}
// FprintFunc returns a new function that prints the passed arguments as
// colorized with color.Fprint().
func (c *Color) FprintFunc() func(w io.Writer, a ...interface{}) {
return func(w io.Writer, a ...interface{}) {
c.Fprint(w, a...)
}
}
// PrintFunc returns a new function that prints the passed arguments as
// colorized with color.Print().
func (c *Color) PrintFunc() func(a ...interface{}) {
return func(a ...interface{}) {
c.Print(a...)
}
}
// FprintfFunc returns a new function that prints the passed arguments as
// colorized with color.Fprintf().
func (c *Color) FprintfFunc() func(w io.Writer, format string, a ...interface{}) {
return func(w io.Writer, format string, a ...interface{}) {
c.Fprintf(w, format, a...)
}
}
// PrintfFunc returns a new function that prints the passed arguments as
// colorized with color.Printf().
func (c *Color) PrintfFunc() func(format string, a ...interface{}) {
return func(format string, a ...interface{}) {
c.Printf(format, a...)
}
}
// FprintlnFunc returns a new function that prints the passed arguments as
// colorized with color.Fprintln().
func (c *Color) FprintlnFunc() func(w io.Writer, a ...interface{}) {
return func(w io.Writer, a ...interface{}) {
c.Fprintln(w, a...)
}
}
// PrintlnFunc returns a new function that prints the passed arguments as
// colorized with color.Println().
func (c *Color) PrintlnFunc() func(a ...interface{}) {
return func(a ...interface{}) {
c.Println(a...)
}
}
// SprintFunc returns a new function that returns colorized strings for the
// given arguments with fmt.Sprint(). Useful to put into or mix into other
// string. Windows users should use this in conjunction with color.Output, example:
//
// put := New(FgYellow).SprintFunc()
// fmt.Fprintf(color.Output, "This is a %s", put("warning"))
func (c *Color) SprintFunc() func(a ...interface{}) string {
return func(a ...interface{}) string {
return c.wrap(fmt.Sprint(a...))
}
}
// SprintfFunc returns a new function that returns colorized strings for the
// given arguments with fmt.Sprintf(). Useful to put into or mix into other
// string. Windows users should use this in conjunction with color.Output.
func (c *Color) SprintfFunc() func(format string, a ...interface{}) string {
return func(format string, a ...interface{}) string {
return c.wrap(fmt.Sprintf(format, a...))
}
}
// SprintlnFunc returns a new function that returns colorized strings for the
// given arguments with fmt.Sprintln(). Useful to put into or mix into other
// string. Windows users should use this in conjunction with color.Output.
func (c *Color) SprintlnFunc() func(a ...interface{}) string {
return func(a ...interface{}) string {
return c.wrap(fmt.Sprintln(a...))
}
}
// sequence returns a formated SGR sequence to be plugged into a "\x1b[...m"
// an example output might be: "1;36" -> bold cyan
func (c *Color) sequence() string {
format := make([]string, len(c.params))
for i, v := range c.params {
format[i] = strconv.Itoa(int(v))
}
return strings.Join(format, ";")
}
// wrap wraps the s string with the colors attributes. The string is ready to
// be printed.
func (c *Color) wrap(s string) string {
if c.isNoColorSet() {
return s
}
return c.format() + s + c.unformat()
}
func (c *Color) format() string {
return fmt.Sprintf("%s[%sm", escape, c.sequence())
}
func (c *Color) unformat() string {
return fmt.Sprintf("%s[%dm", escape, Reset)
}
// DisableColor disables the color output. Useful to not change any existing
// code and still being able to output. Can be used for flags like
// "--no-color". To enable back use EnableColor() method.
func (c *Color) DisableColor() {
c.noColor = boolPtr(true)
}
// EnableColor enables the color output. Use it in conjunction with
// DisableColor(). Otherwise this method has no side effects.
func (c *Color) EnableColor() {
c.noColor = boolPtr(false)
}
func (c *Color) isNoColorSet() bool {
// check first if we have user setted action
if c.noColor != nil {
return *c.noColor
}
// if not return the global option, which is disabled by default
return NoColor
}
// Equals returns a boolean value indicating whether two colors are equal.
func (c *Color) Equals(c2 *Color) bool {
if len(c.params) != len(c2.params) {
return false
}
for _, attr := range c.params {
if !c2.attrExists(attr) {
return false
}
}
return true
}
func (c *Color) attrExists(a Attribute) bool {
for _, attr := range c.params {
if attr == a {
return true
}
}
return false
}
func boolPtr(v bool) *bool {
return &v
}
func getCachedColor(p Attribute) *Color {
colorsCacheMu.Lock()
defer colorsCacheMu.Unlock()
c, ok := colorsCache[p]
if !ok {
c = New(p)
colorsCache[p] = c
}
return c
}
func colorPrint(format string, p Attribute, a ...interface{}) {
c := getCachedColor(p)
if !strings.HasSuffix(format, "\n") {
format += "\n"
}
if len(a) == 0 {
c.Print(format)
} else {
c.Printf(format, a...)
}
}
func colorString(format string, p Attribute, a ...interface{}) string {
c := getCachedColor(p)
if len(a) == 0 {
return c.SprintFunc()(format)
}
return c.SprintfFunc()(format, a...)
}
// Black is a convenient helper function to print with black foreground. A
// newline is appended to format by default.
func Black(format string, a ...interface{}) { colorPrint(format, FgBlack, a...) }
// Red is a convenient helper function to print with red foreground. A
// newline is appended to format by default.
func Red(format string, a ...interface{}) { colorPrint(format, FgRed, a...) }
// Green is a convenient helper function to print with green foreground. A
// newline is appended to format by default.
func Green(format string, a ...interface{}) { colorPrint(format, FgGreen, a...) }
// Yellow is a convenient helper function to print with yellow foreground.
// A newline is appended to format by default.
func Yellow(format string, a ...interface{}) { colorPrint(format, FgYellow, a...) }
// Blue is a convenient helper function to print with blue foreground. A
// newline is appended to format by default.
func Blue(format string, a ...interface{}) { colorPrint(format, FgBlue, a...) }
// Magenta is a convenient helper function to print with magenta foreground.
// A newline is appended to format by default.
func Magenta(format string, a ...interface{}) { colorPrint(format, FgMagenta, a...) }
// Cyan is a convenient helper function to print with cyan foreground. A
// newline is appended to format by default.
func Cyan(format string, a ...interface{}) { colorPrint(format, FgCyan, a...) }
// White is a convenient helper function to print with white foreground. A
// newline is appended to format by default.
func White(format string, a ...interface{}) { colorPrint(format, FgWhite, a...) }
// BlackString is a convenient helper function to return a string with black
// foreground.
func BlackString(format string, a ...interface{}) string { return colorString(format, FgBlack, a...) }
// RedString is a convenient helper function to return a string with red
// foreground.
func RedString(format string, a ...interface{}) string { return colorString(format, FgRed, a...) }
// GreenString is a convenient helper function to return a string with green
// foreground.
func GreenString(format string, a ...interface{}) string { return colorString(format, FgGreen, a...) }
// YellowString is a convenient helper function to return a string with yellow
// foreground.
func YellowString(format string, a ...interface{}) string { return colorString(format, FgYellow, a...) }
// BlueString is a convenient helper function to return a string with blue
// foreground.
func BlueString(format string, a ...interface{}) string { return colorString(format, FgBlue, a...) }
// MagentaString is a convenient helper function to return a string with magenta
// foreground.
func MagentaString(format string, a ...interface{}) string {
return colorString(format, FgMagenta, a...)
}
// CyanString is a convenient helper function to return a string with cyan
// foreground.
func CyanString(format string, a ...interface{}) string { return colorString(format, FgCyan, a...) }
// WhiteString is a convenient helper function to return a string with white
// foreground.
func WhiteString(format string, a ...interface{}) string { return colorString(format, FgWhite, a...) }
// HiBlack is a convenient helper function to print with hi-intensity black foreground. A
// newline is appended to format by default.
func HiBlack(format string, a ...interface{}) { colorPrint(format, FgHiBlack, a...) }
// HiRed is a convenient helper function to print with hi-intensity red foreground. A
// newline is appended to format by default.
func HiRed(format string, a ...interface{}) { colorPrint(format, FgHiRed, a...) }
// HiGreen is a convenient helper function to print with hi-intensity green foreground. A
// newline is appended to format by default.
func HiGreen(format string, a ...interface{}) { colorPrint(format, FgHiGreen, a...) }
// HiYellow is a convenient helper function to print with hi-intensity yellow foreground.
// A newline is appended to format by default.
func HiYellow(format string, a ...interface{}) { colorPrint(format, FgHiYellow, a...) }
// HiBlue is a convenient helper function to print with hi-intensity blue foreground. A
// newline is appended to format by default.
func HiBlue(format string, a ...interface{}) { colorPrint(format, FgHiBlue, a...) }
// HiMagenta is a convenient helper function to print with hi-intensity magenta foreground.
// A newline is appended to format by default.
func HiMagenta(format string, a ...interface{}) { colorPrint(format, FgHiMagenta, a...) }
// HiCyan is a convenient helper function to print with hi-intensity cyan foreground. A
// newline is appended to format by default.
func HiCyan(format string, a ...interface{}) { colorPrint(format, FgHiCyan, a...) }
// HiWhite is a convenient helper function to print with hi-intensity white foreground. A
// newline is appended to format by default.
func HiWhite(format string, a ...interface{}) { colorPrint(format, FgHiWhite, a...) }
// HiBlackString is a convenient helper function to return a string with hi-intensity black
// foreground.
func HiBlackString(format string, a ...interface{}) string {
return colorString(format, FgHiBlack, a...)
}
// HiRedString is a convenient helper function to return a string with hi-intensity red
// foreground.
func HiRedString(format string, a ...interface{}) string { return colorString(format, FgHiRed, a...) }
// HiGreenString is a convenient helper function to return a string with hi-intensity green
// foreground.
func HiGreenString(format string, a ...interface{}) string {
return colorString(format, FgHiGreen, a...)
}
// HiYellowString is a convenient helper function to return a string with hi-intensity yellow
// foreground.
func HiYellowString(format string, a ...interface{}) string {
return colorString(format, FgHiYellow, a...)
}
// HiBlueString is a convenient helper function to return a string with hi-intensity blue
// foreground.
func HiBlueString(format string, a ...interface{}) string { return colorString(format, FgHiBlue, a...) }
// HiMagentaString is a convenient helper function to return a string with hi-intensity magenta
// foreground.
func HiMagentaString(format string, a ...interface{}) string {
return colorString(format, FgHiMagenta, a...)
}
// HiCyanString is a convenient helper function to return a string with hi-intensity cyan
// foreground.
func HiCyanString(format string, a ...interface{}) string { return colorString(format, FgHiCyan, a...) }
// HiWhiteString is a convenient helper function to return a string with hi-intensity white
// foreground.
func HiWhiteString(format string, a ...interface{}) string {
return colorString(format, FgHiWhite, a...)
}

133
vendor/github.com/fatih/color/doc.go generated vendored
View File

@@ -1,133 +0,0 @@
/*
Package color is an ANSI color package to output colorized or SGR defined
output to the standard output. The API can be used in several way, pick one
that suits you.
Use simple and default helper functions with predefined foreground colors:
color.Cyan("Prints text in cyan.")
// a newline will be appended automatically
color.Blue("Prints %s in blue.", "text")
// More default foreground colors..
color.Red("We have red")
color.Yellow("Yellow color too!")
color.Magenta("And many others ..")
// Hi-intensity colors
color.HiGreen("Bright green color.")
color.HiBlack("Bright black means gray..")
color.HiWhite("Shiny white color!")
However there are times where custom color mixes are required. Below are some
examples to create custom color objects and use the print functions of each
separate color object.
// Create a new color object
c := color.New(color.FgCyan).Add(color.Underline)
c.Println("Prints cyan text with an underline.")
// Or just add them to New()
d := color.New(color.FgCyan, color.Bold)
d.Printf("This prints bold cyan %s\n", "too!.")
// Mix up foreground and background colors, create new mixes!
red := color.New(color.FgRed)
boldRed := red.Add(color.Bold)
boldRed.Println("This will print text in bold red.")
whiteBackground := red.Add(color.BgWhite)
whiteBackground.Println("Red text with White background.")
// Use your own io.Writer output
color.New(color.FgBlue).Fprintln(myWriter, "blue color!")
blue := color.New(color.FgBlue)
blue.Fprint(myWriter, "This will print text in blue.")
You can create PrintXxx functions to simplify even more:
// Create a custom print function for convenient
red := color.New(color.FgRed).PrintfFunc()
red("warning")
red("error: %s", err)
// Mix up multiple attributes
notice := color.New(color.Bold, color.FgGreen).PrintlnFunc()
notice("don't forget this...")
You can also FprintXxx functions to pass your own io.Writer:
blue := color.New(FgBlue).FprintfFunc()
blue(myWriter, "important notice: %s", stars)
// Mix up with multiple attributes
success := color.New(color.Bold, color.FgGreen).FprintlnFunc()
success(myWriter, don't forget this...")
Or create SprintXxx functions to mix strings with other non-colorized strings:
yellow := New(FgYellow).SprintFunc()
red := New(FgRed).SprintFunc()
fmt.Printf("this is a %s and this is %s.\n", yellow("warning"), red("error"))
info := New(FgWhite, BgGreen).SprintFunc()
fmt.Printf("this %s rocks!\n", info("package"))
Windows support is enabled by default. All Print functions work as intended.
However only for color.SprintXXX functions, user should use fmt.FprintXXX and
set the output to color.Output:
fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))
info := New(FgWhite, BgGreen).SprintFunc()
fmt.Fprintf(color.Output, "this %s rocks!\n", info("package"))
Using with existing code is possible. Just use the Set() method to set the
standard output to the given parameters. That way a rewrite of an existing
code is not required.
// Use handy standard colors.
color.Set(color.FgYellow)
fmt.Println("Existing text will be now in Yellow")
fmt.Printf("This one %s\n", "too")
color.Unset() // don't forget to unset
// You can mix up parameters
color.Set(color.FgMagenta, color.Bold)
defer color.Unset() // use it in your function
fmt.Println("All text will be now bold magenta.")
There might be a case where you want to disable color output (for example to
pipe the standard output of your app to somewhere else). `Color` has support to
disable colors both globally and for single color definition. For example
suppose you have a CLI app and a `--no-color` bool flag. You can easily disable
the color output with:
var flagNoColor = flag.Bool("no-color", false, "Disable color output")
if *flagNoColor {
color.NoColor = true // disables colorized output
}
It also has support for single color definitions (local). You can
disable/enable color output on the fly:
c := color.New(color.FgCyan)
c.Println("Prints cyan text")
c.DisableColor()
c.Println("This is printed without any color")
c.EnableColor()
c.Println("This prints again cyan...")
*/
package color

View File

@@ -24,7 +24,7 @@
// ... Use conn to send and receive messages.
// }
//
// Call the connection WriteMessage and ReadMessages methods to send and
// Call the connection's WriteMessage and ReadMessage methods to send and
// receive messages as a slice of bytes. This snippet of code shows how to echo
// messages using these methods:
//

View File

@@ -1,9 +0,0 @@
language: go
go:
- tip
before_install:
- go get github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/cover
script:
- $HOME/gopath/bin/goveralls -repotoken xnXqRGwgW3SXIguzxf90ZSK1GPYZPaGrw

View File

@@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2016 Yasuhiro Matsumoto
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,48 +0,0 @@
# go-colorable
[![Godoc Reference](https://godoc.org/github.com/mattn/go-colorable?status.svg)](http://godoc.org/github.com/mattn/go-colorable)
[![Build Status](https://travis-ci.org/mattn/go-colorable.svg?branch=master)](https://travis-ci.org/mattn/go-colorable)
[![Coverage Status](https://coveralls.io/repos/github/mattn/go-colorable/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-colorable?branch=master)
[![Go Report Card](https://goreportcard.com/badge/mattn/go-colorable)](https://goreportcard.com/report/mattn/go-colorable)
Colorable writer for windows.
For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But I don't want.)
This package is possible to handle escape sequence for ansi color on windows.
## Too Bad!
![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/bad.png)
## So Good!
![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/good.png)
## Usage
```go
logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true})
logrus.SetOutput(colorable.NewColorableStdout())
logrus.Info("succeeded")
logrus.Warn("not correct")
logrus.Error("something error")
logrus.Fatal("panic")
```
You can compile above code on non-windows OSs.
## Installation
```
$ go get github.com/mattn/go-colorable
```
# License
MIT
# Author
Yasuhiro Matsumoto (a.k.a mattn)

View File

@@ -1,29 +0,0 @@
// +build appengine
package colorable
import (
"io"
"os"
_ "github.com/mattn/go-isatty"
)
// NewColorable return new instance of Writer which handle escape sequence.
func NewColorable(file *os.File) io.Writer {
if file == nil {
panic("nil passed instead of *os.File to NewColorable()")
}
return file
}
// NewColorableStdout return new instance of Writer which handle escape sequence for stdout.
func NewColorableStdout() io.Writer {
return os.Stdout
}
// NewColorableStderr return new instance of Writer which handle escape sequence for stderr.
func NewColorableStderr() io.Writer {
return os.Stderr
}

View File

@@ -1,30 +0,0 @@
// +build !windows
// +build !appengine
package colorable
import (
"io"
"os"
_ "github.com/mattn/go-isatty"
)
// NewColorable return new instance of Writer which handle escape sequence.
func NewColorable(file *os.File) io.Writer {
if file == nil {
panic("nil passed instead of *os.File to NewColorable()")
}
return file
}
// NewColorableStdout return new instance of Writer which handle escape sequence for stdout.
func NewColorableStdout() io.Writer {
return os.Stdout
}
// NewColorableStderr return new instance of Writer which handle escape sequence for stderr.
func NewColorableStderr() io.Writer {
return os.Stderr
}

View File

@@ -1,968 +0,0 @@
// +build windows
// +build !appengine
package colorable
import (
"bytes"
"io"
"math"
"os"
"strconv"
"strings"
"syscall"
"unsafe"
"github.com/mattn/go-isatty"
)
const (
foregroundBlue = 0x1
foregroundGreen = 0x2
foregroundRed = 0x4
foregroundIntensity = 0x8
foregroundMask = (foregroundRed | foregroundBlue | foregroundGreen | foregroundIntensity)
backgroundBlue = 0x10
backgroundGreen = 0x20
backgroundRed = 0x40
backgroundIntensity = 0x80
backgroundMask = (backgroundRed | backgroundBlue | backgroundGreen | backgroundIntensity)
)
const (
genericRead = 0x80000000
genericWrite = 0x40000000
)
const (
consoleTextmodeBuffer = 0x1
)
type wchar uint16
type short int16
type dword uint32
type word uint16
type coord struct {
x short
y short
}
type smallRect struct {
left short
top short
right short
bottom short
}
type consoleScreenBufferInfo struct {
size coord
cursorPosition coord
attributes word
window smallRect
maximumWindowSize coord
}
type consoleCursorInfo struct {
size dword
visible int32
}
var (
kernel32 = syscall.NewLazyDLL("kernel32.dll")
procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo")
procSetConsoleTextAttribute = kernel32.NewProc("SetConsoleTextAttribute")
procSetConsoleCursorPosition = kernel32.NewProc("SetConsoleCursorPosition")
procFillConsoleOutputCharacter = kernel32.NewProc("FillConsoleOutputCharacterW")
procFillConsoleOutputAttribute = kernel32.NewProc("FillConsoleOutputAttribute")
procGetConsoleCursorInfo = kernel32.NewProc("GetConsoleCursorInfo")
procSetConsoleCursorInfo = kernel32.NewProc("SetConsoleCursorInfo")
procSetConsoleTitle = kernel32.NewProc("SetConsoleTitleW")
procCreateConsoleScreenBuffer = kernel32.NewProc("CreateConsoleScreenBuffer")
)
// Writer provide colorable Writer to the console
type Writer struct {
out io.Writer
handle syscall.Handle
althandle syscall.Handle
oldattr word
oldpos coord
rest bytes.Buffer
}
// NewColorable return new instance of Writer which handle escape sequence from File.
func NewColorable(file *os.File) io.Writer {
if file == nil {
panic("nil passed instead of *os.File to NewColorable()")
}
if isatty.IsTerminal(file.Fd()) {
var csbi consoleScreenBufferInfo
handle := syscall.Handle(file.Fd())
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
return &Writer{out: file, handle: handle, oldattr: csbi.attributes, oldpos: coord{0, 0}}
}
return file
}
// NewColorableStdout return new instance of Writer which handle escape sequence for stdout.
func NewColorableStdout() io.Writer {
return NewColorable(os.Stdout)
}
// NewColorableStderr return new instance of Writer which handle escape sequence for stderr.
func NewColorableStderr() io.Writer {
return NewColorable(os.Stderr)
}
var color256 = map[int]int{
0: 0x000000,
1: 0x800000,
2: 0x008000,
3: 0x808000,
4: 0x000080,
5: 0x800080,
6: 0x008080,
7: 0xc0c0c0,
8: 0x808080,
9: 0xff0000,
10: 0x00ff00,
11: 0xffff00,
12: 0x0000ff,
13: 0xff00ff,
14: 0x00ffff,
15: 0xffffff,
16: 0x000000,
17: 0x00005f,
18: 0x000087,
19: 0x0000af,
20: 0x0000d7,
21: 0x0000ff,
22: 0x005f00,
23: 0x005f5f,
24: 0x005f87,
25: 0x005faf,
26: 0x005fd7,
27: 0x005fff,
28: 0x008700,
29: 0x00875f,
30: 0x008787,
31: 0x0087af,
32: 0x0087d7,
33: 0x0087ff,
34: 0x00af00,
35: 0x00af5f,
36: 0x00af87,
37: 0x00afaf,
38: 0x00afd7,
39: 0x00afff,
40: 0x00d700,
41: 0x00d75f,
42: 0x00d787,
43: 0x00d7af,
44: 0x00d7d7,
45: 0x00d7ff,
46: 0x00ff00,
47: 0x00ff5f,
48: 0x00ff87,
49: 0x00ffaf,
50: 0x00ffd7,
51: 0x00ffff,
52: 0x5f0000,
53: 0x5f005f,
54: 0x5f0087,
55: 0x5f00af,
56: 0x5f00d7,
57: 0x5f00ff,
58: 0x5f5f00,
59: 0x5f5f5f,
60: 0x5f5f87,
61: 0x5f5faf,
62: 0x5f5fd7,
63: 0x5f5fff,
64: 0x5f8700,
65: 0x5f875f,
66: 0x5f8787,
67: 0x5f87af,
68: 0x5f87d7,
69: 0x5f87ff,
70: 0x5faf00,
71: 0x5faf5f,
72: 0x5faf87,
73: 0x5fafaf,
74: 0x5fafd7,
75: 0x5fafff,
76: 0x5fd700,
77: 0x5fd75f,
78: 0x5fd787,
79: 0x5fd7af,
80: 0x5fd7d7,
81: 0x5fd7ff,
82: 0x5fff00,
83: 0x5fff5f,
84: 0x5fff87,
85: 0x5fffaf,
86: 0x5fffd7,
87: 0x5fffff,
88: 0x870000,
89: 0x87005f,
90: 0x870087,
91: 0x8700af,
92: 0x8700d7,
93: 0x8700ff,
94: 0x875f00,
95: 0x875f5f,
96: 0x875f87,
97: 0x875faf,
98: 0x875fd7,
99: 0x875fff,
100: 0x878700,
101: 0x87875f,
102: 0x878787,
103: 0x8787af,
104: 0x8787d7,
105: 0x8787ff,
106: 0x87af00,
107: 0x87af5f,
108: 0x87af87,
109: 0x87afaf,
110: 0x87afd7,
111: 0x87afff,
112: 0x87d700,
113: 0x87d75f,
114: 0x87d787,
115: 0x87d7af,
116: 0x87d7d7,
117: 0x87d7ff,
118: 0x87ff00,
119: 0x87ff5f,
120: 0x87ff87,
121: 0x87ffaf,
122: 0x87ffd7,
123: 0x87ffff,
124: 0xaf0000,
125: 0xaf005f,
126: 0xaf0087,
127: 0xaf00af,
128: 0xaf00d7,
129: 0xaf00ff,
130: 0xaf5f00,
131: 0xaf5f5f,
132: 0xaf5f87,
133: 0xaf5faf,
134: 0xaf5fd7,
135: 0xaf5fff,
136: 0xaf8700,
137: 0xaf875f,
138: 0xaf8787,
139: 0xaf87af,
140: 0xaf87d7,
141: 0xaf87ff,
142: 0xafaf00,
143: 0xafaf5f,
144: 0xafaf87,
145: 0xafafaf,
146: 0xafafd7,
147: 0xafafff,
148: 0xafd700,
149: 0xafd75f,
150: 0xafd787,
151: 0xafd7af,
152: 0xafd7d7,
153: 0xafd7ff,
154: 0xafff00,
155: 0xafff5f,
156: 0xafff87,
157: 0xafffaf,
158: 0xafffd7,
159: 0xafffff,
160: 0xd70000,
161: 0xd7005f,
162: 0xd70087,
163: 0xd700af,
164: 0xd700d7,
165: 0xd700ff,
166: 0xd75f00,
167: 0xd75f5f,
168: 0xd75f87,
169: 0xd75faf,
170: 0xd75fd7,
171: 0xd75fff,
172: 0xd78700,
173: 0xd7875f,
174: 0xd78787,
175: 0xd787af,
176: 0xd787d7,
177: 0xd787ff,
178: 0xd7af00,
179: 0xd7af5f,
180: 0xd7af87,
181: 0xd7afaf,
182: 0xd7afd7,
183: 0xd7afff,
184: 0xd7d700,
185: 0xd7d75f,
186: 0xd7d787,
187: 0xd7d7af,
188: 0xd7d7d7,
189: 0xd7d7ff,
190: 0xd7ff00,
191: 0xd7ff5f,
192: 0xd7ff87,
193: 0xd7ffaf,
194: 0xd7ffd7,
195: 0xd7ffff,
196: 0xff0000,
197: 0xff005f,
198: 0xff0087,
199: 0xff00af,
200: 0xff00d7,
201: 0xff00ff,
202: 0xff5f00,
203: 0xff5f5f,
204: 0xff5f87,
205: 0xff5faf,
206: 0xff5fd7,
207: 0xff5fff,
208: 0xff8700,
209: 0xff875f,
210: 0xff8787,
211: 0xff87af,
212: 0xff87d7,
213: 0xff87ff,
214: 0xffaf00,
215: 0xffaf5f,
216: 0xffaf87,
217: 0xffafaf,
218: 0xffafd7,
219: 0xffafff,
220: 0xffd700,
221: 0xffd75f,
222: 0xffd787,
223: 0xffd7af,
224: 0xffd7d7,
225: 0xffd7ff,
226: 0xffff00,
227: 0xffff5f,
228: 0xffff87,
229: 0xffffaf,
230: 0xffffd7,
231: 0xffffff,
232: 0x080808,
233: 0x121212,
234: 0x1c1c1c,
235: 0x262626,
236: 0x303030,
237: 0x3a3a3a,
238: 0x444444,
239: 0x4e4e4e,
240: 0x585858,
241: 0x626262,
242: 0x6c6c6c,
243: 0x767676,
244: 0x808080,
245: 0x8a8a8a,
246: 0x949494,
247: 0x9e9e9e,
248: 0xa8a8a8,
249: 0xb2b2b2,
250: 0xbcbcbc,
251: 0xc6c6c6,
252: 0xd0d0d0,
253: 0xdadada,
254: 0xe4e4e4,
255: 0xeeeeee,
}
// `\033]0;TITLESTR\007`
func doTitleSequence(er *bytes.Reader) error {
var c byte
var err error
c, err = er.ReadByte()
if err != nil {
return err
}
if c != '0' && c != '2' {
return nil
}
c, err = er.ReadByte()
if err != nil {
return err
}
if c != ';' {
return nil
}
title := make([]byte, 0, 80)
for {
c, err = er.ReadByte()
if err != nil {
return err
}
if c == 0x07 || c == '\n' {
break
}
title = append(title, c)
}
if len(title) > 0 {
title8, err := syscall.UTF16PtrFromString(string(title))
if err == nil {
procSetConsoleTitle.Call(uintptr(unsafe.Pointer(title8)))
}
}
return nil
}
// Write write data on console
func (w *Writer) Write(data []byte) (n int, err error) {
var csbi consoleScreenBufferInfo
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
handle := w.handle
var er *bytes.Reader
if w.rest.Len() > 0 {
var rest bytes.Buffer
w.rest.WriteTo(&rest)
w.rest.Reset()
rest.Write(data)
er = bytes.NewReader(rest.Bytes())
} else {
er = bytes.NewReader(data)
}
var bw [1]byte
loop:
for {
c1, err := er.ReadByte()
if err != nil {
break loop
}
if c1 != 0x1b {
bw[0] = c1
w.out.Write(bw[:])
continue
}
c2, err := er.ReadByte()
if err != nil {
break loop
}
if c2 == ']' {
w.rest.WriteByte(c1)
w.rest.WriteByte(c2)
er.WriteTo(&w.rest)
if bytes.IndexByte(w.rest.Bytes(), 0x07) == -1 {
break loop
}
er = bytes.NewReader(w.rest.Bytes()[2:])
err := doTitleSequence(er)
if err != nil {
break loop
}
w.rest.Reset()
continue
}
if c2 != 0x5b {
continue
}
w.rest.WriteByte(c1)
w.rest.WriteByte(c2)
er.WriteTo(&w.rest)
var buf bytes.Buffer
var m byte
for i, c := range w.rest.Bytes()[2:] {
if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' {
m = c
er = bytes.NewReader(w.rest.Bytes()[2+i+1:])
w.rest.Reset()
break
}
buf.Write([]byte(string(c)))
}
if m == 0 {
break loop
}
switch m {
case 'A':
n, err = strconv.Atoi(buf.String())
if err != nil {
continue
}
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
csbi.cursorPosition.y -= short(n)
procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
case 'B':
n, err = strconv.Atoi(buf.String())
if err != nil {
continue
}
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
csbi.cursorPosition.y += short(n)
procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
case 'C':
n, err = strconv.Atoi(buf.String())
if err != nil {
continue
}
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
csbi.cursorPosition.x += short(n)
procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
case 'D':
n, err = strconv.Atoi(buf.String())
if err != nil {
continue
}
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
csbi.cursorPosition.x -= short(n)
if csbi.cursorPosition.x < 0 {
csbi.cursorPosition.x = 0
}
procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
case 'E':
n, err = strconv.Atoi(buf.String())
if err != nil {
continue
}
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
csbi.cursorPosition.x = 0
csbi.cursorPosition.y += short(n)
procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
case 'F':
n, err = strconv.Atoi(buf.String())
if err != nil {
continue
}
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
csbi.cursorPosition.x = 0
csbi.cursorPosition.y -= short(n)
procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
case 'G':
n, err = strconv.Atoi(buf.String())
if err != nil {
continue
}
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
csbi.cursorPosition.x = short(n - 1)
procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
case 'H', 'f':
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
if buf.Len() > 0 {
token := strings.Split(buf.String(), ";")
switch len(token) {
case 1:
n1, err := strconv.Atoi(token[0])
if err != nil {
continue
}
csbi.cursorPosition.y = short(n1 - 1)
case 2:
n1, err := strconv.Atoi(token[0])
if err != nil {
continue
}
n2, err := strconv.Atoi(token[1])
if err != nil {
continue
}
csbi.cursorPosition.x = short(n2 - 1)
csbi.cursorPosition.y = short(n1 - 1)
}
} else {
csbi.cursorPosition.y = 0
}
procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
case 'J':
n := 0
if buf.Len() > 0 {
n, err = strconv.Atoi(buf.String())
if err != nil {
continue
}
}
var count, written dword
var cursor coord
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
switch n {
case 0:
cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y}
count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.size.y-csbi.cursorPosition.y)*csbi.size.x)
case 1:
cursor = coord{x: csbi.window.left, y: csbi.window.top}
count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.window.top-csbi.cursorPosition.y)*csbi.size.x)
case 2:
cursor = coord{x: csbi.window.left, y: csbi.window.top}
count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.size.y-csbi.cursorPosition.y)*csbi.size.x)
}
procFillConsoleOutputCharacter.Call(uintptr(handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
procFillConsoleOutputAttribute.Call(uintptr(handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
case 'K':
n := 0
if buf.Len() > 0 {
n, err = strconv.Atoi(buf.String())
if err != nil {
continue
}
}
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
var cursor coord
var count, written dword
switch n {
case 0:
cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y}
count = dword(csbi.size.x - csbi.cursorPosition.x)
case 1:
cursor = coord{x: csbi.window.left, y: csbi.window.top + csbi.cursorPosition.y}
count = dword(csbi.size.x - csbi.cursorPosition.x)
case 2:
cursor = coord{x: csbi.window.left, y: csbi.window.top + csbi.cursorPosition.y}
count = dword(csbi.size.x)
}
procFillConsoleOutputCharacter.Call(uintptr(handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
procFillConsoleOutputAttribute.Call(uintptr(handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
case 'm':
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
attr := csbi.attributes
cs := buf.String()
if cs == "" {
procSetConsoleTextAttribute.Call(uintptr(handle), uintptr(w.oldattr))
continue
}
token := strings.Split(cs, ";")
for i := 0; i < len(token); i++ {
ns := token[i]
if n, err = strconv.Atoi(ns); err == nil {
switch {
case n == 0 || n == 100:
attr = w.oldattr
case 1 <= n && n <= 5:
attr |= foregroundIntensity
case n == 7:
attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4)
case n == 22 || n == 25:
attr |= foregroundIntensity
case n == 27:
attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4)
case 30 <= n && n <= 37:
attr &= backgroundMask
if (n-30)&1 != 0 {
attr |= foregroundRed
}
if (n-30)&2 != 0 {
attr |= foregroundGreen
}
if (n-30)&4 != 0 {
attr |= foregroundBlue
}
case n == 38: // set foreground color.
if i < len(token)-2 && (token[i+1] == "5" || token[i+1] == "05") {
if n256, err := strconv.Atoi(token[i+2]); err == nil {
if n256foreAttr == nil {
n256setup()
}
attr &= backgroundMask
attr |= n256foreAttr[n256]
i += 2
}
} else if len(token) == 5 && token[i+1] == "2" {
var r, g, b int
r, _ = strconv.Atoi(token[i+2])
g, _ = strconv.Atoi(token[i+3])
b, _ = strconv.Atoi(token[i+4])
i += 4
if r > 127 {
attr |= foregroundRed
}
if g > 127 {
attr |= foregroundGreen
}
if b > 127 {
attr |= foregroundBlue
}
} else {
attr = attr & (w.oldattr & backgroundMask)
}
case n == 39: // reset foreground color.
attr &= backgroundMask
attr |= w.oldattr & foregroundMask
case 40 <= n && n <= 47:
attr &= foregroundMask
if (n-40)&1 != 0 {
attr |= backgroundRed
}
if (n-40)&2 != 0 {
attr |= backgroundGreen
}
if (n-40)&4 != 0 {
attr |= backgroundBlue
}
case n == 48: // set background color.
if i < len(token)-2 && token[i+1] == "5" {
if n256, err := strconv.Atoi(token[i+2]); err == nil {
if n256backAttr == nil {
n256setup()
}
attr &= foregroundMask
attr |= n256backAttr[n256]
i += 2
}
} else if len(token) == 5 && token[i+1] == "2" {
var r, g, b int
r, _ = strconv.Atoi(token[i+2])
g, _ = strconv.Atoi(token[i+3])
b, _ = strconv.Atoi(token[i+4])
i += 4
if r > 127 {
attr |= backgroundRed
}
if g > 127 {
attr |= backgroundGreen
}
if b > 127 {
attr |= backgroundBlue
}
} else {
attr = attr & (w.oldattr & foregroundMask)
}
case n == 49: // reset foreground color.
attr &= foregroundMask
attr |= w.oldattr & backgroundMask
case 90 <= n && n <= 97:
attr = (attr & backgroundMask)
attr |= foregroundIntensity
if (n-90)&1 != 0 {
attr |= foregroundRed
}
if (n-90)&2 != 0 {
attr |= foregroundGreen
}
if (n-90)&4 != 0 {
attr |= foregroundBlue
}
case 100 <= n && n <= 107:
attr = (attr & foregroundMask)
attr |= backgroundIntensity
if (n-100)&1 != 0 {
attr |= backgroundRed
}
if (n-100)&2 != 0 {
attr |= backgroundGreen
}
if (n-100)&4 != 0 {
attr |= backgroundBlue
}
}
procSetConsoleTextAttribute.Call(uintptr(handle), uintptr(attr))
}
}
case 'h':
var ci consoleCursorInfo
cs := buf.String()
if cs == "5>" {
procGetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci)))
ci.visible = 0
procSetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci)))
} else if cs == "?25" {
procGetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci)))
ci.visible = 1
procSetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci)))
} else if cs == "?1049" {
if w.althandle == 0 {
h, _, _ := procCreateConsoleScreenBuffer.Call(uintptr(genericRead|genericWrite), 0, 0, uintptr(consoleTextmodeBuffer), 0, 0)
w.althandle = syscall.Handle(h)
if w.althandle != 0 {
handle = w.althandle
}
}
}
case 'l':
var ci consoleCursorInfo
cs := buf.String()
if cs == "5>" {
procGetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci)))
ci.visible = 1
procSetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci)))
} else if cs == "?25" {
procGetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci)))
ci.visible = 0
procSetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci)))
} else if cs == "?1049" {
if w.althandle != 0 {
syscall.CloseHandle(w.althandle)
w.althandle = 0
handle = w.handle
}
}
case 's':
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
w.oldpos = csbi.cursorPosition
case 'u':
procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&w.oldpos)))
}
}
return len(data), nil
}
type consoleColor struct {
rgb int
red bool
green bool
blue bool
intensity bool
}
func (c consoleColor) foregroundAttr() (attr word) {
if c.red {
attr |= foregroundRed
}
if c.green {
attr |= foregroundGreen
}
if c.blue {
attr |= foregroundBlue
}
if c.intensity {
attr |= foregroundIntensity
}
return
}
func (c consoleColor) backgroundAttr() (attr word) {
if c.red {
attr |= backgroundRed
}
if c.green {
attr |= backgroundGreen
}
if c.blue {
attr |= backgroundBlue
}
if c.intensity {
attr |= backgroundIntensity
}
return
}
var color16 = []consoleColor{
{0x000000, false, false, false, false},
{0x000080, false, false, true, false},
{0x008000, false, true, false, false},
{0x008080, false, true, true, false},
{0x800000, true, false, false, false},
{0x800080, true, false, true, false},
{0x808000, true, true, false, false},
{0xc0c0c0, true, true, true, false},
{0x808080, false, false, false, true},
{0x0000ff, false, false, true, true},
{0x00ff00, false, true, false, true},
{0x00ffff, false, true, true, true},
{0xff0000, true, false, false, true},
{0xff00ff, true, false, true, true},
{0xffff00, true, true, false, true},
{0xffffff, true, true, true, true},
}
type hsv struct {
h, s, v float32
}
func (a hsv) dist(b hsv) float32 {
dh := a.h - b.h
switch {
case dh > 0.5:
dh = 1 - dh
case dh < -0.5:
dh = -1 - dh
}
ds := a.s - b.s
dv := a.v - b.v
return float32(math.Sqrt(float64(dh*dh + ds*ds + dv*dv)))
}
func toHSV(rgb int) hsv {
r, g, b := float32((rgb&0xFF0000)>>16)/256.0,
float32((rgb&0x00FF00)>>8)/256.0,
float32(rgb&0x0000FF)/256.0
min, max := minmax3f(r, g, b)
h := max - min
if h > 0 {
if max == r {
h = (g - b) / h
if h < 0 {
h += 6
}
} else if max == g {
h = 2 + (b-r)/h
} else {
h = 4 + (r-g)/h
}
}
h /= 6.0
s := max - min
if max != 0 {
s /= max
}
v := max
return hsv{h: h, s: s, v: v}
}
type hsvTable []hsv
func toHSVTable(rgbTable []consoleColor) hsvTable {
t := make(hsvTable, len(rgbTable))
for i, c := range rgbTable {
t[i] = toHSV(c.rgb)
}
return t
}
func (t hsvTable) find(rgb int) consoleColor {
hsv := toHSV(rgb)
n := 7
l := float32(5.0)
for i, p := range t {
d := hsv.dist(p)
if d < l {
l, n = d, i
}
}
return color16[n]
}
func minmax3f(a, b, c float32) (min, max float32) {
if a < b {
if b < c {
return a, c
} else if a < c {
return a, b
} else {
return c, b
}
} else {
if a < c {
return b, c
} else if b < c {
return b, a
} else {
return c, a
}
}
}
var n256foreAttr []word
var n256backAttr []word
func n256setup() {
n256foreAttr = make([]word, 256)
n256backAttr = make([]word, 256)
t := toHSVTable(color16)
for i, rgb := range color256 {
c := t.find(rgb)
n256foreAttr[i] = c.foregroundAttr()
n256backAttr[i] = c.backgroundAttr()
}
}

View File

@@ -1,55 +0,0 @@
package colorable
import (
"bytes"
"io"
)
// NonColorable hold writer but remove escape sequence.
type NonColorable struct {
out io.Writer
}
// NewNonColorable return new instance of Writer which remove escape sequence from Writer.
func NewNonColorable(w io.Writer) io.Writer {
return &NonColorable{out: w}
}
// Write write data on console
func (w *NonColorable) Write(data []byte) (n int, err error) {
er := bytes.NewReader(data)
var bw [1]byte
loop:
for {
c1, err := er.ReadByte()
if err != nil {
break loop
}
if c1 != 0x1b {
bw[0] = c1
w.out.Write(bw[:])
continue
}
c2, err := er.ReadByte()
if err != nil {
break loop
}
if c2 != 0x5b {
continue
}
var buf bytes.Buffer
for {
c, err := er.ReadByte()
if err != nil {
break loop
}
if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' {
break
}
buf.Write([]byte(string(c)))
}
}
return len(data), nil
}

View File

@@ -1,9 +0,0 @@
language: go
go:
- tip
before_install:
- go get github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/cover
script:
- $HOME/gopath/bin/goveralls -repotoken 3gHdORO5k5ziZcWMBxnd9LrMZaJs8m9x5

View File

@@ -1,9 +0,0 @@
Copyright (c) Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
MIT License (Expat)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,50 +0,0 @@
# go-isatty
[![Godoc Reference](https://godoc.org/github.com/mattn/go-isatty?status.svg)](http://godoc.org/github.com/mattn/go-isatty)
[![Build Status](https://travis-ci.org/mattn/go-isatty.svg?branch=master)](https://travis-ci.org/mattn/go-isatty)
[![Coverage Status](https://coveralls.io/repos/github/mattn/go-isatty/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-isatty?branch=master)
[![Go Report Card](https://goreportcard.com/badge/mattn/go-isatty)](https://goreportcard.com/report/mattn/go-isatty)
isatty for golang
## Usage
```go
package main
import (
"fmt"
"github.com/mattn/go-isatty"
"os"
)
func main() {
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Println("Is Terminal")
} else if isatty.IsCygwinTerminal(os.Stdout.Fd()) {
fmt.Println("Is Cygwin/MSYS2 Terminal")
} else {
fmt.Println("Is Not Terminal")
}
}
```
## Installation
```
$ go get github.com/mattn/go-isatty
```
## License
MIT
## Author
Yasuhiro Matsumoto (a.k.a mattn)
## Thanks
* k-takata: base idea for IsCygwinTerminal
https://github.com/k-takata/go-iscygpty

View File

@@ -1,2 +0,0 @@
// Package isatty implements interface to isatty
package isatty

View File

@@ -1,15 +0,0 @@
// +build appengine
package isatty
// IsTerminal returns true if the file descriptor is terminal which
// is always false on on appengine classic which is a sandboxed PaaS.
func IsTerminal(fd uintptr) bool {
return false
}
// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
// terminal. This is also always false on this environment.
func IsCygwinTerminal(fd uintptr) bool {
return false
}

View File

@@ -1,18 +0,0 @@
// +build darwin freebsd openbsd netbsd dragonfly
// +build !appengine
package isatty
import (
"syscall"
"unsafe"
)
const ioctlReadTermios = syscall.TIOCGETA
// IsTerminal return true if the file descriptor is terminal.
func IsTerminal(fd uintptr) bool {
var termios syscall.Termios
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
return err == 0
}

View File

@@ -1,18 +0,0 @@
// +build linux
// +build !appengine
package isatty
import (
"syscall"
"unsafe"
)
const ioctlReadTermios = syscall.TCGETS
// IsTerminal return true if the file descriptor is terminal.
func IsTerminal(fd uintptr) bool {
var termios syscall.Termios
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
return err == 0
}

View File

@@ -1,10 +0,0 @@
// +build !windows
// +build !appengine
package isatty
// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
// terminal. This is also always false on this environment.
func IsCygwinTerminal(fd uintptr) bool {
return false
}

View File

@@ -1,16 +0,0 @@
// +build solaris
// +build !appengine
package isatty
import (
"golang.org/x/sys/unix"
)
// IsTerminal returns true if the given file descriptor is a terminal.
// see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c
func IsTerminal(fd uintptr) bool {
var termio unix.Termio
err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio)
return err == nil
}

View File

@@ -1,94 +0,0 @@
// +build windows
// +build !appengine
package isatty
import (
"strings"
"syscall"
"unicode/utf16"
"unsafe"
)
const (
fileNameInfo uintptr = 2
fileTypePipe = 3
)
var (
kernel32 = syscall.NewLazyDLL("kernel32.dll")
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx")
procGetFileType = kernel32.NewProc("GetFileType")
)
func init() {
// Check if GetFileInformationByHandleEx is available.
if procGetFileInformationByHandleEx.Find() != nil {
procGetFileInformationByHandleEx = nil
}
}
// IsTerminal return true if the file descriptor is terminal.
func IsTerminal(fd uintptr) bool {
var st uint32
r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0)
return r != 0 && e == 0
}
// Check pipe name is used for cygwin/msys2 pty.
// Cygwin/MSYS2 PTY has a name like:
// \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master
func isCygwinPipeName(name string) bool {
token := strings.Split(name, "-")
if len(token) < 5 {
return false
}
if token[0] != `\msys` && token[0] != `\cygwin` {
return false
}
if token[1] == "" {
return false
}
if !strings.HasPrefix(token[2], "pty") {
return false
}
if token[3] != `from` && token[3] != `to` {
return false
}
if token[4] != "master" {
return false
}
return true
}
// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
// terminal.
func IsCygwinTerminal(fd uintptr) bool {
if procGetFileInformationByHandleEx == nil {
return false
}
// Cygwin/msys's pty is a pipe.
ft, _, e := syscall.Syscall(procGetFileType.Addr(), 1, fd, 0, 0)
if ft != fileTypePipe || e != 0 {
return false
}
var buf [2 + syscall.MAX_PATH]uint16
r, _, e := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(),
4, fd, fileNameInfo, uintptr(unsafe.Pointer(&buf)),
uintptr(len(buf)*2), 0, 0)
if r == 0 || e != 0 {
return false
}
l := *(*uint32)(unsafe.Pointer(&buf))
return isCygwinPipeName(string(utf16.Decode(buf[2 : 2+l/2])))
}

View File

@@ -1,4 +0,0 @@
language: go
sudo: false
go:
- tip

View File

@@ -1,49 +0,0 @@
# go-tty
Simple tty utility
## Usage
```go
tty, err := tty.Open()
if err != nil {
log.Fatal(err)
}
defer tty.Close()
for {
r, err := tty.ReadRune()
if err != nil {
log.Fatal(err)
}
// handle key event
}
```
if you are on windows and want to display ANSI colors, use <a href="https://github.com/mattn/go-colorable">go-colorable</a>.
```go
tty, err := tty.Open()
if err != nil {
log.Fatal(err)
}
defer tty.Close()
out := colorable.NewColorable(tty.Output())
fmt.Fprintln(out, "\x1b[2J")
```
## Installation
```
$ go get github.com/mattn/go-tty
```
## License
MIT
## Author
Yasuhiro Matsumoto (a.k.a mattn)

120
vendor/github.com/mattn/go-tty/tty.go generated vendored
View File

@@ -1,120 +0,0 @@
package tty
import (
"os"
"strings"
"unicode"
)
func Open() (*TTY, error) {
return open()
}
func (tty *TTY) Raw() (func() error, error) {
return tty.raw()
}
func (tty *TTY) MustRaw() func() error {
f, err := tty.raw()
if err != nil {
panic(err.Error())
}
return f
}
func (tty *TTY) Buffered() bool {
return tty.buffered()
}
func (tty *TTY) ReadRune() (rune, error) {
return tty.readRune()
}
func (tty *TTY) Close() error {
return tty.close()
}
func (tty *TTY) Size() (int, int, error) {
return tty.size()
}
func (tty *TTY) Input() *os.File {
return tty.input()
}
func (tty *TTY) Output() *os.File {
return tty.output()
}
// Display types.
const (
displayNone = iota
displayRune
displayMask
)
func (tty *TTY) readString(displayType int) (string, error) {
rs := []rune{}
loop:
for {
r, err := tty.readRune()
if err != nil {
return "", err
}
switch r {
case 13:
break loop
case 8, 127:
if len(rs) > 0 {
rs = rs[:len(rs)-1]
if displayType != displayNone {
tty.Output().WriteString("\b \b")
}
}
default:
if unicode.IsPrint(r) {
rs = append(rs, r)
switch displayType {
case displayRune:
tty.Output().WriteString(string(r))
case displayMask:
tty.Output().WriteString("*")
}
}
}
}
return string(rs), nil
}
func (tty *TTY) ReadString() (string, error) {
defer tty.Output().WriteString("\n")
return tty.readString(displayRune)
}
func (tty *TTY) ReadPassword() (string, error) {
defer tty.Output().WriteString("\n")
return tty.readString(displayMask)
}
func (tty *TTY) ReadPasswordNoEcho() (string, error) {
defer tty.Output().WriteString("\n")
return tty.readString(displayNone)
}
func (tty *TTY) ReadPasswordClear() (string, error) {
s, err := tty.readString(displayMask)
tty.Output().WriteString(
strings.Repeat("\b", len(s)) +
strings.Repeat(" ", len(s)) +
strings.Repeat("\b", len(s)))
return s, err
}
type WINSIZE struct {
W int
H int
}
func (tty *TTY) SIGWINCH() chan WINSIZE {
return tty.sigwinch()
}

View File

@@ -1,12 +0,0 @@
// +build darwin dragonfly freebsd netbsd openbsd
package tty
import (
"syscall"
)
const (
ioctlReadTermios = syscall.TIOCGETA
ioctlWriteTermios = syscall.TIOCSETA
)

View File

@@ -1,8 +0,0 @@
// +build linux
package tty
const (
ioctlReadTermios = 0x5401 // syscall.TCGETS
ioctlWriteTermios = 0x5402 // syscall.TCSETS
)

View File

@@ -1,63 +0,0 @@
package tty
import (
"bufio"
"os"
"syscall"
)
type TTY struct {
in *os.File
bin *bufio.Reader
out *os.File
}
func open() (*TTY, error) {
tty := new(TTY)
in, err := os.Open("/dev/cons")
if err != nil {
return nil, err
}
tty.in = in
tty.bin = bufio.NewReader(in)
out, err := os.OpenFile("/dev/cons", syscall.O_WRONLY, 0)
if err != nil {
return nil, err
}
tty.out = out
return tty, nil
}
func (tty *TTY) buffered() bool {
return tty.bin.Buffered() > 0
}
func (tty *TTY) readRune() (rune, error) {
r, _, err := tty.bin.ReadRune()
return r, err
}
func (tty *TTY) close() (err error) {
if err2 := tty.in.Close(); err2 != nil {
err = err2
}
if err2 := tty.out.Close(); err2 != nil {
err = err2
}
return
}
func (tty *TTY) size() (int, int, error) {
return 80, 24, nil
}
func (tty *TTY) input() *os.File {
return tty.in
}
func (tty *TTY) output() *os.File {
return tty.out
}

View File

@@ -1,126 +0,0 @@
// +build !windows
// +build !plan9
package tty
import (
"bufio"
"os"
"os/signal"
"syscall"
"unsafe"
"golang.org/x/sys/unix"
)
type TTY struct {
in *os.File
bin *bufio.Reader
out *os.File
termios syscall.Termios
ws chan WINSIZE
ss chan os.Signal
}
func open() (*TTY, error) {
tty := new(TTY)
in, err := os.Open("/dev/tty")
if err != nil {
return nil, err
}
tty.in = in
tty.bin = bufio.NewReader(in)
out, err := os.OpenFile("/dev/tty", syscall.O_WRONLY, 0)
if err != nil {
return nil, err
}
tty.out = out
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(tty.in.Fd()), ioctlReadTermios, uintptr(unsafe.Pointer(&tty.termios)), 0, 0, 0); err != 0 {
return nil, err
}
newios := tty.termios
newios.Iflag &^= syscall.ISTRIP | syscall.INLCR | syscall.ICRNL | syscall.IGNCR | syscall.IXON | syscall.IXOFF
newios.Lflag &^= syscall.ECHO | syscall.ICANON /*| syscall.ISIG*/
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(tty.in.Fd()), ioctlWriteTermios, uintptr(unsafe.Pointer(&newios)), 0, 0, 0); err != 0 {
return nil, err
}
tty.ws = make(chan WINSIZE)
tty.ss = make(chan os.Signal, 1)
signal.Notify(tty.ss, syscall.SIGWINCH)
go func() {
for sig := range tty.ss {
switch sig {
case syscall.SIGWINCH:
if w, h, err := tty.size(); err == nil {
tty.ws <- WINSIZE{
W: w,
H: h,
}
}
default:
}
}
}()
return tty, nil
}
func (tty *TTY) buffered() bool {
return tty.bin.Buffered() > 0
}
func (tty *TTY) readRune() (rune, error) {
r, _, err := tty.bin.ReadRune()
return r, err
}
func (tty *TTY) close() error {
close(tty.ss)
close(tty.ws)
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(tty.in.Fd()), ioctlWriteTermios, uintptr(unsafe.Pointer(&tty.termios)), 0, 0, 0)
return err
}
func (tty *TTY) size() (int, int, error) {
var dim [4]uint16
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(tty.out.Fd()), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&dim)), 0, 0, 0); err != 0 {
return -1, -1, err
}
return int(dim[1]), int(dim[0]), nil
}
func (tty *TTY) input() *os.File {
return tty.in
}
func (tty *TTY) output() *os.File {
return tty.out
}
func (tty *TTY) raw() (func() error, error) {
termios, err := unix.IoctlGetTermios(int(tty.in.Fd()), ioctlReadTermios)
if err != nil {
return nil, err
}
termios.Iflag &^= unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON
termios.Oflag &^= unix.OPOST
termios.Lflag &^= unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN
termios.Cflag &^= unix.CSIZE | unix.PARENB
termios.Cflag |= unix.CS8
termios.Cc[unix.VMIN] = 1
termios.Cc[unix.VTIME] = 0
if err := unix.IoctlSetTermios(int(tty.in.Fd()), ioctlWriteTermios, termios); err != nil {
return nil, err
}
return func() error {
if err := unix.IoctlSetTermios(int(tty.in.Fd()), ioctlWriteTermios, termios); err != nil {
return err
}
return nil
}, nil
}

View File

@@ -1,323 +0,0 @@
// +build windows
package tty
import (
"os"
"syscall"
"unsafe"
"github.com/mattn/go-isatty"
)
const (
rightAltPressed = 1
leftAltPressed = 2
rightCtrlPressed = 4
leftCtrlPressed = 8
shiftPressed = 0x0010
ctrlPressed = rightCtrlPressed | leftCtrlPressed
altPressed = rightAltPressed | leftAltPressed
)
const (
enableProcessedInput = 0x1
enableLineInput = 0x2
enableEchoInput = 0x4
enableWindowInput = 0x8
enableMouseInput = 0x10
enableInsertMode = 0x20
enableQuickEditMode = 0x40
enableExtendedFlag = 0x80
enableProcessedOutput = 1
enableWrapAtEolOutput = 2
keyEvent = 0x1
mouseEvent = 0x2
windowBufferSizeEvent = 0x4
)
var kernel32 = syscall.NewLazyDLL("kernel32.dll")
var (
procAllocConsole = kernel32.NewProc("AllocConsole")
procSetStdHandle = kernel32.NewProc("SetStdHandle")
procGetStdHandle = kernel32.NewProc("GetStdHandle")
procSetConsoleScreenBufferSize = kernel32.NewProc("SetConsoleScreenBufferSize")
procCreateConsoleScreenBuffer = kernel32.NewProc("CreateConsoleScreenBuffer")
procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo")
procWriteConsoleOutputCharacter = kernel32.NewProc("WriteConsoleOutputCharacterW")
procWriteConsoleOutputAttribute = kernel32.NewProc("WriteConsoleOutputAttribute")
procGetConsoleCursorInfo = kernel32.NewProc("GetConsoleCursorInfo")
procSetConsoleCursorInfo = kernel32.NewProc("SetConsoleCursorInfo")
procSetConsoleCursorPosition = kernel32.NewProc("SetConsoleCursorPosition")
procReadConsoleInput = kernel32.NewProc("ReadConsoleInputW")
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
procSetConsoleMode = kernel32.NewProc("SetConsoleMode")
procFillConsoleOutputCharacter = kernel32.NewProc("FillConsoleOutputCharacterW")
procFillConsoleOutputAttribute = kernel32.NewProc("FillConsoleOutputAttribute")
procScrollConsoleScreenBuffer = kernel32.NewProc("ScrollConsoleScreenBufferW")
)
type wchar uint16
type short int16
type dword uint32
type word uint16
type coord struct {
x short
y short
}
type smallRect struct {
left short
top short
right short
bottom short
}
type consoleScreenBufferInfo struct {
size coord
cursorPosition coord
attributes word
window smallRect
maximumWindowSize coord
}
type consoleCursorInfo struct {
size dword
visible int32
}
type inputRecord struct {
eventType word
_ [2]byte
event [16]byte
}
type keyEventRecord struct {
keyDown int32
repeatCount word
virtualKeyCode word
virtualScanCode word
unicodeChar wchar
controlKeyState dword
}
type windowBufferSizeRecord struct {
size coord
}
type mouseEventRecord struct {
mousePos coord
buttonState dword
controlKeyState dword
eventFlags dword
}
type charInfo struct {
unicodeChar wchar
attributes word
}
type TTY struct {
in *os.File
out *os.File
st uint32
rs []rune
ws chan WINSIZE
}
func readConsoleInput(fd uintptr, record *inputRecord) (err error) {
var w uint32
r1, _, err := procReadConsoleInput.Call(fd, uintptr(unsafe.Pointer(record)), 1, uintptr(unsafe.Pointer(&w)))
if r1 == 0 {
return err
}
return nil
}
func open() (*TTY, error) {
tty := new(TTY)
if false && isatty.IsTerminal(os.Stdin.Fd()) {
tty.in = os.Stdin
} else {
conin, err := os.Open("CONIN$")
if err != nil {
return nil, err
}
tty.in = conin
}
if isatty.IsTerminal(os.Stdout.Fd()) {
tty.out = os.Stdout
} else {
procAllocConsole.Call()
out, err := syscall.Open("CONOUT$", syscall.O_RDWR, 0)
if err != nil {
return nil, err
}
tty.out = os.NewFile(uintptr(out), "/dev/tty")
}
h := tty.in.Fd()
var st uint32
r1, _, err := procGetConsoleMode.Call(h, uintptr(unsafe.Pointer(&st)))
if r1 == 0 {
return nil, err
}
tty.st = st
st &^= enableEchoInput
st &^= enableInsertMode
st &^= enableLineInput
st &^= enableMouseInput
st &^= enableWindowInput
st &^= enableExtendedFlag
st &^= enableQuickEditMode
st |= enableProcessedInput
// ignore error
procSetConsoleMode.Call(h, uintptr(st))
tty.ws = make(chan WINSIZE)
return tty, nil
}
func (tty *TTY) buffered() bool {
return len(tty.rs) > 0
}
func (tty *TTY) readRune() (rune, error) {
if len(tty.rs) > 0 {
r := tty.rs[0]
tty.rs = tty.rs[1:]
return r, nil
}
var ir inputRecord
err := readConsoleInput(tty.in.Fd(), &ir)
if err != nil {
return 0, err
}
switch ir.eventType {
case windowBufferSizeEvent:
wr := (*windowBufferSizeRecord)(unsafe.Pointer(&ir.event))
tty.ws <- WINSIZE{
W: int(wr.size.x),
H: int(wr.size.y),
}
case keyEvent:
kr := (*keyEventRecord)(unsafe.Pointer(&ir.event))
if kr.keyDown != 0 {
if kr.controlKeyState&altPressed != 0 && kr.unicodeChar > 0 {
tty.rs = []rune{rune(kr.unicodeChar)}
return rune(0x1b), nil
}
if kr.unicodeChar > 0 {
if kr.controlKeyState&shiftPressed != 0 {
switch kr.unicodeChar {
case 0x09:
tty.rs = []rune{0x5b, 0x5a}
return rune(0x1b), nil
}
}
return rune(kr.unicodeChar), nil
}
vk := kr.virtualKeyCode
switch vk {
case 0x21: // page-up
tty.rs = []rune{0x5b, 0x35, 0x7e}
return rune(0x1b), nil
case 0x22: // page-down
tty.rs = []rune{0x5b, 0x36, 0x7e}
return rune(0x1b), nil
case 0x23: // end
tty.rs = []rune{0x5b, 0x46}
return rune(0x1b), nil
case 0x24: // home
tty.rs = []rune{0x5b, 0x48}
return rune(0x1b), nil
case 0x25: // left
tty.rs = []rune{0x5b, 0x44}
return rune(0x1b), nil
case 0x26: // up
tty.rs = []rune{0x5b, 0x41}
return rune(0x1b), nil
case 0x27: // right
tty.rs = []rune{0x5b, 0x43}
return rune(0x1b), nil
case 0x28: // down
tty.rs = []rune{0x5b, 0x42}
return rune(0x1b), nil
case 0x2e: // delete
tty.rs = []rune{0x5b, 0x33, 0x7e}
return rune(0x1b), nil
case 0x70, 0x71, 0x72, 0x73: // F1,F2,F3,F4
tty.rs = []rune{0x5b, 0x4f, rune(vk) - 0x20}
return rune(0x1b), nil
case 0x074, 0x75, 0x76, 0x77: // F5,F6,F7,F8
tty.rs = []rune{0x5b, 0x31, rune(vk) - 0x3f, 0x7e}
return rune(0x1b), nil
case 0x78, 0x79: // F9,F10
tty.rs = []rune{0x5b, 0x32, rune(vk) - 0x48, 0x7e}
return rune(0x1b), nil
case 0x7a, 0x7b: // F11,F12
tty.rs = []rune{0x5b, 0x32, rune(vk) - 0x47, 0x7e}
return rune(0x1b), nil
}
return 0, nil
}
}
return 0, nil
}
func (tty *TTY) close() error {
close(tty.ws)
procSetConsoleMode.Call(tty.in.Fd(), uintptr(tty.st))
return nil
}
func (tty *TTY) size() (int, int, error) {
var csbi consoleScreenBufferInfo
r1, _, err := procGetConsoleScreenBufferInfo.Call(tty.out.Fd(), uintptr(unsafe.Pointer(&csbi)))
if r1 == 0 {
return 0, 0, err
}
return int(csbi.window.right - csbi.window.left + 1), int(csbi.window.bottom - csbi.window.top + 1), nil
}
func (tty *TTY) input() *os.File {
return tty.in
}
func (tty *TTY) output() *os.File {
return tty.out
}
func (tty *TTY) raw() (func() error, error) {
var st uint32
r1, _, err := procGetConsoleMode.Call(tty.in.Fd(), uintptr(unsafe.Pointer(&st)))
if r1 == 0 {
return nil, err
}
mode := st &^ (enableEchoInput | enableProcessedInput | enableLineInput | enableProcessedOutput)
r1, _, err = procSetConsoleMode.Call(tty.in.Fd(), uintptr(mode))
if r1 == 0 {
return nil, err
}
return func() error {
r1, _, err := procSetConsoleMode.Call(tty.in.Fd(), uintptr(st))
if r1 == 0 {
return err
}
return nil
}, nil
}
func (tty *TTY) sigwinch() chan WINSIZE {
return tty.ws
}

View File

@@ -1,4 +0,0 @@
./bin
./.dapper
./dist
./.trash-cache

View File

@@ -1,7 +0,0 @@
pipeline:
build:
image: rancher/dapper:1.10.3
volumes:
- /var/run/docker.sock:/var/run/docker.sock
commands:
- dapper ci

View File

@@ -1,5 +0,0 @@
/.dapper
/bin
/dist
*.swp
/.trash-cache

View File

@@ -1,30 +0,0 @@
FROM ubuntu:16.04
# FROM arm=armhf/ubuntu:16.04
ARG DAPPER_HOST_ARCH=amd64
ENV HOST_ARCH=${DAPPER_HOST_ARCH} ARCH=${DAPPER_HOST_ARCH}
RUN apt-get update && \
apt-get install -y gcc ca-certificates git wget curl vim less file && \
rm -f /bin/sh && ln -s /bin/bash /bin/sh
ENV GOLANG_ARCH_amd64=amd64 GOLANG_ARCH_arm=armv6l GOLANG_ARCH=GOLANG_ARCH_${ARCH} \
GOPATH=/go PATH=/go/bin:/usr/local/go/bin:${PATH} SHELL=/bin/bash
ENV DOCKER_URL_amd64=https://get.docker.com/builds/Linux/x86_64/docker-1.10.3 \
DOCKER_URL_arm=https://github.com/rancher/docker/releases/download/v1.10.3-ros1/docker-1.10.3_arm \
DOCKER_URL=DOCKER_URL_${ARCH}
RUN wget -O - ${!DOCKER_URL} > /usr/bin/docker && chmod +x /usr/bin/docker
RUN wget -O - https://storage.googleapis.com/golang/go1.7.1.linux-${!GOLANG_ARCH}.tar.gz | tar -xzf - -C /usr/local && \
go get github.com/rancher/trash && go get github.com/golang/lint/golint
ENV DAPPER_SOURCE /go/src/github.com/rancher/go-rancher/
ENV DAPPER_OUTPUT ./bin
ENV DAPPER_DOCKER_SOCKET true
ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache
ENV HOME ${DAPPER_SOURCE}
WORKDIR ${DAPPER_SOURCE}
ENTRYPOINT ["./scripts/entry"]
CMD ["ci"]

View File

@@ -1,177 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

View File

@@ -1,23 +0,0 @@
TARGETS := $(shell ls scripts)
.dapper:
@echo Downloading dapper
@curl -sL https://releases.rancher.com/dapper/latest/dapper-`uname -s`-`uname -m` > .dapper.tmp
@@chmod +x .dapper.tmp
@./.dapper.tmp -v
@mv .dapper.tmp .dapper
$(TARGETS): .dapper
./.dapper $@
trash: .dapper
./.dapper -m bind trash
trash-keep: .dapper
./.dapper -m bind trash -k
deps: trash
.DEFAULT_GOAL := ci
.PHONY: $(TARGETS)

View File

@@ -1,55 +0,0 @@
# Go Bindings for Rancher API
# Generating Code
First, you must have a master version of Rancher running. The best way to do this is:
```sh
docker run -p 8080:8080 -d rancher/server:master
```
Once Rancher is running, you can run the gen-schema.sh script:
```sh
./scripts/gen-schema.sh http://<docker host ip>:8080
# The default url is http://localhost:8080, so if rancher/server is listening on localhost, you can omit the url:
./scripts/gen-schema.sh
```
This will add, remove, and modify go files appropriately. Submit a PR that includes *all* these changes.
## Important caveats
1. If you are running on macOS, you must have gnu-sed installed as sed for this to work properly.
2. If you are running against cattle that is running out of an IDE and you don't have go-machine-service running (you probably don't), you'll see a number of unexpected removed or modified files like `generated_host.go` `generated_machine.go` and `generated_*config.go`.
# Building
```sh
godep go build ./client
```
# Tests
```sh
godep go test ./client
```
# Contact
For bugs, questions, comments, corrections, suggestions, etc., open an issue in
[rancher/rancher](//github.com/rancher/rancher/issues) with a title starting with `[go-rancher] `.
Or just [click here](//github.com/rancher/rancher/issues/new?title=%5Bgo-rancher%5D%20) to create a new issue.
# License
Copyright (c) 2014-2015 [Rancher Labs, Inc.](http://rancher.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -1,6 +0,0 @@
github.com/pkg/errors 1d2e60385a13aaa66134984235061c2f9302520e
github.com/gorilla/context 215affda49addc4c8ef7e2534915df2c8c35c6cd
github.com/gorilla/mux f15e0c49460fd49eebe2bcc8486b05d1bef68d3a
github.com/gorilla/websocket 1551221275a7bd42978745a376b2531f791d88f3
github.com/Sirupsen/logrus 26709e2714106fb8ad40b773b711ebce25b78914
gopkg.in/yaml.v2 a83829b6f1293c91addabc89d0571c246397bbf4

View File

@@ -1,39 +0,0 @@
package client
import (
"net/http"
"github.com/gorilla/websocket"
)
type RancherBaseClientImpl struct {
Opts *ClientOpts
Schemas *Schemas
Types map[string]Schema
}
type RancherBaseClient interface {
Websocket(string, map[string][]string) (*websocket.Conn, *http.Response, error)
List(string, *ListOpts, interface{}) error
Post(string, interface{}, interface{}) error
GetLink(Resource, string, interface{}) error
Create(string, interface{}, interface{}) error
Update(string, *Resource, interface{}, interface{}) error
ById(string, string, interface{}) error
Delete(*Resource) error
Reload(*Resource, interface{}) error
Action(string, string, *Resource, interface{}, interface{}) error
GetOpts() *ClientOpts
GetSchemas() *Schemas
GetTypes() map[string]Schema
doGet(string, *ListOpts, interface{}) error
doList(string, *ListOpts, interface{}) error
doNext(string, interface{}) error
doModify(string, string, interface{}, interface{}) error
doCreate(string, interface{}, interface{}) error
doUpdate(string, *Resource, interface{}, interface{}) error
doById(string, string, interface{}) error
doResourceDelete(string, *Resource) error
doAction(string, string, *Resource, interface{}, interface{}) error
}

View File

@@ -1,625 +0,0 @@
package client
import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
"regexp"
"strings"
"time"
"github.com/gorilla/websocket"
"github.com/pkg/errors"
)
const (
SELF = "self"
COLLECTION = "collection"
)
var (
debug = false
dialer = &websocket.Dialer{}
privateFieldRegex = regexp.MustCompile("^[[:lower:]]")
oldVersions = []string{"v1", "v2-beta", "v2"}
)
type ClientOpts struct {
Url string
AccessKey string
SecretKey string
Timeout time.Duration
}
type ApiError struct {
StatusCode int
Url string
Msg string
Status string
Body string
}
func (e *ApiError) Error() string {
return e.Msg
}
func IsNotFound(err error) bool {
apiError, ok := err.(*ApiError)
if !ok {
return false
}
return apiError.StatusCode == http.StatusNotFound
}
func newApiError(resp *http.Response, url string) *ApiError {
contents, err := ioutil.ReadAll(resp.Body)
var body string
if err != nil {
body = "Unreadable body."
} else {
body = string(contents)
}
data := map[string]interface{}{}
if json.Unmarshal(contents, &data) == nil {
delete(data, "id")
delete(data, "links")
delete(data, "actions")
delete(data, "type")
delete(data, "status")
buf := &bytes.Buffer{}
for k, v := range data {
if v == nil {
continue
}
if buf.Len() > 0 {
buf.WriteString(", ")
}
fmt.Fprintf(buf, "%s=%v", k, v)
}
body = buf.String()
}
formattedMsg := fmt.Sprintf("Bad response statusCode [%d]. Status [%s]. Body: [%s] from [%s]",
resp.StatusCode, resp.Status, body, url)
return &ApiError{
Url: url,
Msg: formattedMsg,
StatusCode: resp.StatusCode,
Status: resp.Status,
Body: body,
}
}
func contains(array []string, item string) bool {
for _, check := range array {
if check == item {
return true
}
}
return false
}
func appendFilters(urlString string, filters map[string]interface{}) (string, error) {
if len(filters) == 0 {
return urlString, nil
}
u, err := url.Parse(urlString)
if err != nil {
return "", err
}
q := u.Query()
for k, v := range filters {
if l, ok := v.([]string); ok {
for _, v := range l {
q.Add(k, v)
}
} else {
q.Add(k, fmt.Sprintf("%v", v))
}
}
u.RawQuery = q.Encode()
return u.String(), nil
}
func NormalizeUrl(existingUrl string) (string, error) {
u, err := url.Parse(existingUrl)
if err != nil {
return "", err
}
if u.Path == "" || u.Path == "/" {
u.Path = "v3"
} else {
for _, ver := range oldVersions {
if u.Path == "/"+ver || strings.HasPrefix(u.Path, "/"+ver+"/") {
u.Path = strings.Replace(u.Path, "/"+ver, "/v3", 1)
}
}
}
return u.String(), nil
}
func setupRancherBaseClient(rancherClient *RancherBaseClientImpl, opts *ClientOpts) error {
var err error
opts.Url, err = NormalizeUrl(opts.Url)
if err != nil {
return err
}
if opts.Timeout == 0 {
opts.Timeout = time.Second * 10
}
client := &http.Client{Timeout: opts.Timeout}
req, err := http.NewRequest("GET", opts.Url, nil)
if err != nil {
return err
}
req.SetBasicAuth(opts.AccessKey, opts.SecretKey)
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return newApiError(resp, opts.Url)
}
schemasUrls := resp.Header.Get("X-API-Schemas")
if len(schemasUrls) == 0 {
return errors.New("Failed to find schema at [" + opts.Url + "]")
}
if schemasUrls != opts.Url {
req, err = http.NewRequest("GET", schemasUrls, nil)
req.SetBasicAuth(opts.AccessKey, opts.SecretKey)
if err != nil {
return err
}
resp, err = client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return newApiError(resp, opts.Url)
}
}
var schemas Schemas
bytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
err = json.Unmarshal(bytes, &schemas)
if err != nil {
return err
}
rancherClient.Opts = opts
rancherClient.Schemas = &schemas
for _, schema := range schemas.Data {
rancherClient.Types[schema.Id] = schema
}
return nil
}
func NewListOpts() *ListOpts {
return &ListOpts{
Filters: map[string]interface{}{},
}
}
func (rancherClient *RancherBaseClientImpl) setupRequest(req *http.Request) {
req.SetBasicAuth(rancherClient.Opts.AccessKey, rancherClient.Opts.SecretKey)
}
func (rancherClient *RancherBaseClientImpl) newHttpClient() *http.Client {
if rancherClient.Opts.Timeout == 0 {
rancherClient.Opts.Timeout = time.Second * 10
}
return &http.Client{Timeout: rancherClient.Opts.Timeout}
}
func (rancherClient *RancherBaseClientImpl) doDelete(url string) error {
client := rancherClient.newHttpClient()
req, err := http.NewRequest("DELETE", url, nil)
if err != nil {
return err
}
rancherClient.setupRequest(req)
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
io.Copy(ioutil.Discard, resp.Body)
if resp.StatusCode >= 300 {
return newApiError(resp, url)
}
return nil
}
func (rancherClient *RancherBaseClientImpl) Websocket(url string, headers map[string][]string) (*websocket.Conn, *http.Response, error) {
httpHeaders := http.Header{}
for k, v := range httpHeaders {
httpHeaders[k] = v
}
if rancherClient.Opts != nil {
s := rancherClient.Opts.AccessKey + ":" + rancherClient.Opts.SecretKey
httpHeaders.Add("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(s)))
}
return dialer.Dial(url, http.Header(httpHeaders))
}
func (rancherClient *RancherBaseClientImpl) doGet(url string, opts *ListOpts, respObject interface{}) error {
if opts == nil {
opts = NewListOpts()
}
url, err := appendFilters(url, opts.Filters)
if err != nil {
return err
}
if debug {
fmt.Println("GET " + url)
}
client := rancherClient.newHttpClient()
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return err
}
rancherClient.setupRequest(req)
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return newApiError(resp, url)
}
byteContent, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
if debug {
fmt.Println("Response <= " + string(byteContent))
}
if err := json.Unmarshal(byteContent, respObject); err != nil {
return errors.Wrap(err, fmt.Sprintf("Failed to parse: %s", byteContent))
}
return nil
}
func (rancherClient *RancherBaseClientImpl) List(schemaType string, opts *ListOpts, respObject interface{}) error {
return rancherClient.doList(schemaType, opts, respObject)
}
func (rancherClient *RancherBaseClientImpl) doList(schemaType string, opts *ListOpts, respObject interface{}) error {
schema, ok := rancherClient.Types[schemaType]
if !ok {
return errors.New("Unknown schema type [" + schemaType + "]")
}
if !contains(schema.CollectionMethods, "GET") {
return errors.New("Resource type [" + schemaType + "] is not listable")
}
collectionUrl, ok := schema.Links[COLLECTION]
if !ok {
return errors.New("Failed to find collection URL for [" + schemaType + "]")
}
return rancherClient.doGet(collectionUrl, opts, respObject)
}
func (rancherClient *RancherBaseClientImpl) doNext(nextUrl string, respObject interface{}) error {
return rancherClient.doGet(nextUrl, nil, respObject)
}
func (rancherClient *RancherBaseClientImpl) Post(url string, createObj interface{}, respObject interface{}) error {
return rancherClient.doModify("POST", url, createObj, respObject)
}
func (rancherClient *RancherBaseClientImpl) GetLink(resource Resource, link string, respObject interface{}) error {
url := resource.Links[link]
if url == "" {
return fmt.Errorf("Failed to find link: %s", link)
}
return rancherClient.doGet(url, &ListOpts{}, respObject)
}
func (rancherClient *RancherBaseClientImpl) doModify(method string, url string, createObj interface{}, respObject interface{}) error {
bodyContent, err := json.Marshal(createObj)
if err != nil {
return err
}
if debug {
fmt.Println(method + " " + url)
fmt.Println("Request => " + string(bodyContent))
}
client := rancherClient.newHttpClient()
req, err := http.NewRequest(method, url, bytes.NewBuffer(bodyContent))
if err != nil {
return err
}
rancherClient.setupRequest(req)
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode >= 300 {
return newApiError(resp, url)
}
byteContent, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
if len(byteContent) > 0 {
if debug {
fmt.Println("Response <= " + string(byteContent))
}
return json.Unmarshal(byteContent, respObject)
}
return nil
}
func (rancherClient *RancherBaseClientImpl) Create(schemaType string, createObj interface{}, respObject interface{}) error {
return rancherClient.doCreate(schemaType, createObj, respObject)
}
func (rancherClient *RancherBaseClientImpl) doCreate(schemaType string, createObj interface{}, respObject interface{}) error {
if createObj == nil {
createObj = map[string]string{}
}
if respObject == nil {
respObject = &map[string]interface{}{}
}
schema, ok := rancherClient.Types[schemaType]
if !ok {
return errors.New("Unknown schema type [" + schemaType + "]")
}
if !contains(schema.CollectionMethods, "POST") {
return errors.New("Resource type [" + schemaType + "] is not creatable")
}
var collectionUrl string
collectionUrl, ok = schema.Links[COLLECTION]
if !ok {
// return errors.New("Failed to find collection URL for [" + schemaType + "]")
// This is a hack to address https://github.com/rancher/cattle/issues/254
re := regexp.MustCompile("schemas.*")
collectionUrl = re.ReplaceAllString(schema.Links[SELF], schema.PluralName)
}
return rancherClient.doModify("POST", collectionUrl, createObj, respObject)
}
func (rancherClient *RancherBaseClientImpl) Update(schemaType string, existing *Resource, updates interface{}, respObject interface{}) error {
return rancherClient.doUpdate(schemaType, existing, updates, respObject)
}
func (rancherClient *RancherBaseClientImpl) doUpdate(schemaType string, existing *Resource, updates interface{}, respObject interface{}) error {
if existing == nil {
return errors.New("Existing object is nil")
}
selfUrl, ok := existing.Links[SELF]
if !ok {
return errors.New(fmt.Sprintf("Failed to find self URL of [%v]", existing))
}
if updates == nil {
updates = map[string]string{}
}
if respObject == nil {
respObject = &map[string]interface{}{}
}
schema, ok := rancherClient.Types[schemaType]
if !ok {
return errors.New("Unknown schema type [" + schemaType + "]")
}
if !contains(schema.ResourceMethods, "PUT") {
return errors.New("Resource type [" + schemaType + "] is not updatable")
}
return rancherClient.doModify("PUT", selfUrl, updates, respObject)
}
func (rancherClient *RancherBaseClientImpl) ById(schemaType string, id string, respObject interface{}) error {
return rancherClient.doById(schemaType, id, respObject)
}
func (rancherClient *RancherBaseClientImpl) doById(schemaType string, id string, respObject interface{}) error {
schema, ok := rancherClient.Types[schemaType]
if !ok {
return errors.New("Unknown schema type [" + schemaType + "]")
}
if !contains(schema.ResourceMethods, "GET") {
return errors.New("Resource type [" + schemaType + "] can not be looked up by ID")
}
collectionUrl, ok := schema.Links[COLLECTION]
if !ok {
return errors.New("Failed to find collection URL for [" + schemaType + "]")
}
err := rancherClient.doGet(collectionUrl+"/"+id, nil, respObject)
//TODO check for 404 and return nil, nil
return err
}
func (rancherClient *RancherBaseClientImpl) Delete(existing *Resource) error {
if existing == nil {
return nil
}
return rancherClient.doResourceDelete(existing.Type, existing)
}
func (rancherClient *RancherBaseClientImpl) doResourceDelete(schemaType string, existing *Resource) error {
schema, ok := rancherClient.Types[schemaType]
if !ok {
return errors.New("Unknown schema type [" + schemaType + "]")
}
if !contains(schema.ResourceMethods, "DELETE") {
return errors.New("Resource type [" + schemaType + "] can not be deleted")
}
selfUrl, ok := existing.Links[SELF]
if !ok {
return errors.New(fmt.Sprintf("Failed to find self URL of [%v]", existing))
}
return rancherClient.doDelete(selfUrl)
}
func (rancherClient *RancherBaseClientImpl) Reload(existing *Resource, output interface{}) error {
selfUrl, ok := existing.Links[SELF]
if !ok {
return errors.New(fmt.Sprintf("Failed to find self URL of [%v]", existing))
}
return rancherClient.doGet(selfUrl, NewListOpts(), output)
}
func (rancherClient *RancherBaseClientImpl) Action(schemaType string, action string,
existing *Resource, inputObject, respObject interface{}) error {
return rancherClient.doAction(schemaType, action, existing, inputObject, respObject)
}
func (rancherClient *RancherBaseClientImpl) doAction(schemaType string, action string,
existing *Resource, inputObject, respObject interface{}) error {
if existing == nil {
return errors.New("Existing object is nil")
}
actionUrl, ok := existing.Actions[action]
if !ok {
return errors.New(fmt.Sprintf("Action [%v] not available on [%v]", action, existing))
}
_, ok = rancherClient.Types[schemaType]
if !ok {
return errors.New("Unknown schema type [" + schemaType + "]")
}
var input io.Reader
if inputObject != nil {
bodyContent, err := json.Marshal(inputObject)
if err != nil {
return err
}
if debug {
fmt.Println("Request => " + string(bodyContent))
}
input = bytes.NewBuffer(bodyContent)
}
client := rancherClient.newHttpClient()
req, err := http.NewRequest("POST", actionUrl, input)
if err != nil {
return err
}
rancherClient.setupRequest(req)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Content-Length", "0")
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode >= 300 {
return newApiError(resp, actionUrl)
}
byteContent, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
if debug {
fmt.Println("Response <= " + string(byteContent))
}
return json.Unmarshal(byteContent, respObject)
}
func (rancherClient *RancherBaseClientImpl) GetOpts() *ClientOpts {
return rancherClient.Opts
}
func (rancherClient *RancherBaseClientImpl) GetSchemas() *Schemas {
return rancherClient.Schemas
}
func (rancherClient *RancherBaseClientImpl) GetTypes() map[string]Schema {
return rancherClient.Types
}
func init() {
debug = os.Getenv("RANCHER_CLIENT_DEBUG") == "true"
if debug {
fmt.Println("Rancher client debug on")
}
}

View File

@@ -1,177 +0,0 @@
package client
const (
ACCOUNT_TYPE = "account"
)
type Account struct {
Resource
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
ClusterOwner bool `json:"clusterOwner,omitempty" yaml:"cluster_owner,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
ExternalIdType string `json:"externalIdType,omitempty" yaml:"external_id_type,omitempty"`
Identity string `json:"identity,omitempty" yaml:"identity,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
Version string `json:"version,omitempty" yaml:"version,omitempty"`
}
type AccountCollection struct {
Collection
Data []Account `json:"data,omitempty"`
client *AccountClient
}
type AccountClient struct {
rancherClient *RancherClient
}
type AccountOperations interface {
List(opts *ListOpts) (*AccountCollection, error)
Create(opts *Account) (*Account, error)
Update(existing *Account, updates interface{}) (*Account, error)
ById(id string) (*Account, error)
Delete(container *Account) error
ActionActivate(*Account) (*Account, error)
ActionCreate(*Account) (*Account, error)
ActionDeactivate(*Account) (*Account, error)
ActionPurge(*Account) (*Account, error)
ActionRemove(*Account) (*Account, error)
ActionUpdate(*Account) (*Account, error)
}
func newAccountClient(rancherClient *RancherClient) *AccountClient {
return &AccountClient{
rancherClient: rancherClient,
}
}
func (c *AccountClient) Create(container *Account) (*Account, error) {
resp := &Account{}
err := c.rancherClient.doCreate(ACCOUNT_TYPE, container, resp)
return resp, err
}
func (c *AccountClient) Update(existing *Account, updates interface{}) (*Account, error) {
resp := &Account{}
err := c.rancherClient.doUpdate(ACCOUNT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *AccountClient) List(opts *ListOpts) (*AccountCollection, error) {
resp := &AccountCollection{}
err := c.rancherClient.doList(ACCOUNT_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *AccountCollection) Next() (*AccountCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &AccountCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *AccountClient) ById(id string) (*Account, error) {
resp := &Account{}
err := c.rancherClient.doById(ACCOUNT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *AccountClient) Delete(container *Account) error {
return c.rancherClient.doResourceDelete(ACCOUNT_TYPE, &container.Resource)
}
func (c *AccountClient) ActionActivate(resource *Account) (*Account, error) {
resp := &Account{}
err := c.rancherClient.doAction(ACCOUNT_TYPE, "activate", &resource.Resource, nil, resp)
return resp, err
}
func (c *AccountClient) ActionCreate(resource *Account) (*Account, error) {
resp := &Account{}
err := c.rancherClient.doAction(ACCOUNT_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *AccountClient) ActionDeactivate(resource *Account) (*Account, error) {
resp := &Account{}
err := c.rancherClient.doAction(ACCOUNT_TYPE, "deactivate", &resource.Resource, nil, resp)
return resp, err
}
func (c *AccountClient) ActionPurge(resource *Account) (*Account, error) {
resp := &Account{}
err := c.rancherClient.doAction(ACCOUNT_TYPE, "purge", &resource.Resource, nil, resp)
return resp, err
}
func (c *AccountClient) ActionRemove(resource *Account) (*Account, error) {
resp := &Account{}
err := c.rancherClient.doAction(ACCOUNT_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}
func (c *AccountClient) ActionUpdate(resource *Account) (*Account, error) {
resp := &Account{}
err := c.rancherClient.doAction(ACCOUNT_TYPE, "update", &resource.Resource, nil, resp)
return resp, err
}

View File

@@ -1,79 +0,0 @@
package client
const (
ADD_OUTPUTS_INPUT_TYPE = "addOutputsInput"
)
type AddOutputsInput struct {
Resource
Outputs map[string]string `json:"outputs,omitempty" yaml:"outputs,omitempty"`
}
type AddOutputsInputCollection struct {
Collection
Data []AddOutputsInput `json:"data,omitempty"`
client *AddOutputsInputClient
}
type AddOutputsInputClient struct {
rancherClient *RancherClient
}
type AddOutputsInputOperations interface {
List(opts *ListOpts) (*AddOutputsInputCollection, error)
Create(opts *AddOutputsInput) (*AddOutputsInput, error)
Update(existing *AddOutputsInput, updates interface{}) (*AddOutputsInput, error)
ById(id string) (*AddOutputsInput, error)
Delete(container *AddOutputsInput) error
}
func newAddOutputsInputClient(rancherClient *RancherClient) *AddOutputsInputClient {
return &AddOutputsInputClient{
rancherClient: rancherClient,
}
}
func (c *AddOutputsInputClient) Create(container *AddOutputsInput) (*AddOutputsInput, error) {
resp := &AddOutputsInput{}
err := c.rancherClient.doCreate(ADD_OUTPUTS_INPUT_TYPE, container, resp)
return resp, err
}
func (c *AddOutputsInputClient) Update(existing *AddOutputsInput, updates interface{}) (*AddOutputsInput, error) {
resp := &AddOutputsInput{}
err := c.rancherClient.doUpdate(ADD_OUTPUTS_INPUT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *AddOutputsInputClient) List(opts *ListOpts) (*AddOutputsInputCollection, error) {
resp := &AddOutputsInputCollection{}
err := c.rancherClient.doList(ADD_OUTPUTS_INPUT_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *AddOutputsInputCollection) Next() (*AddOutputsInputCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &AddOutputsInputCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *AddOutputsInputClient) ById(id string) (*AddOutputsInput, error) {
resp := &AddOutputsInput{}
err := c.rancherClient.doById(ADD_OUTPUTS_INPUT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *AddOutputsInputClient) Delete(container *AddOutputsInput) error {
return c.rancherClient.doResourceDelete(ADD_OUTPUTS_INPUT_TYPE, &container.Resource)
}

View File

@@ -1,180 +0,0 @@
package client
const (
AGENT_TYPE = "agent"
)
type Agent struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
Uri string `json:"uri,omitempty" yaml:"uri,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type AgentCollection struct {
Collection
Data []Agent `json:"data,omitempty"`
client *AgentClient
}
type AgentClient struct {
rancherClient *RancherClient
}
type AgentOperations interface {
List(opts *ListOpts) (*AgentCollection, error)
Create(opts *Agent) (*Agent, error)
Update(existing *Agent, updates interface{}) (*Agent, error)
ById(id string) (*Agent, error)
Delete(container *Agent) error
ActionActivate(*Agent) (*Agent, error)
ActionCreate(*Agent) (*Agent, error)
ActionDeactivate(*Agent) (*Agent, error)
ActionDisconnect(*Agent) (*Agent, error)
ActionError(*Agent) (*Agent, error)
ActionReconnect(*Agent) (*Agent, error)
ActionRemove(*Agent) (*Agent, error)
}
func newAgentClient(rancherClient *RancherClient) *AgentClient {
return &AgentClient{
rancherClient: rancherClient,
}
}
func (c *AgentClient) Create(container *Agent) (*Agent, error) {
resp := &Agent{}
err := c.rancherClient.doCreate(AGENT_TYPE, container, resp)
return resp, err
}
func (c *AgentClient) Update(existing *Agent, updates interface{}) (*Agent, error) {
resp := &Agent{}
err := c.rancherClient.doUpdate(AGENT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *AgentClient) List(opts *ListOpts) (*AgentCollection, error) {
resp := &AgentCollection{}
err := c.rancherClient.doList(AGENT_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *AgentCollection) Next() (*AgentCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &AgentCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *AgentClient) ById(id string) (*Agent, error) {
resp := &Agent{}
err := c.rancherClient.doById(AGENT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *AgentClient) Delete(container *Agent) error {
return c.rancherClient.doResourceDelete(AGENT_TYPE, &container.Resource)
}
func (c *AgentClient) ActionActivate(resource *Agent) (*Agent, error) {
resp := &Agent{}
err := c.rancherClient.doAction(AGENT_TYPE, "activate", &resource.Resource, nil, resp)
return resp, err
}
func (c *AgentClient) ActionCreate(resource *Agent) (*Agent, error) {
resp := &Agent{}
err := c.rancherClient.doAction(AGENT_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *AgentClient) ActionDeactivate(resource *Agent) (*Agent, error) {
resp := &Agent{}
err := c.rancherClient.doAction(AGENT_TYPE, "deactivate", &resource.Resource, nil, resp)
return resp, err
}
func (c *AgentClient) ActionDisconnect(resource *Agent) (*Agent, error) {
resp := &Agent{}
err := c.rancherClient.doAction(AGENT_TYPE, "disconnect", &resource.Resource, nil, resp)
return resp, err
}
func (c *AgentClient) ActionError(resource *Agent) (*Agent, error) {
resp := &Agent{}
err := c.rancherClient.doAction(AGENT_TYPE, "error", &resource.Resource, nil, resp)
return resp, err
}
func (c *AgentClient) ActionReconnect(resource *Agent) (*Agent, error) {
resp := &Agent{}
err := c.rancherClient.doAction(AGENT_TYPE, "reconnect", &resource.Resource, nil, resp)
return resp, err
}
func (c *AgentClient) ActionRemove(resource *Agent) (*Agent, error) {
resp := &Agent{}
err := c.rancherClient.doAction(AGENT_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}

View File

@@ -1,137 +0,0 @@
package client
const (
AMAZONEC2CONFIG_TYPE = "amazonec2Config"
)
type Amazonec2Config struct {
Resource
AccessKey string `json:"accessKey,omitempty" yaml:"access_key,omitempty"`
Ami string `json:"ami,omitempty" yaml:"ami,omitempty"`
BlockDurationMinutes string `json:"blockDurationMinutes,omitempty" yaml:"block_duration_minutes,omitempty"`
DeviceName string `json:"deviceName,omitempty" yaml:"device_name,omitempty"`
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
IamInstanceProfile string `json:"iamInstanceProfile,omitempty" yaml:"iam_instance_profile,omitempty"`
InsecureTransport bool `json:"insecureTransport,omitempty" yaml:"insecure_transport,omitempty"`
InstanceType string `json:"instanceType,omitempty" yaml:"instance_type,omitempty"`
KeypairName string `json:"keypairName,omitempty" yaml:"keypair_name,omitempty"`
Monitoring bool `json:"monitoring,omitempty" yaml:"monitoring,omitempty"`
OpenPort []string `json:"openPort,omitempty" yaml:"open_port,omitempty"`
PrivateAddressOnly bool `json:"privateAddressOnly,omitempty" yaml:"private_address_only,omitempty"`
Region string `json:"region,omitempty" yaml:"region,omitempty"`
RequestSpotInstance bool `json:"requestSpotInstance,omitempty" yaml:"request_spot_instance,omitempty"`
Retries string `json:"retries,omitempty" yaml:"retries,omitempty"`
RootSize string `json:"rootSize,omitempty" yaml:"root_size,omitempty"`
SecretKey string `json:"secretKey,omitempty" yaml:"secret_key,omitempty"`
SecurityGroup []string `json:"securityGroup,omitempty" yaml:"security_group,omitempty"`
SessionToken string `json:"sessionToken,omitempty" yaml:"session_token,omitempty"`
SpotPrice string `json:"spotPrice,omitempty" yaml:"spot_price,omitempty"`
SshKeypath string `json:"sshKeypath,omitempty" yaml:"ssh_keypath,omitempty"`
SshUser string `json:"sshUser,omitempty" yaml:"ssh_user,omitempty"`
SubnetId string `json:"subnetId,omitempty" yaml:"subnet_id,omitempty"`
Tags string `json:"tags,omitempty" yaml:"tags,omitempty"`
UseEbsOptimizedInstance bool `json:"useEbsOptimizedInstance,omitempty" yaml:"use_ebs_optimized_instance,omitempty"`
UsePrivateAddress bool `json:"usePrivateAddress,omitempty" yaml:"use_private_address,omitempty"`
Userdata string `json:"userdata,omitempty" yaml:"userdata,omitempty"`
VolumeType string `json:"volumeType,omitempty" yaml:"volume_type,omitempty"`
VpcId string `json:"vpcId,omitempty" yaml:"vpc_id,omitempty"`
Zone string `json:"zone,omitempty" yaml:"zone,omitempty"`
}
type Amazonec2ConfigCollection struct {
Collection
Data []Amazonec2Config `json:"data,omitempty"`
client *Amazonec2ConfigClient
}
type Amazonec2ConfigClient struct {
rancherClient *RancherClient
}
type Amazonec2ConfigOperations interface {
List(opts *ListOpts) (*Amazonec2ConfigCollection, error)
Create(opts *Amazonec2Config) (*Amazonec2Config, error)
Update(existing *Amazonec2Config, updates interface{}) (*Amazonec2Config, error)
ById(id string) (*Amazonec2Config, error)
Delete(container *Amazonec2Config) error
}
func newAmazonec2ConfigClient(rancherClient *RancherClient) *Amazonec2ConfigClient {
return &Amazonec2ConfigClient{
rancherClient: rancherClient,
}
}
func (c *Amazonec2ConfigClient) Create(container *Amazonec2Config) (*Amazonec2Config, error) {
resp := &Amazonec2Config{}
err := c.rancherClient.doCreate(AMAZONEC2CONFIG_TYPE, container, resp)
return resp, err
}
func (c *Amazonec2ConfigClient) Update(existing *Amazonec2Config, updates interface{}) (*Amazonec2Config, error) {
resp := &Amazonec2Config{}
err := c.rancherClient.doUpdate(AMAZONEC2CONFIG_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *Amazonec2ConfigClient) List(opts *ListOpts) (*Amazonec2ConfigCollection, error) {
resp := &Amazonec2ConfigCollection{}
err := c.rancherClient.doList(AMAZONEC2CONFIG_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *Amazonec2ConfigCollection) Next() (*Amazonec2ConfigCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &Amazonec2ConfigCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *Amazonec2ConfigClient) ById(id string) (*Amazonec2Config, error) {
resp := &Amazonec2Config{}
err := c.rancherClient.doById(AMAZONEC2CONFIG_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *Amazonec2ConfigClient) Delete(container *Amazonec2Config) error {
return c.rancherClient.doResourceDelete(AMAZONEC2CONFIG_TYPE, &container.Resource)
}

View File

@@ -1,149 +0,0 @@
package client
const (
API_KEY_TYPE = "apiKey"
)
type ApiKey struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
PublicValue string `json:"publicValue,omitempty" yaml:"public_value,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
SecretValue string `json:"secretValue,omitempty" yaml:"secret_value,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ApiKeyCollection struct {
Collection
Data []ApiKey `json:"data,omitempty"`
client *ApiKeyClient
}
type ApiKeyClient struct {
rancherClient *RancherClient
}
type ApiKeyOperations interface {
List(opts *ListOpts) (*ApiKeyCollection, error)
Create(opts *ApiKey) (*ApiKey, error)
Update(existing *ApiKey, updates interface{}) (*ApiKey, error)
ById(id string) (*ApiKey, error)
Delete(container *ApiKey) error
ActionActivate(*ApiKey) (*Credential, error)
ActionCreate(*ApiKey) (*Credential, error)
ActionDeactivate(*ApiKey) (*Credential, error)
ActionRemove(*ApiKey) (*Credential, error)
}
func newApiKeyClient(rancherClient *RancherClient) *ApiKeyClient {
return &ApiKeyClient{
rancherClient: rancherClient,
}
}
func (c *ApiKeyClient) Create(container *ApiKey) (*ApiKey, error) {
resp := &ApiKey{}
err := c.rancherClient.doCreate(API_KEY_TYPE, container, resp)
return resp, err
}
func (c *ApiKeyClient) Update(existing *ApiKey, updates interface{}) (*ApiKey, error) {
resp := &ApiKey{}
err := c.rancherClient.doUpdate(API_KEY_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ApiKeyClient) List(opts *ListOpts) (*ApiKeyCollection, error) {
resp := &ApiKeyCollection{}
err := c.rancherClient.doList(API_KEY_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ApiKeyCollection) Next() (*ApiKeyCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ApiKeyCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ApiKeyClient) ById(id string) (*ApiKey, error) {
resp := &ApiKey{}
err := c.rancherClient.doById(API_KEY_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ApiKeyClient) Delete(container *ApiKey) error {
return c.rancherClient.doResourceDelete(API_KEY_TYPE, &container.Resource)
}
func (c *ApiKeyClient) ActionActivate(resource *ApiKey) (*Credential, error) {
resp := &Credential{}
err := c.rancherClient.doAction(API_KEY_TYPE, "activate", &resource.Resource, nil, resp)
return resp, err
}
func (c *ApiKeyClient) ActionCreate(resource *ApiKey) (*Credential, error) {
resp := &Credential{}
err := c.rancherClient.doAction(API_KEY_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ApiKeyClient) ActionDeactivate(resource *ApiKey) (*Credential, error) {
resp := &Credential{}
err := c.rancherClient.doAction(API_KEY_TYPE, "deactivate", &resource.Resource, nil, resp)
return resp, err
}
func (c *ApiKeyClient) ActionRemove(resource *ApiKey) (*Credential, error) {
resp := &Credential{}
err := c.rancherClient.doAction(API_KEY_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}

View File

@@ -1,105 +0,0 @@
package client
const (
AUDIT_LOG_TYPE = "auditLog"
)
type AuditLog struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
AuthType string `json:"authType,omitempty" yaml:"auth_type,omitempty"`
AuthenticatedAsAccountId string `json:"authenticatedAsAccountId,omitempty" yaml:"authenticated_as_account_id,omitempty"`
AuthenticatedAsIdentityId string `json:"authenticatedAsIdentityId,omitempty" yaml:"authenticated_as_identity_id,omitempty"`
ClientIp string `json:"clientIp,omitempty" yaml:"client_ip,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
RequestObject string `json:"requestObject,omitempty" yaml:"request_object,omitempty"`
ResourceId int64 `json:"resourceId,omitempty" yaml:"resource_id,omitempty"`
ResourceType string `json:"resourceType,omitempty" yaml:"resource_type,omitempty"`
ResponseCode int64 `json:"responseCode,omitempty" yaml:"response_code,omitempty"`
ResponseObject string `json:"responseObject,omitempty" yaml:"response_object,omitempty"`
}
type AuditLogCollection struct {
Collection
Data []AuditLog `json:"data,omitempty"`
client *AuditLogClient
}
type AuditLogClient struct {
rancherClient *RancherClient
}
type AuditLogOperations interface {
List(opts *ListOpts) (*AuditLogCollection, error)
Create(opts *AuditLog) (*AuditLog, error)
Update(existing *AuditLog, updates interface{}) (*AuditLog, error)
ById(id string) (*AuditLog, error)
Delete(container *AuditLog) error
}
func newAuditLogClient(rancherClient *RancherClient) *AuditLogClient {
return &AuditLogClient{
rancherClient: rancherClient,
}
}
func (c *AuditLogClient) Create(container *AuditLog) (*AuditLog, error) {
resp := &AuditLog{}
err := c.rancherClient.doCreate(AUDIT_LOG_TYPE, container, resp)
return resp, err
}
func (c *AuditLogClient) Update(existing *AuditLog, updates interface{}) (*AuditLog, error) {
resp := &AuditLog{}
err := c.rancherClient.doUpdate(AUDIT_LOG_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *AuditLogClient) List(opts *ListOpts) (*AuditLogCollection, error) {
resp := &AuditLogCollection{}
err := c.rancherClient.doList(AUDIT_LOG_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *AuditLogCollection) Next() (*AuditLogCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &AuditLogCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *AuditLogClient) ById(id string) (*AuditLog, error) {
resp := &AuditLog{}
err := c.rancherClient.doById(AUDIT_LOG_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *AuditLogClient) Delete(container *AuditLog) error {
return c.rancherClient.doResourceDelete(AUDIT_LOG_TYPE, &container.Resource)
}

View File

@@ -1,121 +0,0 @@
package client
const (
AZURE_CONFIG_TYPE = "azureConfig"
)
type AzureConfig struct {
Resource
AvailabilitySet string `json:"availabilitySet,omitempty" yaml:"availability_set,omitempty"`
ClientId string `json:"clientId,omitempty" yaml:"client_id,omitempty"`
ClientSecret string `json:"clientSecret,omitempty" yaml:"client_secret,omitempty"`
CustomData string `json:"customData,omitempty" yaml:"custom_data,omitempty"`
Dns string `json:"dns,omitempty" yaml:"dns,omitempty"`
DockerPort string `json:"dockerPort,omitempty" yaml:"docker_port,omitempty"`
Environment string `json:"environment,omitempty" yaml:"environment,omitempty"`
Image string `json:"image,omitempty" yaml:"image,omitempty"`
Location string `json:"location,omitempty" yaml:"location,omitempty"`
NoPublicIp bool `json:"noPublicIp,omitempty" yaml:"no_public_ip,omitempty"`
OpenPort []string `json:"openPort,omitempty" yaml:"open_port,omitempty"`
PrivateIpAddress string `json:"privateIpAddress,omitempty" yaml:"private_ip_address,omitempty"`
ResourceGroup string `json:"resourceGroup,omitempty" yaml:"resource_group,omitempty"`
Size string `json:"size,omitempty" yaml:"size,omitempty"`
SshUser string `json:"sshUser,omitempty" yaml:"ssh_user,omitempty"`
StaticPublicIp bool `json:"staticPublicIp,omitempty" yaml:"static_public_ip,omitempty"`
StorageType string `json:"storageType,omitempty" yaml:"storage_type,omitempty"`
Subnet string `json:"subnet,omitempty" yaml:"subnet,omitempty"`
SubnetPrefix string `json:"subnetPrefix,omitempty" yaml:"subnet_prefix,omitempty"`
SubscriptionId string `json:"subscriptionId,omitempty" yaml:"subscription_id,omitempty"`
UsePrivateIp bool `json:"usePrivateIp,omitempty" yaml:"use_private_ip,omitempty"`
Vnet string `json:"vnet,omitempty" yaml:"vnet,omitempty"`
}
type AzureConfigCollection struct {
Collection
Data []AzureConfig `json:"data,omitempty"`
client *AzureConfigClient
}
type AzureConfigClient struct {
rancherClient *RancherClient
}
type AzureConfigOperations interface {
List(opts *ListOpts) (*AzureConfigCollection, error)
Create(opts *AzureConfig) (*AzureConfig, error)
Update(existing *AzureConfig, updates interface{}) (*AzureConfig, error)
ById(id string) (*AzureConfig, error)
Delete(container *AzureConfig) error
}
func newAzureConfigClient(rancherClient *RancherClient) *AzureConfigClient {
return &AzureConfigClient{
rancherClient: rancherClient,
}
}
func (c *AzureConfigClient) Create(container *AzureConfig) (*AzureConfig, error) {
resp := &AzureConfig{}
err := c.rancherClient.doCreate(AZURE_CONFIG_TYPE, container, resp)
return resp, err
}
func (c *AzureConfigClient) Update(existing *AzureConfig, updates interface{}) (*AzureConfig, error) {
resp := &AzureConfig{}
err := c.rancherClient.doUpdate(AZURE_CONFIG_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *AzureConfigClient) List(opts *ListOpts) (*AzureConfigCollection, error) {
resp := &AzureConfigCollection{}
err := c.rancherClient.doList(AZURE_CONFIG_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *AzureConfigCollection) Next() (*AzureConfigCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &AzureConfigCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *AzureConfigClient) ById(id string) (*AzureConfig, error) {
resp := &AzureConfig{}
err := c.rancherClient.doById(AZURE_CONFIG_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *AzureConfigClient) Delete(container *AzureConfig) error {
return c.rancherClient.doResourceDelete(AZURE_CONFIG_TYPE, &container.Resource)
}

View File

@@ -1,93 +0,0 @@
package client
const (
AZUREADCONFIG_TYPE = "azureadconfig"
)
type Azureadconfig struct {
Resource
AccessMode string `json:"accessMode,omitempty" yaml:"access_mode,omitempty"`
AdminAccountPassword string `json:"adminAccountPassword,omitempty" yaml:"admin_account_password,omitempty"`
AdminAccountUsername string `json:"adminAccountUsername,omitempty" yaml:"admin_account_username,omitempty"`
ClientId string `json:"clientId,omitempty" yaml:"client_id,omitempty"`
Domain string `json:"domain,omitempty" yaml:"domain,omitempty"`
Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
TenantId string `json:"tenantId,omitempty" yaml:"tenant_id,omitempty"`
}
type AzureadconfigCollection struct {
Collection
Data []Azureadconfig `json:"data,omitempty"`
client *AzureadconfigClient
}
type AzureadconfigClient struct {
rancherClient *RancherClient
}
type AzureadconfigOperations interface {
List(opts *ListOpts) (*AzureadconfigCollection, error)
Create(opts *Azureadconfig) (*Azureadconfig, error)
Update(existing *Azureadconfig, updates interface{}) (*Azureadconfig, error)
ById(id string) (*Azureadconfig, error)
Delete(container *Azureadconfig) error
}
func newAzureadconfigClient(rancherClient *RancherClient) *AzureadconfigClient {
return &AzureadconfigClient{
rancherClient: rancherClient,
}
}
func (c *AzureadconfigClient) Create(container *Azureadconfig) (*Azureadconfig, error) {
resp := &Azureadconfig{}
err := c.rancherClient.doCreate(AZUREADCONFIG_TYPE, container, resp)
return resp, err
}
func (c *AzureadconfigClient) Update(existing *Azureadconfig, updates interface{}) (*Azureadconfig, error) {
resp := &Azureadconfig{}
err := c.rancherClient.doUpdate(AZUREADCONFIG_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *AzureadconfigClient) List(opts *ListOpts) (*AzureadconfigCollection, error) {
resp := &AzureadconfigCollection{}
err := c.rancherClient.doList(AZUREADCONFIG_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *AzureadconfigCollection) Next() (*AzureadconfigCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &AzureadconfigCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *AzureadconfigClient) ById(id string) (*Azureadconfig, error) {
resp := &Azureadconfig{}
err := c.rancherClient.doById(AZUREADCONFIG_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *AzureadconfigClient) Delete(container *Azureadconfig) error {
return c.rancherClient.doResourceDelete(AZUREADCONFIG_TYPE, &container.Resource)
}

View File

@@ -1,77 +0,0 @@
package client
const (
BASE_MACHINE_CONFIG_TYPE = "baseMachineConfig"
)
type BaseMachineConfig struct {
Resource
}
type BaseMachineConfigCollection struct {
Collection
Data []BaseMachineConfig `json:"data,omitempty"`
client *BaseMachineConfigClient
}
type BaseMachineConfigClient struct {
rancherClient *RancherClient
}
type BaseMachineConfigOperations interface {
List(opts *ListOpts) (*BaseMachineConfigCollection, error)
Create(opts *BaseMachineConfig) (*BaseMachineConfig, error)
Update(existing *BaseMachineConfig, updates interface{}) (*BaseMachineConfig, error)
ById(id string) (*BaseMachineConfig, error)
Delete(container *BaseMachineConfig) error
}
func newBaseMachineConfigClient(rancherClient *RancherClient) *BaseMachineConfigClient {
return &BaseMachineConfigClient{
rancherClient: rancherClient,
}
}
func (c *BaseMachineConfigClient) Create(container *BaseMachineConfig) (*BaseMachineConfig, error) {
resp := &BaseMachineConfig{}
err := c.rancherClient.doCreate(BASE_MACHINE_CONFIG_TYPE, container, resp)
return resp, err
}
func (c *BaseMachineConfigClient) Update(existing *BaseMachineConfig, updates interface{}) (*BaseMachineConfig, error) {
resp := &BaseMachineConfig{}
err := c.rancherClient.doUpdate(BASE_MACHINE_CONFIG_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *BaseMachineConfigClient) List(opts *ListOpts) (*BaseMachineConfigCollection, error) {
resp := &BaseMachineConfigCollection{}
err := c.rancherClient.doList(BASE_MACHINE_CONFIG_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *BaseMachineConfigCollection) Next() (*BaseMachineConfigCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &BaseMachineConfigCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *BaseMachineConfigClient) ById(id string) (*BaseMachineConfig, error) {
resp := &BaseMachineConfig{}
err := c.rancherClient.doById(BASE_MACHINE_CONFIG_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *BaseMachineConfigClient) Delete(container *BaseMachineConfig) error {
return c.rancherClient.doResourceDelete(BASE_MACHINE_CONFIG_TYPE, &container.Resource)
}

View File

@@ -1,87 +0,0 @@
package client
const (
BLKIO_DEVICE_OPTION_TYPE = "blkioDeviceOption"
)
type BlkioDeviceOption struct {
Resource
ReadBps int64 `json:"readBps,omitempty" yaml:"read_bps,omitempty"`
ReadIops int64 `json:"readIops,omitempty" yaml:"read_iops,omitempty"`
Weight int64 `json:"weight,omitempty" yaml:"weight,omitempty"`
WriteBps int64 `json:"writeBps,omitempty" yaml:"write_bps,omitempty"`
WriteIops int64 `json:"writeIops,omitempty" yaml:"write_iops,omitempty"`
}
type BlkioDeviceOptionCollection struct {
Collection
Data []BlkioDeviceOption `json:"data,omitempty"`
client *BlkioDeviceOptionClient
}
type BlkioDeviceOptionClient struct {
rancherClient *RancherClient
}
type BlkioDeviceOptionOperations interface {
List(opts *ListOpts) (*BlkioDeviceOptionCollection, error)
Create(opts *BlkioDeviceOption) (*BlkioDeviceOption, error)
Update(existing *BlkioDeviceOption, updates interface{}) (*BlkioDeviceOption, error)
ById(id string) (*BlkioDeviceOption, error)
Delete(container *BlkioDeviceOption) error
}
func newBlkioDeviceOptionClient(rancherClient *RancherClient) *BlkioDeviceOptionClient {
return &BlkioDeviceOptionClient{
rancherClient: rancherClient,
}
}
func (c *BlkioDeviceOptionClient) Create(container *BlkioDeviceOption) (*BlkioDeviceOption, error) {
resp := &BlkioDeviceOption{}
err := c.rancherClient.doCreate(BLKIO_DEVICE_OPTION_TYPE, container, resp)
return resp, err
}
func (c *BlkioDeviceOptionClient) Update(existing *BlkioDeviceOption, updates interface{}) (*BlkioDeviceOption, error) {
resp := &BlkioDeviceOption{}
err := c.rancherClient.doUpdate(BLKIO_DEVICE_OPTION_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *BlkioDeviceOptionClient) List(opts *ListOpts) (*BlkioDeviceOptionCollection, error) {
resp := &BlkioDeviceOptionCollection{}
err := c.rancherClient.doList(BLKIO_DEVICE_OPTION_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *BlkioDeviceOptionCollection) Next() (*BlkioDeviceOptionCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &BlkioDeviceOptionCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *BlkioDeviceOptionClient) ById(id string) (*BlkioDeviceOption, error) {
resp := &BlkioDeviceOption{}
err := c.rancherClient.doById(BLKIO_DEVICE_OPTION_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *BlkioDeviceOptionClient) Delete(container *BlkioDeviceOption) error {
return c.rancherClient.doResourceDelete(BLKIO_DEVICE_OPTION_TYPE, &container.Resource)
}

View File

@@ -1,158 +0,0 @@
package client
const (
CERTIFICATE_TYPE = "certificate"
)
type Certificate struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
Algorithm string `json:"algorithm,omitempty" yaml:"algorithm,omitempty"`
CN string `json:"cN,omitempty" yaml:"cn,omitempty"`
Cert string `json:"cert,omitempty" yaml:"cert,omitempty"`
CertChain string `json:"certChain,omitempty" yaml:"cert_chain,omitempty"`
CertFingerprint string `json:"certFingerprint,omitempty" yaml:"cert_fingerprint,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
ExpiresAt string `json:"expiresAt,omitempty" yaml:"expires_at,omitempty"`
IssuedAt string `json:"issuedAt,omitempty" yaml:"issued_at,omitempty"`
Issuer string `json:"issuer,omitempty" yaml:"issuer,omitempty"`
Key string `json:"key,omitempty" yaml:"key,omitempty"`
KeySize int64 `json:"keySize,omitempty" yaml:"key_size,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
SerialNumber string `json:"serialNumber,omitempty" yaml:"serial_number,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
SubjectAlternativeNames []string `json:"subjectAlternativeNames,omitempty" yaml:"subject_alternative_names,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
Version string `json:"version,omitempty" yaml:"version,omitempty"`
}
type CertificateCollection struct {
Collection
Data []Certificate `json:"data,omitempty"`
client *CertificateClient
}
type CertificateClient struct {
rancherClient *RancherClient
}
type CertificateOperations interface {
List(opts *ListOpts) (*CertificateCollection, error)
Create(opts *Certificate) (*Certificate, error)
Update(existing *Certificate, updates interface{}) (*Certificate, error)
ById(id string) (*Certificate, error)
Delete(container *Certificate) error
ActionCreate(*Certificate) (*Certificate, error)
ActionRemove(*Certificate) (*Certificate, error)
ActionUpdate(*Certificate) (*Certificate, error)
}
func newCertificateClient(rancherClient *RancherClient) *CertificateClient {
return &CertificateClient{
rancherClient: rancherClient,
}
}
func (c *CertificateClient) Create(container *Certificate) (*Certificate, error) {
resp := &Certificate{}
err := c.rancherClient.doCreate(CERTIFICATE_TYPE, container, resp)
return resp, err
}
func (c *CertificateClient) Update(existing *Certificate, updates interface{}) (*Certificate, error) {
resp := &Certificate{}
err := c.rancherClient.doUpdate(CERTIFICATE_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *CertificateClient) List(opts *ListOpts) (*CertificateCollection, error) {
resp := &CertificateCollection{}
err := c.rancherClient.doList(CERTIFICATE_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *CertificateCollection) Next() (*CertificateCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &CertificateCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *CertificateClient) ById(id string) (*Certificate, error) {
resp := &Certificate{}
err := c.rancherClient.doById(CERTIFICATE_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *CertificateClient) Delete(container *Certificate) error {
return c.rancherClient.doResourceDelete(CERTIFICATE_TYPE, &container.Resource)
}
func (c *CertificateClient) ActionCreate(resource *Certificate) (*Certificate, error) {
resp := &Certificate{}
err := c.rancherClient.doAction(CERTIFICATE_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *CertificateClient) ActionRemove(resource *Certificate) (*Certificate, error) {
resp := &Certificate{}
err := c.rancherClient.doAction(CERTIFICATE_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}
func (c *CertificateClient) ActionUpdate(resource *Certificate) (*Certificate, error) {
resp := &Certificate{}
err := c.rancherClient.doAction(CERTIFICATE_TYPE, "update", &resource.Resource, nil, resp)
return resp, err
}

View File

@@ -1,81 +0,0 @@
package client
const (
CHANGE_SECRET_INPUT_TYPE = "changeSecretInput"
)
type ChangeSecretInput struct {
Resource
NewSecret string `json:"newSecret,omitempty" yaml:"new_secret,omitempty"`
OldSecret string `json:"oldSecret,omitempty" yaml:"old_secret,omitempty"`
}
type ChangeSecretInputCollection struct {
Collection
Data []ChangeSecretInput `json:"data,omitempty"`
client *ChangeSecretInputClient
}
type ChangeSecretInputClient struct {
rancherClient *RancherClient
}
type ChangeSecretInputOperations interface {
List(opts *ListOpts) (*ChangeSecretInputCollection, error)
Create(opts *ChangeSecretInput) (*ChangeSecretInput, error)
Update(existing *ChangeSecretInput, updates interface{}) (*ChangeSecretInput, error)
ById(id string) (*ChangeSecretInput, error)
Delete(container *ChangeSecretInput) error
}
func newChangeSecretInputClient(rancherClient *RancherClient) *ChangeSecretInputClient {
return &ChangeSecretInputClient{
rancherClient: rancherClient,
}
}
func (c *ChangeSecretInputClient) Create(container *ChangeSecretInput) (*ChangeSecretInput, error) {
resp := &ChangeSecretInput{}
err := c.rancherClient.doCreate(CHANGE_SECRET_INPUT_TYPE, container, resp)
return resp, err
}
func (c *ChangeSecretInputClient) Update(existing *ChangeSecretInput, updates interface{}) (*ChangeSecretInput, error) {
resp := &ChangeSecretInput{}
err := c.rancherClient.doUpdate(CHANGE_SECRET_INPUT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ChangeSecretInputClient) List(opts *ListOpts) (*ChangeSecretInputCollection, error) {
resp := &ChangeSecretInputCollection{}
err := c.rancherClient.doList(CHANGE_SECRET_INPUT_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ChangeSecretInputCollection) Next() (*ChangeSecretInputCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ChangeSecretInputCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ChangeSecretInputClient) ById(id string) (*ChangeSecretInput, error) {
resp := &ChangeSecretInput{}
err := c.rancherClient.doById(CHANGE_SECRET_INPUT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ChangeSecretInputClient) Delete(container *ChangeSecretInput) error {
return c.rancherClient.doResourceDelete(CHANGE_SECRET_INPUT_TYPE, &container.Resource)
}

View File

@@ -1,305 +0,0 @@
package client
type RancherClient struct {
RancherBaseClient
Account AccountOperations
AddOutputsInput AddOutputsInputOperations
Agent AgentOperations
Amazonec2Config Amazonec2ConfigOperations
ApiKey ApiKeyOperations
AuditLog AuditLogOperations
AzureConfig AzureConfigOperations
Azureadconfig AzureadconfigOperations
BaseMachineConfig BaseMachineConfigOperations
BlkioDeviceOption BlkioDeviceOptionOperations
Certificate CertificateOperations
ChangeSecretInput ChangeSecretInputOperations
Cluster ClusterOperations
ClusterIdentity ClusterIdentityOperations
ComposeConfig ComposeConfigOperations
ComposeConfigInput ComposeConfigInputOperations
Container ContainerOperations
ContainerConfig ContainerConfigOperations
ContainerEvent ContainerEventOperations
ContainerExec ContainerExecOperations
ContainerLogs ContainerLogsOperations
ContainerProxy ContainerProxyOperations
ContainerUpgrade ContainerUpgradeOperations
Credential CredentialOperations
Databasechangelog DatabasechangelogOperations
Databasechangeloglock DatabasechangeloglockOperations
DefaultNetwork DefaultNetworkOperations
DependsOn DependsOnOperations
DeploymentSyncRequest DeploymentSyncRequestOperations
DeploymentSyncResponse DeploymentSyncResponseOperations
DeploymentUnit DeploymentUnitOperations
DigitaloceanConfig DigitaloceanConfigOperations
DnsService DnsServiceOperations
DynamicSchema DynamicSchemaOperations
EnvironmentInfo EnvironmentInfoOperations
Error ErrorOperations
ExternalDnsEvent ExternalDnsEventOperations
ExternalEvent ExternalEventOperations
ExternalHostEvent ExternalHostEventOperations
ExternalService ExternalServiceOperations
ExternalServiceEvent ExternalServiceEventOperations
FieldDocumentation FieldDocumentationOperations
GenericObject GenericObjectOperations
HaMembership HaMembershipOperations
HealthcheckInfo HealthcheckInfoOperations
HealthcheckState HealthcheckStateOperations
Host HostOperations
HostAccess HostAccessOperations
HostApiProxyToken HostApiProxyTokenOperations
HostInfo HostInfoOperations
HostTemplate HostTemplateOperations
Identity IdentityOperations
InServiceUpgradeStrategy InServiceUpgradeStrategyOperations
Instance InstanceOperations
InstanceConsole InstanceConsoleOperations
InstanceConsoleInput InstanceConsoleInputOperations
InstanceHealthCheck InstanceHealthCheckOperations
InstanceInfo InstanceInfoOperations
InstanceRemove InstanceRemoveOperations
InstanceStatus InstanceStatusOperations
InstanceStop InstanceStopOperations
K8sClientConfig K8sClientConfigOperations
K8sServerConfig K8sServerConfigOperations
LaunchConfig LaunchConfigOperations
LbConfig LbConfigOperations
LbTargetConfig LbTargetConfigOperations
Ldapconfig LdapconfigOperations
Link LinkOperations
LoadBalancerCookieStickinessPolicy LoadBalancerCookieStickinessPolicyOperations
LoadBalancerService LoadBalancerServiceOperations
LocalAuthConfig LocalAuthConfigOperations
LogConfig LogConfigOperations
MachineDriver MachineDriverOperations
MetadataObject MetadataObjectOperations
MetadataSyncRequest MetadataSyncRequestOperations
Mount MountOperations
MountEntry MountEntryOperations
Network NetworkOperations
NetworkDriver NetworkDriverOperations
NetworkDriverService NetworkDriverServiceOperations
NetworkInfo NetworkInfoOperations
NetworkPolicyRule NetworkPolicyRuleOperations
NetworkPolicyRuleBetween NetworkPolicyRuleBetweenOperations
NetworkPolicyRuleMember NetworkPolicyRuleMemberOperations
NetworkPolicyRuleWithin NetworkPolicyRuleWithinOperations
Openldapconfig OpenldapconfigOperations
PacketConfig PacketConfigOperations
Password PasswordOperations
PortRule PortRuleOperations
ProcessExecution ProcessExecutionOperations
ProcessInstance ProcessInstanceOperations
ProcessPool ProcessPoolOperations
ProcessSummary ProcessSummaryOperations
Project ProjectOperations
ProjectMember ProjectMemberOperations
PublicEndpoint PublicEndpointOperations
Publish PublishOperations
PullTask PullTaskOperations
Register RegisterOperations
RegistrationToken RegistrationTokenOperations
Registry RegistryOperations
RegistryCredential RegistryCredentialOperations
RestartPolicy RestartPolicyOperations
Revision RevisionOperations
ScalingGroup ScalingGroupOperations
ScheduledUpgrade ScheduledUpgradeOperations
Secret SecretOperations
SecretReference SecretReferenceOperations
SelectorService SelectorServiceOperations
Service ServiceOperations
ServiceEvent ServiceEventOperations
ServiceInfo ServiceInfoOperations
ServiceLog ServiceLogOperations
ServiceProxy ServiceProxyOperations
ServiceRollback ServiceRollbackOperations
ServiceUpgrade ServiceUpgradeOperations
ServiceUpgradeStrategy ServiceUpgradeStrategyOperations
ServicesPortRange ServicesPortRangeOperations
SetProjectMembersInput SetProjectMembersInputOperations
Setting SettingOperations
Stack StackOperations
StackConfiguration StackConfigurationOperations
StackInfo StackInfoOperations
StackUpgrade StackUpgradeOperations
StatsAccess StatsAccessOperations
StorageDriver StorageDriverOperations
StorageDriverService StorageDriverServiceOperations
StoragePool StoragePoolOperations
Subnet SubnetOperations
Subscribe SubscribeOperations
TargetPortRule TargetPortRuleOperations
TypeDocumentation TypeDocumentationOperations
Ulimit UlimitOperations
VirtualMachine VirtualMachineOperations
VirtualMachineDisk VirtualMachineDiskOperations
Volume VolumeOperations
VolumeActivateInput VolumeActivateInputOperations
VolumeTemplate VolumeTemplateOperations
}
func constructClient(rancherBaseClient *RancherBaseClientImpl) *RancherClient {
client := &RancherClient{
RancherBaseClient: rancherBaseClient,
}
client.Account = newAccountClient(client)
client.AddOutputsInput = newAddOutputsInputClient(client)
client.Agent = newAgentClient(client)
client.Amazonec2Config = newAmazonec2ConfigClient(client)
client.ApiKey = newApiKeyClient(client)
client.AuditLog = newAuditLogClient(client)
client.AzureConfig = newAzureConfigClient(client)
client.Azureadconfig = newAzureadconfigClient(client)
client.BaseMachineConfig = newBaseMachineConfigClient(client)
client.BlkioDeviceOption = newBlkioDeviceOptionClient(client)
client.Certificate = newCertificateClient(client)
client.ChangeSecretInput = newChangeSecretInputClient(client)
client.Cluster = newClusterClient(client)
client.ClusterIdentity = newClusterIdentityClient(client)
client.ComposeConfig = newComposeConfigClient(client)
client.ComposeConfigInput = newComposeConfigInputClient(client)
client.Container = newContainerClient(client)
client.ContainerConfig = newContainerConfigClient(client)
client.ContainerEvent = newContainerEventClient(client)
client.ContainerExec = newContainerExecClient(client)
client.ContainerLogs = newContainerLogsClient(client)
client.ContainerProxy = newContainerProxyClient(client)
client.ContainerUpgrade = newContainerUpgradeClient(client)
client.Credential = newCredentialClient(client)
client.Databasechangelog = newDatabasechangelogClient(client)
client.Databasechangeloglock = newDatabasechangeloglockClient(client)
client.DefaultNetwork = newDefaultNetworkClient(client)
client.DependsOn = newDependsOnClient(client)
client.DeploymentSyncRequest = newDeploymentSyncRequestClient(client)
client.DeploymentSyncResponse = newDeploymentSyncResponseClient(client)
client.DeploymentUnit = newDeploymentUnitClient(client)
client.DigitaloceanConfig = newDigitaloceanConfigClient(client)
client.DnsService = newDnsServiceClient(client)
client.DynamicSchema = newDynamicSchemaClient(client)
client.EnvironmentInfo = newEnvironmentInfoClient(client)
client.Error = newErrorClient(client)
client.ExternalDnsEvent = newExternalDnsEventClient(client)
client.ExternalEvent = newExternalEventClient(client)
client.ExternalHostEvent = newExternalHostEventClient(client)
client.ExternalService = newExternalServiceClient(client)
client.ExternalServiceEvent = newExternalServiceEventClient(client)
client.FieldDocumentation = newFieldDocumentationClient(client)
client.GenericObject = newGenericObjectClient(client)
client.HaMembership = newHaMembershipClient(client)
client.HealthcheckInfo = newHealthcheckInfoClient(client)
client.HealthcheckState = newHealthcheckStateClient(client)
client.Host = newHostClient(client)
client.HostAccess = newHostAccessClient(client)
client.HostApiProxyToken = newHostApiProxyTokenClient(client)
client.HostInfo = newHostInfoClient(client)
client.HostTemplate = newHostTemplateClient(client)
client.Identity = newIdentityClient(client)
client.InServiceUpgradeStrategy = newInServiceUpgradeStrategyClient(client)
client.Instance = newInstanceClient(client)
client.InstanceConsole = newInstanceConsoleClient(client)
client.InstanceConsoleInput = newInstanceConsoleInputClient(client)
client.InstanceHealthCheck = newInstanceHealthCheckClient(client)
client.InstanceInfo = newInstanceInfoClient(client)
client.InstanceRemove = newInstanceRemoveClient(client)
client.InstanceStatus = newInstanceStatusClient(client)
client.InstanceStop = newInstanceStopClient(client)
client.K8sClientConfig = newK8sClientConfigClient(client)
client.K8sServerConfig = newK8sServerConfigClient(client)
client.LaunchConfig = newLaunchConfigClient(client)
client.LbConfig = newLbConfigClient(client)
client.LbTargetConfig = newLbTargetConfigClient(client)
client.Ldapconfig = newLdapconfigClient(client)
client.Link = newLinkClient(client)
client.LoadBalancerCookieStickinessPolicy = newLoadBalancerCookieStickinessPolicyClient(client)
client.LoadBalancerService = newLoadBalancerServiceClient(client)
client.LocalAuthConfig = newLocalAuthConfigClient(client)
client.LogConfig = newLogConfigClient(client)
client.MachineDriver = newMachineDriverClient(client)
client.MetadataObject = newMetadataObjectClient(client)
client.MetadataSyncRequest = newMetadataSyncRequestClient(client)
client.Mount = newMountClient(client)
client.MountEntry = newMountEntryClient(client)
client.Network = newNetworkClient(client)
client.NetworkDriver = newNetworkDriverClient(client)
client.NetworkDriverService = newNetworkDriverServiceClient(client)
client.NetworkInfo = newNetworkInfoClient(client)
client.NetworkPolicyRule = newNetworkPolicyRuleClient(client)
client.NetworkPolicyRuleBetween = newNetworkPolicyRuleBetweenClient(client)
client.NetworkPolicyRuleMember = newNetworkPolicyRuleMemberClient(client)
client.NetworkPolicyRuleWithin = newNetworkPolicyRuleWithinClient(client)
client.Openldapconfig = newOpenldapconfigClient(client)
client.PacketConfig = newPacketConfigClient(client)
client.Password = newPasswordClient(client)
client.PortRule = newPortRuleClient(client)
client.ProcessExecution = newProcessExecutionClient(client)
client.ProcessInstance = newProcessInstanceClient(client)
client.ProcessPool = newProcessPoolClient(client)
client.ProcessSummary = newProcessSummaryClient(client)
client.Project = newProjectClient(client)
client.ProjectMember = newProjectMemberClient(client)
client.PublicEndpoint = newPublicEndpointClient(client)
client.Publish = newPublishClient(client)
client.PullTask = newPullTaskClient(client)
client.Register = newRegisterClient(client)
client.RegistrationToken = newRegistrationTokenClient(client)
client.Registry = newRegistryClient(client)
client.RegistryCredential = newRegistryCredentialClient(client)
client.RestartPolicy = newRestartPolicyClient(client)
client.Revision = newRevisionClient(client)
client.ScalingGroup = newScalingGroupClient(client)
client.ScheduledUpgrade = newScheduledUpgradeClient(client)
client.Secret = newSecretClient(client)
client.SecretReference = newSecretReferenceClient(client)
client.SelectorService = newSelectorServiceClient(client)
client.Service = newServiceClient(client)
client.ServiceEvent = newServiceEventClient(client)
client.ServiceInfo = newServiceInfoClient(client)
client.ServiceLog = newServiceLogClient(client)
client.ServiceProxy = newServiceProxyClient(client)
client.ServiceRollback = newServiceRollbackClient(client)
client.ServiceUpgrade = newServiceUpgradeClient(client)
client.ServiceUpgradeStrategy = newServiceUpgradeStrategyClient(client)
client.ServicesPortRange = newServicesPortRangeClient(client)
client.SetProjectMembersInput = newSetProjectMembersInputClient(client)
client.Setting = newSettingClient(client)
client.Stack = newStackClient(client)
client.StackConfiguration = newStackConfigurationClient(client)
client.StackInfo = newStackInfoClient(client)
client.StackUpgrade = newStackUpgradeClient(client)
client.StatsAccess = newStatsAccessClient(client)
client.StorageDriver = newStorageDriverClient(client)
client.StorageDriverService = newStorageDriverServiceClient(client)
client.StoragePool = newStoragePoolClient(client)
client.Subnet = newSubnetClient(client)
client.Subscribe = newSubscribeClient(client)
client.TargetPortRule = newTargetPortRuleClient(client)
client.TypeDocumentation = newTypeDocumentationClient(client)
client.Ulimit = newUlimitClient(client)
client.VirtualMachine = newVirtualMachineClient(client)
client.VirtualMachineDisk = newVirtualMachineDiskClient(client)
client.Volume = newVolumeClient(client)
client.VolumeActivateInput = newVolumeActivateInputClient(client)
client.VolumeTemplate = newVolumeTemplateClient(client)
return client
}
func NewRancherClient(opts *ClientOpts) (*RancherClient, error) {
rancherBaseClient := &RancherBaseClientImpl{
Types: map[string]Schema{},
}
client := constructClient(rancherBaseClient)
err := setupRancherBaseClient(rancherBaseClient, opts)
if err != nil {
return nil, err
}
return client, nil
}

View File

@@ -1,168 +0,0 @@
package client
const (
CLUSTER_TYPE = "cluster"
)
type Cluster struct {
Resource
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Embedded bool `json:"embedded,omitempty" yaml:"embedded,omitempty"`
HostRemoveDelaySeconds int64 `json:"hostRemoveDelaySeconds,omitempty" yaml:"host_remove_delay_seconds,omitempty"`
Identity ClusterIdentity `json:"identity,omitempty" yaml:"identity,omitempty"`
K8sClientConfig *K8sClientConfig `json:"k8sClientConfig,omitempty" yaml:"k8s_client_config,omitempty"`
K8sServerConfig *K8sServerConfig `json:"k8sServerConfig,omitempty" yaml:"k8s_server_config,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Orchestration string `json:"orchestration,omitempty" yaml:"orchestration,omitempty"`
RegistrationToken *RegistrationToken `json:"registrationToken,omitempty" yaml:"registration_token,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
SystemStacks []Stack `json:"systemStacks,omitempty" yaml:"system_stacks,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ClusterCollection struct {
Collection
Data []Cluster `json:"data,omitempty"`
client *ClusterClient
}
type ClusterClient struct {
rancherClient *RancherClient
}
type ClusterOperations interface {
List(opts *ListOpts) (*ClusterCollection, error)
Create(opts *Cluster) (*Cluster, error)
Update(existing *Cluster, updates interface{}) (*Cluster, error)
ById(id string) (*Cluster, error)
Delete(container *Cluster) error
ActionActivate(*Cluster) (*Cluster, error)
ActionCreate(*Cluster) (*Cluster, error)
ActionError(*Cluster) (*Cluster, error)
ActionRemove(*Cluster) (*Cluster, error)
ActionUpdate(*Cluster) (*Cluster, error)
}
func newClusterClient(rancherClient *RancherClient) *ClusterClient {
return &ClusterClient{
rancherClient: rancherClient,
}
}
func (c *ClusterClient) Create(container *Cluster) (*Cluster, error) {
resp := &Cluster{}
err := c.rancherClient.doCreate(CLUSTER_TYPE, container, resp)
return resp, err
}
func (c *ClusterClient) Update(existing *Cluster, updates interface{}) (*Cluster, error) {
resp := &Cluster{}
err := c.rancherClient.doUpdate(CLUSTER_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ClusterClient) List(opts *ListOpts) (*ClusterCollection, error) {
resp := &ClusterCollection{}
err := c.rancherClient.doList(CLUSTER_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ClusterCollection) Next() (*ClusterCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ClusterCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ClusterClient) ById(id string) (*Cluster, error) {
resp := &Cluster{}
err := c.rancherClient.doById(CLUSTER_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ClusterClient) Delete(container *Cluster) error {
return c.rancherClient.doResourceDelete(CLUSTER_TYPE, &container.Resource)
}
func (c *ClusterClient) ActionActivate(resource *Cluster) (*Cluster, error) {
resp := &Cluster{}
err := c.rancherClient.doAction(CLUSTER_TYPE, "activate", &resource.Resource, nil, resp)
return resp, err
}
func (c *ClusterClient) ActionCreate(resource *Cluster) (*Cluster, error) {
resp := &Cluster{}
err := c.rancherClient.doAction(CLUSTER_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ClusterClient) ActionError(resource *Cluster) (*Cluster, error) {
resp := &Cluster{}
err := c.rancherClient.doAction(CLUSTER_TYPE, "error", &resource.Resource, nil, resp)
return resp, err
}
func (c *ClusterClient) ActionRemove(resource *Cluster) (*Cluster, error) {
resp := &Cluster{}
err := c.rancherClient.doAction(CLUSTER_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}
func (c *ClusterClient) ActionUpdate(resource *Cluster) (*Cluster, error) {
resp := &Cluster{}
err := c.rancherClient.doAction(CLUSTER_TYPE, "update", &resource.Resource, nil, resp)
return resp, err
}

View File

@@ -1,85 +0,0 @@
package client
const (
CLUSTER_IDENTITY_TYPE = "clusterIdentity"
)
type ClusterIdentity struct {
Resource
Attributes map[string]string `json:"attributes,omitempty" yaml:"attributes,omitempty"`
Groups []string `json:"groups,omitempty" yaml:"groups,omitempty"`
UserId string `json:"userId,omitempty" yaml:"user_id,omitempty"`
Username string `json:"username,omitempty" yaml:"username,omitempty"`
}
type ClusterIdentityCollection struct {
Collection
Data []ClusterIdentity `json:"data,omitempty"`
client *ClusterIdentityClient
}
type ClusterIdentityClient struct {
rancherClient *RancherClient
}
type ClusterIdentityOperations interface {
List(opts *ListOpts) (*ClusterIdentityCollection, error)
Create(opts *ClusterIdentity) (*ClusterIdentity, error)
Update(existing *ClusterIdentity, updates interface{}) (*ClusterIdentity, error)
ById(id string) (*ClusterIdentity, error)
Delete(container *ClusterIdentity) error
}
func newClusterIdentityClient(rancherClient *RancherClient) *ClusterIdentityClient {
return &ClusterIdentityClient{
rancherClient: rancherClient,
}
}
func (c *ClusterIdentityClient) Create(container *ClusterIdentity) (*ClusterIdentity, error) {
resp := &ClusterIdentity{}
err := c.rancherClient.doCreate(CLUSTER_IDENTITY_TYPE, container, resp)
return resp, err
}
func (c *ClusterIdentityClient) Update(existing *ClusterIdentity, updates interface{}) (*ClusterIdentity, error) {
resp := &ClusterIdentity{}
err := c.rancherClient.doUpdate(CLUSTER_IDENTITY_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ClusterIdentityClient) List(opts *ListOpts) (*ClusterIdentityCollection, error) {
resp := &ClusterIdentityCollection{}
err := c.rancherClient.doList(CLUSTER_IDENTITY_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ClusterIdentityCollection) Next() (*ClusterIdentityCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ClusterIdentityCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ClusterIdentityClient) ById(id string) (*ClusterIdentity, error) {
resp := &ClusterIdentity{}
err := c.rancherClient.doById(CLUSTER_IDENTITY_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ClusterIdentityClient) Delete(container *ClusterIdentity) error {
return c.rancherClient.doResourceDelete(CLUSTER_IDENTITY_TYPE, &container.Resource)
}

View File

@@ -1,87 +0,0 @@
package client
const (
CLUSTER_MEMBERSHIP_TYPE = "clusterMembership"
)
type ClusterMembership struct {
Resource
Clustered bool `json:"clustered,omitempty" yaml:"clustered,omitempty"`
Config string `json:"config,omitempty" yaml:"config,omitempty"`
Heartbeat int64 `json:"heartbeat,omitempty" yaml:"heartbeat,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ClusterMembershipCollection struct {
Collection
Data []ClusterMembership `json:"data,omitempty"`
client *ClusterMembershipClient
}
type ClusterMembershipClient struct {
rancherClient *RancherClient
}
type ClusterMembershipOperations interface {
List(opts *ListOpts) (*ClusterMembershipCollection, error)
Create(opts *ClusterMembership) (*ClusterMembership, error)
Update(existing *ClusterMembership, updates interface{}) (*ClusterMembership, error)
ById(id string) (*ClusterMembership, error)
Delete(container *ClusterMembership) error
}
func newClusterMembershipClient(rancherClient *RancherClient) *ClusterMembershipClient {
return &ClusterMembershipClient{
rancherClient: rancherClient,
}
}
func (c *ClusterMembershipClient) Create(container *ClusterMembership) (*ClusterMembership, error) {
resp := &ClusterMembership{}
err := c.rancherClient.doCreate(CLUSTER_MEMBERSHIP_TYPE, container, resp)
return resp, err
}
func (c *ClusterMembershipClient) Update(existing *ClusterMembership, updates interface{}) (*ClusterMembership, error) {
resp := &ClusterMembership{}
err := c.rancherClient.doUpdate(CLUSTER_MEMBERSHIP_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ClusterMembershipClient) List(opts *ListOpts) (*ClusterMembershipCollection, error) {
resp := &ClusterMembershipCollection{}
err := c.rancherClient.doList(CLUSTER_MEMBERSHIP_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ClusterMembershipCollection) Next() (*ClusterMembershipCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ClusterMembershipCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ClusterMembershipClient) ById(id string) (*ClusterMembership, error) {
resp := &ClusterMembership{}
err := c.rancherClient.doById(CLUSTER_MEMBERSHIP_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ClusterMembershipClient) Delete(container *ClusterMembership) error {
return c.rancherClient.doResourceDelete(CLUSTER_MEMBERSHIP_TYPE, &container.Resource)
}

View File

@@ -1,79 +0,0 @@
package client
const (
COMPOSE_CONFIG_TYPE = "composeConfig"
)
type ComposeConfig struct {
Resource
Templates map[string]string `json:"templates,omitempty" yaml:"templates,omitempty"`
}
type ComposeConfigCollection struct {
Collection
Data []ComposeConfig `json:"data,omitempty"`
client *ComposeConfigClient
}
type ComposeConfigClient struct {
rancherClient *RancherClient
}
type ComposeConfigOperations interface {
List(opts *ListOpts) (*ComposeConfigCollection, error)
Create(opts *ComposeConfig) (*ComposeConfig, error)
Update(existing *ComposeConfig, updates interface{}) (*ComposeConfig, error)
ById(id string) (*ComposeConfig, error)
Delete(container *ComposeConfig) error
}
func newComposeConfigClient(rancherClient *RancherClient) *ComposeConfigClient {
return &ComposeConfigClient{
rancherClient: rancherClient,
}
}
func (c *ComposeConfigClient) Create(container *ComposeConfig) (*ComposeConfig, error) {
resp := &ComposeConfig{}
err := c.rancherClient.doCreate(COMPOSE_CONFIG_TYPE, container, resp)
return resp, err
}
func (c *ComposeConfigClient) Update(existing *ComposeConfig, updates interface{}) (*ComposeConfig, error) {
resp := &ComposeConfig{}
err := c.rancherClient.doUpdate(COMPOSE_CONFIG_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ComposeConfigClient) List(opts *ListOpts) (*ComposeConfigCollection, error) {
resp := &ComposeConfigCollection{}
err := c.rancherClient.doList(COMPOSE_CONFIG_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ComposeConfigCollection) Next() (*ComposeConfigCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ComposeConfigCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ComposeConfigClient) ById(id string) (*ComposeConfig, error) {
resp := &ComposeConfig{}
err := c.rancherClient.doById(COMPOSE_CONFIG_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ComposeConfigClient) Delete(container *ComposeConfig) error {
return c.rancherClient.doResourceDelete(COMPOSE_CONFIG_TYPE, &container.Resource)
}

View File

@@ -1,79 +0,0 @@
package client
const (
COMPOSE_CONFIG_INPUT_TYPE = "composeConfigInput"
)
type ComposeConfigInput struct {
Resource
ServiceIds []string `json:"serviceIds,omitempty" yaml:"service_ids,omitempty"`
}
type ComposeConfigInputCollection struct {
Collection
Data []ComposeConfigInput `json:"data,omitempty"`
client *ComposeConfigInputClient
}
type ComposeConfigInputClient struct {
rancherClient *RancherClient
}
type ComposeConfigInputOperations interface {
List(opts *ListOpts) (*ComposeConfigInputCollection, error)
Create(opts *ComposeConfigInput) (*ComposeConfigInput, error)
Update(existing *ComposeConfigInput, updates interface{}) (*ComposeConfigInput, error)
ById(id string) (*ComposeConfigInput, error)
Delete(container *ComposeConfigInput) error
}
func newComposeConfigInputClient(rancherClient *RancherClient) *ComposeConfigInputClient {
return &ComposeConfigInputClient{
rancherClient: rancherClient,
}
}
func (c *ComposeConfigInputClient) Create(container *ComposeConfigInput) (*ComposeConfigInput, error) {
resp := &ComposeConfigInput{}
err := c.rancherClient.doCreate(COMPOSE_CONFIG_INPUT_TYPE, container, resp)
return resp, err
}
func (c *ComposeConfigInputClient) Update(existing *ComposeConfigInput, updates interface{}) (*ComposeConfigInput, error) {
resp := &ComposeConfigInput{}
err := c.rancherClient.doUpdate(COMPOSE_CONFIG_INPUT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ComposeConfigInputClient) List(opts *ListOpts) (*ComposeConfigInputCollection, error) {
resp := &ComposeConfigInputCollection{}
err := c.rancherClient.doList(COMPOSE_CONFIG_INPUT_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ComposeConfigInputCollection) Next() (*ComposeConfigInputCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ComposeConfigInputCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ComposeConfigInputClient) ById(id string) (*ComposeConfigInput, error) {
resp := &ComposeConfigInput{}
err := c.rancherClient.doById(COMPOSE_CONFIG_INPUT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ComposeConfigInputClient) Delete(container *ComposeConfigInput) error {
return c.rancherClient.doResourceDelete(COMPOSE_CONFIG_INPUT_TYPE, &container.Resource)
}

View File

@@ -1,469 +0,0 @@
package client
const (
CONTAINER_TYPE = "container"
)
type Container struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"`
BlkioDeviceOptions map[string]interface{} `json:"blkioDeviceOptions,omitempty" yaml:"blkio_device_options,omitempty"`
BlkioWeight int64 `json:"blkioWeight,omitempty" yaml:"blkio_weight,omitempty"`
CapAdd []string `json:"capAdd,omitempty" yaml:"cap_add,omitempty"`
CapDrop []string `json:"capDrop,omitempty" yaml:"cap_drop,omitempty"`
CgroupParent string `json:"cgroupParent,omitempty" yaml:"cgroup_parent,omitempty"`
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
Command []string `json:"command,omitempty" yaml:"command,omitempty"`
Count int64 `json:"count,omitempty" yaml:"count,omitempty"`
CpuCount int64 `json:"cpuCount,omitempty" yaml:"cpu_count,omitempty"`
CpuPercent int64 `json:"cpuPercent,omitempty" yaml:"cpu_percent,omitempty"`
CpuPeriod int64 `json:"cpuPeriod,omitempty" yaml:"cpu_period,omitempty"`
CpuQuota int64 `json:"cpuQuota,omitempty" yaml:"cpu_quota,omitempty"`
CpuSetCpu string `json:"cpuSetCpu,omitempty" yaml:"cpu_set_cpu,omitempty"`
CpuSetMems string `json:"cpuSetMems,omitempty" yaml:"cpu_set_mems,omitempty"`
CpuShares int64 `json:"cpuShares,omitempty" yaml:"cpu_shares,omitempty"`
CreateIndex int64 `json:"createIndex,omitempty" yaml:"create_index,omitempty"`
CreateOnly bool `json:"createOnly,omitempty" yaml:"create_only,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
DataVolumeMounts map[string]interface{} `json:"dataVolumeMounts,omitempty" yaml:"data_volume_mounts,omitempty"`
DataVolumes []string `json:"dataVolumes,omitempty" yaml:"data_volumes,omitempty"`
DataVolumesFrom []string `json:"dataVolumesFrom,omitempty" yaml:"data_volumes_from,omitempty"`
DependsOn []DependsOn `json:"dependsOn,omitempty" yaml:"depends_on,omitempty"`
DeploymentUnitId string `json:"deploymentUnitId,omitempty" yaml:"deployment_unit_id,omitempty"`
DeploymentUnitUuid string `json:"deploymentUnitUuid,omitempty" yaml:"deployment_unit_uuid,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Desired bool `json:"desired,omitempty" yaml:"desired,omitempty"`
Devices []string `json:"devices,omitempty" yaml:"devices,omitempty"`
DiskQuota int64 `json:"diskQuota,omitempty" yaml:"disk_quota,omitempty"`
Dns []string `json:"dns,omitempty" yaml:"dns,omitempty"`
DnsOpt []string `json:"dnsOpt,omitempty" yaml:"dns_opt,omitempty"`
DnsSearch []string `json:"dnsSearch,omitempty" yaml:"dns_search,omitempty"`
DomainName string `json:"domainName,omitempty" yaml:"domain_name,omitempty"`
EntryPoint []string `json:"entryPoint,omitempty" yaml:"entry_point,omitempty"`
Environment map[string]string `json:"environment,omitempty" yaml:"environment,omitempty"`
ExitCode int64 `json:"exitCode,omitempty" yaml:"exit_code,omitempty"`
Expose []string `json:"expose,omitempty" yaml:"expose,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
ExtraHosts []string `json:"extraHosts,omitempty" yaml:"extra_hosts,omitempty"`
FirstRunning string `json:"firstRunning,omitempty" yaml:"first_running,omitempty"`
GroupAdd []string `json:"groupAdd,omitempty" yaml:"group_add,omitempty"`
HealthCheck *InstanceHealthCheck `json:"healthCheck,omitempty" yaml:"health_check,omitempty"`
HealthCmd []string `json:"healthCmd,omitempty" yaml:"health_cmd,omitempty"`
HealthInterval int64 `json:"healthInterval,omitempty" yaml:"health_interval,omitempty"`
HealthRetries int64 `json:"healthRetries,omitempty" yaml:"health_retries,omitempty"`
HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"`
HealthTimeout int64 `json:"healthTimeout,omitempty" yaml:"health_timeout,omitempty"`
HealthcheckStates []HealthcheckState `json:"healthcheckStates,omitempty" yaml:"healthcheck_states,omitempty"`
HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"`
Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"`
Image string `json:"image,omitempty" yaml:"image,omitempty"`
ImageUuid string `json:"imageUuid,omitempty" yaml:"image_uuid,omitempty"`
InstanceLinks []Link `json:"instanceLinks,omitempty" yaml:"instance_links,omitempty"`
InstanceTriggeredStop string `json:"instanceTriggeredStop,omitempty" yaml:"instance_triggered_stop,omitempty"`
IoMaximumBandwidth int64 `json:"ioMaximumBandwidth,omitempty" yaml:"io_maximum_bandwidth,omitempty"`
IoMaximumIOps int64 `json:"ioMaximumIOps,omitempty" yaml:"io_maximum_iops,omitempty"`
Ip string `json:"ip,omitempty" yaml:"ip,omitempty"`
Ip6 string `json:"ip6,omitempty" yaml:"ip6,omitempty"`
IpcContainerId string `json:"ipcContainerId,omitempty" yaml:"ipc_container_id,omitempty"`
IpcMode string `json:"ipcMode,omitempty" yaml:"ipc_mode,omitempty"`
Isolation string `json:"isolation,omitempty" yaml:"isolation,omitempty"`
KernelMemory int64 `json:"kernelMemory,omitempty" yaml:"kernel_memory,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
LogConfig *LogConfig `json:"logConfig,omitempty" yaml:"log_config,omitempty"`
LxcConf map[string]string `json:"lxcConf,omitempty" yaml:"lxc_conf,omitempty"`
Memory int64 `json:"memory,omitempty" yaml:"memory,omitempty"`
MemoryReservation int64 `json:"memoryReservation,omitempty" yaml:"memory_reservation,omitempty"`
MemorySwap int64 `json:"memorySwap,omitempty" yaml:"memory_swap,omitempty"`
MemorySwappiness int64 `json:"memorySwappiness,omitempty" yaml:"memory_swappiness,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty"`
MilliCpuReservation int64 `json:"milliCpuReservation,omitempty" yaml:"milli_cpu_reservation,omitempty"`
Mounts []MountEntry `json:"mounts,omitempty" yaml:"mounts,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
NativeContainer bool `json:"nativeContainer,omitempty" yaml:"native_container,omitempty"`
NetAlias []string `json:"netAlias,omitempty" yaml:"net_alias,omitempty"`
NetworkContainerId string `json:"networkContainerId,omitempty" yaml:"network_container_id,omitempty"`
NetworkIds []string `json:"networkIds,omitempty" yaml:"network_ids,omitempty"`
NetworkMode string `json:"networkMode,omitempty" yaml:"network_mode,omitempty"`
OomKillDisable bool `json:"oomKillDisable,omitempty" yaml:"oom_kill_disable,omitempty"`
OomScoreAdj int64 `json:"oomScoreAdj,omitempty" yaml:"oom_score_adj,omitempty"`
PidContainerId string `json:"pidContainerId,omitempty" yaml:"pid_container_id,omitempty"`
PidMode string `json:"pidMode,omitempty" yaml:"pid_mode,omitempty"`
PidsLimit int64 `json:"pidsLimit,omitempty" yaml:"pids_limit,omitempty"`
Ports []string `json:"ports,omitempty" yaml:"ports,omitempty"`
PrePullOnUpgrade string `json:"prePullOnUpgrade,omitempty" yaml:"pre_pull_on_upgrade,omitempty"`
PrimaryIpAddress string `json:"primaryIpAddress,omitempty" yaml:"primary_ip_address,omitempty"`
PrimaryNetworkId string `json:"primaryNetworkId,omitempty" yaml:"primary_network_id,omitempty"`
Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"`
PublicEndpoints []PublicEndpoint `json:"publicEndpoints,omitempty" yaml:"public_endpoints,omitempty"`
PublishAllPorts bool `json:"publishAllPorts,omitempty" yaml:"publish_all_ports,omitempty"`
ReadOnly bool `json:"readOnly,omitempty" yaml:"read_only,omitempty"`
RegistryCredentialId string `json:"registryCredentialId,omitempty" yaml:"registry_credential_id,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
RequestedHostId string `json:"requestedHostId,omitempty" yaml:"requested_host_id,omitempty"`
RequestedIpAddress string `json:"requestedIpAddress,omitempty" yaml:"requested_ip_address,omitempty"`
RestartPolicy *RestartPolicy `json:"restartPolicy,omitempty" yaml:"restart_policy,omitempty"`
RetainIp bool `json:"retainIp,omitempty" yaml:"retain_ip,omitempty"`
RevisionId string `json:"revisionId,omitempty" yaml:"revision_id,omitempty"`
Secrets []SecretReference `json:"secrets,omitempty" yaml:"secrets,omitempty"`
SecurityOpt []string `json:"securityOpt,omitempty" yaml:"security_opt,omitempty"`
ServiceId string `json:"serviceId,omitempty" yaml:"service_id,omitempty"`
ServiceIds []string `json:"serviceIds,omitempty" yaml:"service_ids,omitempty"`
ShmSize int64 `json:"shmSize,omitempty" yaml:"shm_size,omitempty"`
ShouldRestart bool `json:"shouldRestart,omitempty" yaml:"should_restart,omitempty"`
SidekickTo string `json:"sidekickTo,omitempty" yaml:"sidekick_to,omitempty"`
StackId string `json:"stackId,omitempty" yaml:"stack_id,omitempty"`
StartCount int64 `json:"startCount,omitempty" yaml:"start_count,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
StdinOpen bool `json:"stdinOpen,omitempty" yaml:"stdin_open,omitempty"`
StopSignal string `json:"stopSignal,omitempty" yaml:"stop_signal,omitempty"`
StopTimeout int64 `json:"stopTimeout,omitempty" yaml:"stop_timeout,omitempty"`
StorageOpt map[string]string `json:"storageOpt,omitempty" yaml:"storage_opt,omitempty"`
Sysctls map[string]string `json:"sysctls,omitempty" yaml:"sysctls,omitempty"`
Tmpfs map[string]string `json:"tmpfs,omitempty" yaml:"tmpfs,omitempty"`
Token string `json:"token,omitempty" yaml:"token,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
Tty bool `json:"tty,omitempty" yaml:"tty,omitempty"`
Ulimits []Ulimit `json:"ulimits,omitempty" yaml:"ulimits,omitempty"`
User string `json:"user,omitempty" yaml:"user,omitempty"`
UserPorts []string `json:"userPorts,omitempty" yaml:"user_ports,omitempty"`
UsernsMode string `json:"usernsMode,omitempty" yaml:"userns_mode,omitempty"`
Uts string `json:"uts,omitempty" yaml:"uts,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
Version string `json:"version,omitempty" yaml:"version,omitempty"`
VolumeDriver string `json:"volumeDriver,omitempty" yaml:"volume_driver,omitempty"`
WorkingDir string `json:"workingDir,omitempty" yaml:"working_dir,omitempty"`
}
type ContainerCollection struct {
Collection
Data []Container `json:"data,omitempty"`
client *ContainerClient
}
type ContainerClient struct {
rancherClient *RancherClient
}
type ContainerOperations interface {
List(opts *ListOpts) (*ContainerCollection, error)
Create(opts *Container) (*Container, error)
Update(existing *Container, updates interface{}) (*Container, error)
ById(id string) (*Container, error)
Delete(container *Container) error
ActionConsole(*Container, *InstanceConsoleInput) (*InstanceConsole, error)
ActionConverttoservice(*Container) (*Service, error)
ActionCreate(*Container) (*Instance, error)
ActionError(*Container) (*Instance, error)
ActionExecute(*Container, *ContainerExec) (*HostAccess, error)
ActionLogs(*Container, *ContainerLogs) (*HostAccess, error)
ActionProxy(*Container, *ContainerProxy) (*HostAccess, error)
ActionRemove(*Container, *InstanceRemove) (*Instance, error)
ActionRestart(*Container) (*Instance, error)
ActionStart(*Container) (*Instance, error)
ActionStop(*Container, *InstanceStop) (*Instance, error)
ActionUpgrade(*Container, *ContainerUpgrade) (*Revision, error)
}
func newContainerClient(rancherClient *RancherClient) *ContainerClient {
return &ContainerClient{
rancherClient: rancherClient,
}
}
func (c *ContainerClient) Create(container *Container) (*Container, error) {
resp := &Container{}
err := c.rancherClient.doCreate(CONTAINER_TYPE, container, resp)
return resp, err
}
func (c *ContainerClient) Update(existing *Container, updates interface{}) (*Container, error) {
resp := &Container{}
err := c.rancherClient.doUpdate(CONTAINER_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ContainerClient) List(opts *ListOpts) (*ContainerCollection, error) {
resp := &ContainerCollection{}
err := c.rancherClient.doList(CONTAINER_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ContainerCollection) Next() (*ContainerCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ContainerCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ContainerClient) ById(id string) (*Container, error) {
resp := &Container{}
err := c.rancherClient.doById(CONTAINER_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ContainerClient) Delete(container *Container) error {
return c.rancherClient.doResourceDelete(CONTAINER_TYPE, &container.Resource)
}
func (c *ContainerClient) ActionConsole(resource *Container, input *InstanceConsoleInput) (*InstanceConsole, error) {
resp := &InstanceConsole{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "console", &resource.Resource, input, resp)
return resp, err
}
func (c *ContainerClient) ActionConverttoservice(resource *Container) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "converttoservice", &resource.Resource, nil, resp)
return resp, err
}
func (c *ContainerClient) ActionCreate(resource *Container) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ContainerClient) ActionError(resource *Container) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "error", &resource.Resource, nil, resp)
return resp, err
}
func (c *ContainerClient) ActionExecute(resource *Container, input *ContainerExec) (*HostAccess, error) {
resp := &HostAccess{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "execute", &resource.Resource, input, resp)
return resp, err
}
func (c *ContainerClient) ActionLogs(resource *Container, input *ContainerLogs) (*HostAccess, error) {
resp := &HostAccess{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "logs", &resource.Resource, input, resp)
return resp, err
}
func (c *ContainerClient) ActionProxy(resource *Container, input *ContainerProxy) (*HostAccess, error) {
resp := &HostAccess{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "proxy", &resource.Resource, input, resp)
return resp, err
}
func (c *ContainerClient) ActionRemove(resource *Container, input *InstanceRemove) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "remove", &resource.Resource, input, resp)
return resp, err
}
func (c *ContainerClient) ActionRestart(resource *Container) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "restart", &resource.Resource, nil, resp)
return resp, err
}
func (c *ContainerClient) ActionStart(resource *Container) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "start", &resource.Resource, nil, resp)
return resp, err
}
func (c *ContainerClient) ActionStop(resource *Container, input *InstanceStop) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "stop", &resource.Resource, input, resp)
return resp, err
}
func (c *ContainerClient) ActionUpgrade(resource *Container, input *ContainerUpgrade) (*Revision, error) {
resp := &Revision{}
err := c.rancherClient.doAction(CONTAINER_TYPE, "upgrade", &resource.Resource, input, resp)
return resp, err
}

View File

@@ -1,458 +0,0 @@
package client
const (
CONTAINER_CONFIG_TYPE = "containerConfig"
)
type ContainerConfig struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"`
BlkioDeviceOptions map[string]interface{} `json:"blkioDeviceOptions,omitempty" yaml:"blkio_device_options,omitempty"`
BlkioWeight int64 `json:"blkioWeight,omitempty" yaml:"blkio_weight,omitempty"`
CapAdd []string `json:"capAdd,omitempty" yaml:"cap_add,omitempty"`
CapDrop []string `json:"capDrop,omitempty" yaml:"cap_drop,omitempty"`
CgroupParent string `json:"cgroupParent,omitempty" yaml:"cgroup_parent,omitempty"`
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
Command []string `json:"command,omitempty" yaml:"command,omitempty"`
Count int64 `json:"count,omitempty" yaml:"count,omitempty"`
CpuCount int64 `json:"cpuCount,omitempty" yaml:"cpu_count,omitempty"`
CpuPercent int64 `json:"cpuPercent,omitempty" yaml:"cpu_percent,omitempty"`
CpuPeriod int64 `json:"cpuPeriod,omitempty" yaml:"cpu_period,omitempty"`
CpuQuota int64 `json:"cpuQuota,omitempty" yaml:"cpu_quota,omitempty"`
CpuSetCpu string `json:"cpuSetCpu,omitempty" yaml:"cpu_set_cpu,omitempty"`
CpuSetMems string `json:"cpuSetMems,omitempty" yaml:"cpu_set_mems,omitempty"`
CpuShares int64 `json:"cpuShares,omitempty" yaml:"cpu_shares,omitempty"`
CreateIndex int64 `json:"createIndex,omitempty" yaml:"create_index,omitempty"`
CreateOnly bool `json:"createOnly,omitempty" yaml:"create_only,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
DataVolumeMounts map[string]interface{} `json:"dataVolumeMounts,omitempty" yaml:"data_volume_mounts,omitempty"`
DataVolumes []string `json:"dataVolumes,omitempty" yaml:"data_volumes,omitempty"`
DataVolumesFrom []string `json:"dataVolumesFrom,omitempty" yaml:"data_volumes_from,omitempty"`
DependsOn []DependsOn `json:"dependsOn,omitempty" yaml:"depends_on,omitempty"`
DeploymentUnitId string `json:"deploymentUnitId,omitempty" yaml:"deployment_unit_id,omitempty"`
DeploymentUnitUuid string `json:"deploymentUnitUuid,omitempty" yaml:"deployment_unit_uuid,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Desired bool `json:"desired,omitempty" yaml:"desired,omitempty"`
Devices []string `json:"devices,omitempty" yaml:"devices,omitempty"`
DiskQuota int64 `json:"diskQuota,omitempty" yaml:"disk_quota,omitempty"`
Dns []string `json:"dns,omitempty" yaml:"dns,omitempty"`
DnsOpt []string `json:"dnsOpt,omitempty" yaml:"dns_opt,omitempty"`
DnsSearch []string `json:"dnsSearch,omitempty" yaml:"dns_search,omitempty"`
DomainName string `json:"domainName,omitempty" yaml:"domain_name,omitempty"`
EntryPoint []string `json:"entryPoint,omitempty" yaml:"entry_point,omitempty"`
Environment map[string]string `json:"environment,omitempty" yaml:"environment,omitempty"`
ExitCode int64 `json:"exitCode,omitempty" yaml:"exit_code,omitempty"`
Expose []string `json:"expose,omitempty" yaml:"expose,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
ExtraHosts []string `json:"extraHosts,omitempty" yaml:"extra_hosts,omitempty"`
FirstRunning string `json:"firstRunning,omitempty" yaml:"first_running,omitempty"`
GroupAdd []string `json:"groupAdd,omitempty" yaml:"group_add,omitempty"`
HealthCheck *InstanceHealthCheck `json:"healthCheck,omitempty" yaml:"health_check,omitempty"`
HealthCmd []string `json:"healthCmd,omitempty" yaml:"health_cmd,omitempty"`
HealthInterval int64 `json:"healthInterval,omitempty" yaml:"health_interval,omitempty"`
HealthRetries int64 `json:"healthRetries,omitempty" yaml:"health_retries,omitempty"`
HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"`
HealthTimeout int64 `json:"healthTimeout,omitempty" yaml:"health_timeout,omitempty"`
HealthcheckStates []HealthcheckState `json:"healthcheckStates,omitempty" yaml:"healthcheck_states,omitempty"`
HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"`
Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"`
Image string `json:"image,omitempty" yaml:"image,omitempty"`
ImageUuid string `json:"imageUuid,omitempty" yaml:"image_uuid,omitempty"`
InstanceLinks []Link `json:"instanceLinks,omitempty" yaml:"instance_links,omitempty"`
InstanceTriggeredStop string `json:"instanceTriggeredStop,omitempty" yaml:"instance_triggered_stop,omitempty"`
IoMaximumBandwidth int64 `json:"ioMaximumBandwidth,omitempty" yaml:"io_maximum_bandwidth,omitempty"`
IoMaximumIOps int64 `json:"ioMaximumIOps,omitempty" yaml:"io_maximum_iops,omitempty"`
Ip string `json:"ip,omitempty" yaml:"ip,omitempty"`
Ip6 string `json:"ip6,omitempty" yaml:"ip6,omitempty"`
IpcContainerId string `json:"ipcContainerId,omitempty" yaml:"ipc_container_id,omitempty"`
IpcMode string `json:"ipcMode,omitempty" yaml:"ipc_mode,omitempty"`
Isolation string `json:"isolation,omitempty" yaml:"isolation,omitempty"`
KernelMemory int64 `json:"kernelMemory,omitempty" yaml:"kernel_memory,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
LogConfig *LogConfig `json:"logConfig,omitempty" yaml:"log_config,omitempty"`
LxcConf map[string]string `json:"lxcConf,omitempty" yaml:"lxc_conf,omitempty"`
Memory int64 `json:"memory,omitempty" yaml:"memory,omitempty"`
MemoryReservation int64 `json:"memoryReservation,omitempty" yaml:"memory_reservation,omitempty"`
MemorySwap int64 `json:"memorySwap,omitempty" yaml:"memory_swap,omitempty"`
MemorySwappiness int64 `json:"memorySwappiness,omitempty" yaml:"memory_swappiness,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty"`
MilliCpuReservation int64 `json:"milliCpuReservation,omitempty" yaml:"milli_cpu_reservation,omitempty"`
Mounts []MountEntry `json:"mounts,omitempty" yaml:"mounts,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
NativeContainer bool `json:"nativeContainer,omitempty" yaml:"native_container,omitempty"`
NetAlias []string `json:"netAlias,omitempty" yaml:"net_alias,omitempty"`
NetworkContainerId string `json:"networkContainerId,omitempty" yaml:"network_container_id,omitempty"`
NetworkIds []string `json:"networkIds,omitempty" yaml:"network_ids,omitempty"`
NetworkMode string `json:"networkMode,omitempty" yaml:"network_mode,omitempty"`
OomKillDisable bool `json:"oomKillDisable,omitempty" yaml:"oom_kill_disable,omitempty"`
OomScoreAdj int64 `json:"oomScoreAdj,omitempty" yaml:"oom_score_adj,omitempty"`
PidContainerId string `json:"pidContainerId,omitempty" yaml:"pid_container_id,omitempty"`
PidMode string `json:"pidMode,omitempty" yaml:"pid_mode,omitempty"`
PidsLimit int64 `json:"pidsLimit,omitempty" yaml:"pids_limit,omitempty"`
Ports []string `json:"ports,omitempty" yaml:"ports,omitempty"`
PrePullOnUpgrade string `json:"prePullOnUpgrade,omitempty" yaml:"pre_pull_on_upgrade,omitempty"`
PrimaryIpAddress string `json:"primaryIpAddress,omitempty" yaml:"primary_ip_address,omitempty"`
PrimaryNetworkId string `json:"primaryNetworkId,omitempty" yaml:"primary_network_id,omitempty"`
Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"`
PublicEndpoints []PublicEndpoint `json:"publicEndpoints,omitempty" yaml:"public_endpoints,omitempty"`
PublishAllPorts bool `json:"publishAllPorts,omitempty" yaml:"publish_all_ports,omitempty"`
ReadOnly bool `json:"readOnly,omitempty" yaml:"read_only,omitempty"`
RegistryCredentialId string `json:"registryCredentialId,omitempty" yaml:"registry_credential_id,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
RequestedHostId string `json:"requestedHostId,omitempty" yaml:"requested_host_id,omitempty"`
RequestedIpAddress string `json:"requestedIpAddress,omitempty" yaml:"requested_ip_address,omitempty"`
RestartPolicy *RestartPolicy `json:"restartPolicy,omitempty" yaml:"restart_policy,omitempty"`
RetainIp bool `json:"retainIp,omitempty" yaml:"retain_ip,omitempty"`
RevisionId string `json:"revisionId,omitempty" yaml:"revision_id,omitempty"`
Secrets []SecretReference `json:"secrets,omitempty" yaml:"secrets,omitempty"`
SecurityOpt []string `json:"securityOpt,omitempty" yaml:"security_opt,omitempty"`
ServiceId string `json:"serviceId,omitempty" yaml:"service_id,omitempty"`
ServiceIds []string `json:"serviceIds,omitempty" yaml:"service_ids,omitempty"`
ShmSize int64 `json:"shmSize,omitempty" yaml:"shm_size,omitempty"`
ShouldRestart bool `json:"shouldRestart,omitempty" yaml:"should_restart,omitempty"`
SidekickTo string `json:"sidekickTo,omitempty" yaml:"sidekick_to,omitempty"`
StackId string `json:"stackId,omitempty" yaml:"stack_id,omitempty"`
StartCount int64 `json:"startCount,omitempty" yaml:"start_count,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
StdinOpen bool `json:"stdinOpen,omitempty" yaml:"stdin_open,omitempty"`
StopSignal string `json:"stopSignal,omitempty" yaml:"stop_signal,omitempty"`
StopTimeout int64 `json:"stopTimeout,omitempty" yaml:"stop_timeout,omitempty"`
StorageOpt map[string]string `json:"storageOpt,omitempty" yaml:"storage_opt,omitempty"`
Sysctls map[string]string `json:"sysctls,omitempty" yaml:"sysctls,omitempty"`
Tmpfs map[string]string `json:"tmpfs,omitempty" yaml:"tmpfs,omitempty"`
Token string `json:"token,omitempty" yaml:"token,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
Tty bool `json:"tty,omitempty" yaml:"tty,omitempty"`
Ulimits []Ulimit `json:"ulimits,omitempty" yaml:"ulimits,omitempty"`
User string `json:"user,omitempty" yaml:"user,omitempty"`
UserPorts []string `json:"userPorts,omitempty" yaml:"user_ports,omitempty"`
UsernsMode string `json:"usernsMode,omitempty" yaml:"userns_mode,omitempty"`
Uts string `json:"uts,omitempty" yaml:"uts,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
Version string `json:"version,omitempty" yaml:"version,omitempty"`
VolumeDriver string `json:"volumeDriver,omitempty" yaml:"volume_driver,omitempty"`
WorkingDir string `json:"workingDir,omitempty" yaml:"working_dir,omitempty"`
}
type ContainerConfigCollection struct {
Collection
Data []ContainerConfig `json:"data,omitempty"`
client *ContainerConfigClient
}
type ContainerConfigClient struct {
rancherClient *RancherClient
}
type ContainerConfigOperations interface {
List(opts *ListOpts) (*ContainerConfigCollection, error)
Create(opts *ContainerConfig) (*ContainerConfig, error)
Update(existing *ContainerConfig, updates interface{}) (*ContainerConfig, error)
ById(id string) (*ContainerConfig, error)
Delete(container *ContainerConfig) error
ActionConsole(*ContainerConfig, *InstanceConsoleInput) (*InstanceConsole, error)
ActionConverttoservice(*ContainerConfig) (*Service, error)
ActionCreate(*ContainerConfig) (*Instance, error)
ActionError(*ContainerConfig) (*Instance, error)
ActionExecute(*ContainerConfig, *ContainerExec) (*HostAccess, error)
ActionProxy(*ContainerConfig, *ContainerProxy) (*HostAccess, error)
ActionRemove(*ContainerConfig, *InstanceRemove) (*Instance, error)
ActionRestart(*ContainerConfig) (*Instance, error)
ActionStart(*ContainerConfig) (*Instance, error)
ActionStop(*ContainerConfig, *InstanceStop) (*Instance, error)
ActionUpgrade(*ContainerConfig, *ContainerUpgrade) (*Revision, error)
}
func newContainerConfigClient(rancherClient *RancherClient) *ContainerConfigClient {
return &ContainerConfigClient{
rancherClient: rancherClient,
}
}
func (c *ContainerConfigClient) Create(container *ContainerConfig) (*ContainerConfig, error) {
resp := &ContainerConfig{}
err := c.rancherClient.doCreate(CONTAINER_CONFIG_TYPE, container, resp)
return resp, err
}
func (c *ContainerConfigClient) Update(existing *ContainerConfig, updates interface{}) (*ContainerConfig, error) {
resp := &ContainerConfig{}
err := c.rancherClient.doUpdate(CONTAINER_CONFIG_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ContainerConfigClient) List(opts *ListOpts) (*ContainerConfigCollection, error) {
resp := &ContainerConfigCollection{}
err := c.rancherClient.doList(CONTAINER_CONFIG_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ContainerConfigCollection) Next() (*ContainerConfigCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ContainerConfigCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ContainerConfigClient) ById(id string) (*ContainerConfig, error) {
resp := &ContainerConfig{}
err := c.rancherClient.doById(CONTAINER_CONFIG_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ContainerConfigClient) Delete(container *ContainerConfig) error {
return c.rancherClient.doResourceDelete(CONTAINER_CONFIG_TYPE, &container.Resource)
}
func (c *ContainerConfigClient) ActionConsole(resource *ContainerConfig, input *InstanceConsoleInput) (*InstanceConsole, error) {
resp := &InstanceConsole{}
err := c.rancherClient.doAction(CONTAINER_CONFIG_TYPE, "console", &resource.Resource, input, resp)
return resp, err
}
func (c *ContainerConfigClient) ActionConverttoservice(resource *ContainerConfig) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(CONTAINER_CONFIG_TYPE, "converttoservice", &resource.Resource, nil, resp)
return resp, err
}
func (c *ContainerConfigClient) ActionCreate(resource *ContainerConfig) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_CONFIG_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ContainerConfigClient) ActionError(resource *ContainerConfig) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_CONFIG_TYPE, "error", &resource.Resource, nil, resp)
return resp, err
}
func (c *ContainerConfigClient) ActionExecute(resource *ContainerConfig, input *ContainerExec) (*HostAccess, error) {
resp := &HostAccess{}
err := c.rancherClient.doAction(CONTAINER_CONFIG_TYPE, "execute", &resource.Resource, input, resp)
return resp, err
}
func (c *ContainerConfigClient) ActionProxy(resource *ContainerConfig, input *ContainerProxy) (*HostAccess, error) {
resp := &HostAccess{}
err := c.rancherClient.doAction(CONTAINER_CONFIG_TYPE, "proxy", &resource.Resource, input, resp)
return resp, err
}
func (c *ContainerConfigClient) ActionRemove(resource *ContainerConfig, input *InstanceRemove) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_CONFIG_TYPE, "remove", &resource.Resource, input, resp)
return resp, err
}
func (c *ContainerConfigClient) ActionRestart(resource *ContainerConfig) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_CONFIG_TYPE, "restart", &resource.Resource, nil, resp)
return resp, err
}
func (c *ContainerConfigClient) ActionStart(resource *ContainerConfig) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_CONFIG_TYPE, "start", &resource.Resource, nil, resp)
return resp, err
}
func (c *ContainerConfigClient) ActionStop(resource *ContainerConfig, input *InstanceStop) (*Instance, error) {
resp := &Instance{}
err := c.rancherClient.doAction(CONTAINER_CONFIG_TYPE, "stop", &resource.Resource, input, resp)
return resp, err
}
func (c *ContainerConfigClient) ActionUpgrade(resource *ContainerConfig, input *ContainerUpgrade) (*Revision, error) {
resp := &Revision{}
err := c.rancherClient.doAction(CONTAINER_CONFIG_TYPE, "upgrade", &resource.Resource, input, resp)
return resp, err
}

View File

@@ -1,91 +0,0 @@
package client
const (
CONTAINER_EVENT_TYPE = "containerEvent"
)
type ContainerEvent struct {
Resource
ClusterId int64 `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
ContainerUuid string `json:"containerUuid,omitempty" yaml:"container_uuid,omitempty"`
DockerInspect interface{} `json:"dockerInspect,omitempty" yaml:"docker_inspect,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
ExternalStatus string `json:"externalStatus,omitempty" yaml:"external_status,omitempty"`
HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"`
ReportedHostUuid string `json:"reportedHostUuid,omitempty" yaml:"reported_host_uuid,omitempty"`
}
type ContainerEventCollection struct {
Collection
Data []ContainerEvent `json:"data,omitempty"`
client *ContainerEventClient
}
type ContainerEventClient struct {
rancherClient *RancherClient
}
type ContainerEventOperations interface {
List(opts *ListOpts) (*ContainerEventCollection, error)
Create(opts *ContainerEvent) (*ContainerEvent, error)
Update(existing *ContainerEvent, updates interface{}) (*ContainerEvent, error)
ById(id string) (*ContainerEvent, error)
Delete(container *ContainerEvent) error
}
func newContainerEventClient(rancherClient *RancherClient) *ContainerEventClient {
return &ContainerEventClient{
rancherClient: rancherClient,
}
}
func (c *ContainerEventClient) Create(container *ContainerEvent) (*ContainerEvent, error) {
resp := &ContainerEvent{}
err := c.rancherClient.doCreate(CONTAINER_EVENT_TYPE, container, resp)
return resp, err
}
func (c *ContainerEventClient) Update(existing *ContainerEvent, updates interface{}) (*ContainerEvent, error) {
resp := &ContainerEvent{}
err := c.rancherClient.doUpdate(CONTAINER_EVENT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ContainerEventClient) List(opts *ListOpts) (*ContainerEventCollection, error) {
resp := &ContainerEventCollection{}
err := c.rancherClient.doList(CONTAINER_EVENT_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ContainerEventCollection) Next() (*ContainerEventCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ContainerEventCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ContainerEventClient) ById(id string) (*ContainerEvent, error) {
resp := &ContainerEvent{}
err := c.rancherClient.doById(CONTAINER_EVENT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ContainerEventClient) Delete(container *ContainerEvent) error {
return c.rancherClient.doResourceDelete(CONTAINER_EVENT_TYPE, &container.Resource)
}

View File

@@ -1,85 +0,0 @@
package client
const (
CONTAINER_EXEC_TYPE = "containerExec"
)
type ContainerExec struct {
Resource
AttachStdin bool `json:"attachStdin,omitempty" yaml:"attach_stdin,omitempty"`
AttachStdout bool `json:"attachStdout,omitempty" yaml:"attach_stdout,omitempty"`
Command []string `json:"command,omitempty" yaml:"command,omitempty"`
Tty bool `json:"tty,omitempty" yaml:"tty,omitempty"`
}
type ContainerExecCollection struct {
Collection
Data []ContainerExec `json:"data,omitempty"`
client *ContainerExecClient
}
type ContainerExecClient struct {
rancherClient *RancherClient
}
type ContainerExecOperations interface {
List(opts *ListOpts) (*ContainerExecCollection, error)
Create(opts *ContainerExec) (*ContainerExec, error)
Update(existing *ContainerExec, updates interface{}) (*ContainerExec, error)
ById(id string) (*ContainerExec, error)
Delete(container *ContainerExec) error
}
func newContainerExecClient(rancherClient *RancherClient) *ContainerExecClient {
return &ContainerExecClient{
rancherClient: rancherClient,
}
}
func (c *ContainerExecClient) Create(container *ContainerExec) (*ContainerExec, error) {
resp := &ContainerExec{}
err := c.rancherClient.doCreate(CONTAINER_EXEC_TYPE, container, resp)
return resp, err
}
func (c *ContainerExecClient) Update(existing *ContainerExec, updates interface{}) (*ContainerExec, error) {
resp := &ContainerExec{}
err := c.rancherClient.doUpdate(CONTAINER_EXEC_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ContainerExecClient) List(opts *ListOpts) (*ContainerExecCollection, error) {
resp := &ContainerExecCollection{}
err := c.rancherClient.doList(CONTAINER_EXEC_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ContainerExecCollection) Next() (*ContainerExecCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ContainerExecCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ContainerExecClient) ById(id string) (*ContainerExec, error) {
resp := &ContainerExec{}
err := c.rancherClient.doById(CONTAINER_EXEC_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ContainerExecClient) Delete(container *ContainerExec) error {
return c.rancherClient.doResourceDelete(CONTAINER_EXEC_TYPE, &container.Resource)
}

View File

@@ -1,81 +0,0 @@
package client
const (
CONTAINER_LOGS_TYPE = "containerLogs"
)
type ContainerLogs struct {
Resource
Follow bool `json:"follow,omitempty" yaml:"follow,omitempty"`
Lines int64 `json:"lines,omitempty" yaml:"lines,omitempty"`
}
type ContainerLogsCollection struct {
Collection
Data []ContainerLogs `json:"data,omitempty"`
client *ContainerLogsClient
}
type ContainerLogsClient struct {
rancherClient *RancherClient
}
type ContainerLogsOperations interface {
List(opts *ListOpts) (*ContainerLogsCollection, error)
Create(opts *ContainerLogs) (*ContainerLogs, error)
Update(existing *ContainerLogs, updates interface{}) (*ContainerLogs, error)
ById(id string) (*ContainerLogs, error)
Delete(container *ContainerLogs) error
}
func newContainerLogsClient(rancherClient *RancherClient) *ContainerLogsClient {
return &ContainerLogsClient{
rancherClient: rancherClient,
}
}
func (c *ContainerLogsClient) Create(container *ContainerLogs) (*ContainerLogs, error) {
resp := &ContainerLogs{}
err := c.rancherClient.doCreate(CONTAINER_LOGS_TYPE, container, resp)
return resp, err
}
func (c *ContainerLogsClient) Update(existing *ContainerLogs, updates interface{}) (*ContainerLogs, error) {
resp := &ContainerLogs{}
err := c.rancherClient.doUpdate(CONTAINER_LOGS_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ContainerLogsClient) List(opts *ListOpts) (*ContainerLogsCollection, error) {
resp := &ContainerLogsCollection{}
err := c.rancherClient.doList(CONTAINER_LOGS_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ContainerLogsCollection) Next() (*ContainerLogsCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ContainerLogsCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ContainerLogsClient) ById(id string) (*ContainerLogs, error) {
resp := &ContainerLogs{}
err := c.rancherClient.doById(CONTAINER_LOGS_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ContainerLogsClient) Delete(container *ContainerLogs) error {
return c.rancherClient.doResourceDelete(CONTAINER_LOGS_TYPE, &container.Resource)
}

View File

@@ -1,81 +0,0 @@
package client
const (
CONTAINER_PROXY_TYPE = "containerProxy"
)
type ContainerProxy struct {
Resource
Port int64 `json:"port,omitempty" yaml:"port,omitempty"`
Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"`
}
type ContainerProxyCollection struct {
Collection
Data []ContainerProxy `json:"data,omitempty"`
client *ContainerProxyClient
}
type ContainerProxyClient struct {
rancherClient *RancherClient
}
type ContainerProxyOperations interface {
List(opts *ListOpts) (*ContainerProxyCollection, error)
Create(opts *ContainerProxy) (*ContainerProxy, error)
Update(existing *ContainerProxy, updates interface{}) (*ContainerProxy, error)
ById(id string) (*ContainerProxy, error)
Delete(container *ContainerProxy) error
}
func newContainerProxyClient(rancherClient *RancherClient) *ContainerProxyClient {
return &ContainerProxyClient{
rancherClient: rancherClient,
}
}
func (c *ContainerProxyClient) Create(container *ContainerProxy) (*ContainerProxy, error) {
resp := &ContainerProxy{}
err := c.rancherClient.doCreate(CONTAINER_PROXY_TYPE, container, resp)
return resp, err
}
func (c *ContainerProxyClient) Update(existing *ContainerProxy, updates interface{}) (*ContainerProxy, error) {
resp := &ContainerProxy{}
err := c.rancherClient.doUpdate(CONTAINER_PROXY_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ContainerProxyClient) List(opts *ListOpts) (*ContainerProxyCollection, error) {
resp := &ContainerProxyCollection{}
err := c.rancherClient.doList(CONTAINER_PROXY_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ContainerProxyCollection) Next() (*ContainerProxyCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ContainerProxyCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ContainerProxyClient) ById(id string) (*ContainerProxy, error) {
resp := &ContainerProxy{}
err := c.rancherClient.doById(CONTAINER_PROXY_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ContainerProxyClient) Delete(container *ContainerProxy) error {
return c.rancherClient.doResourceDelete(CONTAINER_PROXY_TYPE, &container.Resource)
}

View File

@@ -1,79 +0,0 @@
package client
const (
CONTAINER_UPGRADE_TYPE = "containerUpgrade"
)
type ContainerUpgrade struct {
Resource
Config ContainerConfig `json:"config,omitempty" yaml:"config,omitempty"`
}
type ContainerUpgradeCollection struct {
Collection
Data []ContainerUpgrade `json:"data,omitempty"`
client *ContainerUpgradeClient
}
type ContainerUpgradeClient struct {
rancherClient *RancherClient
}
type ContainerUpgradeOperations interface {
List(opts *ListOpts) (*ContainerUpgradeCollection, error)
Create(opts *ContainerUpgrade) (*ContainerUpgrade, error)
Update(existing *ContainerUpgrade, updates interface{}) (*ContainerUpgrade, error)
ById(id string) (*ContainerUpgrade, error)
Delete(container *ContainerUpgrade) error
}
func newContainerUpgradeClient(rancherClient *RancherClient) *ContainerUpgradeClient {
return &ContainerUpgradeClient{
rancherClient: rancherClient,
}
}
func (c *ContainerUpgradeClient) Create(container *ContainerUpgrade) (*ContainerUpgrade, error) {
resp := &ContainerUpgrade{}
err := c.rancherClient.doCreate(CONTAINER_UPGRADE_TYPE, container, resp)
return resp, err
}
func (c *ContainerUpgradeClient) Update(existing *ContainerUpgrade, updates interface{}) (*ContainerUpgrade, error) {
resp := &ContainerUpgrade{}
err := c.rancherClient.doUpdate(CONTAINER_UPGRADE_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ContainerUpgradeClient) List(opts *ListOpts) (*ContainerUpgradeCollection, error) {
resp := &ContainerUpgradeCollection{}
err := c.rancherClient.doList(CONTAINER_UPGRADE_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ContainerUpgradeCollection) Next() (*ContainerUpgradeCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ContainerUpgradeCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ContainerUpgradeClient) ById(id string) (*ContainerUpgrade, error) {
resp := &ContainerUpgrade{}
err := c.rancherClient.doById(CONTAINER_UPGRADE_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ContainerUpgradeClient) Delete(container *ContainerUpgrade) error {
return c.rancherClient.doResourceDelete(CONTAINER_UPGRADE_TYPE, &container.Resource)
}

View File

@@ -1,149 +0,0 @@
package client
const (
CREDENTIAL_TYPE = "credential"
)
type Credential struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
PublicValue string `json:"publicValue,omitempty" yaml:"public_value,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
SecretValue string `json:"secretValue,omitempty" yaml:"secret_value,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type CredentialCollection struct {
Collection
Data []Credential `json:"data,omitempty"`
client *CredentialClient
}
type CredentialClient struct {
rancherClient *RancherClient
}
type CredentialOperations interface {
List(opts *ListOpts) (*CredentialCollection, error)
Create(opts *Credential) (*Credential, error)
Update(existing *Credential, updates interface{}) (*Credential, error)
ById(id string) (*Credential, error)
Delete(container *Credential) error
ActionActivate(*Credential) (*Credential, error)
ActionCreate(*Credential) (*Credential, error)
ActionDeactivate(*Credential) (*Credential, error)
ActionRemove(*Credential) (*Credential, error)
}
func newCredentialClient(rancherClient *RancherClient) *CredentialClient {
return &CredentialClient{
rancherClient: rancherClient,
}
}
func (c *CredentialClient) Create(container *Credential) (*Credential, error) {
resp := &Credential{}
err := c.rancherClient.doCreate(CREDENTIAL_TYPE, container, resp)
return resp, err
}
func (c *CredentialClient) Update(existing *Credential, updates interface{}) (*Credential, error) {
resp := &Credential{}
err := c.rancherClient.doUpdate(CREDENTIAL_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *CredentialClient) List(opts *ListOpts) (*CredentialCollection, error) {
resp := &CredentialCollection{}
err := c.rancherClient.doList(CREDENTIAL_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *CredentialCollection) Next() (*CredentialCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &CredentialCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *CredentialClient) ById(id string) (*Credential, error) {
resp := &Credential{}
err := c.rancherClient.doById(CREDENTIAL_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *CredentialClient) Delete(container *Credential) error {
return c.rancherClient.doResourceDelete(CREDENTIAL_TYPE, &container.Resource)
}
func (c *CredentialClient) ActionActivate(resource *Credential) (*Credential, error) {
resp := &Credential{}
err := c.rancherClient.doAction(CREDENTIAL_TYPE, "activate", &resource.Resource, nil, resp)
return resp, err
}
func (c *CredentialClient) ActionCreate(resource *Credential) (*Credential, error) {
resp := &Credential{}
err := c.rancherClient.doAction(CREDENTIAL_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *CredentialClient) ActionDeactivate(resource *Credential) (*Credential, error) {
resp := &Credential{}
err := c.rancherClient.doAction(CREDENTIAL_TYPE, "deactivate", &resource.Resource, nil, resp)
return resp, err
}
func (c *CredentialClient) ActionRemove(resource *Credential) (*Credential, error) {
resp := &Credential{}
err := c.rancherClient.doAction(CREDENTIAL_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}

View File

@@ -1,103 +0,0 @@
package client
const (
DATABASECHANGELOG_TYPE = "databasechangelog"
)
type Databasechangelog struct {
Resource
Author string `json:"author,omitempty" yaml:"author,omitempty"`
Comments string `json:"comments,omitempty" yaml:"comments,omitempty"`
Contexts string `json:"contexts,omitempty" yaml:"contexts,omitempty"`
Dateexecuted string `json:"dateexecuted,omitempty" yaml:"dateexecuted,omitempty"`
DeploymentId string `json:"deploymentId,omitempty" yaml:"deployment_id,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Exectype string `json:"exectype,omitempty" yaml:"exectype,omitempty"`
Filename string `json:"filename,omitempty" yaml:"filename,omitempty"`
Labels string `json:"labels,omitempty" yaml:"labels,omitempty"`
Liquibase string `json:"liquibase,omitempty" yaml:"liquibase,omitempty"`
Md5sum string `json:"md5sum,omitempty" yaml:"md5sum,omitempty"`
Orderexecuted int64 `json:"orderexecuted,omitempty" yaml:"orderexecuted,omitempty"`
Tag string `json:"tag,omitempty" yaml:"tag,omitempty"`
}
type DatabasechangelogCollection struct {
Collection
Data []Databasechangelog `json:"data,omitempty"`
client *DatabasechangelogClient
}
type DatabasechangelogClient struct {
rancherClient *RancherClient
}
type DatabasechangelogOperations interface {
List(opts *ListOpts) (*DatabasechangelogCollection, error)
Create(opts *Databasechangelog) (*Databasechangelog, error)
Update(existing *Databasechangelog, updates interface{}) (*Databasechangelog, error)
ById(id string) (*Databasechangelog, error)
Delete(container *Databasechangelog) error
}
func newDatabasechangelogClient(rancherClient *RancherClient) *DatabasechangelogClient {
return &DatabasechangelogClient{
rancherClient: rancherClient,
}
}
func (c *DatabasechangelogClient) Create(container *Databasechangelog) (*Databasechangelog, error) {
resp := &Databasechangelog{}
err := c.rancherClient.doCreate(DATABASECHANGELOG_TYPE, container, resp)
return resp, err
}
func (c *DatabasechangelogClient) Update(existing *Databasechangelog, updates interface{}) (*Databasechangelog, error) {
resp := &Databasechangelog{}
err := c.rancherClient.doUpdate(DATABASECHANGELOG_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *DatabasechangelogClient) List(opts *ListOpts) (*DatabasechangelogCollection, error) {
resp := &DatabasechangelogCollection{}
err := c.rancherClient.doList(DATABASECHANGELOG_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *DatabasechangelogCollection) Next() (*DatabasechangelogCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &DatabasechangelogCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *DatabasechangelogClient) ById(id string) (*Databasechangelog, error) {
resp := &Databasechangelog{}
err := c.rancherClient.doById(DATABASECHANGELOG_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *DatabasechangelogClient) Delete(container *Databasechangelog) error {
return c.rancherClient.doResourceDelete(DATABASECHANGELOG_TYPE, &container.Resource)
}

View File

@@ -1,83 +0,0 @@
package client
const (
DATABASECHANGELOGLOCK_TYPE = "databasechangeloglock"
)
type Databasechangeloglock struct {
Resource
Locked bool `json:"locked,omitempty" yaml:"locked,omitempty"`
Lockedby string `json:"lockedby,omitempty" yaml:"lockedby,omitempty"`
Lockgranted string `json:"lockgranted,omitempty" yaml:"lockgranted,omitempty"`
}
type DatabasechangeloglockCollection struct {
Collection
Data []Databasechangeloglock `json:"data,omitempty"`
client *DatabasechangeloglockClient
}
type DatabasechangeloglockClient struct {
rancherClient *RancherClient
}
type DatabasechangeloglockOperations interface {
List(opts *ListOpts) (*DatabasechangeloglockCollection, error)
Create(opts *Databasechangeloglock) (*Databasechangeloglock, error)
Update(existing *Databasechangeloglock, updates interface{}) (*Databasechangeloglock, error)
ById(id string) (*Databasechangeloglock, error)
Delete(container *Databasechangeloglock) error
}
func newDatabasechangeloglockClient(rancherClient *RancherClient) *DatabasechangeloglockClient {
return &DatabasechangeloglockClient{
rancherClient: rancherClient,
}
}
func (c *DatabasechangeloglockClient) Create(container *Databasechangeloglock) (*Databasechangeloglock, error) {
resp := &Databasechangeloglock{}
err := c.rancherClient.doCreate(DATABASECHANGELOGLOCK_TYPE, container, resp)
return resp, err
}
func (c *DatabasechangeloglockClient) Update(existing *Databasechangeloglock, updates interface{}) (*Databasechangeloglock, error) {
resp := &Databasechangeloglock{}
err := c.rancherClient.doUpdate(DATABASECHANGELOGLOCK_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *DatabasechangeloglockClient) List(opts *ListOpts) (*DatabasechangeloglockCollection, error) {
resp := &DatabasechangeloglockCollection{}
err := c.rancherClient.doList(DATABASECHANGELOGLOCK_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *DatabasechangeloglockCollection) Next() (*DatabasechangeloglockCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &DatabasechangeloglockCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *DatabasechangeloglockClient) ById(id string) (*Databasechangeloglock, error) {
resp := &Databasechangeloglock{}
err := c.rancherClient.doById(DATABASECHANGELOGLOCK_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *DatabasechangeloglockClient) Delete(container *Databasechangeloglock) error {
return c.rancherClient.doResourceDelete(DATABASECHANGELOGLOCK_TYPE, &container.Resource)
}

View File

@@ -1,135 +0,0 @@
package client
const (
DEFAULT_NETWORK_TYPE = "defaultNetwork"
)
type DefaultNetwork struct {
Resource
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
DefaultPolicyAction string `json:"defaultPolicyAction,omitempty" yaml:"default_policy_action,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Dns []string `json:"dns,omitempty" yaml:"dns,omitempty"`
DnsSearch []string `json:"dnsSearch,omitempty" yaml:"dns_search,omitempty"`
HostPorts bool `json:"hostPorts,omitempty" yaml:"host_ports,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Policy []NetworkPolicyRule `json:"policy,omitempty" yaml:"policy,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Subnets []Subnet `json:"subnets,omitempty" yaml:"subnets,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type DefaultNetworkCollection struct {
Collection
Data []DefaultNetwork `json:"data,omitempty"`
client *DefaultNetworkClient
}
type DefaultNetworkClient struct {
rancherClient *RancherClient
}
type DefaultNetworkOperations interface {
List(opts *ListOpts) (*DefaultNetworkCollection, error)
Create(opts *DefaultNetwork) (*DefaultNetwork, error)
Update(existing *DefaultNetwork, updates interface{}) (*DefaultNetwork, error)
ById(id string) (*DefaultNetwork, error)
Delete(container *DefaultNetwork) error
ActionCreate(*DefaultNetwork) (*Network, error)
ActionRemove(*DefaultNetwork) (*Network, error)
}
func newDefaultNetworkClient(rancherClient *RancherClient) *DefaultNetworkClient {
return &DefaultNetworkClient{
rancherClient: rancherClient,
}
}
func (c *DefaultNetworkClient) Create(container *DefaultNetwork) (*DefaultNetwork, error) {
resp := &DefaultNetwork{}
err := c.rancherClient.doCreate(DEFAULT_NETWORK_TYPE, container, resp)
return resp, err
}
func (c *DefaultNetworkClient) Update(existing *DefaultNetwork, updates interface{}) (*DefaultNetwork, error) {
resp := &DefaultNetwork{}
err := c.rancherClient.doUpdate(DEFAULT_NETWORK_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *DefaultNetworkClient) List(opts *ListOpts) (*DefaultNetworkCollection, error) {
resp := &DefaultNetworkCollection{}
err := c.rancherClient.doList(DEFAULT_NETWORK_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *DefaultNetworkCollection) Next() (*DefaultNetworkCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &DefaultNetworkCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *DefaultNetworkClient) ById(id string) (*DefaultNetwork, error) {
resp := &DefaultNetwork{}
err := c.rancherClient.doById(DEFAULT_NETWORK_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *DefaultNetworkClient) Delete(container *DefaultNetwork) error {
return c.rancherClient.doResourceDelete(DEFAULT_NETWORK_TYPE, &container.Resource)
}
func (c *DefaultNetworkClient) ActionCreate(resource *DefaultNetwork) (*Network, error) {
resp := &Network{}
err := c.rancherClient.doAction(DEFAULT_NETWORK_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *DefaultNetworkClient) ActionRemove(resource *DefaultNetwork) (*Network, error) {
resp := &Network{}
err := c.rancherClient.doAction(DEFAULT_NETWORK_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}

View File

@@ -1,83 +0,0 @@
package client
const (
DEPENDS_ON_TYPE = "dependsOn"
)
type DependsOn struct {
Resource
Condition string `json:"condition,omitempty" yaml:"condition,omitempty"`
Container string `json:"container,omitempty" yaml:"container,omitempty"`
Service string `json:"service,omitempty" yaml:"service,omitempty"`
}
type DependsOnCollection struct {
Collection
Data []DependsOn `json:"data,omitempty"`
client *DependsOnClient
}
type DependsOnClient struct {
rancherClient *RancherClient
}
type DependsOnOperations interface {
List(opts *ListOpts) (*DependsOnCollection, error)
Create(opts *DependsOn) (*DependsOn, error)
Update(existing *DependsOn, updates interface{}) (*DependsOn, error)
ById(id string) (*DependsOn, error)
Delete(container *DependsOn) error
}
func newDependsOnClient(rancherClient *RancherClient) *DependsOnClient {
return &DependsOnClient{
rancherClient: rancherClient,
}
}
func (c *DependsOnClient) Create(container *DependsOn) (*DependsOn, error) {
resp := &DependsOn{}
err := c.rancherClient.doCreate(DEPENDS_ON_TYPE, container, resp)
return resp, err
}
func (c *DependsOnClient) Update(existing *DependsOn, updates interface{}) (*DependsOn, error) {
resp := &DependsOn{}
err := c.rancherClient.doUpdate(DEPENDS_ON_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *DependsOnClient) List(opts *ListOpts) (*DependsOnCollection, error) {
resp := &DependsOnCollection{}
err := c.rancherClient.doList(DEPENDS_ON_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *DependsOnCollection) Next() (*DependsOnCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &DependsOnCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *DependsOnClient) ById(id string) (*DependsOn, error) {
resp := &DependsOn{}
err := c.rancherClient.doById(DEPENDS_ON_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *DependsOnClient) Delete(container *DependsOn) error {
return c.rancherClient.doResourceDelete(DEPENDS_ON_TYPE, &container.Resource)
}

View File

@@ -1,97 +0,0 @@
package client
const (
DEPLOYMENT_SYNC_REQUEST_TYPE = "deploymentSyncRequest"
)
type DeploymentSyncRequest struct {
Resource
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
Containers []Container `json:"containers,omitempty" yaml:"containers,omitempty"`
DeploymentUnitUuid string `json:"deploymentUnitUuid,omitempty" yaml:"deployment_unit_uuid,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
Networks []Network `json:"networks,omitempty" yaml:"networks,omitempty"`
NodeName string `json:"nodeName,omitempty" yaml:"node_name,omitempty"`
RegistryCredentials []Credential `json:"registryCredentials,omitempty" yaml:"registry_credentials,omitempty"`
Revision string `json:"revision,omitempty" yaml:"revision,omitempty"`
Volumes []Volume `json:"volumes,omitempty" yaml:"volumes,omitempty"`
}
type DeploymentSyncRequestCollection struct {
Collection
Data []DeploymentSyncRequest `json:"data,omitempty"`
client *DeploymentSyncRequestClient
}
type DeploymentSyncRequestClient struct {
rancherClient *RancherClient
}
type DeploymentSyncRequestOperations interface {
List(opts *ListOpts) (*DeploymentSyncRequestCollection, error)
Create(opts *DeploymentSyncRequest) (*DeploymentSyncRequest, error)
Update(existing *DeploymentSyncRequest, updates interface{}) (*DeploymentSyncRequest, error)
ById(id string) (*DeploymentSyncRequest, error)
Delete(container *DeploymentSyncRequest) error
}
func newDeploymentSyncRequestClient(rancherClient *RancherClient) *DeploymentSyncRequestClient {
return &DeploymentSyncRequestClient{
rancherClient: rancherClient,
}
}
func (c *DeploymentSyncRequestClient) Create(container *DeploymentSyncRequest) (*DeploymentSyncRequest, error) {
resp := &DeploymentSyncRequest{}
err := c.rancherClient.doCreate(DEPLOYMENT_SYNC_REQUEST_TYPE, container, resp)
return resp, err
}
func (c *DeploymentSyncRequestClient) Update(existing *DeploymentSyncRequest, updates interface{}) (*DeploymentSyncRequest, error) {
resp := &DeploymentSyncRequest{}
err := c.rancherClient.doUpdate(DEPLOYMENT_SYNC_REQUEST_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *DeploymentSyncRequestClient) List(opts *ListOpts) (*DeploymentSyncRequestCollection, error) {
resp := &DeploymentSyncRequestCollection{}
err := c.rancherClient.doList(DEPLOYMENT_SYNC_REQUEST_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *DeploymentSyncRequestCollection) Next() (*DeploymentSyncRequestCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &DeploymentSyncRequestCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *DeploymentSyncRequestClient) ById(id string) (*DeploymentSyncRequest, error) {
resp := &DeploymentSyncRequest{}
err := c.rancherClient.doById(DEPLOYMENT_SYNC_REQUEST_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *DeploymentSyncRequestClient) Delete(container *DeploymentSyncRequest) error {
return c.rancherClient.doResourceDelete(DEPLOYMENT_SYNC_REQUEST_TYPE, &container.Resource)
}

View File

@@ -1,83 +0,0 @@
package client
const (
DEPLOYMENT_SYNC_RESPONSE_TYPE = "deploymentSyncResponse"
)
type DeploymentSyncResponse struct {
Resource
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
InstanceStatus []InstanceStatus `json:"instanceStatus,omitempty" yaml:"instance_status,omitempty"`
NodeName string `json:"nodeName,omitempty" yaml:"node_name,omitempty"`
}
type DeploymentSyncResponseCollection struct {
Collection
Data []DeploymentSyncResponse `json:"data,omitempty"`
client *DeploymentSyncResponseClient
}
type DeploymentSyncResponseClient struct {
rancherClient *RancherClient
}
type DeploymentSyncResponseOperations interface {
List(opts *ListOpts) (*DeploymentSyncResponseCollection, error)
Create(opts *DeploymentSyncResponse) (*DeploymentSyncResponse, error)
Update(existing *DeploymentSyncResponse, updates interface{}) (*DeploymentSyncResponse, error)
ById(id string) (*DeploymentSyncResponse, error)
Delete(container *DeploymentSyncResponse) error
}
func newDeploymentSyncResponseClient(rancherClient *RancherClient) *DeploymentSyncResponseClient {
return &DeploymentSyncResponseClient{
rancherClient: rancherClient,
}
}
func (c *DeploymentSyncResponseClient) Create(container *DeploymentSyncResponse) (*DeploymentSyncResponse, error) {
resp := &DeploymentSyncResponse{}
err := c.rancherClient.doCreate(DEPLOYMENT_SYNC_RESPONSE_TYPE, container, resp)
return resp, err
}
func (c *DeploymentSyncResponseClient) Update(existing *DeploymentSyncResponse, updates interface{}) (*DeploymentSyncResponse, error) {
resp := &DeploymentSyncResponse{}
err := c.rancherClient.doUpdate(DEPLOYMENT_SYNC_RESPONSE_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *DeploymentSyncResponseClient) List(opts *ListOpts) (*DeploymentSyncResponseCollection, error) {
resp := &DeploymentSyncResponseCollection{}
err := c.rancherClient.doList(DEPLOYMENT_SYNC_RESPONSE_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *DeploymentSyncResponseCollection) Next() (*DeploymentSyncResponseCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &DeploymentSyncResponseCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *DeploymentSyncResponseClient) ById(id string) (*DeploymentSyncResponse, error) {
resp := &DeploymentSyncResponse{}
err := c.rancherClient.doById(DEPLOYMENT_SYNC_RESPONSE_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *DeploymentSyncResponseClient) Delete(container *DeploymentSyncResponse) error {
return c.rancherClient.doResourceDelete(DEPLOYMENT_SYNC_RESPONSE_TYPE, &container.Resource)
}

View File

@@ -1,188 +0,0 @@
package client
const (
DEPLOYMENT_UNIT_TYPE = "deploymentUnit"
)
type DeploymentUnit struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
RequestedRevisionId string `json:"requestedRevisionId,omitempty" yaml:"requested_revision_id,omitempty"`
RevisionId string `json:"revisionId,omitempty" yaml:"revision_id,omitempty"`
ServiceId string `json:"serviceId,omitempty" yaml:"service_id,omitempty"`
ServiceIndex string `json:"serviceIndex,omitempty" yaml:"service_index,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type DeploymentUnitCollection struct {
Collection
Data []DeploymentUnit `json:"data,omitempty"`
client *DeploymentUnitClient
}
type DeploymentUnitClient struct {
rancherClient *RancherClient
}
type DeploymentUnitOperations interface {
List(opts *ListOpts) (*DeploymentUnitCollection, error)
Create(opts *DeploymentUnit) (*DeploymentUnit, error)
Update(existing *DeploymentUnit, updates interface{}) (*DeploymentUnit, error)
ById(id string) (*DeploymentUnit, error)
Delete(container *DeploymentUnit) error
ActionActivate(*DeploymentUnit) (*DeploymentUnit, error)
ActionCreate(*DeploymentUnit) (*DeploymentUnit, error)
ActionDeactivate(*DeploymentUnit) (*DeploymentUnit, error)
ActionError(*DeploymentUnit) (*DeploymentUnit, error)
ActionPause(*DeploymentUnit) (*DeploymentUnit, error)
ActionRemove(*DeploymentUnit) (*DeploymentUnit, error)
ActionUpdate(*DeploymentUnit) (*DeploymentUnit, error)
}
func newDeploymentUnitClient(rancherClient *RancherClient) *DeploymentUnitClient {
return &DeploymentUnitClient{
rancherClient: rancherClient,
}
}
func (c *DeploymentUnitClient) Create(container *DeploymentUnit) (*DeploymentUnit, error) {
resp := &DeploymentUnit{}
err := c.rancherClient.doCreate(DEPLOYMENT_UNIT_TYPE, container, resp)
return resp, err
}
func (c *DeploymentUnitClient) Update(existing *DeploymentUnit, updates interface{}) (*DeploymentUnit, error) {
resp := &DeploymentUnit{}
err := c.rancherClient.doUpdate(DEPLOYMENT_UNIT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *DeploymentUnitClient) List(opts *ListOpts) (*DeploymentUnitCollection, error) {
resp := &DeploymentUnitCollection{}
err := c.rancherClient.doList(DEPLOYMENT_UNIT_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *DeploymentUnitCollection) Next() (*DeploymentUnitCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &DeploymentUnitCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *DeploymentUnitClient) ById(id string) (*DeploymentUnit, error) {
resp := &DeploymentUnit{}
err := c.rancherClient.doById(DEPLOYMENT_UNIT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *DeploymentUnitClient) Delete(container *DeploymentUnit) error {
return c.rancherClient.doResourceDelete(DEPLOYMENT_UNIT_TYPE, &container.Resource)
}
func (c *DeploymentUnitClient) ActionActivate(resource *DeploymentUnit) (*DeploymentUnit, error) {
resp := &DeploymentUnit{}
err := c.rancherClient.doAction(DEPLOYMENT_UNIT_TYPE, "activate", &resource.Resource, nil, resp)
return resp, err
}
func (c *DeploymentUnitClient) ActionCreate(resource *DeploymentUnit) (*DeploymentUnit, error) {
resp := &DeploymentUnit{}
err := c.rancherClient.doAction(DEPLOYMENT_UNIT_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *DeploymentUnitClient) ActionDeactivate(resource *DeploymentUnit) (*DeploymentUnit, error) {
resp := &DeploymentUnit{}
err := c.rancherClient.doAction(DEPLOYMENT_UNIT_TYPE, "deactivate", &resource.Resource, nil, resp)
return resp, err
}
func (c *DeploymentUnitClient) ActionError(resource *DeploymentUnit) (*DeploymentUnit, error) {
resp := &DeploymentUnit{}
err := c.rancherClient.doAction(DEPLOYMENT_UNIT_TYPE, "error", &resource.Resource, nil, resp)
return resp, err
}
func (c *DeploymentUnitClient) ActionPause(resource *DeploymentUnit) (*DeploymentUnit, error) {
resp := &DeploymentUnit{}
err := c.rancherClient.doAction(DEPLOYMENT_UNIT_TYPE, "pause", &resource.Resource, nil, resp)
return resp, err
}
func (c *DeploymentUnitClient) ActionRemove(resource *DeploymentUnit) (*DeploymentUnit, error) {
resp := &DeploymentUnit{}
err := c.rancherClient.doAction(DEPLOYMENT_UNIT_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}
func (c *DeploymentUnitClient) ActionUpdate(resource *DeploymentUnit) (*DeploymentUnit, error) {
resp := &DeploymentUnit{}
err := c.rancherClient.doAction(DEPLOYMENT_UNIT_TYPE, "update", &resource.Resource, nil, resp)
return resp, err
}

View File

@@ -1,103 +0,0 @@
package client
const (
DIGITALOCEAN_CONFIG_TYPE = "digitaloceanConfig"
)
type DigitaloceanConfig struct {
Resource
AccessToken string `json:"accessToken,omitempty" yaml:"access_token,omitempty"`
Backups bool `json:"backups,omitempty" yaml:"backups,omitempty"`
Image string `json:"image,omitempty" yaml:"image,omitempty"`
Ipv6 bool `json:"ipv6,omitempty" yaml:"ipv6,omitempty"`
PrivateNetworking bool `json:"privateNetworking,omitempty" yaml:"private_networking,omitempty"`
Region string `json:"region,omitempty" yaml:"region,omitempty"`
Size string `json:"size,omitempty" yaml:"size,omitempty"`
SshKeyFingerprint string `json:"sshKeyFingerprint,omitempty" yaml:"ssh_key_fingerprint,omitempty"`
SshKeyPath string `json:"sshKeyPath,omitempty" yaml:"ssh_key_path,omitempty"`
SshPort string `json:"sshPort,omitempty" yaml:"ssh_port,omitempty"`
SshUser string `json:"sshUser,omitempty" yaml:"ssh_user,omitempty"`
Tags string `json:"tags,omitempty" yaml:"tags,omitempty"`
Userdata string `json:"userdata,omitempty" yaml:"userdata,omitempty"`
}
type DigitaloceanConfigCollection struct {
Collection
Data []DigitaloceanConfig `json:"data,omitempty"`
client *DigitaloceanConfigClient
}
type DigitaloceanConfigClient struct {
rancherClient *RancherClient
}
type DigitaloceanConfigOperations interface {
List(opts *ListOpts) (*DigitaloceanConfigCollection, error)
Create(opts *DigitaloceanConfig) (*DigitaloceanConfig, error)
Update(existing *DigitaloceanConfig, updates interface{}) (*DigitaloceanConfig, error)
ById(id string) (*DigitaloceanConfig, error)
Delete(container *DigitaloceanConfig) error
}
func newDigitaloceanConfigClient(rancherClient *RancherClient) *DigitaloceanConfigClient {
return &DigitaloceanConfigClient{
rancherClient: rancherClient,
}
}
func (c *DigitaloceanConfigClient) Create(container *DigitaloceanConfig) (*DigitaloceanConfig, error) {
resp := &DigitaloceanConfig{}
err := c.rancherClient.doCreate(DIGITALOCEAN_CONFIG_TYPE, container, resp)
return resp, err
}
func (c *DigitaloceanConfigClient) Update(existing *DigitaloceanConfig, updates interface{}) (*DigitaloceanConfig, error) {
resp := &DigitaloceanConfig{}
err := c.rancherClient.doUpdate(DIGITALOCEAN_CONFIG_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *DigitaloceanConfigClient) List(opts *ListOpts) (*DigitaloceanConfigCollection, error) {
resp := &DigitaloceanConfigCollection{}
err := c.rancherClient.doList(DIGITALOCEAN_CONFIG_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *DigitaloceanConfigCollection) Next() (*DigitaloceanConfigCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &DigitaloceanConfigCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *DigitaloceanConfigClient) ById(id string) (*DigitaloceanConfig, error) {
resp := &DigitaloceanConfig{}
err := c.rancherClient.doById(DIGITALOCEAN_CONFIG_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *DigitaloceanConfigClient) Delete(container *DigitaloceanConfig) error {
return c.rancherClient.doResourceDelete(DIGITALOCEAN_CONFIG_TYPE, &container.Resource)
}

View File

@@ -1,274 +0,0 @@
package client
const (
DNS_SERVICE_TYPE = "dnsService"
)
type DnsService struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
AssignServiceIpAddress bool `json:"assignServiceIpAddress,omitempty" yaml:"assign_service_ip_address,omitempty"`
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
CompleteUpdate bool `json:"completeUpdate,omitempty" yaml:"complete_update,omitempty"`
CreateOnly bool `json:"createOnly,omitempty" yaml:"create_only,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
Fqdn string `json:"fqdn,omitempty" yaml:"fqdn,omitempty"`
HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"`
InstanceIds []string `json:"instanceIds,omitempty" yaml:"instance_ids,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
LaunchConfig *LaunchConfig `json:"launchConfig,omitempty" yaml:"launch_config,omitempty"`
LbTargetConfig *LbTargetConfig `json:"lbTargetConfig,omitempty" yaml:"lb_target_config,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
PreviousRevisionId string `json:"previousRevisionId,omitempty" yaml:"previous_revision_id,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
RevisionId string `json:"revisionId,omitempty" yaml:"revision_id,omitempty"`
ServiceLinks []Link `json:"serviceLinks,omitempty" yaml:"service_links,omitempty"`
StackId string `json:"stackId,omitempty" yaml:"stack_id,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
Upgrade *ServiceUpgrade `json:"upgrade,omitempty" yaml:"upgrade,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type DnsServiceCollection struct {
Collection
Data []DnsService `json:"data,omitempty"`
client *DnsServiceClient
}
type DnsServiceClient struct {
rancherClient *RancherClient
}
type DnsServiceOperations interface {
List(opts *ListOpts) (*DnsServiceCollection, error)
Create(opts *DnsService) (*DnsService, error)
Update(existing *DnsService, updates interface{}) (*DnsService, error)
ById(id string) (*DnsService, error)
Delete(container *DnsService) error
ActionActivate(*DnsService) (*Service, error)
ActionCancelupgrade(*DnsService) (*Service, error)
ActionCreate(*DnsService) (*Service, error)
ActionDeactivate(*DnsService) (*Service, error)
ActionError(*DnsService) (*Service, error)
ActionFinishupgrade(*DnsService) (*Service, error)
ActionGarbagecollect(*DnsService) (*Service, error)
ActionPause(*DnsService) (*Service, error)
ActionRemove(*DnsService) (*Service, error)
ActionRestart(*DnsService) (*Service, error)
ActionRollback(*DnsService, *ServiceRollback) (*Service, error)
ActionUpdate(*DnsService) (*Service, error)
ActionUpgrade(*DnsService, *ServiceUpgrade) (*Service, error)
}
func newDnsServiceClient(rancherClient *RancherClient) *DnsServiceClient {
return &DnsServiceClient{
rancherClient: rancherClient,
}
}
func (c *DnsServiceClient) Create(container *DnsService) (*DnsService, error) {
resp := &DnsService{}
err := c.rancherClient.doCreate(DNS_SERVICE_TYPE, container, resp)
return resp, err
}
func (c *DnsServiceClient) Update(existing *DnsService, updates interface{}) (*DnsService, error) {
resp := &DnsService{}
err := c.rancherClient.doUpdate(DNS_SERVICE_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *DnsServiceClient) List(opts *ListOpts) (*DnsServiceCollection, error) {
resp := &DnsServiceCollection{}
err := c.rancherClient.doList(DNS_SERVICE_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *DnsServiceCollection) Next() (*DnsServiceCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &DnsServiceCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *DnsServiceClient) ById(id string) (*DnsService, error) {
resp := &DnsService{}
err := c.rancherClient.doById(DNS_SERVICE_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *DnsServiceClient) Delete(container *DnsService) error {
return c.rancherClient.doResourceDelete(DNS_SERVICE_TYPE, &container.Resource)
}
func (c *DnsServiceClient) ActionActivate(resource *DnsService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "activate", &resource.Resource, nil, resp)
return resp, err
}
func (c *DnsServiceClient) ActionCancelupgrade(resource *DnsService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "cancelupgrade", &resource.Resource, nil, resp)
return resp, err
}
func (c *DnsServiceClient) ActionCreate(resource *DnsService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *DnsServiceClient) ActionDeactivate(resource *DnsService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "deactivate", &resource.Resource, nil, resp)
return resp, err
}
func (c *DnsServiceClient) ActionError(resource *DnsService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "error", &resource.Resource, nil, resp)
return resp, err
}
func (c *DnsServiceClient) ActionFinishupgrade(resource *DnsService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "finishupgrade", &resource.Resource, nil, resp)
return resp, err
}
func (c *DnsServiceClient) ActionGarbagecollect(resource *DnsService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "garbagecollect", &resource.Resource, nil, resp)
return resp, err
}
func (c *DnsServiceClient) ActionPause(resource *DnsService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "pause", &resource.Resource, nil, resp)
return resp, err
}
func (c *DnsServiceClient) ActionRemove(resource *DnsService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}
func (c *DnsServiceClient) ActionRestart(resource *DnsService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "restart", &resource.Resource, nil, resp)
return resp, err
}
func (c *DnsServiceClient) ActionRollback(resource *DnsService, input *ServiceRollback) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "rollback", &resource.Resource, input, resp)
return resp, err
}
func (c *DnsServiceClient) ActionUpdate(resource *DnsService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "update", &resource.Resource, nil, resp)
return resp, err
}
func (c *DnsServiceClient) ActionUpgrade(resource *DnsService, input *ServiceUpgrade) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "upgrade", &resource.Resource, input, resp)
return resp, err
}

View File

@@ -1,125 +0,0 @@
package client
const (
DYNAMIC_SCHEMA_TYPE = "dynamicSchema"
)
type DynamicSchema struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Definition string `json:"definition,omitempty" yaml:"definition,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Parent string `json:"parent,omitempty" yaml:"parent,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
Roles []string `json:"roles,omitempty" yaml:"roles,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type DynamicSchemaCollection struct {
Collection
Data []DynamicSchema `json:"data,omitempty"`
client *DynamicSchemaClient
}
type DynamicSchemaClient struct {
rancherClient *RancherClient
}
type DynamicSchemaOperations interface {
List(opts *ListOpts) (*DynamicSchemaCollection, error)
Create(opts *DynamicSchema) (*DynamicSchema, error)
Update(existing *DynamicSchema, updates interface{}) (*DynamicSchema, error)
ById(id string) (*DynamicSchema, error)
Delete(container *DynamicSchema) error
ActionCreate(*DynamicSchema) (*DynamicSchema, error)
ActionRemove(*DynamicSchema) (*DynamicSchema, error)
}
func newDynamicSchemaClient(rancherClient *RancherClient) *DynamicSchemaClient {
return &DynamicSchemaClient{
rancherClient: rancherClient,
}
}
func (c *DynamicSchemaClient) Create(container *DynamicSchema) (*DynamicSchema, error) {
resp := &DynamicSchema{}
err := c.rancherClient.doCreate(DYNAMIC_SCHEMA_TYPE, container, resp)
return resp, err
}
func (c *DynamicSchemaClient) Update(existing *DynamicSchema, updates interface{}) (*DynamicSchema, error) {
resp := &DynamicSchema{}
err := c.rancherClient.doUpdate(DYNAMIC_SCHEMA_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *DynamicSchemaClient) List(opts *ListOpts) (*DynamicSchemaCollection, error) {
resp := &DynamicSchemaCollection{}
err := c.rancherClient.doList(DYNAMIC_SCHEMA_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *DynamicSchemaCollection) Next() (*DynamicSchemaCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &DynamicSchemaCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *DynamicSchemaClient) ById(id string) (*DynamicSchema, error) {
resp := &DynamicSchema{}
err := c.rancherClient.doById(DYNAMIC_SCHEMA_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *DynamicSchemaClient) Delete(container *DynamicSchema) error {
return c.rancherClient.doResourceDelete(DYNAMIC_SCHEMA_TYPE, &container.Resource)
}
func (c *DynamicSchemaClient) ActionCreate(resource *DynamicSchema) (*DynamicSchema, error) {
resp := &DynamicSchema{}
err := c.rancherClient.doAction(DYNAMIC_SCHEMA_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *DynamicSchemaClient) ActionRemove(resource *DynamicSchema) (*DynamicSchema, error) {
resp := &DynamicSchema{}
err := c.rancherClient.doAction(DYNAMIC_SCHEMA_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}

View File

@@ -1,93 +0,0 @@
package client
const (
ENVIRONMENT_INFO_TYPE = "environmentInfo"
)
type EnvironmentInfo struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
EnvironmentUuid string `json:"environmentUuid,omitempty" yaml:"environment_uuid,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
InfoType string `json:"infoType,omitempty" yaml:"info_type,omitempty"`
InfoTypeId string `json:"infoTypeId,omitempty" yaml:"info_type_id,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
System bool `json:"system,omitempty" yaml:"system,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type EnvironmentInfoCollection struct {
Collection
Data []EnvironmentInfo `json:"data,omitempty"`
client *EnvironmentInfoClient
}
type EnvironmentInfoClient struct {
rancherClient *RancherClient
}
type EnvironmentInfoOperations interface {
List(opts *ListOpts) (*EnvironmentInfoCollection, error)
Create(opts *EnvironmentInfo) (*EnvironmentInfo, error)
Update(existing *EnvironmentInfo, updates interface{}) (*EnvironmentInfo, error)
ById(id string) (*EnvironmentInfo, error)
Delete(container *EnvironmentInfo) error
}
func newEnvironmentInfoClient(rancherClient *RancherClient) *EnvironmentInfoClient {
return &EnvironmentInfoClient{
rancherClient: rancherClient,
}
}
func (c *EnvironmentInfoClient) Create(container *EnvironmentInfo) (*EnvironmentInfo, error) {
resp := &EnvironmentInfo{}
err := c.rancherClient.doCreate(ENVIRONMENT_INFO_TYPE, container, resp)
return resp, err
}
func (c *EnvironmentInfoClient) Update(existing *EnvironmentInfo, updates interface{}) (*EnvironmentInfo, error) {
resp := &EnvironmentInfo{}
err := c.rancherClient.doUpdate(ENVIRONMENT_INFO_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *EnvironmentInfoClient) List(opts *ListOpts) (*EnvironmentInfoCollection, error) {
resp := &EnvironmentInfoCollection{}
err := c.rancherClient.doList(ENVIRONMENT_INFO_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *EnvironmentInfoCollection) Next() (*EnvironmentInfoCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &EnvironmentInfoCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *EnvironmentInfoClient) ById(id string) (*EnvironmentInfo, error) {
resp := &EnvironmentInfo{}
err := c.rancherClient.doById(ENVIRONMENT_INFO_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *EnvironmentInfoClient) Delete(container *EnvironmentInfo) error {
return c.rancherClient.doResourceDelete(ENVIRONMENT_INFO_TYPE, &container.Resource)
}

View File

@@ -1,85 +0,0 @@
package client
const (
ERROR_TYPE = "error"
)
type Error struct {
Resource
Code string `json:"code,omitempty" yaml:"code,omitempty"`
Detail string `json:"detail,omitempty" yaml:"detail,omitempty"`
Message string `json:"message,omitempty" yaml:"message,omitempty"`
Status int64 `json:"status,omitempty" yaml:"status,omitempty"`
}
type ErrorCollection struct {
Collection
Data []Error `json:"data,omitempty"`
client *ErrorClient
}
type ErrorClient struct {
rancherClient *RancherClient
}
type ErrorOperations interface {
List(opts *ListOpts) (*ErrorCollection, error)
Create(opts *Error) (*Error, error)
Update(existing *Error, updates interface{}) (*Error, error)
ById(id string) (*Error, error)
Delete(container *Error) error
}
func newErrorClient(rancherClient *RancherClient) *ErrorClient {
return &ErrorClient{
rancherClient: rancherClient,
}
}
func (c *ErrorClient) Create(container *Error) (*Error, error) {
resp := &Error{}
err := c.rancherClient.doCreate(ERROR_TYPE, container, resp)
return resp, err
}
func (c *ErrorClient) Update(existing *Error, updates interface{}) (*Error, error) {
resp := &Error{}
err := c.rancherClient.doUpdate(ERROR_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ErrorClient) List(opts *ListOpts) (*ErrorCollection, error) {
resp := &ErrorCollection{}
err := c.rancherClient.doList(ERROR_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ErrorCollection) Next() (*ErrorCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ErrorCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ErrorClient) ById(id string) (*Error, error) {
resp := &Error{}
err := c.rancherClient.doById(ERROR_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ErrorClient) Delete(container *Error) error {
return c.rancherClient.doResourceDelete(ERROR_TYPE, &container.Resource)
}

View File

@@ -1,101 +0,0 @@
package client
const (
EXTERNAL_DNS_EVENT_TYPE = "externalDnsEvent"
)
type ExternalDnsEvent struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
Fqdn string `json:"fqdn,omitempty" yaml:"fqdn,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
ReportedAccountId string `json:"reportedAccountId,omitempty" yaml:"reported_account_id,omitempty"`
ServiceName string `json:"serviceName,omitempty" yaml:"service_name,omitempty"`
StackName string `json:"stackName,omitempty" yaml:"stack_name,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ExternalDnsEventCollection struct {
Collection
Data []ExternalDnsEvent `json:"data,omitempty"`
client *ExternalDnsEventClient
}
type ExternalDnsEventClient struct {
rancherClient *RancherClient
}
type ExternalDnsEventOperations interface {
List(opts *ListOpts) (*ExternalDnsEventCollection, error)
Create(opts *ExternalDnsEvent) (*ExternalDnsEvent, error)
Update(existing *ExternalDnsEvent, updates interface{}) (*ExternalDnsEvent, error)
ById(id string) (*ExternalDnsEvent, error)
Delete(container *ExternalDnsEvent) error
}
func newExternalDnsEventClient(rancherClient *RancherClient) *ExternalDnsEventClient {
return &ExternalDnsEventClient{
rancherClient: rancherClient,
}
}
func (c *ExternalDnsEventClient) Create(container *ExternalDnsEvent) (*ExternalDnsEvent, error) {
resp := &ExternalDnsEvent{}
err := c.rancherClient.doCreate(EXTERNAL_DNS_EVENT_TYPE, container, resp)
return resp, err
}
func (c *ExternalDnsEventClient) Update(existing *ExternalDnsEvent, updates interface{}) (*ExternalDnsEvent, error) {
resp := &ExternalDnsEvent{}
err := c.rancherClient.doUpdate(EXTERNAL_DNS_EVENT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ExternalDnsEventClient) List(opts *ListOpts) (*ExternalDnsEventCollection, error) {
resp := &ExternalDnsEventCollection{}
err := c.rancherClient.doList(EXTERNAL_DNS_EVENT_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ExternalDnsEventCollection) Next() (*ExternalDnsEventCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ExternalDnsEventCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ExternalDnsEventClient) ById(id string) (*ExternalDnsEvent, error) {
resp := &ExternalDnsEvent{}
err := c.rancherClient.doById(EXTERNAL_DNS_EVENT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ExternalDnsEventClient) Delete(container *ExternalDnsEvent) error {
return c.rancherClient.doResourceDelete(EXTERNAL_DNS_EVENT_TYPE, &container.Resource)
}

View File

@@ -1,95 +0,0 @@
package client
const (
EXTERNAL_EVENT_TYPE = "externalEvent"
)
type ExternalEvent struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
ReportedAccountId string `json:"reportedAccountId,omitempty" yaml:"reported_account_id,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ExternalEventCollection struct {
Collection
Data []ExternalEvent `json:"data,omitempty"`
client *ExternalEventClient
}
type ExternalEventClient struct {
rancherClient *RancherClient
}
type ExternalEventOperations interface {
List(opts *ListOpts) (*ExternalEventCollection, error)
Create(opts *ExternalEvent) (*ExternalEvent, error)
Update(existing *ExternalEvent, updates interface{}) (*ExternalEvent, error)
ById(id string) (*ExternalEvent, error)
Delete(container *ExternalEvent) error
}
func newExternalEventClient(rancherClient *RancherClient) *ExternalEventClient {
return &ExternalEventClient{
rancherClient: rancherClient,
}
}
func (c *ExternalEventClient) Create(container *ExternalEvent) (*ExternalEvent, error) {
resp := &ExternalEvent{}
err := c.rancherClient.doCreate(EXTERNAL_EVENT_TYPE, container, resp)
return resp, err
}
func (c *ExternalEventClient) Update(existing *ExternalEvent, updates interface{}) (*ExternalEvent, error) {
resp := &ExternalEvent{}
err := c.rancherClient.doUpdate(EXTERNAL_EVENT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ExternalEventClient) List(opts *ListOpts) (*ExternalEventCollection, error) {
resp := &ExternalEventCollection{}
err := c.rancherClient.doList(EXTERNAL_EVENT_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ExternalEventCollection) Next() (*ExternalEventCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ExternalEventCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ExternalEventClient) ById(id string) (*ExternalEvent, error) {
resp := &ExternalEvent{}
err := c.rancherClient.doById(EXTERNAL_EVENT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ExternalEventClient) Delete(container *ExternalEvent) error {
return c.rancherClient.doResourceDelete(EXTERNAL_EVENT_TYPE, &container.Resource)
}

View File

@@ -1,101 +0,0 @@
package client
const (
EXTERNAL_HOST_EVENT_TYPE = "externalHostEvent"
)
type ExternalHostEvent struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
DeleteHost bool `json:"deleteHost,omitempty" yaml:"delete_host,omitempty"`
EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"`
HostLabel string `json:"hostLabel,omitempty" yaml:"host_label,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
ReportedAccountId string `json:"reportedAccountId,omitempty" yaml:"reported_account_id,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ExternalHostEventCollection struct {
Collection
Data []ExternalHostEvent `json:"data,omitempty"`
client *ExternalHostEventClient
}
type ExternalHostEventClient struct {
rancherClient *RancherClient
}
type ExternalHostEventOperations interface {
List(opts *ListOpts) (*ExternalHostEventCollection, error)
Create(opts *ExternalHostEvent) (*ExternalHostEvent, error)
Update(existing *ExternalHostEvent, updates interface{}) (*ExternalHostEvent, error)
ById(id string) (*ExternalHostEvent, error)
Delete(container *ExternalHostEvent) error
}
func newExternalHostEventClient(rancherClient *RancherClient) *ExternalHostEventClient {
return &ExternalHostEventClient{
rancherClient: rancherClient,
}
}
func (c *ExternalHostEventClient) Create(container *ExternalHostEvent) (*ExternalHostEvent, error) {
resp := &ExternalHostEvent{}
err := c.rancherClient.doCreate(EXTERNAL_HOST_EVENT_TYPE, container, resp)
return resp, err
}
func (c *ExternalHostEventClient) Update(existing *ExternalHostEvent, updates interface{}) (*ExternalHostEvent, error) {
resp := &ExternalHostEvent{}
err := c.rancherClient.doUpdate(EXTERNAL_HOST_EVENT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ExternalHostEventClient) List(opts *ListOpts) (*ExternalHostEventCollection, error) {
resp := &ExternalHostEventCollection{}
err := c.rancherClient.doList(EXTERNAL_HOST_EVENT_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ExternalHostEventCollection) Next() (*ExternalHostEventCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ExternalHostEventCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ExternalHostEventClient) ById(id string) (*ExternalHostEvent, error) {
resp := &ExternalHostEvent{}
err := c.rancherClient.doById(EXTERNAL_HOST_EVENT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ExternalHostEventClient) Delete(container *ExternalHostEvent) error {
return c.rancherClient.doResourceDelete(EXTERNAL_HOST_EVENT_TYPE, &container.Resource)
}

View File

@@ -1,278 +0,0 @@
package client
const (
EXTERNAL_SERVICE_TYPE = "externalService"
)
type ExternalService struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
CompleteUpdate bool `json:"completeUpdate,omitempty" yaml:"complete_update,omitempty"`
CreateOnly bool `json:"createOnly,omitempty" yaml:"create_only,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
ExternalIpAddresses []string `json:"externalIpAddresses,omitempty" yaml:"external_ip_addresses,omitempty"`
Fqdn string `json:"fqdn,omitempty" yaml:"fqdn,omitempty"`
HealthCheck *InstanceHealthCheck `json:"healthCheck,omitempty" yaml:"health_check,omitempty"`
HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"`
Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"`
InstanceIds []string `json:"instanceIds,omitempty" yaml:"instance_ids,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
LaunchConfig *LaunchConfig `json:"launchConfig,omitempty" yaml:"launch_config,omitempty"`
LbTargetConfig *LbTargetConfig `json:"lbTargetConfig,omitempty" yaml:"lb_target_config,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
PreviousRevisionId string `json:"previousRevisionId,omitempty" yaml:"previous_revision_id,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
RevisionId string `json:"revisionId,omitempty" yaml:"revision_id,omitempty"`
ServiceLinks []Link `json:"serviceLinks,omitempty" yaml:"service_links,omitempty"`
StackId string `json:"stackId,omitempty" yaml:"stack_id,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
Upgrade *ServiceUpgrade `json:"upgrade,omitempty" yaml:"upgrade,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ExternalServiceCollection struct {
Collection
Data []ExternalService `json:"data,omitempty"`
client *ExternalServiceClient
}
type ExternalServiceClient struct {
rancherClient *RancherClient
}
type ExternalServiceOperations interface {
List(opts *ListOpts) (*ExternalServiceCollection, error)
Create(opts *ExternalService) (*ExternalService, error)
Update(existing *ExternalService, updates interface{}) (*ExternalService, error)
ById(id string) (*ExternalService, error)
Delete(container *ExternalService) error
ActionActivate(*ExternalService) (*Service, error)
ActionCancelupgrade(*ExternalService) (*Service, error)
ActionCreate(*ExternalService) (*Service, error)
ActionDeactivate(*ExternalService) (*Service, error)
ActionError(*ExternalService) (*Service, error)
ActionFinishupgrade(*ExternalService) (*Service, error)
ActionGarbagecollect(*ExternalService) (*Service, error)
ActionPause(*ExternalService) (*Service, error)
ActionRemove(*ExternalService) (*Service, error)
ActionRestart(*ExternalService) (*Service, error)
ActionRollback(*ExternalService, *ServiceRollback) (*Service, error)
ActionUpdate(*ExternalService) (*Service, error)
ActionUpgrade(*ExternalService, *ServiceUpgrade) (*Service, error)
}
func newExternalServiceClient(rancherClient *RancherClient) *ExternalServiceClient {
return &ExternalServiceClient{
rancherClient: rancherClient,
}
}
func (c *ExternalServiceClient) Create(container *ExternalService) (*ExternalService, error) {
resp := &ExternalService{}
err := c.rancherClient.doCreate(EXTERNAL_SERVICE_TYPE, container, resp)
return resp, err
}
func (c *ExternalServiceClient) Update(existing *ExternalService, updates interface{}) (*ExternalService, error) {
resp := &ExternalService{}
err := c.rancherClient.doUpdate(EXTERNAL_SERVICE_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ExternalServiceClient) List(opts *ListOpts) (*ExternalServiceCollection, error) {
resp := &ExternalServiceCollection{}
err := c.rancherClient.doList(EXTERNAL_SERVICE_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ExternalServiceCollection) Next() (*ExternalServiceCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ExternalServiceCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ExternalServiceClient) ById(id string) (*ExternalService, error) {
resp := &ExternalService{}
err := c.rancherClient.doById(EXTERNAL_SERVICE_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ExternalServiceClient) Delete(container *ExternalService) error {
return c.rancherClient.doResourceDelete(EXTERNAL_SERVICE_TYPE, &container.Resource)
}
func (c *ExternalServiceClient) ActionActivate(resource *ExternalService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "activate", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalServiceClient) ActionCancelupgrade(resource *ExternalService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "cancelupgrade", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalServiceClient) ActionCreate(resource *ExternalService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalServiceClient) ActionDeactivate(resource *ExternalService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "deactivate", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalServiceClient) ActionError(resource *ExternalService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "error", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalServiceClient) ActionFinishupgrade(resource *ExternalService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "finishupgrade", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalServiceClient) ActionGarbagecollect(resource *ExternalService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "garbagecollect", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalServiceClient) ActionPause(resource *ExternalService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "pause", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalServiceClient) ActionRemove(resource *ExternalService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalServiceClient) ActionRestart(resource *ExternalService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "restart", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalServiceClient) ActionRollback(resource *ExternalService, input *ServiceRollback) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "rollback", &resource.Resource, input, resp)
return resp, err
}
func (c *ExternalServiceClient) ActionUpdate(resource *ExternalService) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "update", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalServiceClient) ActionUpgrade(resource *ExternalService, input *ServiceUpgrade) (*Service, error) {
resp := &Service{}
err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "upgrade", &resource.Resource, input, resp)
return resp, err
}

View File

@@ -1,99 +0,0 @@
package client
const (
EXTERNAL_SERVICE_EVENT_TYPE = "externalServiceEvent"
)
type ExternalServiceEvent struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Environment interface{} `json:"environment,omitempty" yaml:"environment,omitempty"`
EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
ReportedAccountId string `json:"reportedAccountId,omitempty" yaml:"reported_account_id,omitempty"`
Service interface{} `json:"service,omitempty" yaml:"service,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ExternalServiceEventCollection struct {
Collection
Data []ExternalServiceEvent `json:"data,omitempty"`
client *ExternalServiceEventClient
}
type ExternalServiceEventClient struct {
rancherClient *RancherClient
}
type ExternalServiceEventOperations interface {
List(opts *ListOpts) (*ExternalServiceEventCollection, error)
Create(opts *ExternalServiceEvent) (*ExternalServiceEvent, error)
Update(existing *ExternalServiceEvent, updates interface{}) (*ExternalServiceEvent, error)
ById(id string) (*ExternalServiceEvent, error)
Delete(container *ExternalServiceEvent) error
}
func newExternalServiceEventClient(rancherClient *RancherClient) *ExternalServiceEventClient {
return &ExternalServiceEventClient{
rancherClient: rancherClient,
}
}
func (c *ExternalServiceEventClient) Create(container *ExternalServiceEvent) (*ExternalServiceEvent, error) {
resp := &ExternalServiceEvent{}
err := c.rancherClient.doCreate(EXTERNAL_SERVICE_EVENT_TYPE, container, resp)
return resp, err
}
func (c *ExternalServiceEventClient) Update(existing *ExternalServiceEvent, updates interface{}) (*ExternalServiceEvent, error) {
resp := &ExternalServiceEvent{}
err := c.rancherClient.doUpdate(EXTERNAL_SERVICE_EVENT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ExternalServiceEventClient) List(opts *ListOpts) (*ExternalServiceEventCollection, error) {
resp := &ExternalServiceEventCollection{}
err := c.rancherClient.doList(EXTERNAL_SERVICE_EVENT_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ExternalServiceEventCollection) Next() (*ExternalServiceEventCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ExternalServiceEventCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ExternalServiceEventClient) ById(id string) (*ExternalServiceEvent, error) {
resp := &ExternalServiceEvent{}
err := c.rancherClient.doById(EXTERNAL_SERVICE_EVENT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ExternalServiceEventClient) Delete(container *ExternalServiceEvent) error {
return c.rancherClient.doResourceDelete(EXTERNAL_SERVICE_EVENT_TYPE, &container.Resource)
}

View File

@@ -1,79 +0,0 @@
package client
const (
FIELD_DOCUMENTATION_TYPE = "fieldDocumentation"
)
type FieldDocumentation struct {
Resource
Description string `json:"description,omitempty" yaml:"description,omitempty"`
}
type FieldDocumentationCollection struct {
Collection
Data []FieldDocumentation `json:"data,omitempty"`
client *FieldDocumentationClient
}
type FieldDocumentationClient struct {
rancherClient *RancherClient
}
type FieldDocumentationOperations interface {
List(opts *ListOpts) (*FieldDocumentationCollection, error)
Create(opts *FieldDocumentation) (*FieldDocumentation, error)
Update(existing *FieldDocumentation, updates interface{}) (*FieldDocumentation, error)
ById(id string) (*FieldDocumentation, error)
Delete(container *FieldDocumentation) error
}
func newFieldDocumentationClient(rancherClient *RancherClient) *FieldDocumentationClient {
return &FieldDocumentationClient{
rancherClient: rancherClient,
}
}
func (c *FieldDocumentationClient) Create(container *FieldDocumentation) (*FieldDocumentation, error) {
resp := &FieldDocumentation{}
err := c.rancherClient.doCreate(FIELD_DOCUMENTATION_TYPE, container, resp)
return resp, err
}
func (c *FieldDocumentationClient) Update(existing *FieldDocumentation, updates interface{}) (*FieldDocumentation, error) {
resp := &FieldDocumentation{}
err := c.rancherClient.doUpdate(FIELD_DOCUMENTATION_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *FieldDocumentationClient) List(opts *ListOpts) (*FieldDocumentationCollection, error) {
resp := &FieldDocumentationCollection{}
err := c.rancherClient.doList(FIELD_DOCUMENTATION_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *FieldDocumentationCollection) Next() (*FieldDocumentationCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &FieldDocumentationCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *FieldDocumentationClient) ById(id string) (*FieldDocumentation, error) {
resp := &FieldDocumentation{}
err := c.rancherClient.doById(FIELD_DOCUMENTATION_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *FieldDocumentationClient) Delete(container *FieldDocumentation) error {
return c.rancherClient.doResourceDelete(FIELD_DOCUMENTATION_TYPE, &container.Resource)
}

View File

@@ -1,127 +0,0 @@
package client
const (
GENERIC_OBJECT_TYPE = "genericObject"
)
type GenericObject struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Key string `json:"key,omitempty" yaml:"key,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
ResourceData map[string]interface{} `json:"resourceData,omitempty" yaml:"resource_data,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type GenericObjectCollection struct {
Collection
Data []GenericObject `json:"data,omitempty"`
client *GenericObjectClient
}
type GenericObjectClient struct {
rancherClient *RancherClient
}
type GenericObjectOperations interface {
List(opts *ListOpts) (*GenericObjectCollection, error)
Create(opts *GenericObject) (*GenericObject, error)
Update(existing *GenericObject, updates interface{}) (*GenericObject, error)
ById(id string) (*GenericObject, error)
Delete(container *GenericObject) error
ActionCreate(*GenericObject) (*GenericObject, error)
ActionRemove(*GenericObject) (*GenericObject, error)
}
func newGenericObjectClient(rancherClient *RancherClient) *GenericObjectClient {
return &GenericObjectClient{
rancherClient: rancherClient,
}
}
func (c *GenericObjectClient) Create(container *GenericObject) (*GenericObject, error) {
resp := &GenericObject{}
err := c.rancherClient.doCreate(GENERIC_OBJECT_TYPE, container, resp)
return resp, err
}
func (c *GenericObjectClient) Update(existing *GenericObject, updates interface{}) (*GenericObject, error) {
resp := &GenericObject{}
err := c.rancherClient.doUpdate(GENERIC_OBJECT_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *GenericObjectClient) List(opts *ListOpts) (*GenericObjectCollection, error) {
resp := &GenericObjectCollection{}
err := c.rancherClient.doList(GENERIC_OBJECT_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *GenericObjectCollection) Next() (*GenericObjectCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &GenericObjectCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *GenericObjectClient) ById(id string) (*GenericObject, error) {
resp := &GenericObject{}
err := c.rancherClient.doById(GENERIC_OBJECT_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *GenericObjectClient) Delete(container *GenericObject) error {
return c.rancherClient.doResourceDelete(GENERIC_OBJECT_TYPE, &container.Resource)
}
func (c *GenericObjectClient) ActionCreate(resource *GenericObject) (*GenericObject, error) {
resp := &GenericObject{}
err := c.rancherClient.doAction(GENERIC_OBJECT_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *GenericObjectClient) ActionRemove(resource *GenericObject) (*GenericObject, error) {
resp := &GenericObject{}
err := c.rancherClient.doAction(GENERIC_OBJECT_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}

View File

@@ -1,87 +0,0 @@
package client
const (
HA_MEMBERSHIP_TYPE = "haMembership"
)
type HaMembership struct {
Resource
Clustered bool `json:"clustered,omitempty" yaml:"clustered,omitempty"`
Config string `json:"config,omitempty" yaml:"config,omitempty"`
Heartbeat int64 `json:"heartbeat,omitempty" yaml:"heartbeat,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type HaMembershipCollection struct {
Collection
Data []HaMembership `json:"data,omitempty"`
client *HaMembershipClient
}
type HaMembershipClient struct {
rancherClient *RancherClient
}
type HaMembershipOperations interface {
List(opts *ListOpts) (*HaMembershipCollection, error)
Create(opts *HaMembership) (*HaMembership, error)
Update(existing *HaMembership, updates interface{}) (*HaMembership, error)
ById(id string) (*HaMembership, error)
Delete(container *HaMembership) error
}
func newHaMembershipClient(rancherClient *RancherClient) *HaMembershipClient {
return &HaMembershipClient{
rancherClient: rancherClient,
}
}
func (c *HaMembershipClient) Create(container *HaMembership) (*HaMembership, error) {
resp := &HaMembership{}
err := c.rancherClient.doCreate(HA_MEMBERSHIP_TYPE, container, resp)
return resp, err
}
func (c *HaMembershipClient) Update(existing *HaMembership, updates interface{}) (*HaMembership, error) {
resp := &HaMembership{}
err := c.rancherClient.doUpdate(HA_MEMBERSHIP_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *HaMembershipClient) List(opts *ListOpts) (*HaMembershipCollection, error) {
resp := &HaMembershipCollection{}
err := c.rancherClient.doList(HA_MEMBERSHIP_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *HaMembershipCollection) Next() (*HaMembershipCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &HaMembershipCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *HaMembershipClient) ById(id string) (*HaMembership, error) {
resp := &HaMembership{}
err := c.rancherClient.doById(HA_MEMBERSHIP_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *HaMembershipClient) Delete(container *HaMembership) error {
return c.rancherClient.doResourceDelete(HA_MEMBERSHIP_TYPE, &container.Resource)
}

View File

@@ -1,91 +0,0 @@
package client
const (
HEALTHCHECK_INFO_TYPE = "healthcheckInfo"
)
type HealthcheckInfo struct {
Resource
HealthyThreshold int64 `json:"healthyThreshold,omitempty" yaml:"healthy_threshold,omitempty"`
InitializingTimeout int64 `json:"initializingTimeout,omitempty" yaml:"initializing_timeout,omitempty"`
Interval int64 `json:"interval,omitempty" yaml:"interval,omitempty"`
Port int64 `json:"port,omitempty" yaml:"port,omitempty"`
RequestLine string `json:"requestLine,omitempty" yaml:"request_line,omitempty"`
ResponseTimeout int64 `json:"responseTimeout,omitempty" yaml:"response_timeout,omitempty"`
UnhealthyThreshold int64 `json:"unhealthyThreshold,omitempty" yaml:"unhealthy_threshold,omitempty"`
}
type HealthcheckInfoCollection struct {
Collection
Data []HealthcheckInfo `json:"data,omitempty"`
client *HealthcheckInfoClient
}
type HealthcheckInfoClient struct {
rancherClient *RancherClient
}
type HealthcheckInfoOperations interface {
List(opts *ListOpts) (*HealthcheckInfoCollection, error)
Create(opts *HealthcheckInfo) (*HealthcheckInfo, error)
Update(existing *HealthcheckInfo, updates interface{}) (*HealthcheckInfo, error)
ById(id string) (*HealthcheckInfo, error)
Delete(container *HealthcheckInfo) error
}
func newHealthcheckInfoClient(rancherClient *RancherClient) *HealthcheckInfoClient {
return &HealthcheckInfoClient{
rancherClient: rancherClient,
}
}
func (c *HealthcheckInfoClient) Create(container *HealthcheckInfo) (*HealthcheckInfo, error) {
resp := &HealthcheckInfo{}
err := c.rancherClient.doCreate(HEALTHCHECK_INFO_TYPE, container, resp)
return resp, err
}
func (c *HealthcheckInfoClient) Update(existing *HealthcheckInfo, updates interface{}) (*HealthcheckInfo, error) {
resp := &HealthcheckInfo{}
err := c.rancherClient.doUpdate(HEALTHCHECK_INFO_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *HealthcheckInfoClient) List(opts *ListOpts) (*HealthcheckInfoCollection, error) {
resp := &HealthcheckInfoCollection{}
err := c.rancherClient.doList(HEALTHCHECK_INFO_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *HealthcheckInfoCollection) Next() (*HealthcheckInfoCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &HealthcheckInfoCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *HealthcheckInfoClient) ById(id string) (*HealthcheckInfo, error) {
resp := &HealthcheckInfo{}
err := c.rancherClient.doById(HEALTHCHECK_INFO_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *HealthcheckInfoClient) Delete(container *HealthcheckInfo) error {
return c.rancherClient.doResourceDelete(HEALTHCHECK_INFO_TYPE, &container.Resource)
}

View File

@@ -1,81 +0,0 @@
package client
const (
HEALTHCHECK_STATE_TYPE = "healthcheckState"
)
type HealthcheckState struct {
Resource
HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"`
HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"`
}
type HealthcheckStateCollection struct {
Collection
Data []HealthcheckState `json:"data,omitempty"`
client *HealthcheckStateClient
}
type HealthcheckStateClient struct {
rancherClient *RancherClient
}
type HealthcheckStateOperations interface {
List(opts *ListOpts) (*HealthcheckStateCollection, error)
Create(opts *HealthcheckState) (*HealthcheckState, error)
Update(existing *HealthcheckState, updates interface{}) (*HealthcheckState, error)
ById(id string) (*HealthcheckState, error)
Delete(container *HealthcheckState) error
}
func newHealthcheckStateClient(rancherClient *RancherClient) *HealthcheckStateClient {
return &HealthcheckStateClient{
rancherClient: rancherClient,
}
}
func (c *HealthcheckStateClient) Create(container *HealthcheckState) (*HealthcheckState, error) {
resp := &HealthcheckState{}
err := c.rancherClient.doCreate(HEALTHCHECK_STATE_TYPE, container, resp)
return resp, err
}
func (c *HealthcheckStateClient) Update(existing *HealthcheckState, updates interface{}) (*HealthcheckState, error) {
resp := &HealthcheckState{}
err := c.rancherClient.doUpdate(HEALTHCHECK_STATE_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *HealthcheckStateClient) List(opts *ListOpts) (*HealthcheckStateCollection, error) {
resp := &HealthcheckStateCollection{}
err := c.rancherClient.doList(HEALTHCHECK_STATE_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *HealthcheckStateCollection) Next() (*HealthcheckStateCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &HealthcheckStateCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *HealthcheckStateClient) ById(id string) (*HealthcheckState, error) {
resp := &HealthcheckState{}
err := c.rancherClient.doById(HEALTHCHECK_STATE_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *HealthcheckStateClient) Delete(container *HealthcheckState) error {
return c.rancherClient.doResourceDelete(HEALTHCHECK_STATE_TYPE, &container.Resource)
}

View File

@@ -1,262 +0,0 @@
package client
const (
HOST_TYPE = "host"
)
type Host struct {
Resource
AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"`
AgentIpAddress string `json:"agentIpAddress,omitempty" yaml:"agent_ip_address,omitempty"`
AgentState string `json:"agentState,omitempty" yaml:"agent_state,omitempty"`
Amazonec2Config *Amazonec2Config `json:"amazonec2Config,omitempty" yaml:"amazonec2config,omitempty"`
AuthCertificateAuthority string `json:"authCertificateAuthority,omitempty" yaml:"auth_certificate_authority,omitempty"`
AuthKey string `json:"authKey,omitempty" yaml:"auth_key,omitempty"`
AzureConfig *AzureConfig `json:"azureConfig,omitempty" yaml:"azure_config,omitempty"`
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
DigitaloceanConfig *DigitaloceanConfig `json:"digitaloceanConfig,omitempty" yaml:"digitalocean_config,omitempty"`
DockerVersion string `json:"dockerVersion,omitempty" yaml:"docker_version,omitempty"`
Driver string `json:"driver,omitempty" yaml:"driver,omitempty"`
EngineEnv map[string]string `json:"engineEnv,omitempty" yaml:"engine_env,omitempty"`
EngineInsecureRegistry []string `json:"engineInsecureRegistry,omitempty" yaml:"engine_insecure_registry,omitempty"`
EngineInstallUrl string `json:"engineInstallUrl,omitempty" yaml:"engine_install_url,omitempty"`
EngineLabel map[string]string `json:"engineLabel,omitempty" yaml:"engine_label,omitempty"`
EngineOpt map[string]string `json:"engineOpt,omitempty" yaml:"engine_opt,omitempty"`
EngineRegistryMirror []string `json:"engineRegistryMirror,omitempty" yaml:"engine_registry_mirror,omitempty"`
EngineStorageDriver string `json:"engineStorageDriver,omitempty" yaml:"engine_storage_driver,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
ExtractedConfig string `json:"extractedConfig,omitempty" yaml:"extracted_config,omitempty"`
HostTemplateId string `json:"hostTemplateId,omitempty" yaml:"host_template_id,omitempty"`
Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"`
Info interface{} `json:"info,omitempty" yaml:"info,omitempty"`
InstanceIds []string `json:"instanceIds,omitempty" yaml:"instance_ids,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
LocalStorageMb int64 `json:"localStorageMb,omitempty" yaml:"local_storage_mb,omitempty"`
Memory int64 `json:"memory,omitempty" yaml:"memory,omitempty"`
MilliCpu int64 `json:"milliCpu,omitempty" yaml:"milli_cpu,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
NodeName string `json:"nodeName,omitempty" yaml:"node_name,omitempty"`
PacketConfig *PacketConfig `json:"packetConfig,omitempty" yaml:"packet_config,omitempty"`
PublicEndpoints []PublicEndpoint `json:"publicEndpoints,omitempty" yaml:"public_endpoints,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
StackId string `json:"stackId,omitempty" yaml:"stack_id,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type HostCollection struct {
Collection
Data []Host `json:"data,omitempty"`
client *HostClient
}
type HostClient struct {
rancherClient *RancherClient
}
type HostOperations interface {
List(opts *ListOpts) (*HostCollection, error)
Create(opts *Host) (*Host, error)
Update(existing *Host, updates interface{}) (*Host, error)
ById(id string) (*Host, error)
Delete(container *Host) error
ActionActivate(*Host) (*Host, error)
ActionCreate(*Host) (*Host, error)
ActionDeactivate(*Host) (*Host, error)
ActionDockersocket(*Host) (*HostAccess, error)
ActionError(*Host) (*Host, error)
ActionEvacuate(*Host) (*Host, error)
ActionProvision(*Host) (*Host, error)
ActionRemove(*Host) (*Host, error)
ActionUpdate(*Host) (*Host, error)
}
func newHostClient(rancherClient *RancherClient) *HostClient {
return &HostClient{
rancherClient: rancherClient,
}
}
func (c *HostClient) Create(container *Host) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doCreate(HOST_TYPE, container, resp)
return resp, err
}
func (c *HostClient) Update(existing *Host, updates interface{}) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doUpdate(HOST_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *HostClient) List(opts *ListOpts) (*HostCollection, error) {
resp := &HostCollection{}
err := c.rancherClient.doList(HOST_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *HostCollection) Next() (*HostCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &HostCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *HostClient) ById(id string) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doById(HOST_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *HostClient) Delete(container *Host) error {
return c.rancherClient.doResourceDelete(HOST_TYPE, &container.Resource)
}
func (c *HostClient) ActionActivate(resource *Host) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doAction(HOST_TYPE, "activate", &resource.Resource, nil, resp)
return resp, err
}
func (c *HostClient) ActionCreate(resource *Host) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doAction(HOST_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *HostClient) ActionDeactivate(resource *Host) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doAction(HOST_TYPE, "deactivate", &resource.Resource, nil, resp)
return resp, err
}
func (c *HostClient) ActionDockersocket(resource *Host) (*HostAccess, error) {
resp := &HostAccess{}
err := c.rancherClient.doAction(HOST_TYPE, "dockersocket", &resource.Resource, nil, resp)
return resp, err
}
func (c *HostClient) ActionError(resource *Host) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doAction(HOST_TYPE, "error", &resource.Resource, nil, resp)
return resp, err
}
func (c *HostClient) ActionEvacuate(resource *Host) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doAction(HOST_TYPE, "evacuate", &resource.Resource, nil, resp)
return resp, err
}
func (c *HostClient) ActionProvision(resource *Host) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doAction(HOST_TYPE, "provision", &resource.Resource, nil, resp)
return resp, err
}
func (c *HostClient) ActionRemove(resource *Host) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doAction(HOST_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}
func (c *HostClient) ActionUpdate(resource *Host) (*Host, error) {
resp := &Host{}
err := c.rancherClient.doAction(HOST_TYPE, "update", &resource.Resource, nil, resp)
return resp, err
}

View File

@@ -1,81 +0,0 @@
package client
const (
HOST_ACCESS_TYPE = "hostAccess"
)
type HostAccess struct {
Resource
Token string `json:"token,omitempty" yaml:"token,omitempty"`
Url string `json:"url,omitempty" yaml:"url,omitempty"`
}
type HostAccessCollection struct {
Collection
Data []HostAccess `json:"data,omitempty"`
client *HostAccessClient
}
type HostAccessClient struct {
rancherClient *RancherClient
}
type HostAccessOperations interface {
List(opts *ListOpts) (*HostAccessCollection, error)
Create(opts *HostAccess) (*HostAccess, error)
Update(existing *HostAccess, updates interface{}) (*HostAccess, error)
ById(id string) (*HostAccess, error)
Delete(container *HostAccess) error
}
func newHostAccessClient(rancherClient *RancherClient) *HostAccessClient {
return &HostAccessClient{
rancherClient: rancherClient,
}
}
func (c *HostAccessClient) Create(container *HostAccess) (*HostAccess, error) {
resp := &HostAccess{}
err := c.rancherClient.doCreate(HOST_ACCESS_TYPE, container, resp)
return resp, err
}
func (c *HostAccessClient) Update(existing *HostAccess, updates interface{}) (*HostAccess, error) {
resp := &HostAccess{}
err := c.rancherClient.doUpdate(HOST_ACCESS_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *HostAccessClient) List(opts *ListOpts) (*HostAccessCollection, error) {
resp := &HostAccessCollection{}
err := c.rancherClient.doList(HOST_ACCESS_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *HostAccessCollection) Next() (*HostAccessCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &HostAccessCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *HostAccessClient) ById(id string) (*HostAccess, error) {
resp := &HostAccess{}
err := c.rancherClient.doById(HOST_ACCESS_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *HostAccessClient) Delete(container *HostAccess) error {
return c.rancherClient.doResourceDelete(HOST_ACCESS_TYPE, &container.Resource)
}

View File

@@ -1,83 +0,0 @@
package client
const (
HOST_API_PROXY_TOKEN_TYPE = "hostApiProxyToken"
)
type HostApiProxyToken struct {
Resource
ReportedUuid string `json:"reportedUuid,omitempty" yaml:"reported_uuid,omitempty"`
Token string `json:"token,omitempty" yaml:"token,omitempty"`
Url string `json:"url,omitempty" yaml:"url,omitempty"`
}
type HostApiProxyTokenCollection struct {
Collection
Data []HostApiProxyToken `json:"data,omitempty"`
client *HostApiProxyTokenClient
}
type HostApiProxyTokenClient struct {
rancherClient *RancherClient
}
type HostApiProxyTokenOperations interface {
List(opts *ListOpts) (*HostApiProxyTokenCollection, error)
Create(opts *HostApiProxyToken) (*HostApiProxyToken, error)
Update(existing *HostApiProxyToken, updates interface{}) (*HostApiProxyToken, error)
ById(id string) (*HostApiProxyToken, error)
Delete(container *HostApiProxyToken) error
}
func newHostApiProxyTokenClient(rancherClient *RancherClient) *HostApiProxyTokenClient {
return &HostApiProxyTokenClient{
rancherClient: rancherClient,
}
}
func (c *HostApiProxyTokenClient) Create(container *HostApiProxyToken) (*HostApiProxyToken, error) {
resp := &HostApiProxyToken{}
err := c.rancherClient.doCreate(HOST_API_PROXY_TOKEN_TYPE, container, resp)
return resp, err
}
func (c *HostApiProxyTokenClient) Update(existing *HostApiProxyToken, updates interface{}) (*HostApiProxyToken, error) {
resp := &HostApiProxyToken{}
err := c.rancherClient.doUpdate(HOST_API_PROXY_TOKEN_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *HostApiProxyTokenClient) List(opts *ListOpts) (*HostApiProxyTokenCollection, error) {
resp := &HostApiProxyTokenCollection{}
err := c.rancherClient.doList(HOST_API_PROXY_TOKEN_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *HostApiProxyTokenCollection) Next() (*HostApiProxyTokenCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &HostApiProxyTokenCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *HostApiProxyTokenClient) ById(id string) (*HostApiProxyToken, error) {
resp := &HostApiProxyToken{}
err := c.rancherClient.doById(HOST_API_PROXY_TOKEN_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *HostApiProxyTokenClient) Delete(container *HostApiProxyToken) error {
return c.rancherClient.doResourceDelete(HOST_API_PROXY_TOKEN_TYPE, &container.Resource)
}

View File

@@ -1,109 +0,0 @@
package client
const (
HOST_INFO_TYPE = "hostInfo"
)
type HostInfo struct {
Resource
AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"`
AgentIp string `json:"agentIp,omitempty" yaml:"agent_ip,omitempty"`
AgentState string `json:"agentState,omitempty" yaml:"agent_state,omitempty"`
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
EnvironmentUuid string `json:"environmentUuid,omitempty" yaml:"environment_uuid,omitempty"`
Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"`
InfoType string `json:"infoType,omitempty" yaml:"info_type,omitempty"`
InfoTypeId string `json:"infoTypeId,omitempty" yaml:"info_type_id,omitempty"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
Memory int64 `json:"memory,omitempty" yaml:"memory,omitempty"`
MilliCpu int64 `json:"milliCpu,omitempty" yaml:"milli_cpu,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
NodeName string `json:"nodeName,omitempty" yaml:"node_name,omitempty"`
Ports []PublicEndpoint `json:"ports,omitempty" yaml:"ports,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type HostInfoCollection struct {
Collection
Data []HostInfo `json:"data,omitempty"`
client *HostInfoClient
}
type HostInfoClient struct {
rancherClient *RancherClient
}
type HostInfoOperations interface {
List(opts *ListOpts) (*HostInfoCollection, error)
Create(opts *HostInfo) (*HostInfo, error)
Update(existing *HostInfo, updates interface{}) (*HostInfo, error)
ById(id string) (*HostInfo, error)
Delete(container *HostInfo) error
}
func newHostInfoClient(rancherClient *RancherClient) *HostInfoClient {
return &HostInfoClient{
rancherClient: rancherClient,
}
}
func (c *HostInfoClient) Create(container *HostInfo) (*HostInfo, error) {
resp := &HostInfo{}
err := c.rancherClient.doCreate(HOST_INFO_TYPE, container, resp)
return resp, err
}
func (c *HostInfoClient) Update(existing *HostInfo, updates interface{}) (*HostInfo, error) {
resp := &HostInfo{}
err := c.rancherClient.doUpdate(HOST_INFO_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *HostInfoClient) List(opts *ListOpts) (*HostInfoCollection, error) {
resp := &HostInfoCollection{}
err := c.rancherClient.doList(HOST_INFO_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *HostInfoCollection) Next() (*HostInfoCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &HostInfoCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *HostInfoClient) ById(id string) (*HostInfo, error) {
resp := &HostInfo{}
err := c.rancherClient.doById(HOST_INFO_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *HostInfoClient) Delete(container *HostInfo) error {
return c.rancherClient.doResourceDelete(HOST_INFO_TYPE, &container.Resource)
}

View File

@@ -1,129 +0,0 @@
package client
const (
HOST_TEMPLATE_TYPE = "hostTemplate"
)
type HostTemplate struct {
Resource
ClusterId string `json:"clusterId,omitempty" yaml:"cluster_id,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Driver string `json:"driver,omitempty" yaml:"driver,omitempty"`
FlavorPrefix string `json:"flavorPrefix,omitempty" yaml:"flavor_prefix,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
PublicValues map[string]interface{} `json:"publicValues,omitempty" yaml:"public_values,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
SecretValues map[string]interface{} `json:"secretValues,omitempty" yaml:"secret_values,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type HostTemplateCollection struct {
Collection
Data []HostTemplate `json:"data,omitempty"`
client *HostTemplateClient
}
type HostTemplateClient struct {
rancherClient *RancherClient
}
type HostTemplateOperations interface {
List(opts *ListOpts) (*HostTemplateCollection, error)
Create(opts *HostTemplate) (*HostTemplate, error)
Update(existing *HostTemplate, updates interface{}) (*HostTemplate, error)
ById(id string) (*HostTemplate, error)
Delete(container *HostTemplate) error
ActionCreate(*HostTemplate) (*HostTemplate, error)
ActionRemove(*HostTemplate) (*HostTemplate, error)
}
func newHostTemplateClient(rancherClient *RancherClient) *HostTemplateClient {
return &HostTemplateClient{
rancherClient: rancherClient,
}
}
func (c *HostTemplateClient) Create(container *HostTemplate) (*HostTemplate, error) {
resp := &HostTemplate{}
err := c.rancherClient.doCreate(HOST_TEMPLATE_TYPE, container, resp)
return resp, err
}
func (c *HostTemplateClient) Update(existing *HostTemplate, updates interface{}) (*HostTemplate, error) {
resp := &HostTemplate{}
err := c.rancherClient.doUpdate(HOST_TEMPLATE_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *HostTemplateClient) List(opts *ListOpts) (*HostTemplateCollection, error) {
resp := &HostTemplateCollection{}
err := c.rancherClient.doList(HOST_TEMPLATE_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *HostTemplateCollection) Next() (*HostTemplateCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &HostTemplateCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *HostTemplateClient) ById(id string) (*HostTemplate, error) {
resp := &HostTemplate{}
err := c.rancherClient.doById(HOST_TEMPLATE_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *HostTemplateClient) Delete(container *HostTemplate) error {
return c.rancherClient.doResourceDelete(HOST_TEMPLATE_TYPE, &container.Resource)
}
func (c *HostTemplateClient) ActionCreate(resource *HostTemplate) (*HostTemplate, error) {
resp := &HostTemplate{}
err := c.rancherClient.doAction(HOST_TEMPLATE_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *HostTemplateClient) ActionRemove(resource *HostTemplate) (*HostTemplate, error) {
resp := &HostTemplate{}
err := c.rancherClient.doAction(HOST_TEMPLATE_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}

View File

@@ -1,97 +0,0 @@
package client
const (
IDENTITY_TYPE = "identity"
)
type Identity struct {
Resource
All string `json:"all,omitempty" yaml:"all,omitempty"`
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
ExternalIdType string `json:"externalIdType,omitempty" yaml:"external_id_type,omitempty"`
Login string `json:"login,omitempty" yaml:"login,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
ProfilePicture string `json:"profilePicture,omitempty" yaml:"profile_picture,omitempty"`
ProfileUrl string `json:"profileUrl,omitempty" yaml:"profile_url,omitempty"`
ProjectId string `json:"projectId,omitempty" yaml:"project_id,omitempty"`
Role string `json:"role,omitempty" yaml:"role,omitempty"`
User bool `json:"user,omitempty" yaml:"user,omitempty"`
}
type IdentityCollection struct {
Collection
Data []Identity `json:"data,omitempty"`
client *IdentityClient
}
type IdentityClient struct {
rancherClient *RancherClient
}
type IdentityOperations interface {
List(opts *ListOpts) (*IdentityCollection, error)
Create(opts *Identity) (*Identity, error)
Update(existing *Identity, updates interface{}) (*Identity, error)
ById(id string) (*Identity, error)
Delete(container *Identity) error
}
func newIdentityClient(rancherClient *RancherClient) *IdentityClient {
return &IdentityClient{
rancherClient: rancherClient,
}
}
func (c *IdentityClient) Create(container *Identity) (*Identity, error) {
resp := &Identity{}
err := c.rancherClient.doCreate(IDENTITY_TYPE, container, resp)
return resp, err
}
func (c *IdentityClient) Update(existing *Identity, updates interface{}) (*Identity, error) {
resp := &Identity{}
err := c.rancherClient.doUpdate(IDENTITY_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *IdentityClient) List(opts *ListOpts) (*IdentityCollection, error) {
resp := &IdentityCollection{}
err := c.rancherClient.doList(IDENTITY_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *IdentityCollection) Next() (*IdentityCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &IdentityCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *IdentityClient) ById(id string) (*Identity, error) {
resp := &Identity{}
err := c.rancherClient.doById(IDENTITY_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *IdentityClient) Delete(container *Identity) error {
return c.rancherClient.doResourceDelete(IDENTITY_TYPE, &container.Resource)
}

Some files were not shown because too many files have changed in this diff Show More